@warpgogol/forge 7.0.0 → 8.0.2
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 +24 -0
- package/bin/cli.js +6 -12
- package/bin/resolve-entry.js +24 -0
- package/dist/os/compass/comment-safety.d.ts +83 -0
- package/dist/os/compass/comment-safety.d.ts.map +1 -0
- package/dist/os/compass/comment-safety.js +305 -0
- package/dist/os/compass/comment-safety.js.map +1 -0
- package/dist/os/compass/compass.module.d.ts.map +1 -1
- package/dist/os/compass/compass.module.js +47 -4
- package/dist/os/compass/compass.module.js.map +1 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.d.ts +2 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-change-summary-handler.js +34 -10
- package/dist/os/compass/handlers/compass-change-summary-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.js +54 -17
- package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -1
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts +14 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js +261 -0
- package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold.d.ts +31 -0
- package/dist/os/compass/handlers/compass-header-scaffold.d.ts.map +1 -0
- package/dist/os/compass/handlers/compass-header-scaffold.js +739 -0
- package/dist/os/compass/handlers/compass-header-scaffold.js.map +1 -0
- package/dist/os/compass/handlers/compass-inventory-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-inventory-handler.js +8 -4
- package/dist/os/compass/handlers/compass-inventory-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-inventory.d.ts +6 -0
- package/dist/os/compass/handlers/compass-inventory.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-inventory.js +28 -13
- package/dist/os/compass/handlers/compass-inventory.js.map +1 -1
- package/dist/os/compass/handlers/compass-migrate-handler.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-migrate-handler.js +12 -26
- package/dist/os/compass/handlers/compass-migrate-handler.js.map +1 -1
- package/dist/os/compass/handlers/compass-migrate.d.ts +15 -2
- package/dist/os/compass/handlers/compass-migrate.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-migrate.js +58 -20
- package/dist/os/compass/handlers/compass-migrate.js.map +1 -1
- package/dist/os/compass/handlers/git-revision.d.ts +10 -0
- package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
- package/dist/os/compass/handlers/git-revision.js +58 -4
- package/dist/os/compass/handlers/git-revision.js.map +1 -1
- package/dist/os/compass/handlers/summary-record.d.ts +20 -5
- package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
- package/dist/os/compass/handlers/summary-record.js +175 -44
- package/dist/os/compass/handlers/summary-record.js.map +1 -1
- package/dist/os/compass/index.d.ts +1 -0
- package/dist/os/compass/index.d.ts.map +1 -1
- package/dist/os/compass/index.js +2 -0
- package/dist/os/compass/index.js.map +1 -1
- package/dist/os/compass/policy.d.ts +9 -0
- package/dist/os/compass/policy.d.ts.map +1 -1
- package/dist/os/compass/policy.js +11 -2
- package/dist/os/compass/policy.js.map +1 -1
- package/dist/os/core/core.module.js +1 -1
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +1 -6
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/queue/types.d.ts +2 -0
- package/dist/os/queue/types.d.ts.map +1 -1
- package/dist/os/queue/types.js +3 -1
- package/dist/os/queue/types.js.map +1 -1
- package/dist/os/rfc/acceptance.d.ts.map +1 -1
- package/dist/os/rfc/acceptance.js +51 -1
- package/dist/os/rfc/acceptance.js.map +1 -1
- package/dist/os/rfc/decision-log.d.ts.map +1 -1
- package/dist/os/rfc/decision-log.js +21 -3
- package/dist/os/rfc/decision-log.js.map +1 -1
- package/dist/os/rfc/dna-trace.d.ts +2 -0
- package/dist/os/rfc/dna-trace.d.ts.map +1 -1
- package/dist/os/rfc/dna-trace.js +13 -4
- package/dist/os/rfc/dna-trace.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp-origin.d.ts +37 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.d.ts.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.js +118 -0
- package/dist/os/rfc/handlers/implement-stamp-origin.js.map +1 -0
- package/dist/os/rfc/handlers/implement-stamp.d.ts +41 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +594 -81
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +42 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.js +147 -0
- package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -0
- package/dist/os/rfc/handlers/validate-rules.d.ts +9 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +60 -8
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/reachable-symbol.d.ts +17 -0
- package/dist/os/rfc/reachable-symbol.d.ts.map +1 -0
- package/dist/os/rfc/reachable-symbol.js +376 -0
- package/dist/os/rfc/reachable-symbol.js.map +1 -0
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +89 -5
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/os/rfc/types.d.ts +81 -12
- package/dist/os/rfc/types.d.ts.map +1 -1
- package/dist/os/rfc/types.js +15 -10
- package/dist/os/rfc/types.js.map +1 -1
- package/dist/os/rfc/verification-evidence.d.ts +10 -1
- package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
- package/dist/os/rfc/verification-evidence.js +175 -10
- package/dist/os/rfc/verification-evidence.js.map +1 -1
- package/dist/os/rfc/verification-origin.d.ts +58 -0
- package/dist/os/rfc/verification-origin.d.ts.map +1 -0
- package/dist/os/rfc/verification-origin.js +346 -0
- package/dist/os/rfc/verification-origin.js.map +1 -0
- package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
- package/dist/os/rfc/verification-refresh.js +11 -1
- package/dist/os/rfc/verification-refresh.js.map +1 -1
- package/dist/os/rfc/verify-workspace.d.ts +23 -0
- package/dist/os/rfc/verify-workspace.d.ts.map +1 -0
- package/dist/os/rfc/verify-workspace.js +278 -0
- package/dist/os/rfc/verify-workspace.js.map +1 -0
- package/dist/os/session/handlers/metrics-rfc.d.ts.map +1 -1
- package/dist/os/session/handlers/metrics-rfc.js +3 -0
- package/dist/os/session/handlers/metrics-rfc.js.map +1 -1
- package/dist/os/spec/spec-status.d.ts.map +1 -1
- package/dist/os/spec/spec-status.js +5 -23
- package/dist/os/spec/spec-status.js.map +1 -1
- package/dist/os/spec/spec-validate.d.ts.map +1 -1
- package/dist/os/spec/spec-validate.js +30 -9
- package/dist/os/spec/spec-validate.js.map +1 -1
- package/dist/os/workflow/handlers.d.ts +0 -4
- package/dist/os/workflow/handlers.d.ts.map +1 -1
- package/dist/os/workflow/handlers.js +9 -36
- package/dist/os/workflow/handlers.js.map +1 -1
- package/dist/os/workflow/index.d.ts +2 -2
- package/dist/os/workflow/index.d.ts.map +1 -1
- package/dist/os/workflow/index.js +1 -1
- package/dist/os/workflow/index.js.map +1 -1
- package/dist/os/workflow/types.d.ts +0 -19
- package/dist/os/workflow/types.d.ts.map +1 -1
- package/dist/os/workflow/types.js +0 -2
- package/dist/os/workflow/types.js.map +1 -1
- package/dist/os/workflow/workflow.module.d.ts.map +1 -1
- package/dist/os/workflow/workflow.module.js +6 -15
- package/dist/os/workflow/workflow.module.js.map +1 -1
- package/dist/src/config/forge-config.d.ts +5 -0
- package/dist/src/config/forge-config.d.ts.map +1 -1
- package/dist/src/config/forge-config.js +5 -2
- package/dist/src/config/forge-config.js.map +1 -1
- package/dist/src/onboarding/agents-generate.js +1 -1
- package/dist/src/onboarding/doctor.js +3 -3
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/init.js +2 -2
- package/dist/src/onboarding/nested-agents-templates.js +1 -1
- package/dist/src/onboarding/prettierignore.js +1 -1
- package/dist/src/onboarding/upgrade.js +2 -2
- package/dist/src/onboarding/workspace-discovery.js +1 -1
- package/dist/src/profiles/profile-schema.d.ts +2 -0
- package/dist/src/profiles/profile-schema.d.ts.map +1 -1
- package/dist/src/profiles/profile-schema.js +1 -0
- package/dist/src/profiles/profile-schema.js.map +1 -1
- package/dist/src/profiles/stack-profile.d.ts +1 -0
- package/dist/src/profiles/stack-profile.d.ts.map +1 -1
- package/dist/src/types.d.ts +23 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -1
- package/dist/src/types.js.map +1 -1
- package/docs/reference/cli.md +0 -1
- package/docs/reference/programmatic-api.md +1 -1
- package/os/adr/handlers/validate.test.ts +14 -0
- package/os/compass/comment-safety.ts +331 -0
- package/os/compass/compass.module.ts +50 -4
- package/os/compass/handlers/compass-change-summary-handler.ts +41 -11
- package/os/compass/handlers/compass-docs-scaffold.ts +59 -17
- package/os/compass/handlers/compass-game-extensions.test.ts +3 -7
- package/os/compass/handlers/compass-header-scaffold-handler.ts +352 -0
- package/os/compass/handlers/compass-header-scaffold.ts +847 -0
- package/os/compass/handlers/compass-inventory-handler.ts +9 -4
- package/os/compass/handlers/compass-inventory.ts +29 -13
- package/os/compass/handlers/compass-migrate-handler.ts +13 -27
- package/os/compass/handlers/compass-migrate.ts +77 -21
- package/os/compass/handlers/git-revision.ts +59 -4
- package/os/compass/handlers/resolve-scan-root-package.test.ts +14 -0
- package/os/compass/handlers/resolve-scan-root-workpiece.test.ts +14 -0
- package/os/compass/handlers/summary-record.ts +194 -41
- package/os/compass/handlers/tests/compass-audit-plan.test.ts +6 -0
- package/os/compass/handlers/tests/compass-audit-record.test.ts +6 -0
- package/os/compass/handlers/tests/compass-audit-validate.test.ts +6 -0
- package/os/compass/handlers/tests/compass-change-summary-handler.test.ts +131 -0
- package/os/compass/handlers/tests/compass-docs-validate.test.ts +6 -0
- package/os/compass/handlers/tests/compass-header-scaffold.test.ts +896 -0
- package/os/compass/handlers/tests/compass-ledger-scope.test.ts +6 -0
- package/os/compass/handlers/tests/compass-migrate.test.ts +87 -9
- package/os/compass/handlers/tests/compass-policy.test.ts +1 -1
- package/os/compass/handlers/tests/compass-text-safety.test.ts +271 -0
- package/os/compass/handlers/tests/compass-v2-contract.test.ts +52 -3
- package/os/compass/handlers/tests/summary-record.test.ts +324 -3
- package/os/compass/index.ts +15 -0
- package/os/compass/policy.ts +27 -2
- package/os/core/core.module.ts +1 -1
- package/os/core/handlers/invariant-engine.test.ts +3 -1
- package/os/core/handlers/note-frontmatter-validate.test.ts +6 -1
- package/os/core/handlers/note-link-validate.test.ts +6 -1
- package/os/core/handlers/note-orphan-detect.test.ts +6 -1
- package/os/core/handlers/package-health.test.ts +6 -0
- package/os/core/handlers/package-health.ts +1 -6
- package/os/mission/handlers/archive.test.ts +14 -0
- package/os/naming/naming-convention.test.ts +14 -0
- package/os/queue/decision-ledger.test.ts +27 -4
- package/os/queue/queue-validate.test.ts +14 -0
- package/os/queue/types.ts +3 -1
- package/os/rfc/acceptance-reachable.test.ts +146 -0
- package/os/rfc/acceptance.test.ts +25 -0
- package/os/rfc/acceptance.ts +51 -1
- package/os/rfc/decision-log.ts +22 -4
- package/os/rfc/dna-trace.ts +17 -5
- package/os/rfc/frontmatter-io.test.ts +14 -0
- package/os/rfc/handlers/implement-stamp-acceptance-verification.test.ts +81 -0
- package/os/rfc/handlers/implement-stamp-binding.test.ts +79 -0
- package/os/rfc/handlers/implement-stamp-origin.test.ts +132 -0
- package/os/rfc/handlers/implement-stamp-origin.ts +154 -0
- package/os/rfc/handlers/implement-stamp-stale.test.ts +20 -2
- package/os/rfc/handlers/implement-stamp.ts +714 -87
- package/os/rfc/handlers/lifecycle.test.ts +14 -0
- package/os/rfc/handlers/rfc-evidence-sync.ts +221 -0
- package/os/rfc/handlers/validate-rules-rfc0997.test.ts +14 -0
- package/os/rfc/handlers/validate-rules-rfc1006.test.ts +14 -0
- package/os/rfc/handlers/validate-rules-rfc1330.test.ts +120 -0
- package/os/rfc/handlers/validate-rules-rfc1334.test.ts +65 -0
- package/os/rfc/handlers/validate-rules.test.ts +14 -0
- package/os/rfc/handlers/validate-rules.ts +80 -7
- package/os/rfc/handlers/validate.test.ts +4 -3
- package/os/rfc/reachable-symbol.ts +441 -0
- package/os/rfc/rfc-0000-template.md +3 -0
- package/os/rfc/rfc-create-concurrent.test.ts +6 -0
- package/os/rfc/rfc-create-hint.test.ts +6 -0
- package/os/rfc/rfc-read-only-no-side-effects.test.ts +6 -0
- package/os/rfc/rfc.module.ts +95 -5
- package/os/rfc/types.ts +106 -12
- package/os/rfc/verification-emit-check.test.ts +14 -0
- package/os/rfc/verification-emit-freshness.test.ts +415 -0
- package/os/rfc/verification-emit.test.ts +14 -0
- package/os/rfc/verification-evidence.ts +230 -10
- package/os/rfc/verification-normalize.test.ts +14 -0
- package/os/rfc/verification-origin.test.ts +236 -0
- package/os/rfc/verification-origin.ts +417 -0
- package/os/rfc/verification-refresh.test.ts +14 -0
- package/os/rfc/verification-refresh.ts +12 -1
- package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +78 -0
- package/os/rfc/verifier/rfc-1333/imp12-gate.acceptance.test.ts +81 -0
- package/os/rfc/verifier/rfc-1333/skills-and-types.acceptance.test.ts +50 -0
- package/os/rfc/verifier/rfc-1333/verify-workspace.acceptance.test.ts +103 -0
- package/os/rfc/verify-workspace.test.ts +122 -0
- package/os/rfc/verify-workspace.ts +342 -0
- package/os/session/handlers/metrics-rfc.ts +3 -0
- package/os/spec/spec-status.test.ts +130 -0
- package/os/spec/spec-status.ts +5 -18
- package/os/spec/spec-validate.test.ts +76 -1
- package/os/spec/spec-validate.ts +26 -7
- package/os/workflow/handlers.ts +8 -42
- package/os/workflow/index.ts +1 -4
- package/os/workflow/types.ts +0 -22
- package/os/workflow/workflow.module.ts +6 -16
- package/package.json +1 -1
- package/skills/_shared/agent-operating-model.md +1 -1
- package/skills/_shared/fo-pipeline-conventions.md +1 -0
- package/skills/fo/fo-add-tests/SKILL.md +14 -0
- package/skills/fo/fo-fix/SKILL.md +2 -1
- package/skills/fo/fo-handoff/SKILL.md +1 -1
- package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +8 -0
- package/skills/fo/fo-idea-i-just-want-to-see-the-result/SKILL.md +4 -2
- package/skills/fo/fo-idea-implement/SKILL.md +68 -53
- package/skills/fo/fo-idea-plan/SKILL.md +3 -1
- package/skills/fo/fo-review/SKILL.md +12 -0
- package/skills/fo/fo-session-save/learned-principles.md +13 -0
- package/skills/fo/fo-step-commit/SKILL.md +1 -1
- package/src/bin-entry.test.ts +37 -0
- package/src/compass/contract-registry.test.ts +14 -0
- package/src/compass/types.test.ts +14 -0
- package/src/config/__tests__/resolve-terminology.test.ts +14 -0
- package/src/config/forge-config.test.ts +14 -0
- package/src/config/forge-config.ts +7 -2
- package/src/forge-module.test.ts +14 -0
- package/src/knowledge/__tests__/promote.test.ts +14 -0
- package/src/knowledge/__tests__/serialize.test.ts +14 -0
- package/src/knowledge/__tests__/sync.test.ts +4 -1
- package/src/knowledge/budgets.test.ts +14 -0
- package/src/knowledge/compact.test.ts +14 -0
- package/src/knowledge/parse.test.ts +14 -0
- package/src/knowledge/schema.test.ts +14 -0
- package/src/migration-adapters/__tests__/ignored-files.test.ts +14 -0
- package/src/migration-adapters/__tests__/registry.test.ts +14 -0
- package/src/migration-adapters/__tests__/types.test.ts +14 -0
- package/src/onboarding/__tests__/workspace-discovery.test.ts +14 -0
- package/src/onboarding/agents-generate.ts +1 -1
- package/src/onboarding/compass-docs/semantic-layer-block.test.ts +6 -0
- package/src/onboarding/create.test.ts +14 -0
- package/src/onboarding/doctor-token-check.test.ts +3 -0
- package/src/onboarding/doctor.test.ts +14 -0
- package/src/onboarding/doctor.ts +3 -3
- package/src/onboarding/init.test.ts +14 -0
- package/src/onboarding/init.ts +2 -2
- package/src/onboarding/nested-agents-templates.ts +1 -1
- package/src/onboarding/prettierignore.ts +1 -1
- package/src/onboarding/scaffold.test.ts +14 -0
- package/src/onboarding/site-workshop-profile.test.ts +3 -0
- package/src/onboarding/upgrade.test.ts +14 -0
- package/src/onboarding/upgrade.ts +2 -2
- package/src/onboarding/workspace-discovery.ts +1 -1
- package/src/pipeline-status.test.ts +14 -0
- package/src/plugin/forge-plugin-manifest.test.ts +14 -0
- package/src/profiles/__tests__/profile-schema.test.ts +14 -0
- package/src/profiles/__tests__/stack-profile.test.ts +14 -0
- package/src/profiles/__tests__/terminology-utils.test.ts +14 -0
- package/src/profiles/profile-schema.ts +1 -0
- package/src/tests/acceptance-criteria.test.ts +14 -0
- package/src/tests/acceptance-probe-kinds.test.ts +14 -0
- package/src/tests/adr-implement-stamp.test.ts +14 -0
- package/src/tests/agents-generate-domain.test.ts +3 -0
- package/src/tests/agents-generate.test.ts +3 -0
- package/src/tests/bindings-schema.test.ts +2 -0
- package/src/tests/budgets.test.ts +14 -0
- package/src/tests/compact.test.ts +14 -0
- package/src/tests/compass-docs-flag.test.ts +6 -0
- package/src/tests/compass-docs-scaffold.test.ts +6 -0
- package/src/tests/compass-docs-validate-scope.test.ts +6 -0
- package/src/tests/contract-registry.test.ts +14 -0
- package/src/tests/create.test.ts +3 -0
- package/src/tests/discover-pack-skills.test.ts +14 -0
- package/src/tests/doctor-autonomy.test.ts +3 -0
- package/src/tests/doctor-bindings.test.ts +6 -1
- package/src/tests/doctor-dist-freshness.test.ts +26 -2
- package/src/tests/doctor-domain.test.ts +6 -1
- package/src/tests/doctor-fix.test.ts +3 -0
- package/src/tests/doctor-nested-agents.test.ts +3 -0
- package/src/tests/doctor-profile-id-known.test.ts +3 -0
- package/src/tests/doctor-skills-unmanaged.test.ts +3 -0
- package/src/tests/doctor-version-sync.test.ts +4 -1
- package/src/tests/editable-generated-region.test.ts +6 -3
- package/src/tests/exploration-handlers.test.ts +14 -0
- package/src/tests/file-size-lint.test.ts +6 -1
- package/src/tests/forge-autonomy-validate.test.ts +3 -1
- package/src/tests/forge-config.test.ts +6 -1
- package/src/tests/forge-validate-compass-docs.test.ts +6 -0
- package/src/tests/fs-atomic.test.ts +14 -0
- package/src/tests/fs.test.ts +14 -0
- package/src/tests/generated-marker.test.ts +14 -0
- package/src/tests/hash.test.ts +14 -0
- package/src/tests/implement-stamp.test.ts +476 -10
- package/src/tests/init-bindings.test.ts +6 -1
- package/src/tests/knowledge-parse.test.ts +14 -0
- package/src/tests/knowledge-pbt.test.ts +14 -0
- package/src/tests/markdown-table.test.ts +6 -3
- package/src/tests/memory-compact.test.ts +3 -0
- package/src/tests/memory-scaffold.test.ts +6 -1
- package/src/tests/metrics-rfc-1053.test.ts +14 -0
- package/src/tests/migration-adapters.test.ts +3 -0
- package/src/tests/package-files.test.ts +4 -1
- package/src/tests/package-health-lint-surface.test.ts +3 -0
- package/src/tests/pinned-check.test.ts +14 -0
- package/src/tests/pinned-init.test.ts +14 -0
- package/src/tests/pinned-validate.test.ts +14 -0
- package/src/tests/plugin-manifest.test.ts +14 -0
- package/src/tests/prettierignore-manage.test.ts +3 -0
- package/src/tests/profile-schema.test.ts +6 -1
- package/src/tests/profile-validate.test.ts +6 -1
- package/src/tests/program-lease.test.ts +3 -0
- package/src/tests/program-paths-extended.test.ts +3 -0
- package/src/tests/program-paths.test.ts +3 -0
- package/src/tests/program-property.test.ts +3 -0
- package/src/tests/program-schemas.test.ts +3 -0
- package/src/tests/program-spec-node.test.ts +3 -0
- package/src/tests/promote.test.ts +14 -0
- package/src/tests/public-surface.test.ts +6 -1
- package/src/tests/registry.test.ts +14 -0
- package/src/tests/rfc-evidence-sync.test.ts +347 -0
- package/src/tests/rfc-implement-stamp-governance.test.ts +403 -0
- package/src/tests/scaffold-project.test.ts +3 -0
- package/src/tests/session-handlers.test.ts +14 -0
- package/src/tests/session-pbt.test.ts +14 -0
- package/src/tests/skill-agents-sync.test.ts +3 -4
- package/src/tests/skill-schema.test.ts +14 -0
- package/src/tests/skill-sync-marker.test.ts +3 -0
- package/src/tests/skill-validate-knowledge.test.ts +14 -0
- package/src/tests/skill-validate.test.ts +14 -0
- package/src/tests/stack-profile.test.ts +6 -1
- package/src/tests/string-utils.test.ts +14 -0
- package/src/tests/upgrade.test.ts +6 -1
- package/src/tests/werkstatt-lock.test.ts +14 -0
- package/src/tests/workspace-discovery-domain.test.ts +6 -1
- package/src/tests/workspace-discovery.test.ts +6 -1
- package/src/types.test.ts +14 -0
- package/src/types.ts +30 -1
- package/src/utils/__tests__/fs-idempotent.test.ts +17 -0
- package/src/utils/__tests__/fs-trash.test.ts +17 -0
- package/src/utils/fs-atomic.test.ts +17 -0
- package/src/utils/fs-trash-sync.test.ts +17 -0
- package/src/utils/fs.test.ts +17 -0
- package/src/utils/generated-marker.test.ts +17 -0
- package/src/utils/hash.test.ts +17 -0
- package/src/utils/string-utils.test.ts +17 -0
- package/src/validators/__tests__/note-orphan-detect.test.ts +14 -0
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
<CHANGE_SUMMARY>
|
|
16
16
|
<item>RFC-1253: created — six-doc scaffold, KG node merge, binding patch, dry-run manifest.</item>
|
|
17
17
|
<item>Derive workspace node id prefixes from directory location (apps/→app-, packages/→pkg-, services/→svc-, dotted elsewhere) — COMPASS-DOC-02 resolves prefixes to paths, so type-derived ids failed validation on apps/ repos (consumer field report).</item>
|
|
18
|
+
<item>RFC-1323: write-time comment-terminator safety — shared comment-safety seam, authored CS-08 reject, injected neutralization, header-region scan</item>
|
|
19
|
+
<item>RFC-1323: review pass — still-open enclosing-style detection, per-file pre-pass parity, scaffold never-throws, docs.scaffold raw-leaf assert, trim per-file skip, CS-08 always-error severity</item>
|
|
18
20
|
</CHANGE_SUMMARY>
|
|
19
21
|
*/
|
|
20
22
|
|
|
@@ -31,6 +33,7 @@ import {
|
|
|
31
33
|
import { stringify as stringifyYaml } from "yaml";
|
|
32
34
|
import { resolveIo } from "../../../src/utils/io.ts";
|
|
33
35
|
import { resolveCompassPolicy } from "../policy.ts";
|
|
36
|
+
import { CompassCommentSafetyError, assertCompassCommentSafe } from "../comment-safety.ts";
|
|
34
37
|
import {
|
|
35
38
|
discoverWorkspaces,
|
|
36
39
|
type WorkspaceDir,
|
|
@@ -78,6 +81,17 @@ function xmlEscape(value: string): string {
|
|
|
78
81
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/**
|
|
85
|
+
* RFC-1323: authored slot data (workspace names, policy reasons, config
|
|
86
|
+
* ids) is asserted BEFORE escaping — post-escape text can no longer carry
|
|
87
|
+
* a terminator, so the contract gate must see the raw value. A slot needing
|
|
88
|
+
* the escape is a data bug worth surfacing, not hiding (COMPASS-CS-08).
|
|
89
|
+
*/
|
|
90
|
+
function esc(value: string, slot: string): string {
|
|
91
|
+
assertCompassCommentSafe(value, "html", { block: `docs-slot:${slot}` });
|
|
92
|
+
return xmlEscape(value);
|
|
93
|
+
}
|
|
94
|
+
|
|
81
95
|
function render(template: string, slots: Record<string, string>): string {
|
|
82
96
|
let out = template;
|
|
83
97
|
for (const [key, value] of Object.entries(slots)) {
|
|
@@ -88,7 +102,7 @@ function render(template: string, slots: Record<string, string>): string {
|
|
|
88
102
|
|
|
89
103
|
/** <item> list lines at 6-space indent for the scan-policy slots. */
|
|
90
104
|
function itemLines(values: readonly string[]): string {
|
|
91
|
-
return values.map((v) => ` <item>${
|
|
105
|
+
return values.map((v) => ` <item>${esc(v, "item")}</item>`).join("\n");
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
interface ScaffoldWorkspace {
|
|
@@ -162,10 +176,10 @@ function collectWorkspaces(workspaceRoot: string, config: ForgeConfig): Scaffold
|
|
|
162
176
|
|
|
163
177
|
function kgNode(ws: ScaffoldWorkspace): string {
|
|
164
178
|
return [
|
|
165
|
-
` <node id="${
|
|
166
|
-
` <name>${
|
|
167
|
-
` <path>\`${
|
|
168
|
-
` <role>${
|
|
179
|
+
` <node id="${esc(ws.id, "kg.node.id")}" type="workspace">`,
|
|
180
|
+
` <name>${esc(ws.name, "kg.node.name")}</name>`,
|
|
181
|
+
` <path>\`${esc(ws.dir, "kg.node.path")}\`</path>`,
|
|
182
|
+
` <role>${esc(ws.type, "kg.node.role")} workspace.</role>`,
|
|
169
183
|
` </node>`,
|
|
170
184
|
].join("\n");
|
|
171
185
|
}
|
|
@@ -255,7 +269,9 @@ export async function runCompassDocsScaffold(
|
|
|
255
269
|
if (name === "knowledge-graph") {
|
|
256
270
|
return {
|
|
257
271
|
rootLinks: workspaces
|
|
258
|
-
.map(
|
|
272
|
+
.map(
|
|
273
|
+
(ws) => ` <link rel="delegates-to" target="${esc(ws.id, "kg.link.target")}" />`,
|
|
274
|
+
)
|
|
259
275
|
.join("\n"),
|
|
260
276
|
workspaceNodes: workspaces.map(kgNode).join("\n"),
|
|
261
277
|
};
|
|
@@ -263,17 +279,18 @@ export async function runCompassDocsScaffold(
|
|
|
263
279
|
if (name === "technology") {
|
|
264
280
|
const engines = rootPkg["engines"] as Record<string, unknown> | undefined;
|
|
265
281
|
return {
|
|
266
|
-
nodeRange:
|
|
267
|
-
packageManager:
|
|
282
|
+
nodeRange: esc(String(engines?.["node"] ?? ">=24 <25"), "technology.nodeRange"),
|
|
283
|
+
packageManager: esc(
|
|
268
284
|
String(rootPkg["packageManager"] ?? "pnpm").split("@")[0] || "pnpm",
|
|
285
|
+
"technology.packageManager",
|
|
269
286
|
),
|
|
270
|
-
profileId:
|
|
287
|
+
profileId: esc(config.profile?.id ?? "unknown", "technology.profileId"),
|
|
271
288
|
workspaceRows: workspaces
|
|
272
289
|
.map(
|
|
273
290
|
(ws) =>
|
|
274
|
-
` <workspace id="${
|
|
275
|
-
` <name>${
|
|
276
|
-
` <path>\`${
|
|
291
|
+
` <workspace id="${esc(ws.id, "tech.ws.id")}" type="${esc(ws.type, "tech.ws.type")}">\n` +
|
|
292
|
+
` <name>${esc(ws.name, "tech.ws.name")}</name>\n` +
|
|
293
|
+
` <path>\`${esc(ws.dir, "tech.ws.path")}\`</path>\n` +
|
|
277
294
|
` </workspace>`,
|
|
278
295
|
)
|
|
279
296
|
.join("\n"),
|
|
@@ -288,13 +305,16 @@ export async function runCompassDocsScaffold(
|
|
|
288
305
|
ignoredDirPrefixes: itemLines([...policy.ignoredDirPrefixes]),
|
|
289
306
|
highRiskPaths: itemLines([...policy.highRiskPaths]),
|
|
290
307
|
excludedPaths: policy.excludedPaths
|
|
291
|
-
.map(
|
|
308
|
+
.map(
|
|
309
|
+
(e) =>
|
|
310
|
+
` <item pattern="${esc(e.pattern, "sm.excluded.pattern")}">${esc(e.reason, "sm.excluded.reason")}</item>`,
|
|
311
|
+
)
|
|
292
312
|
.join("\n"),
|
|
293
|
-
idPattern:
|
|
313
|
+
idPattern: esc(policy.idPattern.source, "sm.idPattern"),
|
|
294
314
|
layerRules: policy.layerRules
|
|
295
315
|
.map(
|
|
296
316
|
(r) =>
|
|
297
|
-
` <rule pattern="${
|
|
317
|
+
` <rule pattern="${esc(r.pattern, "sm.rule.pattern")}" layer="${esc(r.layer, "sm.rule.layer")}" risk-class="${esc(r.risk, "sm.rule.risk")}" />`,
|
|
298
318
|
)
|
|
299
319
|
.join("\n"),
|
|
300
320
|
};
|
|
@@ -308,7 +328,18 @@ export async function runCompassDocsScaffold(
|
|
|
308
328
|
if (await io.exists(abs)) {
|
|
309
329
|
if (name === "knowledge-graph") {
|
|
310
330
|
const source = await io.readFile(abs);
|
|
311
|
-
|
|
331
|
+
let merged: string | null;
|
|
332
|
+
try {
|
|
333
|
+
merged = mergeKgNodes(source, workspaces);
|
|
334
|
+
} catch (err) {
|
|
335
|
+
// RFC-1323: unsafe authored slot data fails this file closed; the
|
|
336
|
+
// batch continues for other docs.
|
|
337
|
+
if (err instanceof CompassCommentSafetyError) {
|
|
338
|
+
files.push({ path: rel, action: "failed", detail: err.message });
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
throw err;
|
|
342
|
+
}
|
|
312
343
|
if (merged === null) {
|
|
313
344
|
files.push({
|
|
314
345
|
path: rel,
|
|
@@ -334,7 +365,18 @@ export async function runCompassDocsScaffold(
|
|
|
334
365
|
files.push({ path: rel, action: "skipped", detail: "exists — authored content preserved" });
|
|
335
366
|
continue;
|
|
336
367
|
}
|
|
337
|
-
|
|
368
|
+
let content: string;
|
|
369
|
+
try {
|
|
370
|
+
content = render(loadTemplate(name), slotsFor(name));
|
|
371
|
+
} catch (err) {
|
|
372
|
+
// RFC-1323: authored slot data carrying a comment terminator fails the
|
|
373
|
+
// file closed (COMPASS-CS-08) — the batch continues for other docs.
|
|
374
|
+
if (err instanceof CompassCommentSafetyError) {
|
|
375
|
+
files.push({ path: rel, action: "failed", detail: err.message });
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
throw err;
|
|
379
|
+
}
|
|
338
380
|
if (!dryRun) {
|
|
339
381
|
await io.mkdir(dirname(abs));
|
|
340
382
|
await io.writeFile(abs, content);
|
|
@@ -8,7 +8,7 @@ and that checkCommentSyntax correctly validates comment prefixes for each file t
|
|
|
8
8
|
</non-goals>
|
|
9
9
|
</MODULE_CONTRACT>
|
|
10
10
|
<CHANGE_SUMMARY>
|
|
11
|
-
<item>Initial: test game extension discovery and comment-syntax validation for .cs, .gd, .tscn, .tres files.</item>
|
|
11
|
+
<item>RFC-1311: carried legacy entry — Initial: test game extension discovery and comment-syntax validation for .cs, .gd, .tscn, .tres files.</item>
|
|
12
12
|
</CHANGE_SUMMARY>
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -111,9 +111,7 @@ test("compass.validate emits COMPASS-SYNTAX-01 for .gd file with wrong comment s
|
|
|
111
111
|
join(tempDir, "packages", "my-game", "src", "Player.gd"),
|
|
112
112
|
`/* <MODULE_CONTRACT>
|
|
113
113
|
<purpose>Player movement and input handling logic for the game</purpose>
|
|
114
|
-
|
|
115
|
-
<item>Do not handle combat logic here</item>
|
|
116
|
-
</non-goals>
|
|
114
|
+
|
|
117
115
|
</MODULE_CONTRACT>
|
|
118
116
|
<CHANGE_SUMMARY>
|
|
119
117
|
<item>Initial creation</item>
|
|
@@ -136,9 +134,7 @@ test("compass.validate does not emit COMPASS-SYNTAX-01 for .gd file with correct
|
|
|
136
134
|
join(tempDir, "packages", "my-game", "src", "Player.gd"),
|
|
137
135
|
`# <MODULE_CONTRACT>
|
|
138
136
|
# <purpose>Player movement and input handling logic for the game</purpose>
|
|
139
|
-
#
|
|
140
|
-
# <item>Do not handle combat logic here</item>
|
|
141
|
-
# </non-goals>
|
|
137
|
+
#
|
|
142
138
|
# </MODULE_CONTRACT>
|
|
143
139
|
# <CHANGE_SUMMARY>
|
|
144
140
|
# <item>Initial creation</item>
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>compass.header.scaffold kernel handler (RFC-1318). Resolves scan root
|
|
4
|
+
and policy, walks the coverage surface (or an explicit --files set), computes
|
|
5
|
+
per-file scaffold dispositions through the pure codemod, enforces the
|
|
6
|
+
dirty-target refusal before any write, and reports census/apply manifests.</purpose>
|
|
7
|
+
<non-goals>
|
|
8
|
+
<item>Do not implement transform logic — that lives in compass-header-scaffold.ts.</item>
|
|
9
|
+
<item>Do not perform a dry-run mode — --census IS the writeless interception mode (Q-20).</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1318: add compass.header.scaffold codemod for mechanical header sweeps</item>
|
|
14
|
+
<item>RFC-1318</item>
|
|
15
|
+
<item>RFC-1323: review pass — still-open enclosing-style detection, per-file pre-pass parity, scaffold never-throws, docs.scaffold raw-leaf assert, trim per-file skip, CS-08 always-error severity</item>
|
|
16
|
+
<item>RFC-1323: re-review pass — frontmatter-zone enclosing-style detection, existing-item pre-pass gating, trim exit-1 on unsafe, nextSteps rule labels, severity/census test coverage</item>
|
|
17
|
+
</CHANGE_SUMMARY>
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
21
|
+
import { writeFileIfChanged } from "../../../src/utils/fs-idempotent.ts";
|
|
22
|
+
import { realpathSync } from "../../../src/utils/sync-fs.ts";
|
|
23
|
+
import { relative, resolve } from "node:path";
|
|
24
|
+
import {
|
|
25
|
+
createCompassInventoryEntries,
|
|
26
|
+
detectAuthoringStatus,
|
|
27
|
+
detectRiskClass,
|
|
28
|
+
detectWorkspaceName,
|
|
29
|
+
getEntrySource,
|
|
30
|
+
getRelativeSegments,
|
|
31
|
+
getWorkspaceRelativeSegments,
|
|
32
|
+
type CompassInventoryEntry,
|
|
33
|
+
} from "./compass-inventory.ts";
|
|
34
|
+
import {
|
|
35
|
+
explicitWorkspaceRelativePath,
|
|
36
|
+
scaffoldFile,
|
|
37
|
+
type ScaffoldDisposition,
|
|
38
|
+
type ScaffoldFileInput,
|
|
39
|
+
type ScaffoldFileResult,
|
|
40
|
+
} from "./compass-header-scaffold.ts";
|
|
41
|
+
import { DIRTY_LIST_CAP, isDirtyPath, listDirtyPaths, repoTopLevel } from "./git-revision.ts";
|
|
42
|
+
import { resolveCompassScanRoot } from "./resolve-scan-root.ts";
|
|
43
|
+
import { resolveCompassPolicy } from "../policy.ts";
|
|
44
|
+
import type {
|
|
45
|
+
ForgeCommandInput,
|
|
46
|
+
ForgeCommandResult,
|
|
47
|
+
ForgeRuntimeContext,
|
|
48
|
+
} from "../../../src/types.ts";
|
|
49
|
+
|
|
50
|
+
const io = ambientIo;
|
|
51
|
+
|
|
52
|
+
export interface ScaffoldFileReport extends Omit<ScaffoldFileResult, "source"> {
|
|
53
|
+
path: string;
|
|
54
|
+
workspaceName: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ScaffoldRunResult {
|
|
58
|
+
mode: "census" | "apply";
|
|
59
|
+
scanned: number;
|
|
60
|
+
files: ScaffoldFileReport[];
|
|
61
|
+
byPackage: Record<string, Partial<Record<ScaffoldDisposition, number>>>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ScaffoldTarget {
|
|
65
|
+
absPath: string;
|
|
66
|
+
pathFromRoot: string;
|
|
67
|
+
workspaceRelativePath: string;
|
|
68
|
+
workspaceName: string;
|
|
69
|
+
skipReason?: string;
|
|
70
|
+
input?: ScaffoldFileInput;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function explicitTarget(
|
|
74
|
+
workspaceRoot: string,
|
|
75
|
+
baseRoot: string,
|
|
76
|
+
file: string,
|
|
77
|
+
policy: ReturnType<typeof resolveCompassPolicy>,
|
|
78
|
+
leafRoot?: string,
|
|
79
|
+
): Promise<ScaffoldTarget> {
|
|
80
|
+
const absPath = resolve(baseRoot, file);
|
|
81
|
+
const pathFromRoot = relative(workspaceRoot, absPath).replace(/\\/g, "/");
|
|
82
|
+
const workspaceRelativePath = leafRoot
|
|
83
|
+
? relative(leafRoot, absPath).replace(/\\/g, "/")
|
|
84
|
+
: explicitWorkspaceRelativePath(absPath, workspaceRoot, policy);
|
|
85
|
+
const segments = getRelativeSegments(absPath, workspaceRoot);
|
|
86
|
+
const workspaceName = detectWorkspaceName(segments, policy);
|
|
87
|
+
const shell: Omit<ScaffoldTarget, "skipReason" | "input"> = {
|
|
88
|
+
absPath,
|
|
89
|
+
pathFromRoot,
|
|
90
|
+
workspaceRelativePath,
|
|
91
|
+
workspaceName,
|
|
92
|
+
};
|
|
93
|
+
// --files bypasses scan roots, not the extension allowlist — a binary or
|
|
94
|
+
// non-source path must never receive a header.
|
|
95
|
+
const lastDot = absPath.lastIndexOf(".");
|
|
96
|
+
const extension = lastDot > absPath.lastIndexOf("/") ? absPath.slice(lastDot) : "";
|
|
97
|
+
if (!policy.fileExtensions.has(extension)) {
|
|
98
|
+
return { ...shell, skipReason: `unsupported extension ${extension || "(none)"}` };
|
|
99
|
+
}
|
|
100
|
+
let source: string;
|
|
101
|
+
try {
|
|
102
|
+
source = await io.readFile(absPath);
|
|
103
|
+
} catch {
|
|
104
|
+
return { ...shell, skipReason: "unreadable" };
|
|
105
|
+
}
|
|
106
|
+
const { authoringStatus, exclusionReason } = detectAuthoringStatus(
|
|
107
|
+
segments,
|
|
108
|
+
workspaceRelativePath,
|
|
109
|
+
source,
|
|
110
|
+
policy,
|
|
111
|
+
);
|
|
112
|
+
if (authoringStatus === "excluded") {
|
|
113
|
+
return { ...shell, skipReason: exclusionReason ?? "excluded" };
|
|
114
|
+
}
|
|
115
|
+
const riskClass = detectRiskClass(pathFromRoot, workspaceRelativePath, policy);
|
|
116
|
+
return {
|
|
117
|
+
...shell,
|
|
118
|
+
input: {
|
|
119
|
+
pathFromRoot,
|
|
120
|
+
workspaceRelativePath,
|
|
121
|
+
source,
|
|
122
|
+
riskClass,
|
|
123
|
+
keyDecisionsRequired: riskClass === "medium" || riskClass === "high",
|
|
124
|
+
isTest: policy.isTestPath(workspaceRelativePath),
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function entryTarget(
|
|
130
|
+
workspaceRoot: string,
|
|
131
|
+
entry: CompassInventoryEntry,
|
|
132
|
+
policy: ReturnType<typeof resolveCompassPolicy>,
|
|
133
|
+
leafRoot?: string,
|
|
134
|
+
): ScaffoldTarget {
|
|
135
|
+
const absPath = resolve(workspaceRoot, entry.path);
|
|
136
|
+
const segments = getRelativeSegments(absPath, workspaceRoot);
|
|
137
|
+
const workspaceRelativePath = leafRoot
|
|
138
|
+
? relative(leafRoot, absPath).replace(/\\/g, "/")
|
|
139
|
+
: getWorkspaceRelativeSegments(segments, policy).join("/");
|
|
140
|
+
if (entry.authoringStatus === "excluded") {
|
|
141
|
+
return {
|
|
142
|
+
absPath,
|
|
143
|
+
pathFromRoot: entry.path,
|
|
144
|
+
workspaceRelativePath,
|
|
145
|
+
workspaceName: entry.workspaceName,
|
|
146
|
+
skipReason: entry.exclusionReason ?? "excluded",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
absPath,
|
|
151
|
+
pathFromRoot: entry.path,
|
|
152
|
+
workspaceRelativePath,
|
|
153
|
+
workspaceName: entry.workspaceName,
|
|
154
|
+
input: {
|
|
155
|
+
pathFromRoot: entry.path,
|
|
156
|
+
workspaceRelativePath,
|
|
157
|
+
source: getEntrySource(entry) ?? "",
|
|
158
|
+
riskClass: entry.riskClass,
|
|
159
|
+
keyDecisionsRequired: entry.keyDecisionsRequired,
|
|
160
|
+
isTest: policy.isTestPath(workspaceRelativePath),
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function runCompassHeaderScaffold(
|
|
166
|
+
input: ForgeCommandInput,
|
|
167
|
+
context: ForgeRuntimeContext,
|
|
168
|
+
): Promise<ForgeCommandResult<ScaffoldRunResult>> {
|
|
169
|
+
const scanRoot = resolveCompassScanRoot(input, context);
|
|
170
|
+
const baseRoot = scanRoot ?? context.workspaceRoot;
|
|
171
|
+
const policy = resolveCompassPolicy(baseRoot, context.forgeRoot);
|
|
172
|
+
const leafRoot =
|
|
173
|
+
scanRoot !== undefined &&
|
|
174
|
+
(input.flags["workpiece"] !== undefined || scanRoot === context.site?.directory)
|
|
175
|
+
? scanRoot
|
|
176
|
+
: undefined;
|
|
177
|
+
|
|
178
|
+
const census = input.flags["census"] === true;
|
|
179
|
+
const force = input.flags["force"] === true;
|
|
180
|
+
|
|
181
|
+
const rawFiles = input.flags["files"];
|
|
182
|
+
const files = (
|
|
183
|
+
Array.isArray(rawFiles)
|
|
184
|
+
? rawFiles.filter((entry): entry is string => typeof entry === "string")
|
|
185
|
+
: typeof rawFiles === "string"
|
|
186
|
+
? [rawFiles]
|
|
187
|
+
: []
|
|
188
|
+
)
|
|
189
|
+
.flatMap((entry) => entry.split(","))
|
|
190
|
+
.map((entry) => entry.trim())
|
|
191
|
+
.filter(Boolean);
|
|
192
|
+
|
|
193
|
+
// ── Target collection ────────────────────────────────────────────────────
|
|
194
|
+
const targets: ScaffoldTarget[] = [];
|
|
195
|
+
if (files.length > 0) {
|
|
196
|
+
for (const file of files) {
|
|
197
|
+
targets.push(await explicitTarget(context.workspaceRoot, baseRoot, file, policy, leafRoot));
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
const entries = await createCompassInventoryEntries(
|
|
201
|
+
context.workspaceRoot,
|
|
202
|
+
input,
|
|
203
|
+
scanRoot,
|
|
204
|
+
policy,
|
|
205
|
+
context.site?.directory,
|
|
206
|
+
);
|
|
207
|
+
for (const entry of entries) {
|
|
208
|
+
targets.push(entryTarget(context.workspaceRoot, entry, policy, leafRoot));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
targets.sort((a, b) => a.pathFromRoot.localeCompare(b.pathFromRoot));
|
|
212
|
+
|
|
213
|
+
// ── Dispositions (identical pass for census and apply — census just never writes) ──
|
|
214
|
+
// Pending write sources live outside the report payload — serializing every
|
|
215
|
+
// file body into data.files[] would balloon a full-repo census.
|
|
216
|
+
const reports: ScaffoldFileReport[] = [];
|
|
217
|
+
const writeSources = new Map<string, string>();
|
|
218
|
+
let scanned = 0;
|
|
219
|
+
for (const target of targets) {
|
|
220
|
+
if (!target.input) {
|
|
221
|
+
reports.push({
|
|
222
|
+
path: target.pathFromRoot,
|
|
223
|
+
workspaceName: target.workspaceName,
|
|
224
|
+
disposition: "skipped",
|
|
225
|
+
repairs: [],
|
|
226
|
+
skipReason: target.skipReason,
|
|
227
|
+
});
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
scanned += 1;
|
|
231
|
+
const source = target.input.source || (await io.readFile(target.absPath));
|
|
232
|
+
const result = scaffoldFile({ ...target.input, source }, policy);
|
|
233
|
+
const { source: nextSource, ...report } = result;
|
|
234
|
+
if (
|
|
235
|
+
result.disposition === "inserted" ||
|
|
236
|
+
result.disposition === "repaired" ||
|
|
237
|
+
result.disposition === "sentinel"
|
|
238
|
+
) {
|
|
239
|
+
writeSources.set(target.pathFromRoot, nextSource);
|
|
240
|
+
}
|
|
241
|
+
reports.push({ path: target.pathFromRoot, workspaceName: target.workspaceName, ...report });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const writes = reports.filter((r) => writeSources.has(r.path));
|
|
245
|
+
|
|
246
|
+
// ── Dirty-target refusal — apply mode only; census never writes ──────────
|
|
247
|
+
if (!census && !force && writes.length > 0) {
|
|
248
|
+
const rawDirty = listDirtyPaths(baseRoot);
|
|
249
|
+
if (rawDirty && rawDirty.length > 0) {
|
|
250
|
+
// Porcelain paths are repo-top-relative while reports carry
|
|
251
|
+
// workspace-relative paths — rebase through the actual top-level so a
|
|
252
|
+
// scoped scan (--package/--packages inside one repo, or a nested
|
|
253
|
+
// --workpiece repo) still sees its dirty targets. realpath both sides:
|
|
254
|
+
// git reports canonical paths while workspaceRoot may be symlinked.
|
|
255
|
+
const topLevel = repoTopLevel(baseRoot);
|
|
256
|
+
let wsRoot = context.workspaceRoot;
|
|
257
|
+
try {
|
|
258
|
+
wsRoot = realpathSync(wsRoot);
|
|
259
|
+
} catch {
|
|
260
|
+
// keep the workspace root as given
|
|
261
|
+
}
|
|
262
|
+
const gitBase = topLevel ?? baseRoot;
|
|
263
|
+
const dirty = rawDirty.map((d) => {
|
|
264
|
+
const rebased = relative(wsRoot, resolve(gitBase, d)).replace(/\\/g, "/");
|
|
265
|
+
return d.endsWith("/") && !rebased.endsWith("/") ? `${rebased}/` : rebased;
|
|
266
|
+
});
|
|
267
|
+
const dirtyTargets = writes.filter((w) => isDirtyPath(w.path, dirty));
|
|
268
|
+
if (dirtyTargets.length > 0) {
|
|
269
|
+
const shown = dirtyTargets.slice(0, DIRTY_LIST_CAP);
|
|
270
|
+
const suffix =
|
|
271
|
+
dirtyTargets.length > shown.length
|
|
272
|
+
? ` … and ${dirtyTargets.length - shown.length} more`
|
|
273
|
+
: "";
|
|
274
|
+
context.logger.error(
|
|
275
|
+
`[compass.header.scaffold] refusing to write — ${dirtyTargets.length} target file(s) carry uncommitted changes:\n${shown.map((p) => ` ${p.path}`).join("\n")}${suffix}\nCommit or stash those files first, or pass --force to override.`,
|
|
276
|
+
);
|
|
277
|
+
return { exitCode: 1, summary: "dirty targets — refused" };
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ── Writes ───────────────────────────────────────────────────────────────
|
|
283
|
+
if (!census) {
|
|
284
|
+
for (const report of writes) {
|
|
285
|
+
const nextSource = writeSources.get(report.path);
|
|
286
|
+
if (nextSource === undefined) continue;
|
|
287
|
+
await writeFileIfChanged(resolve(context.workspaceRoot, report.path), nextSource, context.io);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ── Rollups ──────────────────────────────────────────────────────────────
|
|
292
|
+
const byPackage: Record<string, Partial<Record<ScaffoldDisposition, number>>> = {};
|
|
293
|
+
for (const report of reports) {
|
|
294
|
+
const pkg = byPackage[report.workspaceName] ?? (byPackage[report.workspaceName] = {});
|
|
295
|
+
pkg[report.disposition] = (pkg[report.disposition] ?? 0) + 1;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const counts = new Map<ScaffoldDisposition, number>();
|
|
299
|
+
for (const report of reports) {
|
|
300
|
+
counts.set(report.disposition, (counts.get(report.disposition) ?? 0) + 1);
|
|
301
|
+
}
|
|
302
|
+
const tally = [...counts.entries()].map(([k, v]) => `${k}=${v}`).join(", ");
|
|
303
|
+
|
|
304
|
+
const diagnostics = reports.filter((r) => r.diagnostic);
|
|
305
|
+
if (diagnostics.length > 0) {
|
|
306
|
+
for (const d of diagnostics.slice(0, 10)) {
|
|
307
|
+
context.logger.warn(`[${d.diagnostic!.ruleId}] ${d.path}: ${d.diagnostic!.message}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// RFC-1323: an unsafe-text skip in apply mode means a file the operator
|
|
312
|
+
// asked to scaffold was refused — report the batch, but fail closed so
|
|
313
|
+
// the skipped files are reworded deliberately, not lost in a warning.
|
|
314
|
+
const unsafe = diagnostics.filter((d) => d.diagnostic!.ruleId === "COMPASS-CS-08");
|
|
315
|
+
if (!census && unsafe.length > 0) {
|
|
316
|
+
return {
|
|
317
|
+
data: { mode: "apply", scanned, files: reports, byPackage },
|
|
318
|
+
exitCode: 1,
|
|
319
|
+
summary: `[compass.header.scaffold] apply scanned=${scanned} ${tally} — ${unsafe.length} file(s) skipped on COMPASS-CS-08: ${unsafe.map((d) => d.path).join(", ")}`,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Per-package table in default output — the result contract promises it
|
|
324
|
+
// outside --json too.
|
|
325
|
+
const packageLines = Object.entries(byPackage)
|
|
326
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
327
|
+
.map(
|
|
328
|
+
([pkg, tallies]) =>
|
|
329
|
+
` ${pkg}: ${Object.entries(tallies)
|
|
330
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
331
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
332
|
+
.join(" ")}`,
|
|
333
|
+
);
|
|
334
|
+
if (packageLines.length > 0) {
|
|
335
|
+
context.logger.info(`[compass.header.scaffold] by package:\n${packageLines.join("\n")}`);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
data: { mode: census ? "census" : "apply", scanned, files: reports, byPackage },
|
|
340
|
+
exitCode: 0,
|
|
341
|
+
summary: `[compass.header.scaffold] ${census ? "census" : "apply"} scanned=${scanned} ${tally}`,
|
|
342
|
+
nextSteps:
|
|
343
|
+
diagnostics.length > 0
|
|
344
|
+
? [
|
|
345
|
+
{
|
|
346
|
+
action: `${diagnostics.length} file(s) skipped with diagnostics (${[...new Set(diagnostics.map((d) => d.diagnostic!.ruleId))].join("/")}) — review them manually.`,
|
|
347
|
+
kind: "optional",
|
|
348
|
+
},
|
|
349
|
+
]
|
|
350
|
+
: undefined,
|
|
351
|
+
};
|
|
352
|
+
}
|