@mnstry/atelier 0.2.0-alpha.1 → 0.2.0-alpha.10
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 +372 -0
- package/README.md +402 -205
- package/SECURITY.md +6 -1
- package/contracts/atelier-adoption-policy.v1.schema.json +49 -0
- package/contracts/atelier-coauthor.v1.schema.json +163 -0
- package/contracts/atelier-decision-request.v1.schema.json +476 -0
- package/contracts/atelier-decision-result.v1.schema.json +500 -0
- package/contracts/atelier-guide.v1.schema.json +227 -0
- package/contracts/atelier-intake.v1.schema.json +151 -0
- package/contracts/atelier-migration.v2.schema.json +61 -0
- package/contracts/atelier-obsidian-acceptance-receipt.v1.schema.json +211 -0
- package/contracts/atelier-obsidian-apply-policy.v1.schema.json +298 -0
- package/contracts/atelier-obsidian-corpus-profile.v1.schema.json +98 -0
- package/contracts/atelier-obsidian-edit-operation.v1.schema.json +138 -0
- package/contracts/atelier-obsidian-ext-settings.v1.schema.json +287 -0
- package/contracts/atelier-obsidian-generation-manifest.v1.schema.json +353 -0
- package/contracts/atelier-obsidian-proposal-receipt.v1.schema.json +110 -0
- package/contracts/atelier-obsidian-publication-journal.v1.schema.json +167 -0
- package/contracts/atelier-obsidian-scope.v1.schema.json +264 -0
- package/contracts/atelier-obsidian-service-state.v1.schema.json +149 -0
- package/contracts/atelier-obsidian-source-snapshot.v1.schema.json +179 -0
- package/contracts/atelier-pane-presentation.v1.schema.json +76 -0
- package/contracts/atelier-presentation.v1.schema.json +1293 -0
- package/contracts/atelier-repository-observation.v1.schema.json +163 -0
- package/contracts/atelier-review.v1.schema.json +1601 -0
- package/contracts/atelier-skill-steward.v1.schema.json +692 -0
- package/contracts/atelier-upgrade-plan.v2.schema.json +398 -0
- package/contracts/atelier-upgrade-receipt.v1.schema.json +99 -0
- package/contracts/atelier-vault-publication.v1.schema.json +58 -0
- package/contracts/public-api-baseline.json +57 -0
- package/docs/assurance-controls.md +49 -0
- package/docs/atelier-runtime.md +28 -2
- package/docs/atelier-sync.md +172 -0
- package/docs/blocks/audience-visibility.md +9 -0
- package/docs/blocks/claims.md +61 -0
- package/docs/blocks/conformance-admission.md +15 -0
- package/docs/blocks/will-not-do.md +18 -0
- package/docs/coauthor-session.md +57 -0
- package/docs/connected-composition.md +75 -0
- package/docs/continuity.md +3 -4
- package/docs/decisions.md +167 -0
- package/docs/design.md +167 -0
- package/docs/exact-upgrades.md +159 -0
- package/docs/extension-pack-lifecycle.md +33 -0
- package/docs/guided-upgrades.md +99 -0
- package/docs/install.md +99 -16
- package/docs/intake-and-guides.md +65 -0
- package/docs/integration-and-review-plan.md +409 -0
- package/docs/integration-contract-decisions.md +22 -0
- package/docs/knowledge-graph.md +8 -4
- package/docs/local-review.md +84 -0
- package/docs/local-services.md +328 -0
- package/docs/local-state.md +107 -0
- package/docs/obsidian-contract.md +690 -0
- package/docs/obsidian.md +423 -0
- package/docs/portable-presentation.md +328 -0
- package/docs/presentation-consumer-boundaries.md +75 -0
- package/docs/presentation-review-disposition.md +47 -0
- package/docs/project-command-inventory.md +38 -0
- package/docs/project-options.md +53 -0
- package/docs/release-engineering.md +174 -12
- package/docs/repo-boundary-guard.md +12 -2
- package/docs/review-portability.md +55 -0
- package/docs/skill-steward.md +156 -0
- package/docs/upgrade.md +146 -5
- package/docs/vault-service.md +292 -0
- package/fixtures/atelier-coauthor/invalid/authority.v1.json +5 -0
- package/fixtures/atelier-coauthor/valid/config.v1.json +12 -0
- package/fixtures/atelier-guide/invalid/authority.v1.json +11 -0
- package/fixtures/atelier-guide/valid/capability.v1.json +10 -0
- package/fixtures/atelier-guide/valid/consent.v1.json +11 -0
- package/fixtures/atelier-guide/valid/engagement.v1.json +7 -0
- package/fixtures/atelier-guide/valid/offer.v1.json +10 -0
- package/fixtures/atelier-intake/invalid/authority.v1.json +9 -0
- package/fixtures/atelier-intake/valid/attempt.v1.json +8 -0
- package/fixtures/atelier-intake/valid/completion.v1.json +9 -0
- package/fixtures/atelier-intake/valid/source.v1.json +7 -0
- package/fixtures/atelier-repository-observation/invalid/complete-with-blocker.v1.json +18 -0
- package/fixtures/atelier-repository-observation/valid/complete-local.v1.json +48 -0
- package/fixtures/atelier-review/invalid/authenticated-identity.v1.json +22 -0
- package/fixtures/atelier-review/valid/bound.v1.json +229 -0
- package/fixtures/atelier-review/valid/bundle.v1.json +267 -0
- package/fixtures/atelier-review/valid/contribution.v1.json +22 -0
- package/fixtures/atelier-review/valid/lifecycle.v1.json +14 -0
- package/fixtures/atelier-skill-steward/audit/invalid/source-mutation.v1.json +26 -0
- package/fixtures/atelier-skill-steward/audit/valid/clean.v1.json +26 -0
- package/fixtures/atelier-skill-steward/candidates/invalid/workflow-key.v1.json +37 -0
- package/fixtures/atelier-skill-steward/candidates/valid/create.v1.json +37 -0
- package/fixtures/atelier-skill-steward/lock/invalid/bad-digest.v1.json +18 -0
- package/fixtures/atelier-skill-steward/lock/valid/installed.v1.json +23 -0
- package/fixtures/atelier-skill-steward/plan/invalid/delete-action.v1.json +33 -0
- package/fixtures/atelier-skill-steward/plan/valid/add.v1.json +33 -0
- package/fixtures/atelier-upgrade-transaction/adoption-policy/invalid/example.json +12 -0
- package/fixtures/atelier-upgrade-transaction/adoption-policy/valid/example.json +11 -0
- package/fixtures/atelier-upgrade-transaction/migration/invalid/example.json +20 -0
- package/fixtures/atelier-upgrade-transaction/migration/valid/example.json +19 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-plan/invalid/example.json +58 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-plan/valid/example.json +57 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-receipt/invalid/example.json +15 -0
- package/fixtures/atelier-upgrade-transaction/upgrade-receipt/valid/example.json +14 -0
- package/fixtures/atelier-vault-publication/invalid/publication.json +5 -0
- package/fixtures/atelier-vault-publication/valid/publication.json +11 -0
- package/fixtures/decisions/request/invalid/unknown-authority.v1.json +61 -0
- package/fixtures/decisions/request/valid/triage.v1.json +60 -0
- package/fixtures/decisions/result/invalid/execution-authority.v1.json +50 -0
- package/fixtures/decisions/result/valid/abstained.v1.json +23 -0
- package/fixtures/decisions/result/valid/assessed.v1.json +50 -0
- package/fixtures/obsidian/acceptance/ap05-extra-notes.json +14 -0
- package/fixtures/obsidian/acceptance/receipts/G07.valid.v1.json +63 -0
- package/fixtures/obsidian/acceptance/receipts/G13.valid.v1.json +69 -0
- package/fixtures/obsidian/acceptance/receipts/G14.valid.v1.json +62 -0
- package/fixtures/obsidian/acceptance/receipts/G15.valid.v1.json +56 -0
- package/fixtures/obsidian/acceptance/receipts/G16.valid.v1.json +73 -0
- package/fixtures/obsidian/acceptance/receipts/G17.valid.v1.json +75 -0
- package/fixtures/obsidian/acceptance/receipts/G18.valid.v1.json +64 -0
- package/fixtures/obsidian/acceptance/service-sentinels.json +10 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/duplicate-evidence-name.v1.json +39 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/evidence-by-absolute-path.v1.json +34 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/missing-candidate-tree.v1.json +33 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/no-evidence.v1.json +28 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/unknown-outcome.v1.json +34 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/invalid/unknown-top-level-field.v1.json +35 -0
- package/fixtures/obsidian/contracts/acceptance-receipt/valid/node-gate.v1.json +34 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/automatic-without-edit-class.v1.json +27 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/conflict-overwrite.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/missing-policy-digest.v1.json +28 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unbounded-batch.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unimplemented-edit-class.v1.json +30 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-mode.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-selector-operator.v1.json +22 -0
- package/fixtures/obsidian/contracts/apply-policy/invalid/unknown-top-level-field.v1.json +30 -0
- package/fixtures/obsidian/contracts/apply-policy/valid/automatic-scoped.v1.json +29 -0
- package/fixtures/obsidian/contracts/apply-policy/valid/manual-default.v1.json +20 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/absolute-path-in-ext.v1.json +30 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/absolute-repository-root.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/duplicate-repository-id.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/overlapping-managed-roots.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/unknown-enrollment.v1.json +27 -0
- package/fixtures/obsidian/contracts/corpus-profile/invalid/unknown-top-level-field.v1.json +28 -0
- package/fixtures/obsidian/contracts/corpus-profile/valid/three-repositories.v1.json +27 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/absolute-recovery-ref.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/inline-observed-bytes.v1.json +22 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/missing-base-digest.v1.json +20 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/short-idempotency-key.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/invalid/unknown-kind.v1.json +21 -0
- package/fixtures/obsidian/contracts/edit-operation/valid/pending-body-replacement.v1.json +21 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/absolute-path-prefix.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/apply-policy-in-portable-settings.v1.json +30 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/duplicate-scope-id.v1.json +27 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/machine-local-vault-path.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/service-port-in-portable-settings.v1.json +28 -0
- package/fixtures/obsidian/contracts/ext-settings/invalid/unknown-default-scope.v1.json +27 -0
- package/fixtures/obsidian/contracts/ext-settings/valid/disabled.v1.json +5 -0
- package/fixtures/obsidian/contracts/ext-settings/valid/enabled-with-scopes.v1.json +27 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/absolute-note-path.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/complete-with-unwritten-notes.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/derived-link-claimed-declared.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/duplicate-note-identity.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/in-scope-endpoint-missing.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/title-only-note-path.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/unknown-note-field.v1.json +115 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/unknown-relation-type.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/invalid/withheld-endpoint.v1.json +114 -0
- package/fixtures/obsidian/contracts/generation-manifest/valid/two-notes.v1.json +114 -0
- package/fixtures/obsidian/contracts/oracles/scope-cases.json +412 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/accepted-without-proposal-id.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/missing-adapter-operation-id.v1.json +11 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/unknown-backpressure-outcome.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/invalid/unknown-top-level-field.v1.json +13 -0
- package/fixtures/obsidian/contracts/proposal-receipt/valid/accepted-new.v1.json +12 -0
- package/fixtures/obsidian/contracts/proposal-receipt/valid/deferred.v1.json +12 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/absolute-recovery-ref.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/duplicate-sequence.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/empty-protocol-id.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/missing-protocol-id.v1.json +46 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/unknown-entry-field.v1.json +48 -0
- package/fixtures/obsidian/contracts/publication-journal/invalid/unknown-state.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/valid/committed.v1.json +47 -0
- package/fixtures/obsidian/contracts/publication-journal/valid/updating-after-restart.v1.json +22 -0
- package/fixtures/obsidian/contracts/scope/invalid/absolute-path-prefix.v1.json +15 -0
- package/fixtures/obsidian/contracts/scope/invalid/duplicate-ids.v1.json +18 -0
- package/fixtures/obsidian/contracts/scope/invalid/expansion-without-node-budget.v1.json +40 -0
- package/fixtures/obsidian/contracts/scope/invalid/full-mode-with-subset.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-mode.v1.json +41 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-selector-key.v1.json +15 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-selector-operator.v1.json +14 -0
- package/fixtures/obsidian/contracts/scope/invalid/unknown-top-level-field.v1.json +42 -0
- package/fixtures/obsidian/contracts/scope/valid/explicit-empty.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/valid/focus.v1.json +11 -0
- package/fixtures/obsidian/contracts/scope/valid/full.v1.json +8 -0
- package/fixtures/obsidian/contracts/scope/valid/scoped-set-expression.v1.json +41 -0
- package/fixtures/obsidian/contracts/service-state/invalid/hostname-instead-of-literal-loopback.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/invalid/missing-consent.v1.json +18 -0
- package/fixtures/obsidian/contracts/service-state/invalid/privileged-port.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/invalid/unknown-top-level-field.v1.json +24 -0
- package/fixtures/obsidian/contracts/service-state/invalid/wildcard-bind.v1.json +23 -0
- package/fixtures/obsidian/contracts/service-state/valid/healthy.v1.json +23 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/absolute-file-path.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/duplicate-repository-id.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/mixed-read.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/parent-traversal-path.v1.json +48 -0
- package/fixtures/obsidian/contracts/source-snapshot/invalid/unknown-file-field.v1.json +49 -0
- package/fixtures/obsidian/contracts/source-snapshot/valid/two-repositories.v1.json +48 -0
- package/fixtures/obsidian/edits/workspace.json +65 -0
- package/fixtures/obsidian/materialization/expected-full.json +99 -0
- package/fixtures/obsidian/materialization/expected-scoped.json +39 -0
- package/fixtures/obsidian/materialization/workspace.json +54 -0
- package/fixtures/obsidian/proposals/expected-shapes.json +11 -0
- package/fixtures/projects/sample-workspace/content/source.html.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/data.json.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/logo.png.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/metrics.csv.kg.json +4 -1
- package/fixtures/projects/source-formats-workspace/content/pipeline.yaml.kg.json +4 -1
- package/fixtures/ui/presentation/pane.v1.json +7 -0
- package/fixtures/ui/presentation/reference.v1.json +293 -0
- package/package.json +86 -10
- package/skills/claude/atelier-guided-coauthor/SKILL.md +49 -0
- package/skills/claude/atelier-guided-upgrade/SKILL.md +97 -0
- package/skills/claude/atelier-local-service/SKILL.md +47 -0
- package/skills/claude/atelier-open/SKILL.md +11 -5
- package/skills/claude/atelier-public-boundary/SKILL.md +31 -0
- package/skills/claude/atelier-skill-steward/SKILL.md +62 -0
- package/skills/claude/mnstry-readiness/SKILL.md +5 -0
- package/skills/codex/atelier-guided-coauthor/SKILL.md +49 -0
- package/skills/codex/atelier-guided-upgrade/SKILL.md +97 -0
- package/skills/codex/atelier-local-service/SKILL.md +47 -0
- package/skills/codex/atelier-open/SKILL.md +11 -5
- package/skills/codex/atelier-public-boundary/SKILL.md +31 -0
- package/skills/codex/atelier-skill-steward/SKILL.md +62 -0
- package/skills/codex/mnstry-readiness/SKILL.md +5 -0
- package/src/access/preview-enforcer.mjs +84 -0
- package/src/boundary/content-rules.mjs +283 -20
- package/src/boundary/policy.mjs +213 -91
- package/src/cli/execute-command.mjs +36 -0
- package/src/cli/project-options.mjs +58 -0
- package/src/cli/run.mjs +78 -10
- package/src/coauthor/session.mjs +161 -0
- package/src/coauthor/store.mjs +173 -0
- package/src/collaboration/event-ledger.mjs +348 -0
- package/src/collaboration/index.mjs +17 -0
- package/src/collaboration/inspection-bundle.mjs +223 -0
- package/src/collaboration/proposals.mjs +265 -65
- package/src/collaboration/review-contracts.mjs +25 -0
- package/src/collaboration/review-store.mjs +305 -0
- package/src/commands/attestation.mjs +20 -6
- package/src/commands/coauthor.mjs +26 -0
- package/src/commands/config.mjs +6 -1
- package/src/commands/disclosure.mjs +133 -0
- package/src/commands/distribution.mjs +2 -1
- package/src/commands/extension-pack.mjs +17 -9
- package/src/commands/init.mjs +46 -6
- package/src/commands/obsidian.mjs +371 -0
- package/src/commands/review.mjs +147 -0
- package/src/commands/server.mjs +1 -4
- package/src/commands/setup.mjs +51 -14
- package/src/commands/skills.mjs +199 -0
- package/src/commands/sync.mjs +107 -0
- package/src/composition/registry.mjs +27 -0
- package/src/composition/wire.mjs +122 -0
- package/src/contracts/corpus.mjs +35 -0
- package/src/decisions/contracts.d.mts +96 -0
- package/src/decisions/contracts.mjs +321 -0
- package/src/disclosure/content-scan.mjs +206 -0
- package/src/egress/check.mjs +7 -38
- package/src/egress/forbidden-egress.mjs +32 -18
- package/src/export/atelier-export-contract.mjs +16 -1
- package/src/extension-packs/lifecycle.mjs +154 -0
- package/src/graph/graph.mjs +176 -316
- package/src/graph/knowledge-graph.mjs +643 -43
- package/src/guides/contracts.mjs +54 -0
- package/src/harness/context-client.mjs +9 -1
- package/src/index.mjs +41 -0
- package/src/intake/store.mjs +119 -0
- package/src/preview/channel.mjs +89 -0
- package/src/project/config.mjs +112 -52
- package/src/project/durable-state.mjs +161 -0
- package/src/project/file-class.mjs +180 -0
- package/src/project/package-root.mjs +10 -0
- package/src/project/path-match.mjs +38 -15
- package/src/project/private-state.mjs +120 -0
- package/src/projection/obsidian/contracts.mjs +571 -0
- package/src/projection/obsidian/edits/align.mjs +169 -0
- package/src/projection/obsidian/edits/apply.mjs +889 -0
- package/src/projection/obsidian/edits/arbitrate.mjs +414 -0
- package/src/projection/obsidian/edits/contribution.mjs +108 -0
- package/src/projection/obsidian/edits/index.mjs +19 -0
- package/src/projection/obsidian/edits/object-identity.mjs +61 -0
- package/src/projection/obsidian/edits/object-store.mjs +517 -0
- package/src/projection/obsidian/edits/observe.mjs +123 -0
- package/src/projection/obsidian/edits/policy.mjs +123 -0
- package/src/projection/obsidian/edits/regions.mjs +648 -0
- package/src/projection/obsidian/materialize/byte-lens.mjs +98 -0
- package/src/projection/obsidian/materialize/index.mjs +7 -0
- package/src/projection/obsidian/materialize/path-registry.mjs +105 -0
- package/src/projection/obsidian/materialize/prepare-view.mjs +746 -0
- package/src/projection/obsidian/materialize/settings.mjs +57 -0
- package/src/projection/obsidian/materialize/stage.mjs +27 -0
- package/src/projection/obsidian/proposals/adapter.mjs +572 -0
- package/src/projection/obsidian/proposals/backpressure.mjs +113 -0
- package/src/projection/obsidian/proposals/contribution.mjs +55 -0
- package/src/projection/obsidian/proposals/index.mjs +23 -0
- package/src/projection/obsidian/proposals/observation.mjs +216 -0
- package/src/projection/obsidian/proposals/queue.mjs +277 -0
- package/src/projection/obsidian/proposals/router.mjs +168 -0
- package/src/projection/obsidian/publication/bridge-script.mjs +266 -0
- package/src/projection/obsidian/publication/exchange.mjs +117 -0
- package/src/projection/obsidian/publication/index.mjs +5 -0
- package/src/projection/obsidian/publication/publisher.mjs +588 -0
- package/src/projection/obsidian/publication/test-seam.mjs +16 -0
- package/src/projection/obsidian/publication/transport.mjs +160 -0
- package/src/projection/obsidian/recovery/index.mjs +6 -0
- package/src/projection/obsidian/recovery/journal.mjs +134 -0
- package/src/projection/obsidian/recovery/late-writer.mjs +46 -0
- package/src/projection/obsidian/recovery/restart.mjs +316 -0
- package/src/projection/obsidian/recovery/store.mjs +234 -0
- package/src/projection/obsidian/selection-ui/conflict-view.mjs +91 -0
- package/src/projection/obsidian/selection-ui/contribution.mjs +141 -0
- package/src/projection/obsidian/selection-ui/focus.mjs +82 -0
- package/src/projection/obsidian/selection-ui/index.mjs +12 -0
- package/src/projection/obsidian/selection-ui/policy-setup.mjs +107 -0
- package/src/projection/obsidian/selection-ui/receipt.mjs +173 -0
- package/src/projection/obsidian/selection-ui/selection-state.mjs +122 -0
- package/src/projection/obsidian/selection-ui/selection.mjs +109 -0
- package/src/projection/project.mjs +28 -19
- package/src/readiness-protocols/evidence.mjs +282 -0
- package/src/readiness-protocols/runtime.mjs +4 -3
- package/src/readiness-protocols/source-read.mjs +39 -0
- package/src/runtime/git-adapter.mjs +189 -0
- package/src/runtime/local-state.mjs +439 -0
- package/src/runtime/obsidian/app-capability.mjs +129 -0
- package/src/runtime/obsidian/app-production-seams.mjs +105 -0
- package/src/runtime/obsidian/contributions/proposal-adapter.mjs +4 -0
- package/src/runtime/obsidian/contributions/selection-ui.mjs +4 -0
- package/src/runtime/obsidian/contributions/source-apply.mjs +4 -0
- package/src/runtime/obsidian/contributions.mjs +27 -0
- package/src/runtime/obsidian/documents.mjs +37 -0
- package/src/runtime/obsidian/enablement.mjs +53 -0
- package/src/runtime/obsidian/engine.mjs +532 -0
- package/src/runtime/obsidian/errors.mjs +14 -0
- package/src/runtime/obsidian/extension-points.mjs +103 -0
- package/src/runtime/obsidian/index.mjs +34 -0
- package/src/runtime/obsidian/lifecycle.mjs +258 -0
- package/src/runtime/obsidian/machine-settings.mjs +260 -0
- package/src/runtime/obsidian/observation.mjs +158 -0
- package/src/runtime/obsidian/opening.mjs +263 -0
- package/src/runtime/obsidian/pending-edits.mjs +141 -0
- package/src/runtime/obsidian/pipeline.mjs +122 -0
- package/src/runtime/obsidian/private-lock.mjs +156 -0
- package/src/runtime/obsidian/process-identity.mjs +58 -0
- package/src/runtime/obsidian/service-client.mjs +66 -0
- package/src/runtime/obsidian/service-entry-path.mjs +9 -0
- package/src/runtime/obsidian/service-main.mjs +91 -0
- package/src/runtime/obsidian/service-record.mjs +169 -0
- package/src/runtime/obsidian/service-server.mjs +121 -0
- package/src/runtime/obsidian/service.mjs +216 -0
- package/src/runtime/obsidian/startup-adapters.mjs +87 -0
- package/src/runtime/obsidian/state-store.mjs +180 -0
- package/src/runtime/obsidian/sync-notice.mjs +33 -0
- package/src/runtime/obsidian/tick-loop.mjs +84 -0
- package/src/runtime/obsidian/watchers.mjs +36 -0
- package/src/runtime/repository-observation.mjs +491 -0
- package/src/runtime/supervisor.mjs +803 -0
- package/src/server/local-sidecar.mjs +125 -59
- package/src/server/security.mjs +89 -4
- package/src/server/server.mjs +4 -2
- package/src/skills/steward.mjs +780 -0
- package/src/support/feedback-report.mjs +4 -3
- package/src/ui/presentation/browser.mjs +278 -0
- package/src/ui/presentation/contract.mjs +116 -0
- package/src/ui/presentation/index.mjs +7 -0
- package/src/ui/presentation/native.mjs +153 -0
- package/src/ui/presentation/proof.mjs +57 -0
- package/src/ui/presentation/schema-check.mjs +30 -0
- package/src/ui/presentation/schema.generated.mjs +1371 -0
- package/src/ui/presentation/state.mjs +43 -0
- package/src/ui/presentation/styles.mjs +67 -0
- package/src/ui/presentation/tokens.mjs +74 -0
- package/src/ui/presentation/web.mjs +85 -0
- package/src/ui/review-page.mjs +32 -0
- package/src/upgrade/explanation.mjs +33 -0
- package/src/upgrade/provenance.mjs +338 -0
- package/src/upgrade/transaction-files.mjs +103 -0
- package/src/upgrade/transaction.mjs +475 -0
- package/src/upgrade/upgrade.mjs +65 -29
- package/src/vault/hosts.mjs +21 -0
- package/src/vault/identity.mjs +19 -0
- package/src/vault/index.mjs +7 -0
- package/src/vault/interface.mjs +11 -0
- package/src/vault/metadata.mjs +31 -0
- package/src/vault/privacy.mjs +148 -0
- package/src/vault/probe.mjs +89 -0
- package/src/vault/service.mjs +131 -0
- package/src/vault/source.mjs +45 -0
- package/src/vault/storage.mjs +23 -0
- package/templates/distribution-workspace/.claude/launch.json +6 -2
- package/templates/distribution-workspace/gitignore +1 -0
- package/templates/distribution-workspace/project/README.md +2 -2
- package/templates/external-project-workspace/README.md +45 -0
- package/templates/external-project-workspace/answers.example.json +4 -0
- package/templates/external-project-workspace/atelier.project.json +40 -0
- package/templates/external-project-workspace/boundary-policy.v1.json +60 -0
- package/templates/external-project-workspace/gitignore +8 -0
- package/templates/external-project-workspace/pack-lifecycle.json +14 -0
- package/templates/external-project-workspace/packs/protocols/contract-gate.v1.json +109 -0
- package/templates/external-project-workspace/packs/sample-pack.v1.json +48 -0
- package/templates/external-project-workspace/repo-access.v1.json +9 -0
- package/templates/external-project-workspace/source/README.md +11 -0
- package/templates/launch.json +6 -2
- package/templates/private-domain-workspace/.claude/launch.json +6 -2
- package/templates/private-domain-workspace/domain/README.md +2 -2
- package/templates/private-domain-workspace/gitignore +1 -0
- package/templates/shared-project-workspace/.claude/launch.json +6 -2
- package/templates/shared-project-workspace/gitignore +1 -0
- package/templates/shared-project-workspace/project/README.md +2 -2
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
2
4
|
import { matchesPathPattern, normalizeRelPath } from '../project/path-match.mjs'
|
|
5
|
+
import { sanitizedGitEnvironment } from '../runtime/git-adapter.mjs'
|
|
3
6
|
|
|
4
7
|
export const EMPTY_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
|
|
5
8
|
export const ZERO_SHA_RE = /^0{40,}$/
|
|
6
9
|
|
|
7
10
|
export const RULE_KINDS = Object.freeze(['content', 'path'])
|
|
8
11
|
export const RULE_SEVERITIES = Object.freeze(['error', 'warning'])
|
|
12
|
+
export const DIFF_RESULT_MAX_BYTES = 16 * 1024 * 1024
|
|
13
|
+
export const CHECK_AGGREGATE_MAX_BYTES = 64 * 1024 * 1024
|
|
14
|
+
export const BINARY_FILE_MAX_BYTES = 8 * 1024 * 1024
|
|
15
|
+
export const BINARY_AGGREGATE_MAX_BYTES = 32 * 1024 * 1024
|
|
9
16
|
|
|
10
17
|
// A blanket exception is not an exception, it is switching the rule off. The
|
|
11
18
|
// contract requires a rule, a repo, real paths, and a reason a reviewer can act on.
|
|
@@ -33,7 +40,8 @@ export const DEFAULT_CONTENT_RULES = Object.freeze(
|
|
|
33
40
|
id: 'private-financial-filename',
|
|
34
41
|
kind: 'path',
|
|
35
42
|
severity: 'error',
|
|
36
|
-
pattern:
|
|
43
|
+
pattern:
|
|
44
|
+
'((^|/)\\.env(?:$|[.-])|invoice|payroll|(^|[-_/])salar(y|ies)|bank[-_]?statement|tax[-_]?return|credential|(^|[-_/])password([-_.]|$)|(^|[-_/])secret([-_.]|$)|id_rsa)',
|
|
37
45
|
description: 'Private or financial material does not belong in a source repo.',
|
|
38
46
|
},
|
|
39
47
|
].map(Object.freeze),
|
|
@@ -45,6 +53,7 @@ const trimmed = (value) => (typeof value === 'string' ? value.trim() : '')
|
|
|
45
53
|
export function validateContentRules(rules, { label = 'contentRules' } = {}) {
|
|
46
54
|
const errors = []
|
|
47
55
|
if (!Array.isArray(rules)) return [`${label} must be an array`]
|
|
56
|
+
if (rules.length === 0) errors.push(`${label} must contain at least one rule; omit the field to use the defaults`)
|
|
48
57
|
const seen = new Set()
|
|
49
58
|
for (const [index, rule] of rules.entries()) {
|
|
50
59
|
const at = `${label}[${index}]`
|
|
@@ -112,7 +121,8 @@ export function validateContentRuleExceptions(exceptions, rules = DEFAULT_CONTEN
|
|
|
112
121
|
|
|
113
122
|
export function resolveContentRules(policy) {
|
|
114
123
|
const declared = Array.isArray(policy?.contentRules) ? policy.contentRules : null
|
|
115
|
-
|
|
124
|
+
if (!declared?.length || validateContentRules(declared).length > 0) return DEFAULT_CONTENT_RULES
|
|
125
|
+
return declared
|
|
116
126
|
}
|
|
117
127
|
|
|
118
128
|
export function findException({ exceptions = [], rule, repo, path: filePath }) {
|
|
@@ -209,36 +219,237 @@ export function parseAddedContent(diff) {
|
|
|
209
219
|
|
|
210
220
|
/** Ref updates arrive on the pre-push hook's stdin as `<localRef> <localSha> <remoteRef> <remoteSha>`. */
|
|
211
221
|
export function parsePushRefUpdates(text) {
|
|
222
|
+
return parsePushRefInput(text).updates
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function parsePushRefInput(text) {
|
|
212
226
|
const updates = []
|
|
213
|
-
|
|
227
|
+
const issues = []
|
|
228
|
+
const input = String(text ?? '')
|
|
229
|
+
if (!input.trim()) return { ok: true, kind: 'empty', updates, issues }
|
|
230
|
+
for (const [index, raw] of input.split(/\r?\n/).entries()) {
|
|
231
|
+
if (!raw.trim()) continue
|
|
214
232
|
const parts = raw.trim().split(/\s+/).filter(Boolean)
|
|
215
|
-
if (parts.length
|
|
233
|
+
if (parts.length !== 4) {
|
|
234
|
+
issues.push(`line ${index + 1}: expected four pre-push fields`)
|
|
235
|
+
continue
|
|
236
|
+
}
|
|
216
237
|
const [localRef, localSha, remoteRef, remoteSha] = parts
|
|
238
|
+
if (!/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/i.test(localSha) || !/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/i.test(remoteSha)) {
|
|
239
|
+
issues.push(`line ${index + 1}: ref update contains an invalid object id`)
|
|
240
|
+
continue
|
|
241
|
+
}
|
|
242
|
+
if (!localRef || !remoteRef) {
|
|
243
|
+
issues.push(`line ${index + 1}: ref names are required`)
|
|
244
|
+
continue
|
|
245
|
+
}
|
|
217
246
|
if (ZERO_SHA_RE.test(localSha)) continue // branch deletion pushes no content
|
|
218
247
|
updates.push({ localRef, localSha, remoteRef, remoteSha })
|
|
219
248
|
}
|
|
220
|
-
return
|
|
249
|
+
return issues.length > 0
|
|
250
|
+
? { ok: false, kind: 'invalid', updates: [], issues }
|
|
251
|
+
: { ok: true, kind: updates.length > 0 ? 'valid' : 'empty', updates, issues: [] }
|
|
221
252
|
}
|
|
222
253
|
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
|
|
254
|
+
export function gitOutputResult(repoRoot, args, {
|
|
255
|
+
encoding = 'utf8',
|
|
256
|
+
gitExecutable = 'git',
|
|
257
|
+
maxBuffer = DIFF_RESULT_MAX_BYTES,
|
|
258
|
+
runner = spawnSync,
|
|
259
|
+
} = {}) {
|
|
260
|
+
let result
|
|
261
|
+
try {
|
|
262
|
+
result = runner(gitExecutable, ['-C', repoRoot, ...args], { encoding, maxBuffer, env: sanitizedGitEnvironment() })
|
|
263
|
+
} catch (error) {
|
|
264
|
+
return { ok: false, code: 'git-command-failed', error: error instanceof Error ? error.message : String(error), stdout: null }
|
|
265
|
+
}
|
|
266
|
+
if (result?.error?.code === 'ENOBUFS') {
|
|
267
|
+
return { ok: false, code: 'git-output-limit-exceeded', error: `Git ${args[0] ?? 'command'} exceeded the ${maxBuffer}-byte evidence limit`, stdout: null }
|
|
268
|
+
}
|
|
269
|
+
if (result?.status !== 0) {
|
|
270
|
+
return { ok: false, code: 'git-command-failed', error: `Git ${args[0] ?? 'command'} failed with status ${result?.status ?? 'unknown'}`, stdout: null }
|
|
271
|
+
}
|
|
272
|
+
const stdout = result.stdout ?? (encoding === 'buffer' ? Buffer.alloc(0) : '')
|
|
273
|
+
const bytes = Buffer.isBuffer(stdout) ? stdout.length : Buffer.byteLength(stdout)
|
|
274
|
+
if (bytes > maxBuffer) {
|
|
275
|
+
return { ok: false, code: 'git-output-limit-exceeded', error: `Git ${args[0] ?? 'command'} exceeded the ${maxBuffer}-byte evidence limit`, stdout: null }
|
|
276
|
+
}
|
|
277
|
+
return { ok: true, stdout, bytes }
|
|
226
278
|
}
|
|
227
279
|
|
|
228
280
|
export function pushRangeBase(repoRoot, remoteSha) {
|
|
229
281
|
// A new branch has no remote counterpart, so everything it carries is new:
|
|
230
282
|
// diff against the empty tree rather than silently scanning nothing.
|
|
231
283
|
if (!remoteSha || ZERO_SHA_RE.test(remoteSha)) return EMPTY_TREE
|
|
232
|
-
|
|
284
|
+
const result = spawnSync('git', ['-C', repoRoot, 'rev-parse', '--verify', '--quiet', `${remoteSha}^{commit}`], {
|
|
285
|
+
encoding: 'utf8',
|
|
286
|
+
maxBuffer: 1024 * 1024,
|
|
287
|
+
})
|
|
288
|
+
return result.status === 0 ? remoteSha : EMPTY_TREE
|
|
233
289
|
}
|
|
234
290
|
|
|
235
|
-
export function diffForPushRange(repoRoot, { localSha, remoteSha }) {
|
|
291
|
+
export function diffForPushRange(repoRoot, { localSha, remoteSha }, options = {}) {
|
|
236
292
|
const base = pushRangeBase(repoRoot, remoteSha)
|
|
237
|
-
|
|
293
|
+
const result = gitOutputResult(repoRoot, ['diff', '--unified=0', base, localSha], options)
|
|
294
|
+
return result.ok ? { ...result, base, diff: result.stdout } : { ...result, base, diff: null }
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function stagedDiff(repoRoot, options = {}) {
|
|
298
|
+
const result = gitOutputResult(repoRoot, ['diff', '--cached', '--unified=0'], options)
|
|
299
|
+
return result.ok ? { ...result, diff: result.stdout } : { ...result, diff: null }
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function incompleteDiagnostic({ repo, path: filePath = null, message, details = {} }) {
|
|
303
|
+
return {
|
|
304
|
+
severity: 'error',
|
|
305
|
+
code: 'content-scan-incomplete',
|
|
306
|
+
repo,
|
|
307
|
+
path: filePath,
|
|
308
|
+
line: null,
|
|
309
|
+
message: `${repo ?? 'repository'}${filePath ? `/${filePath}` : ''}: ${message}`,
|
|
310
|
+
details,
|
|
311
|
+
}
|
|
238
312
|
}
|
|
239
313
|
|
|
240
|
-
|
|
241
|
-
|
|
314
|
+
function binaryPathsFromDiff(diff) {
|
|
315
|
+
const paths = new Set()
|
|
316
|
+
let current = null
|
|
317
|
+
for (const line of String(diff ?? '').split('\n')) {
|
|
318
|
+
if (line.startsWith('diff --git ')) {
|
|
319
|
+
const header = line.match(/^diff --git a\/(.*) b\/(.*)$/)
|
|
320
|
+
current = header ? normalizeRelPath(header[2]) : null
|
|
321
|
+
continue
|
|
322
|
+
}
|
|
323
|
+
if (current && (line.startsWith('Binary files ') || line === 'GIT binary patch')) paths.add(current)
|
|
324
|
+
}
|
|
325
|
+
return [...paths]
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function isBinaryBuffer(buffer) {
|
|
329
|
+
if (buffer.subarray(0, Math.min(buffer.length, 8192)).includes(0)) return true
|
|
330
|
+
try {
|
|
331
|
+
new TextDecoder('utf-8', { fatal: true }).decode(buffer)
|
|
332
|
+
return false
|
|
333
|
+
} catch {
|
|
334
|
+
return true
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function scanBinaryBuffer({ buffer, filePath, rules, exceptions, repo }) {
|
|
339
|
+
if (!isBinaryBuffer(buffer)) return []
|
|
340
|
+
const text = buffer.toString('latin1')
|
|
341
|
+
const findings = []
|
|
342
|
+
for (const rule of rules) {
|
|
343
|
+
if ((rule.kind ?? 'content') !== 'content' || !rulePathMatches(rule, filePath)) continue
|
|
344
|
+
if (!new RegExp(rule.pattern).test(text)) continue
|
|
345
|
+
if (findException({ exceptions, rule: rule.id, repo, path: filePath })) continue
|
|
346
|
+
findings.push({
|
|
347
|
+
severity: rule.severity ?? 'error',
|
|
348
|
+
code: 'content-rule-violation',
|
|
349
|
+
rule: rule.id,
|
|
350
|
+
repo,
|
|
351
|
+
path: filePath,
|
|
352
|
+
line: null,
|
|
353
|
+
binary: true,
|
|
354
|
+
message: `${repo ?? ''}/${filePath}: ${rule.description ?? rule.id} (binary content)`.replace(/^\//, ''),
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
return findings
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function readBinaryChanges({ repoRoot, revision, diff, rules, exceptions, repo, gitExecutable, gitRunner }) {
|
|
361
|
+
const findings = []
|
|
362
|
+
const diagnostics = []
|
|
363
|
+
let totalBytes = 0
|
|
364
|
+
for (const filePath of binaryPathsFromDiff(diff)) {
|
|
365
|
+
const spec = revision === ':' ? `:${filePath}` : `${revision}:${filePath}`
|
|
366
|
+
const result = gitOutputResult(repoRoot, ['show', spec], {
|
|
367
|
+
encoding: 'buffer',
|
|
368
|
+
gitExecutable,
|
|
369
|
+
maxBuffer: BINARY_FILE_MAX_BYTES + 1,
|
|
370
|
+
runner: gitRunner,
|
|
371
|
+
})
|
|
372
|
+
if (!result.ok) {
|
|
373
|
+
diagnostics.push(incompleteDiagnostic({
|
|
374
|
+
repo,
|
|
375
|
+
path: filePath,
|
|
376
|
+
message: `binary content could not be read within the ${BINARY_FILE_MAX_BYTES}-byte per-file limit`,
|
|
377
|
+
details: { reason: result.code, limitBytes: BINARY_FILE_MAX_BYTES },
|
|
378
|
+
}))
|
|
379
|
+
continue
|
|
380
|
+
}
|
|
381
|
+
if (result.bytes > BINARY_FILE_MAX_BYTES) {
|
|
382
|
+
diagnostics.push(incompleteDiagnostic({
|
|
383
|
+
repo,
|
|
384
|
+
path: filePath,
|
|
385
|
+
message: `binary content exceeds the ${BINARY_FILE_MAX_BYTES}-byte per-file limit`,
|
|
386
|
+
details: { limitBytes: BINARY_FILE_MAX_BYTES, observedBytes: result.bytes },
|
|
387
|
+
}))
|
|
388
|
+
continue
|
|
389
|
+
}
|
|
390
|
+
totalBytes += result.bytes
|
|
391
|
+
if (totalBytes > BINARY_AGGREGATE_MAX_BYTES) {
|
|
392
|
+
diagnostics.push(incompleteDiagnostic({
|
|
393
|
+
repo,
|
|
394
|
+
path: filePath,
|
|
395
|
+
message: `binary content exceeds the ${BINARY_AGGREGATE_MAX_BYTES}-byte aggregate limit`,
|
|
396
|
+
details: { limitBytes: BINARY_AGGREGATE_MAX_BYTES },
|
|
397
|
+
}))
|
|
398
|
+
break
|
|
399
|
+
}
|
|
400
|
+
findings.push(...scanBinaryBuffer({ buffer: result.stdout, filePath, rules, exceptions, repo }))
|
|
401
|
+
}
|
|
402
|
+
return { findings, diagnostics, bytes: totalBytes }
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export function scanStagedRepository({
|
|
406
|
+
repoRoot,
|
|
407
|
+
rules = DEFAULT_CONTENT_RULES,
|
|
408
|
+
exceptions = [],
|
|
409
|
+
repo = null,
|
|
410
|
+
gitExecutable = 'git',
|
|
411
|
+
gitRunner = spawnSync,
|
|
412
|
+
} = {}) {
|
|
413
|
+
const acquired = stagedDiff(repoRoot, { gitExecutable, runner: gitRunner })
|
|
414
|
+
if (!acquired.ok) {
|
|
415
|
+
return {
|
|
416
|
+
findings: [],
|
|
417
|
+
diagnostics: [incompleteDiagnostic({ repo, message: 'staged evidence could not be acquired', details: { reason: acquired.code } })],
|
|
418
|
+
bytes: 0,
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const files = parseAddedContent(acquired.diff)
|
|
422
|
+
const binary = readBinaryChanges({ repoRoot, revision: ':', diff: acquired.diff, rules, exceptions, repo, gitExecutable, gitRunner })
|
|
423
|
+
return {
|
|
424
|
+
findings: [...scanAddedContent({ files, rules, exceptions, repo }), ...binary.findings],
|
|
425
|
+
diagnostics: binary.diagnostics,
|
|
426
|
+
bytes: acquired.bytes + binary.bytes,
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export function scanPushUpdate({
|
|
431
|
+
repoRoot,
|
|
432
|
+
update,
|
|
433
|
+
rules = DEFAULT_CONTENT_RULES,
|
|
434
|
+
exceptions = [],
|
|
435
|
+
repo = null,
|
|
436
|
+
gitRunner = spawnSync,
|
|
437
|
+
} = {}) {
|
|
438
|
+
const acquired = diffForPushRange(repoRoot, update, { runner: gitRunner })
|
|
439
|
+
if (!acquired.ok) {
|
|
440
|
+
return {
|
|
441
|
+
findings: [],
|
|
442
|
+
diagnostics: [incompleteDiagnostic({ repo, message: 'push evidence could not be acquired', details: { reason: acquired.code } })],
|
|
443
|
+
bytes: 0,
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const files = parseAddedContent(acquired.diff)
|
|
447
|
+
const binary = readBinaryChanges({ repoRoot, revision: update.localSha, diff: acquired.diff, rules, exceptions, repo })
|
|
448
|
+
return {
|
|
449
|
+
findings: [...scanAddedContent({ files, rules, exceptions, repo }), ...binary.findings],
|
|
450
|
+
diagnostics: binary.diagnostics,
|
|
451
|
+
bytes: acquired.bytes + binary.bytes,
|
|
452
|
+
}
|
|
242
453
|
}
|
|
243
454
|
|
|
244
455
|
/**
|
|
@@ -246,17 +457,69 @@ export function stagedDiff(repoRoot) {
|
|
|
246
457
|
* accepted usage, so a repo can see what it has taken on without those findings
|
|
247
458
|
* stopping unrelated work from being pushed.
|
|
248
459
|
*/
|
|
249
|
-
export function scanTree(repoRoot, {
|
|
250
|
-
|
|
460
|
+
export function scanTree(repoRoot, {
|
|
461
|
+
rules = DEFAULT_CONTENT_RULES,
|
|
462
|
+
exceptions = [],
|
|
463
|
+
repo = null,
|
|
464
|
+
source = 'working-tree',
|
|
465
|
+
} = {}) {
|
|
466
|
+
if (!['working-tree', 'head'].includes(source)) {
|
|
467
|
+
return { findings: [], diagnostics: [incompleteDiagnostic({ repo, message: `unknown audit source ${source}` })], source }
|
|
468
|
+
}
|
|
469
|
+
const listed = source === 'head'
|
|
470
|
+
? gitOutputResult(repoRoot, ['ls-tree', '-r', '--name-only', '-z', 'HEAD'])
|
|
471
|
+
: gitOutputResult(repoRoot, ['ls-files', '-co', '--exclude-standard', '-z'])
|
|
472
|
+
if (!listed.ok) {
|
|
473
|
+
return { findings: [], diagnostics: [incompleteDiagnostic({ repo, message: `${source} audit paths could not be acquired`, details: { reason: listed.code } })], source }
|
|
474
|
+
}
|
|
251
475
|
const files = []
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
476
|
+
const findings = []
|
|
477
|
+
const diagnostics = []
|
|
478
|
+
let totalBytes = 0
|
|
479
|
+
for (const rel of listed.stdout.split('\0').filter(Boolean)) {
|
|
480
|
+
let blob
|
|
481
|
+
if (source === 'head') {
|
|
482
|
+
const result = gitOutputResult(repoRoot, ['show', `HEAD:${rel}`], { encoding: 'buffer', maxBuffer: BINARY_FILE_MAX_BYTES + 1 })
|
|
483
|
+
if (!result.ok) {
|
|
484
|
+
diagnostics.push(incompleteDiagnostic({ repo, path: rel, message: 'HEAD blob could not be read', details: { reason: result.code } }))
|
|
485
|
+
continue
|
|
486
|
+
}
|
|
487
|
+
blob = result.stdout
|
|
488
|
+
} else {
|
|
489
|
+
const abs = pathForAudit(repoRoot, rel)
|
|
490
|
+
try {
|
|
491
|
+
const stat = fs.lstatSync(abs)
|
|
492
|
+
if (!stat.isFile() && !stat.isSymbolicLink()) continue
|
|
493
|
+
blob = stat.isSymbolicLink() ? Buffer.from(fs.readlinkSync(abs)) : fs.readFileSync(abs)
|
|
494
|
+
} catch {
|
|
495
|
+
diagnostics.push(incompleteDiagnostic({ repo, path: rel, message: 'working-tree file could not be read' }))
|
|
496
|
+
continue
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (blob.length > BINARY_FILE_MAX_BYTES) {
|
|
500
|
+
diagnostics.push(incompleteDiagnostic({ repo, path: rel, message: `audit content exceeds the ${BINARY_FILE_MAX_BYTES}-byte per-file limit` }))
|
|
501
|
+
continue
|
|
502
|
+
}
|
|
503
|
+
totalBytes += blob.length
|
|
504
|
+
if (totalBytes > BINARY_AGGREGATE_MAX_BYTES) {
|
|
505
|
+
diagnostics.push(incompleteDiagnostic({ repo, path: rel, message: `audit content exceeds the ${BINARY_AGGREGATE_MAX_BYTES}-byte aggregate limit` }))
|
|
506
|
+
break
|
|
507
|
+
}
|
|
508
|
+
if (isBinaryBuffer(blob)) {
|
|
509
|
+
findings.push(...scanBinaryBuffer({ buffer: blob, filePath: rel, rules, exceptions, repo }))
|
|
510
|
+
continue
|
|
511
|
+
}
|
|
512
|
+
const text = blob.toString('utf8')
|
|
255
513
|
files.push({
|
|
256
514
|
path: rel,
|
|
257
515
|
added: true,
|
|
258
|
-
addedLines:
|
|
516
|
+
addedLines: text.split('\n').map((line, index) => ({ number: index + 1, text: line })),
|
|
259
517
|
})
|
|
260
518
|
}
|
|
261
|
-
|
|
519
|
+
findings.push(...scanAddedContent({ files, rules, exceptions, repo }))
|
|
520
|
+
return { findings, diagnostics, source, bytes: totalBytes }
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function pathForAudit(repoRoot, rel) {
|
|
524
|
+
return path.join(repoRoot, ...normalizeRelPath(rel).split('/'))
|
|
262
525
|
}
|