@uniqbit/mate-core 0.21.1 → 1.0.0-canary.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/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/hooks/hooks.json +32 -1
- package/claude-plugin/hooks/workflow-turn.mjs +68 -0
- package/opencode-plugin/src/companion.ts +6 -0
- package/opencode-plugin/src/server.ts +24 -0
- package/package.json +9 -4
- package/src/cli/commands/artifact/apply-context.ts +1 -0
- package/src/cli/commands/artifact/artifact.ts +16 -0
- package/src/cli/commands/artifact/delivery/archive.ts +37 -112
- package/src/cli/commands/artifact/delivery/branch-flags.ts +19 -1
- package/src/cli/commands/artifact/delivery/environment.ts +30 -90
- package/src/cli/commands/artifact/delivery/link.ts +26 -26
- package/src/cli/commands/artifact/delivery/output.ts +27 -4
- package/src/cli/commands/artifact/delivery/resolve.ts +102 -0
- package/src/cli/commands/artifact/delivery/submit.ts +171 -0
- package/src/cli/commands/artifact/delivery/take.ts +46 -0
- package/src/cli/commands/artifact/extract-repo-name.ts +1 -1
- package/src/cli/commands/artifact/finish/command.ts +486 -55
- package/src/cli/commands/artifact/finish/engine.ts +87 -69
- package/src/cli/commands/artifact/finish/finisher.ts +5 -12
- package/src/cli/commands/artifact/finish/git.ts +9 -10
- package/src/cli/commands/artifact/finish/openspec.ts +21 -174
- package/src/cli/commands/artifact/finish/secret-scan.ts +5 -43
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +57 -7
- package/src/cli/commands/artifact/pending/command.ts +187 -10
- package/src/cli/commands/artifact/pending/discovery.ts +7 -11
- package/src/cli/commands/artifact/project/command.ts +59 -0
- package/src/cli/commands/cap/tokensave.ts +2 -2
- package/src/cli/commands/companion/hub.ts +11 -6
- package/src/cli/commands/companion/link.ts +173 -46
- package/src/cli/commands/companion/list.ts +70 -14
- package/src/cli/commands/companion/sync.ts +18 -0
- package/src/cli/commands/companion/update.ts +4 -3
- package/src/cli/commands/doctor.ts +84 -4
- package/src/cli/commands/friction.ts +558 -0
- package/src/cli/commands/install.ts +9 -4
- package/src/cli/commands/plugin/install.ts +82 -35
- package/src/cli/commands/studio/companion-add.ts +12 -27
- package/src/cli/commands/studio/connection.ts +53 -0
- package/src/{lib/factory/outcomes/sessions.ts → cli/commands/studio/live-sessions.ts} +7 -5
- package/src/cli/commands/studio/mcp-manager.ts +162 -0
- package/src/cli/commands/studio/payload.ts +172 -17
- package/src/cli/commands/studio/reports.ts +19 -18
- package/src/cli/commands/studio/routes.ts +8 -24
- package/src/cli/commands/studio/selection.ts +13 -4
- package/src/cli/commands/studio/server.ts +267 -243
- package/src/cli/commands/studio/service-host.ts +269 -0
- package/src/cli/commands/studio/services.ts +53 -34
- package/src/cli/commands/studio/studio-app.ts +1 -0
- package/src/cli/commands/studio/terminal.ts +1 -1
- package/src/cli/commands/studio/vault.ts +41 -40
- package/src/cli/commands/studio/views/model.ts +1 -9
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +6 -5
- package/src/cli/commands/triage.ts +172 -0
- package/src/cli/commands/vscode/release-vsix.json +2 -2
- package/src/cli/commands/workflow/workflow.ts +516 -0
- package/src/cli/commands/working/cleanup.ts +1 -18
- package/src/cli/companion-link-wizard.tsx +158 -91
- package/src/cli/install-plan.tsx +3 -0
- package/src/cli/main.ts +106 -26
- package/src/cli/plugin-commands.ts +6 -1
- package/src/cli/repo-list-table.tsx +73 -37
- package/src/cli/usage.ts +30 -9
- package/src/create-mate.ts +15 -6
- package/src/distribution.ts +2 -0
- package/src/factory-host.ts +75 -0
- package/src/hooks/companion-instructions.ts +19 -8
- package/src/hooks/hook-io.ts +3 -1
- package/src/hooks/session-banner.ts +25 -0
- package/src/hooks/validate-artifact-path.ts +73 -22
- package/src/hooks/workflow-turn.ts +219 -0
- package/src/index.ts +1 -0
- package/src/lib/apply-context/fingerprint.ts +2 -1
- package/src/lib/apply-context/protocol.ts +2 -2
- package/src/lib/artifact-trailer.ts +27 -0
- package/src/lib/change-layout.ts +83 -38
- package/src/lib/delivery/branch-template.ts +4 -12
- package/src/lib/delivery/checkout.ts +3 -2
- package/src/lib/delivery/environment.ts +129 -7
- package/src/lib/delivery/merge-git.ts +312 -28
- package/src/lib/delivery/overlap.ts +81 -16
- package/src/lib/delivery/record-delivery.ts +102 -9
- package/src/lib/delivery/record.ts +186 -24
- package/src/lib/delivery/refresh.ts +241 -152
- package/src/lib/delivery/remote.ts +66 -0
- package/src/lib/delivery/repository-access.ts +30 -66
- package/src/lib/delivery/stages.ts +83 -50
- package/src/lib/delivery/staging/apply-chain.ts +182 -0
- package/src/lib/delivery/staging/artifact-type.ts +101 -0
- package/src/lib/delivery/staging/declared-type.ts +277 -0
- package/src/lib/delivery/staging/linked-merges.ts +175 -0
- package/src/lib/delivery/staging/naming.ts +67 -0
- package/src/lib/delivery/staging/openspec-type.ts +166 -0
- package/src/lib/delivery/staging/pending-edit.ts +291 -0
- package/src/lib/delivery/staging/pending.ts +922 -0
- package/src/lib/delivery/staging/preflight.ts +239 -0
- package/src/lib/delivery/staging/project.ts +512 -0
- package/src/lib/delivery/staging/publish.ts +1024 -0
- package/src/lib/delivery/staging/refs.ts +258 -0
- package/src/lib/delivery/staging/registry.ts +73 -0
- package/src/lib/delivery/staging/replay.ts +310 -0
- package/src/lib/delivery/staging/requirement-blocks.ts +10 -0
- package/src/lib/delivery/staging/resolve.ts +264 -0
- package/src/lib/delivery/staging/settle-linked.ts +176 -0
- package/src/lib/delivery/staging/submit.ts +1050 -0
- package/src/lib/delivery/staging/worktree.ts +130 -0
- package/src/lib/delivery/submit-change.ts +569 -0
- package/src/lib/friction/describe.ts +42 -0
- package/src/lib/friction/fields.ts +60 -0
- package/src/lib/friction/mark.ts +194 -0
- package/src/lib/friction/view/model.ts +67 -0
- package/src/lib/friction/view/read.ts +145 -0
- package/src/lib/friction/view/select.ts +54 -0
- package/src/lib/git-key.ts +15 -0
- package/src/lib/install.ts +2 -0
- package/src/lib/mcp-manager/resolve.ts +88 -0
- package/src/lib/mcp-manager/store.ts +133 -0
- package/src/lib/mcp-manager/types.ts +72 -0
- package/src/lib/mcp-manager/validate.ts +242 -0
- package/src/lib/openspec-canonical-frontmatter.ts +159 -0
- package/src/lib/openspec-cli.ts +10 -5
- package/src/lib/orchestrator/adapters/base.ts +31 -20
- package/src/lib/orchestrator/adapters/claude.ts +21 -7
- package/src/lib/orchestrator/adapters/opencode.ts +4 -0
- package/src/lib/orchestrator/companion-git-sync.ts +152 -16
- package/src/lib/orchestrator/config-store.ts +30 -7
- package/src/lib/orchestrator/engine-floor.ts +16 -4
- package/src/lib/orchestrator/engine-guard.ts +7 -1
- package/src/lib/orchestrator/framework-context.ts +15 -1
- package/src/lib/orchestrator/projection-claude-links.ts +1 -0
- package/src/lib/orchestrator/refresh-working-claude-links.ts +1 -0
- package/src/lib/orchestrator/repo-local-store.ts +14 -0
- package/src/lib/orchestrator/repository-link.ts +80 -52
- package/src/lib/orchestrator/root-context.ts +40 -7
- package/src/lib/orchestrator/session-prepare.ts +11 -1
- package/src/lib/orchestrator/types.ts +4 -0
- package/src/lib/orchestrator/umbrella-checkouts.ts +4 -4
- package/src/lib/package-paths.ts +23 -15
- package/src/lib/prebuilt-workspace-prepare.ts +2 -1
- package/src/lib/prebuilt-workspace.ts +1 -0
- package/src/lib/session-attribution.ts +3 -7
- package/src/lib/session-state.ts +3 -2
- package/src/lib/skills-cli.ts +38 -0
- package/src/lib/tool-manifest.ts +73 -0
- package/src/lib/triage/context.ts +312 -0
- package/src/lib/triage/launch.ts +52 -0
- package/src/lib/triage/prepare.ts +112 -0
- package/src/lib/triage/session.ts +126 -0
- package/src/lib/workflow/declaration.ts +6 -0
- package/src/lib/workflow/handoff.ts +90 -0
- package/src/lib/workflow/hook-trust.ts +108 -0
- package/src/lib/workflow/position.ts +524 -0
- package/src/lib/workflow/report.ts +79 -0
- package/src/lib/workflow/work.ts +106 -0
- package/src/lib/workset/factory-local.ts +2 -2
- package/src/lib/workset/repositories.ts +2 -2
- package/src/lib/workset/stage.ts +4 -2
- package/src/lib/workset/stages.ts +64 -4
- package/src/lib/workset/worktree.ts +32 -14
- package/src/opencode/companion-hooks.ts +63 -14
- package/src/opencode/projected-guidance.ts +7 -2
- package/src/opencode/turn-hook.ts +241 -0
- package/src/playbooks/companion-guidance.ts +7 -4
- package/src/plugin-api.ts +48 -0
- package/src/runtime/artifact-trailers.ts +63 -0
- package/src/runtime/claude-hook-group.ts +2 -0
- package/src/runtime/command-arg.ts +15 -0
- package/src/runtime/command-friction.ts +97 -0
- package/src/runtime/companion-git-state.ts +155 -10
- package/src/runtime/companion-git.ts +86 -11
- package/src/runtime/companion-guidance.ts +120 -17
- package/src/runtime/companion-instructions.ts +1 -1
- package/src/runtime/companion-sync.ts +109 -21
- package/src/runtime/env-names.ts +2 -2
- package/src/runtime/env.ts +7 -6
- package/src/runtime/forge-remote.ts +54 -0
- package/src/runtime/friction-fingerprint.ts +35 -0
- package/src/runtime/friction-log.ts +376 -0
- package/src/runtime/friction-recorder.ts +212 -0
- package/src/runtime/friction-retention.ts +1 -0
- package/src/runtime/friction-state.ts +110 -0
- package/src/runtime/friction-switch.ts +26 -0
- package/src/runtime/friction-vocabulary.ts +42 -0
- package/src/runtime/git-layout.ts +21 -7
- package/src/runtime/git-tracked.ts +13 -2
- package/src/runtime/json-fields.ts +8 -0
- package/src/runtime/pending-records.ts +533 -0
- package/src/runtime/projected-guidance.ts +8 -3
- package/src/runtime/publication-secret-scan.ts +45 -0
- package/src/runtime/secret-patterns.ts +7 -5
- package/src/runtime/secret-values.ts +16 -0
- package/src/runtime/session-id.ts +24 -0
- package/src/runtime/session-prepare-runner.ts +3 -0
- package/src/runtime/skill-prefix.ts +75 -0
- package/src/runtime/submitted-arrivals.ts +547 -0
- package/src/runtime/turn-state.d.mts +14 -0
- package/src/runtime/turn-state.mjs +93 -0
- package/src/runtime/umbrella-children.ts +52 -0
- package/src/runtime/umbrella-folder.ts +31 -3
- package/src/runtime/workflow/change-folders.ts +66 -0
- package/src/runtime/workflow/declaration.ts +720 -0
- package/src/runtime/workflow/globs.ts +85 -0
- package/src/runtime/workflow/next-handoff-process.ts +99 -0
- package/src/runtime/workflow/turn.ts +311 -0
- package/src/runtime/workflow/workflow.ts +262 -0
- package/src/studio.ts +113 -23
- package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/schema.yaml +3 -3
- package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/design.md +1 -1
- package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/proposal.md +1 -1
- package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/tasks.md +1 -1
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +7 -3
- package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +84 -28
- package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +1 -1
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +30 -68
- package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +39 -8
- package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +38 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +65 -12
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +68 -28
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +13 -7
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +1 -1
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +136 -86
- package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +111 -100
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +28 -3
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +39 -5
- package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +138 -0
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +84 -28
- package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +1 -1
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +30 -68
- package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +39 -8
- package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +38 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +65 -12
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +68 -28
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +13 -7
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +1 -1
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +136 -86
- package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +111 -100
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +28 -3
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +39 -5
- package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +138 -0
- package/src/templates/mate-skills/openspec-references.ts +3 -2
- package/src/templates/triage/PLAYBOOK.md +120 -0
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +678 -170
- package/src/tools/setup/capabilities/graphify.ts +23 -1
- package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
- package/src/tools/setup/capabilities/openspec.ts +54 -15
- package/src/tools/setup/capabilities/rtk.ts +47 -94
- package/src/tools/setup/capabilities/tokensave.ts +79 -56
- package/src/tools/setup/context-services.ts +35 -6
- package/src/tools/setup/dynamic-plugins/api.ts +38 -0
- package/src/tools/setup/dynamic-plugins/audiences.ts +31 -16
- package/src/tools/setup/dynamic-plugins/host.ts +2 -32
- package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
- package/src/tools/setup/dynamic-plugins/install.ts +2 -0
- package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
- package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
- package/src/tools/setup/dynamic-plugins/local.ts +492 -0
- package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
- package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
- package/src/tools/setup/dynamic-plugins/workspaces.ts +21 -12
- package/src/tools/setup/engine.ts +75 -4
- package/src/tools/setup/mate.ts +28 -1
- package/src/tools/setup/package-managers/bun.ts +8 -8
- package/src/tools/setup/plugin.ts +28 -1
- package/src/tools/setup/plugins/gitignore.ts +45 -12
- package/src/tools/setup/plugins/guidance.ts +4 -2
- package/src/tools/setup/providers/claude-format.ts +39 -2
- package/src/tools/setup/providers/claude-plugin-hooks.ts +18 -0
- package/src/tools/setup/providers/claude.ts +56 -6
- package/src/tools/setup/providers/opencode-format.ts +13 -3
- package/src/tools/setup/providers/opencode.ts +7 -18
- package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
- package/src/tools/setup/service-registry.ts +69 -0
- package/src/tools/setup/service.ts +245 -0
- package/src/tools/setup/utils.ts +34 -4
- package/src/tools/setup.ts +16 -2
- package/studio-dist/client/assets/DialogTitle-B_G47-lk.js +1 -0
- package/studio-dist/client/assets/app-0NoFqMou.css +2 -0
- package/studio-dist/client/assets/button-D_0295cs.js +1 -0
- package/studio-dist/client/assets/cn-Cx_D6I3u.js +1 -0
- package/studio-dist/client/assets/combobox-D0iPQP50.js +1 -0
- package/studio-dist/client/assets/{companion-view-CrabvxS8.js → companion-view-D3A76MLj.js} +1 -1
- package/studio-dist/client/assets/fields-Ctheim1h.js +1 -0
- package/studio-dist/client/assets/friction-Cn9n_zBA.js +1 -0
- package/studio-dist/client/assets/getting-started-DgoVWbWo.js +1 -0
- package/studio-dist/client/assets/{getting-started-D6kgWwWZ.js → getting-started-MmLqvy01.js} +1 -1
- package/studio-dist/client/assets/getting-started._topic-DBF0khhz.js +1 -0
- package/studio-dist/client/assets/getting-started.index-BRdAVqIh.js +1 -0
- package/studio-dist/client/assets/graph-BVRdq46V.js +2 -0
- package/studio-dist/client/assets/{graph-canvas-Ba37Y5AE.js → graph-canvas-BNzd-eVb.js} +1 -1
- package/studio-dist/client/assets/guides-DY1W9LRs.js +1 -0
- package/studio-dist/client/assets/index-CuTIc9yd.js +40 -0
- package/studio-dist/client/assets/{markdown-view-BOX6x0rL.js → markdown-view-BqZQkk_k.js} +1 -1
- package/studio-dist/client/assets/mcp-CIFxmDs0.js +4 -0
- package/studio-dist/client/assets/panel-DafanLQ4.js +1 -0
- package/studio-dist/client/assets/plugins._service._view-xSRLxHNM.js +1 -0
- package/studio-dist/client/assets/prepaint-C--F50QZ.js +27 -0
- package/studio-dist/client/assets/{queries-RvHeXY12.js → queries-ByCoiacy.js} +1 -1
- package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
- package/studio-dist/client/assets/reports-Diryyked.js +1 -0
- package/studio-dist/client/assets/routes-DbRwPd55.js +1 -0
- package/studio-dist/client/assets/search-BDKQRwa5.js +1 -0
- package/studio-dist/client/assets/select-_9JT3hpU.js +1 -0
- package/studio-dist/client/assets/skills-D5a6ybQM.js +1 -0
- package/studio-dist/client/assets/{specs-B0ldF_6J.js → specs-COAWUTog.js} +1 -1
- package/studio-dist/client/assets/specs-view-9eTn9TcN.js +1 -0
- package/studio-dist/client/assets/steps-BS588WAV.js +1 -0
- package/studio-dist/client/assets/store-3cffhIO6.js +1 -0
- package/studio-dist/client/assets/studio-CG9eioSx.js +100 -0
- package/studio-dist/client/assets/studio-queries-BS1yR7Wc.js +2 -0
- package/studio-dist/client/assets/{usage-C2QJ_0IZ.js → usage-Ccl4d7w0.js} +15 -15
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-D_y83VP7.js +1 -0
- package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
- package/studio-dist/client/assets/useMutation-BDmS2V6y.js +1 -0
- package/studio-dist/client/assets/usePopupHandleStore-BcqpNR-F.js +1 -0
- package/studio-dist/client/assets/vault-C1tOhQMe.js +1 -0
- package/studio-dist/client/assets/warnings-BZ_X1nkO.js +1 -0
- package/studio-dist/client/assets/workflow-Cm2fsnly.js +1 -0
- package/studio-dist/server/assets/DialogTitle-KSVhF_7V.js +421 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-Bn896ZYj.js → __23tanstack-start-server-fn-resolver-QQnIXyKi.js} +40 -28
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +84 -74
- package/studio-dist/server/assets/{button-CgOIVdmD.js → button-C7EMLaX6.js} +229 -5527
- package/studio-dist/server/assets/cn-D7uJiH_O.js +5528 -0
- package/studio-dist/server/assets/{combobox-DV_s9W0s.js → combobox-Dc4_y20Y.js} +6 -5
- package/studio-dist/server/assets/{companion-view-BKVXD3TO.js → companion-view-CrSi37Mb.js} +2 -2
- package/studio-dist/server/assets/{companions-C7fctnU9.js → companions-CDSuLqA4.js} +1 -1
- package/studio-dist/server/assets/{fields-BbieQTD0.js → fields-BxBN6-Dz.js} +10 -2
- package/studio-dist/server/assets/friction-B1K8Kp8r.js +62 -0
- package/studio-dist/server/assets/friction-Vl3B6THL.js +943 -0
- package/studio-dist/server/assets/{getting-started-CRxMWorQ.js → getting-started-B3lu5W7M.js} +2 -2
- package/studio-dist/server/assets/{getting-started._topic-DJKQAzYl.js → getting-started._topic-EYtxZM-Y.js} +2 -2
- package/studio-dist/server/assets/{getting-started.index-D84gec1t.js → getting-started.index-CTaXYycH.js} +2 -2
- package/studio-dist/server/assets/{graph-DDZzXM1L.js → graph-Bhmk7H8V.js} +1 -1
- package/studio-dist/server/assets/{graph-CSje3029.js → graph-D3fXCaKt.js} +8 -8
- package/studio-dist/server/assets/{graph-canvas-22bWB5-2.js → graph-canvas-DIvTodML.js} +2 -2
- package/studio-dist/server/assets/{guides-IE-19POz.js → guides-BZWFpJl-.js} +1 -1
- package/studio-dist/server/assets/{guides-D9dk1Frq.js → guides-CHBkRO6R.js} +1 -1
- package/studio-dist/server/assets/{guides.server-vcYRY5wx.js → guides.server-DX9KRkcK.js} +1 -1
- package/studio-dist/server/assets/{markdown-view-BR8dJ7aR.js → markdown-view-qrCSkVta.js} +1 -1
- package/studio-dist/server/assets/mcp-Ljf4simO.js +1103 -0
- package/studio-dist/server/assets/mcp-manager-DohRwmJU.js +50 -0
- package/studio-dist/server/assets/{panel-BR_t9iMM.js → panel-CAwz4mKp.js} +6 -4
- package/studio-dist/server/assets/plugins._service._view-DUpAo5D_.js +97 -0
- package/studio-dist/server/assets/prepaint-BxZ-pU7t.js +45 -0
- package/studio-dist/server/assets/{queries-DWoTin-q.js → queries-W4LXzTnT.js} +1 -1
- package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
- package/studio-dist/server/assets/{reports-CQ9qQ1-n.js → reports-BVNSPHU3.js} +13 -7
- package/studio-dist/server/assets/{reports-dYDEoBeq.js → reports-CGG_wRN5.js} +1 -1
- package/studio-dist/server/assets/{router-DkRHNTpE.js → router-KH1x6ryF.js} +1039 -1096
- package/studio-dist/server/assets/{routes-B6GfOew4.js → routes-Bl90FC4R.js} +333 -38
- package/studio-dist/server/assets/search-BjG5f16n.js +110 -0
- package/studio-dist/server/assets/{select-Af7Wibii.js → select-B8q9tLbl.js} +5 -4
- package/studio-dist/server/assets/{shell-Hq-hXgnT.js → shell-C5emwofr.js} +12 -3
- package/studio-dist/server/assets/{skills-B7nEuVbx.js → skills-10l0eCfP.js} +8 -8
- package/studio-dist/server/assets/{skills-B_YYL7q8.js → skills-vG6TTvP1.js} +1 -1
- package/studio-dist/server/assets/{specs-BpLUFntA.js → specs-C1P2BEao.js} +4 -4
- package/studio-dist/server/assets/{specs-view-0peMVd22.js → specs-view-csUBtMWU.js} +10 -10
- package/studio-dist/server/assets/{steps-D56DApvK.js → steps-T4wXftgd.js} +88 -45
- package/studio-dist/server/assets/store-CWlRjv9s.js +93 -0
- package/studio-dist/server/assets/{studio-CAcKp3bM.js → studio-D-ZPWSMv.js} +1567 -59
- package/studio-dist/server/assets/{studio-queries-BtRGzDdh.js → studio-queries-DC273ifg.js} +66 -124
- package/studio-dist/server/assets/{usage-COdjd1gD.js → usage-CT3IWLJc.js} +13 -30
- package/studio-dist/server/assets/{usage-f6pqE1tm.js → usage-D4t_ibR8.js} +1 -1
- package/studio-dist/server/assets/{useAnchoredPopupScrollLock-DlBKHRw7.js → useAnchoredPopupScrollLock-BchJDJYg.js} +2 -2
- package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
- package/studio-dist/server/assets/{useMutation-DzTZGenE.js → useMutation-0HbcKUsQ.js} +2 -2
- package/studio-dist/server/assets/usePopupHandleStore-B3SNGTic.js +26 -0
- package/studio-dist/server/assets/{vault-BDuIUq0F.js → vault-BIytrudF.js} +10 -117
- package/studio-dist/server/assets/{vault-BVLp6zu3.js → vault-MINXmyXA.js} +1 -1
- package/studio-dist/server/assets/{views-flRUr21z.js → views-DrmY_3J5.js} +7 -4
- package/studio-dist/server/assets/{warnings-CDy9pdgL.js → warnings-BVZCDbIz.js} +2 -2
- package/studio-dist/server/assets/{workflow-D9GKI2EV.js → workflow-DFdqnMtW.js} +57 -50
- package/studio-dist/server/server.js +2 -2
- package/tool-manifest.yaml +85 -0
- package/src/cli/commands/factory/factory.ts +0 -311
- package/src/cli/commands/studio/factory-credential.ts +0 -35
- package/src/cli/commands/studio/factory-git-tokens.ts +0 -40
- package/src/cli/commands/studio/factory-relay.ts +0 -18
- package/src/cli/commands/studio/repository-add.ts +0 -116
- package/src/cli/commands/studio/workset-session.ts +0 -164
- package/src/lib/delivery/archive-change.ts +0 -165
- package/src/lib/delivery/forge.ts +0 -279
- package/src/lib/delivery/token.ts +0 -24
- package/src/lib/factory/attach-client.ts +0 -123
- package/src/lib/factory/attach.ts +0 -178
- package/src/lib/factory/broker.ts +0 -187
- package/src/lib/factory/bun-commands.ts +0 -39
- package/src/lib/factory/client.ts +0 -113
- package/src/lib/factory/clone-url.ts +0 -39
- package/src/lib/factory/command.ts +0 -77
- package/src/lib/factory/credential-store.ts +0 -153
- package/src/lib/factory/frames.ts +0 -77
- package/src/lib/factory/git-auth.ts +0 -61
- package/src/lib/factory/git-credential-store.ts +0 -181
- package/src/lib/factory/ids.ts +0 -68
- package/src/lib/factory/outcomes/actions.ts +0 -130
- package/src/lib/factory/outcomes/index.ts +0 -457
- package/src/lib/factory/outcomes/lifecycle.ts +0 -212
- package/src/lib/factory/outcomes/runs.ts +0 -81
- package/src/lib/factory/prepare.ts +0 -55
- package/src/lib/factory/pty.ts +0 -103
- package/src/lib/factory/runner/companion-context.ts +0 -178
- package/src/lib/factory/runner/control.ts +0 -92
- package/src/lib/factory/runner/harness-agent.ts +0 -250
- package/src/lib/factory/runner/live.ts +0 -159
- package/src/lib/factory/runner/questions.ts +0 -22
- package/src/lib/factory/runner/rank.ts +0 -26
- package/src/lib/factory/runner/run-policy.ts +0 -12
- package/src/lib/factory/runner/run.ts +0 -199
- package/src/lib/factory/runner/scheduler.ts +0 -498
- package/src/lib/factory/runner/state.ts +0 -233
- package/src/lib/factory/runner/workflow.ts +0 -546
- package/src/lib/factory/runtime.ts +0 -1081
- package/src/lib/factory/sandbox.ts +0 -292
- package/src/lib/factory/worktree-branch.ts +0 -17
- package/src/templates/capabilities/openspec-cap/mate-v1/templates/explore-brief.md +0 -25
- package/studio-dist/client/assets/app-D9cw6szy.css +0 -2
- package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +0 -1
- package/studio-dist/client/assets/button-Br0O1sXw.js +0 -1
- package/studio-dist/client/assets/combobox-DA7RAUUZ.js +0 -1
- package/studio-dist/client/assets/factory-DGS0E16C.js +0 -6
- package/studio-dist/client/assets/fields-6aXBpFhJ.js +0 -1
- package/studio-dist/client/assets/getting-started-Clde4w6P.js +0 -1
- package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +0 -1
- package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +0 -1
- package/studio-dist/client/assets/graph-B_TCBVbu.js +0 -2
- package/studio-dist/client/assets/guides-Du_RtJxP.js +0 -1
- package/studio-dist/client/assets/index-Df8L1LQa.js +0 -40
- package/studio-dist/client/assets/panel-dbmCx7Mx.js +0 -1
- package/studio-dist/client/assets/react-3QStrcDO.js +0 -27
- package/studio-dist/client/assets/report-url-XRL0x1SY.js +0 -1
- package/studio-dist/client/assets/reports-r3IK7Doz.js +0 -1
- package/studio-dist/client/assets/routes-C0A5LTFc.js +0 -1
- package/studio-dist/client/assets/select-CnaMd617.js +0 -1
- package/studio-dist/client/assets/skills-CzjzHpBT.js +0 -1
- package/studio-dist/client/assets/specs-view-BnCLA0gW.js +0 -1
- package/studio-dist/client/assets/spinner-Dcm3fqK1.js +0 -1
- package/studio-dist/client/assets/steps-C0p2N1Pb.js +0 -1
- package/studio-dist/client/assets/store-Dw34catY.js +0 -1
- package/studio-dist/client/assets/studio-Cpz_HRHp.js +0 -100
- package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +0 -2
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +0 -1
- package/studio-dist/client/assets/useMutation-aAr2uiay.js +0 -1
- package/studio-dist/client/assets/vault-BGcxkSIY.js +0 -1
- package/studio-dist/client/assets/warnings-R1cE1rLf.js +0 -1
- package/studio-dist/client/assets/workflow-C2qTrMDH.js +0 -1
- package/studio-dist/server/assets/actions-DYSv-9VV.js +0 -60
- package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +0 -216
- package/studio-dist/server/assets/factory-C7Ybg0xG.js +0 -3075
- package/studio-dist/server/assets/factory-Df5uAHjb.js +0 -116
- package/studio-dist/server/assets/react-CdqSUhaL.js +0 -89
- package/studio-dist/server/assets/report-url-BUXPcE_8.js +0 -9
- package/studio-dist/server/assets/search-BJnWLfkG.js +0 -55
- package/studio-dist/server/assets/spinner-CdwJW4VB.js +0 -20
- package/studio-dist/server/assets/store-Cs17okNG.js +0 -280
- /package/src/lib/{factory/keyed-serial.ts → keyed-serial.ts} +0 -0
- /package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/spec.md +0 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { parse } from "yaml";
|
|
5
|
+
|
|
6
|
+
import { nulPaths, parseBlobBatch, parseRemoteRef } from "./companion-git";
|
|
7
|
+
import { readSubmittedFolders } from "./companion-git-state";
|
|
8
|
+
import { OPENSPEC_LAYOUT, treeBlobs, type SubmittedLayout } from "./submitted-arrivals";
|
|
9
|
+
|
|
10
|
+
/** A change's Delivery Record file. */
|
|
11
|
+
export const DELIVERY_FILE = "delivery.yaml";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The companion's inbox, the pending branch: an orphan branch holding only submitted change
|
|
15
|
+
* folders, so the default branch holds published content only and may be protected.
|
|
16
|
+
*/
|
|
17
|
+
export const INBOX_BRANCH = "mate/inbox";
|
|
18
|
+
|
|
19
|
+
/** Bound on each local Git command; a launch must not wait on a stuck repository. */
|
|
20
|
+
const GIT_TIMEOUT_MS = 2_000;
|
|
21
|
+
|
|
22
|
+
/** Output kept of one Git command; a larger one counts as failed. */
|
|
23
|
+
const MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
24
|
+
|
|
25
|
+
interface GitRead {
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
input?: string;
|
|
28
|
+
/** Options before `-C`, such as `--literal-pathspecs`. */
|
|
29
|
+
globals?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Stdout of a bounded local Git command; null when it fails, times out or prints too much.
|
|
34
|
+
* Asynchronous, so a slow repository never blocks the caller's thread.
|
|
35
|
+
*/
|
|
36
|
+
function gitBytes(
|
|
37
|
+
companionPath: string,
|
|
38
|
+
args: readonly string[],
|
|
39
|
+
options: GitRead = {},
|
|
40
|
+
): Promise<Buffer | null> {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
const child = spawn("git", [...(options.globals ?? []), "-C", companionPath, ...args], {
|
|
43
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
44
|
+
timeout: options.timeoutMs ?? GIT_TIMEOUT_MS,
|
|
45
|
+
});
|
|
46
|
+
const chunks: Buffer[] = [];
|
|
47
|
+
let size = 0;
|
|
48
|
+
child.stdout.on("data", (chunk: Buffer) => {
|
|
49
|
+
size += chunk.length;
|
|
50
|
+
if (size > MAX_OUTPUT_BYTES) child.kill();
|
|
51
|
+
else chunks.push(chunk);
|
|
52
|
+
});
|
|
53
|
+
child.on("error", () => resolve(null));
|
|
54
|
+
child.on("close", (code) => resolve(code === 0 ? Buffer.concat(chunks) : null));
|
|
55
|
+
child.stdin.on("error", () => {});
|
|
56
|
+
child.stdin.end(options.input ?? "");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function gitText(
|
|
61
|
+
companionPath: string,
|
|
62
|
+
args: readonly string[],
|
|
63
|
+
options: GitRead = {},
|
|
64
|
+
): Promise<string | null> {
|
|
65
|
+
return (await gitBytes(companionPath, args, options))?.toString("utf8") ?? null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A repository as the companion's `repos/` folders name it: `acme/widgets` is `acme_widgets`.
|
|
70
|
+
* A repository named `change` is `_change`, so it cannot collide with `change/<name>`; one
|
|
71
|
+
* named `.` or `..` is prefixed the same way, so it never names a parent folder.
|
|
72
|
+
*/
|
|
73
|
+
export function repositorySegment(repository: string): string {
|
|
74
|
+
const segment = repository.toLowerCase().replaceAll("/", "_");
|
|
75
|
+
return segment === "change" || /^\.+$/.test(segment) ? `_${segment}` : segment;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** True when `name` passes `git check-ref-format --branch`, checked without Git. */
|
|
79
|
+
export function isBranchName(name: string): boolean {
|
|
80
|
+
if (!name || name === "@" || name.startsWith("-") || name.endsWith("/") || name.endsWith(".")) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
// oxlint-disable-next-line no-control-regex -- control characters are invalid in refs
|
|
84
|
+
if (/[\u0000- \u007f~^:?*[\\]|\.\.|@\{|\/\//.test(name)) return false;
|
|
85
|
+
return name
|
|
86
|
+
.split("/")
|
|
87
|
+
.every((part) => part !== "" && !part.startsWith(".") && !part.endsWith(".lock"));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Characters a group name may hold: the name reaches shell commands agents run, so it stays
|
|
92
|
+
* free of quotes, `$`, backquotes and other shell syntax, and starts with a letter, digit or `_`,
|
|
93
|
+
* so it is never read as an option.
|
|
94
|
+
*/
|
|
95
|
+
export const GROUP_CHARACTERS = /^\w[\w./-]*$/;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* True for a change name the inbox takes: {@link GROUP_CHARACTERS} without `/`, so
|
|
99
|
+
* `change/<name>` is a group name and the name itself is safe in a shell command. Narrower than
|
|
100
|
+
* a local change name; a folder on the inbox named otherwise is not read.
|
|
101
|
+
*/
|
|
102
|
+
export function isSubmittedName(name: string): boolean {
|
|
103
|
+
return /^\w[\w.-]*$/.test(name);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Longest inbox text printed on one line. */
|
|
107
|
+
const INBOX_TEXT_LIMIT = 200;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Text from the inbox, which any teammate can push, as one printable line: control, bidi and
|
|
111
|
+
* line-separator characters become spaces, so it can neither drive the terminal nor pass for a
|
|
112
|
+
* line of its own.
|
|
113
|
+
*/
|
|
114
|
+
export function inboxText(value: string): string {
|
|
115
|
+
const plain = value
|
|
116
|
+
// oxlint-disable-next-line no-control-regex -- control characters are what is removed
|
|
117
|
+
.replace(/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]+/g, " ")
|
|
118
|
+
.replace(/ {2,}/g, " ")
|
|
119
|
+
.trim();
|
|
120
|
+
return plain.length > INBOX_TEXT_LIMIT ? `${plain.slice(0, INBOX_TEXT_LIMIT)}…` : plain;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A recorded delivery whose repository and branch can name a Delivery Group. */
|
|
124
|
+
export function namesGroup(entry: { repository?: unknown; branch?: unknown }): boolean {
|
|
125
|
+
return (
|
|
126
|
+
typeof entry.branch === "string" &&
|
|
127
|
+
typeof entry.repository === "string" &&
|
|
128
|
+
isBranchName(entry.branch) &&
|
|
129
|
+
GROUP_CHARACTERS.test(entry.branch) &&
|
|
130
|
+
GROUP_CHARACTERS.test(entry.repository)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The Delivery Group a delivery names: `<repository>/<branch>`. */
|
|
135
|
+
export function groupOf(entry: { repository: string; branch: string }): string {
|
|
136
|
+
return `${repositorySegment(entry.repository)}/${entry.branch}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** True when `a` and `b` are the same text apart from CRLF line endings. */
|
|
140
|
+
export function sameTextBesidesLineEndings(a: string, b: string): boolean {
|
|
141
|
+
return a.replaceAll("\r\n", "\n") === b.replaceAll("\r\n", "\n");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The archived record among `ids` holding exactly the files of `source` (blob ids by path, the
|
|
146
|
+
* Delivery Record aside: publication settles it), newest first; null for none. An archive of
|
|
147
|
+
* the same name with other files is another change's, so a reused name stays pending. Blobs
|
|
148
|
+
* that differ are still the same file when `sameBlob` says so: the default branch's Git
|
|
149
|
+
* attributes may normalise line endings the inbox, which has none, stores as written.
|
|
150
|
+
*/
|
|
151
|
+
export async function matchingArchive(
|
|
152
|
+
ids: readonly string[],
|
|
153
|
+
source: ReadonlyMap<string, string> | null,
|
|
154
|
+
archivedAt: (id: string) => Promise<ReadonlyMap<string, string> | null>,
|
|
155
|
+
sameBlob?: (sourceBlob: string, archivedBlob: string) => Promise<boolean>,
|
|
156
|
+
): Promise<string | null> {
|
|
157
|
+
if (ids.length === 0 || !source || source.size === 0) return null;
|
|
158
|
+
for (const id of ids.toReversed()) {
|
|
159
|
+
// oxlint-disable-next-line no-await-in-loop -- rarely more than one archive per name
|
|
160
|
+
const archived = await archivedAt(id);
|
|
161
|
+
if (archived?.size !== source.size) continue;
|
|
162
|
+
let same = true;
|
|
163
|
+
for (const [file, blob] of source) {
|
|
164
|
+
const other = archived.get(file);
|
|
165
|
+
if (other === blob) continue;
|
|
166
|
+
// oxlint-disable-next-line no-await-in-loop -- only blobs that differ are read
|
|
167
|
+
if (other === undefined || !sameBlob || !(await sameBlob(blob, other))) {
|
|
168
|
+
same = false;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (same) return id;
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface TrackingRefs {
|
|
178
|
+
defaultRef: string;
|
|
179
|
+
pendingRef: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The remote-tracking refs of the default branch (`<remote>/HEAD`, else the upstream branch) and
|
|
184
|
+
* of the pending branch; null without an upstream, which is the branch's `@{u}`, then
|
|
185
|
+
* `origin/HEAD`, then `origin/main` or `origin/master`, as `upstreamTarget` resolves it. Off the
|
|
186
|
+
* caller's thread: the session banner reads it.
|
|
187
|
+
*/
|
|
188
|
+
export async function trackingRefs(companionPath: string): Promise<TrackingRefs | null> {
|
|
189
|
+
const [tracked, originHead] = await Promise.all([
|
|
190
|
+
gitText(companionPath, ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]),
|
|
191
|
+
gitText(companionPath, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]),
|
|
192
|
+
]);
|
|
193
|
+
let upstream = parseRemoteRef(tracked ?? "") ?? parseRemoteRef(originHead ?? "");
|
|
194
|
+
for (const branch of upstream ? [] : ["main", "master"]) {
|
|
195
|
+
const ref = `refs/remotes/origin/${branch}`;
|
|
196
|
+
// oxlint-disable-next-line no-await-in-loop -- a decision chain, off the common path
|
|
197
|
+
if ((await gitText(companionPath, ["show-ref", "--verify", "--quiet", ref])) !== null) {
|
|
198
|
+
upstream = { remote: "origin", branch, ref: `origin/${branch}` };
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (!upstream || upstream.remote.startsWith("-") || upstream.branch.startsWith("-")) return null;
|
|
203
|
+
const { remote } = upstream;
|
|
204
|
+
// `origin/HEAD` was read above; another remote's is asked for.
|
|
205
|
+
const head = (
|
|
206
|
+
remote === "origin"
|
|
207
|
+
? originHead
|
|
208
|
+
: await gitText(companionPath, [
|
|
209
|
+
"symbolic-ref",
|
|
210
|
+
"--quiet",
|
|
211
|
+
"--short",
|
|
212
|
+
"--end-of-options",
|
|
213
|
+
`refs/remotes/${remote}/HEAD`,
|
|
214
|
+
])
|
|
215
|
+
)?.trim();
|
|
216
|
+
const defaultBranch = head?.startsWith(`${remote}/`)
|
|
217
|
+
? head.slice(remote.length + 1)
|
|
218
|
+
: upstream.branch;
|
|
219
|
+
const defaultRef = `refs/remotes/${remote}/${defaultBranch}`;
|
|
220
|
+
return { defaultRef, pendingRef: `refs/remotes/${remote}/${INBOX_BRANCH}` };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Fetch refspec for the inbox, as a pattern: it matches nothing on a remote without an inbox
|
|
225
|
+
* instead of failing the fetch it rides along with.
|
|
226
|
+
*/
|
|
227
|
+
export function inboxRefspec(remote: string): string {
|
|
228
|
+
return `+refs/heads/${INBOX_BRANCH}*:refs/remotes/${remote}/${INBOX_BRANCH}*`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface SubmittedCounts {
|
|
232
|
+
/** Changes with `state: submitted` on the pending branch as last fetched. */
|
|
233
|
+
submitted: number;
|
|
234
|
+
/** Of them, the user's own; see {@link submitters}. */
|
|
235
|
+
mine: number;
|
|
236
|
+
/** Delivery Groups with at least one blocked change. */
|
|
237
|
+
blocked: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** A submitted change awaiting publication, as the session line and Studio show it. */
|
|
241
|
+
export interface PendingSubmittedChange {
|
|
242
|
+
name: string;
|
|
243
|
+
/** The deliveries as `repository@branch`, space-joined; empty when none names a branch. */
|
|
244
|
+
group: string;
|
|
245
|
+
blocked: boolean;
|
|
246
|
+
/** The user's own; see {@link submitters}. */
|
|
247
|
+
mine: boolean;
|
|
248
|
+
/** Who submitted it, by the pending branch's history; absent when Git cannot say. */
|
|
249
|
+
author?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Who submitted a change folder, as {@link submitters} reads it. */
|
|
253
|
+
export interface Submitter {
|
|
254
|
+
mine: boolean;
|
|
255
|
+
author?: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Longer than the other reads: the walk reads the inbox's history. */
|
|
259
|
+
const AUTHOR_TIMEOUT_MS = 5_000;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Commit authors by change folder (`<source>/<name>`): the newest commit on `ref` that added the
|
|
263
|
+
* folder's Delivery Record, so a change dropped and submitted again names its latest submitter.
|
|
264
|
+
* One `git log`; empty when Git fails or times out.
|
|
265
|
+
*/
|
|
266
|
+
async function submittedAuthors(
|
|
267
|
+
companionPath: string,
|
|
268
|
+
ref: string,
|
|
269
|
+
folders: readonly string[],
|
|
270
|
+
): Promise<Map<string, { name: string; email: string }>> {
|
|
271
|
+
const authors = new Map<string, { name: string; email: string }>();
|
|
272
|
+
if (folders.length === 0) return authors;
|
|
273
|
+
const log = await gitText(
|
|
274
|
+
companionPath,
|
|
275
|
+
[
|
|
276
|
+
"log",
|
|
277
|
+
"--diff-filter=A",
|
|
278
|
+
"--no-renames",
|
|
279
|
+
"-z",
|
|
280
|
+
"--format=%x01%an%x02%ae",
|
|
281
|
+
"--name-only",
|
|
282
|
+
"--end-of-options",
|
|
283
|
+
ref,
|
|
284
|
+
"--",
|
|
285
|
+
...folders.map((folder) => `${folder}/${DELIVERY_FILE}`),
|
|
286
|
+
],
|
|
287
|
+
{ timeoutMs: AUTHOR_TIMEOUT_MS, globals: ["--literal-pathspecs"] },
|
|
288
|
+
);
|
|
289
|
+
if (log === null) return authors;
|
|
290
|
+
// Per commit: `\x01<name>\x02<email>\0\n<path>\0<path>\0…`, newest first.
|
|
291
|
+
for (const commit of log.split("\x01").slice(1)) {
|
|
292
|
+
const [header = "", ...files] = commit.split("\0");
|
|
293
|
+
const [name = "", email = ""] = header.split("\x02");
|
|
294
|
+
for (const file of files) {
|
|
295
|
+
const folder = path.posix.dirname(file.replace(/^\n/, ""));
|
|
296
|
+
if (file.trim() && !authors.has(folder)) authors.set(folder, { name, email });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return authors;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Whose submitted change folders on `ref` are the user's own: committed with the companion's Git
|
|
304
|
+
* `user.email` (any machine of theirs), or recorded as submitted from this checkout (`local`),
|
|
305
|
+
* which also covers a machine whose email differs. A display hint, never a permission.
|
|
306
|
+
*/
|
|
307
|
+
export async function submitters(
|
|
308
|
+
companionPath: string,
|
|
309
|
+
ref: string,
|
|
310
|
+
folders: readonly string[],
|
|
311
|
+
local: Readonly<Record<string, unknown>> = {},
|
|
312
|
+
): Promise<Map<string, Submitter>> {
|
|
313
|
+
const [authors, configured] = await Promise.all([
|
|
314
|
+
submittedAuthors(companionPath, ref, folders),
|
|
315
|
+
gitText(companionPath, ["config", "--get", "user.email"]),
|
|
316
|
+
]);
|
|
317
|
+
const email = configured?.trim().toLowerCase();
|
|
318
|
+
return new Map(
|
|
319
|
+
folders.map((folder) => {
|
|
320
|
+
const author = authors.get(folder);
|
|
321
|
+
const mine =
|
|
322
|
+
folder in local ||
|
|
323
|
+
(!!email && author !== undefined && author.email.toLowerCase() === email);
|
|
324
|
+
return [folder, { mine, ...(author?.name ? { author: author.name } : {}) }];
|
|
325
|
+
}),
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** A Delivery Record's text as far as the count reads it; null when it does not parse. */
|
|
330
|
+
function recordSummary(
|
|
331
|
+
text: string,
|
|
332
|
+
): { state?: unknown; blocked?: unknown; group: string; deliveryGroup: string | null } | null {
|
|
333
|
+
try {
|
|
334
|
+
const record = parse(text) as {
|
|
335
|
+
state?: unknown;
|
|
336
|
+
blocked?: unknown;
|
|
337
|
+
deliveries?: Array<{ repository?: unknown; branch?: unknown }>;
|
|
338
|
+
} | null;
|
|
339
|
+
if (!record || typeof record !== "object") return null;
|
|
340
|
+
const branches = (Array.isArray(record.deliveries) ? record.deliveries : []).filter(
|
|
341
|
+
(entry) => typeof entry?.branch === "string" && entry.branch.length > 0,
|
|
342
|
+
);
|
|
343
|
+
const group = branches
|
|
344
|
+
.map((entry) => `${String(entry.repository).toLowerCase()}@${String(entry.branch)}`)
|
|
345
|
+
.toSorted()
|
|
346
|
+
.join(" ");
|
|
347
|
+
// As `deliveryGroupFor` names it, short of its scope preference.
|
|
348
|
+
const first = branches.find(namesGroup);
|
|
349
|
+
const deliveryGroup = first
|
|
350
|
+
? groupOf({ repository: String(first.repository), branch: String(first.branch) })
|
|
351
|
+
: null;
|
|
352
|
+
return { state: record.state, blocked: record.blocked, group, deliveryGroup };
|
|
353
|
+
} catch {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** Blob contents by `<rev>:<path>` spec, read in one `cat-file --batch`; missing ones left out. */
|
|
359
|
+
async function readBlobs(
|
|
360
|
+
companionPath: string,
|
|
361
|
+
specs: readonly string[],
|
|
362
|
+
): Promise<Map<string, string>> {
|
|
363
|
+
const out = await gitBytes(companionPath, ["cat-file", "--batch"], {
|
|
364
|
+
input: `${specs.join("\n")}\n`,
|
|
365
|
+
});
|
|
366
|
+
return (out && parseBlobBatch(out, specs)) ?? new Map();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Folder names directly below `dir` at `ref`; empty when Git fails. */
|
|
370
|
+
async function foldersAt(companionPath: string, ref: string, dir: string): Promise<string[]> {
|
|
371
|
+
const listed = await gitText(companionPath, [
|
|
372
|
+
"ls-tree",
|
|
373
|
+
"-z",
|
|
374
|
+
"-d",
|
|
375
|
+
"--name-only",
|
|
376
|
+
"--end-of-options",
|
|
377
|
+
ref,
|
|
378
|
+
"--",
|
|
379
|
+
`${dir}/`,
|
|
380
|
+
]);
|
|
381
|
+
return (
|
|
382
|
+
(listed ?? "")
|
|
383
|
+
.split("\0")
|
|
384
|
+
// A name with a newline would split its line in `readBlobs`' batch; no change has one.
|
|
385
|
+
.filter((entry) => entry && !entry.includes("\n"))
|
|
386
|
+
.map((entry) => entry.split("/").at(-1)!)
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Blob ids by path below `dir` at `ref`, the Delivery Record left out; null when Git fails. */
|
|
391
|
+
async function blobsBelow(
|
|
392
|
+
companionPath: string,
|
|
393
|
+
ref: string,
|
|
394
|
+
dir: string,
|
|
395
|
+
): Promise<Map<string, string> | null> {
|
|
396
|
+
const listed = await gitText(companionPath, [
|
|
397
|
+
"ls-tree",
|
|
398
|
+
"-r",
|
|
399
|
+
"-z",
|
|
400
|
+
"--end-of-options",
|
|
401
|
+
ref,
|
|
402
|
+
"--",
|
|
403
|
+
`${dir}/`,
|
|
404
|
+
]);
|
|
405
|
+
if (listed === null) return null;
|
|
406
|
+
const blobs = treeBlobs(nulPaths(listed), dir);
|
|
407
|
+
blobs.delete(DELIVERY_FILE);
|
|
408
|
+
return blobs;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Submitted changes on the pending branch as last fetched, read with a few bounded local Git
|
|
413
|
+
* commands off the caller's thread and no network, each with its block and submitter (`local`: the folders Mate's local
|
|
414
|
+
* companion state records as submitted from this checkout). A change the default branch already
|
|
415
|
+
* archived is left out. Says nothing about merge state; empty when nothing was
|
|
416
|
+
* fetched or Git fails.
|
|
417
|
+
*/
|
|
418
|
+
export async function pendingSubmittedChanges(
|
|
419
|
+
companionPath: string,
|
|
420
|
+
local: Readonly<Record<string, unknown>> = {},
|
|
421
|
+
layout: SubmittedLayout = OPENSPEC_LAYOUT,
|
|
422
|
+
): Promise<PendingSubmittedChange[]> {
|
|
423
|
+
const changes = await groupedSubmittedChanges(companionPath, local, layout);
|
|
424
|
+
return changes.map(({ deliveryGroup: _deliveryGroup, ...change }) => change);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
interface GroupedSubmittedChange extends PendingSubmittedChange {
|
|
428
|
+
/**
|
|
429
|
+
* Its Delivery Group as `mate artifact pending` names it, after its first recorded branch;
|
|
430
|
+
* `change/<name>` without one.
|
|
431
|
+
*/
|
|
432
|
+
deliveryGroup: string;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
async function groupedSubmittedChanges(
|
|
436
|
+
companionPath: string,
|
|
437
|
+
local: Readonly<Record<string, unknown>>,
|
|
438
|
+
layout: SubmittedLayout,
|
|
439
|
+
): Promise<GroupedSubmittedChange[]> {
|
|
440
|
+
const refs = await trackingRefs(companionPath);
|
|
441
|
+
if (!refs) return [];
|
|
442
|
+
const ref = refs.pendingRef;
|
|
443
|
+
// A type without an archive lists none here: its inbox folders count until they are cleared.
|
|
444
|
+
const { archiveRoot } = layout;
|
|
445
|
+
const names = (await foldersAt(companionPath, ref, layout.source)).filter(
|
|
446
|
+
(name) =>
|
|
447
|
+
isSubmittedName(name) &&
|
|
448
|
+
(archiveRoot === undefined ||
|
|
449
|
+
path.posix.dirname(archiveRoot) !== layout.source ||
|
|
450
|
+
name !== path.posix.basename(archiveRoot)),
|
|
451
|
+
);
|
|
452
|
+
if (names.length === 0) return [];
|
|
453
|
+
const specs = names.map((name) => `${ref}:${layout.source}/${name}/${DELIVERY_FILE}`);
|
|
454
|
+
const [blobs, archives] = await Promise.all([
|
|
455
|
+
readBlobs(companionPath, specs),
|
|
456
|
+
archiveRoot === undefined ? [] : foldersAt(companionPath, refs.defaultRef, archiveRoot),
|
|
457
|
+
]);
|
|
458
|
+
const sameBlob = async (a: string, b: string): Promise<boolean> => {
|
|
459
|
+
const texts = await readBlobs(companionPath, [a, b]);
|
|
460
|
+
const [mine, theirs] = [texts.get(a), texts.get(b)];
|
|
461
|
+
return mine !== undefined && theirs !== undefined && sameTextBesidesLineEndings(mine, theirs);
|
|
462
|
+
};
|
|
463
|
+
// Published, but the inbox was not emptied yet; as `publishedAs` decides.
|
|
464
|
+
const isPublished = async (name: string): Promise<boolean> => {
|
|
465
|
+
const ids = archives.filter((id) => layout.recordName(id) === name);
|
|
466
|
+
if (ids.length === 0) return false;
|
|
467
|
+
const source = await blobsBelow(companionPath, ref, `${layout.source}/${name}`);
|
|
468
|
+
const archived = (id: string) =>
|
|
469
|
+
blobsBelow(companionPath, refs.defaultRef, `${archiveRoot}/${id}`);
|
|
470
|
+
return (await matchingArchive(ids, source, archived, sameBlob)) !== null;
|
|
471
|
+
};
|
|
472
|
+
const submitted = names.flatMap((name, index) => {
|
|
473
|
+
const text = blobs.get(specs[index]!);
|
|
474
|
+
const record = text === undefined ? null : recordSummary(text);
|
|
475
|
+
return record?.state === "submitted" ? [{ name, record }] : [];
|
|
476
|
+
});
|
|
477
|
+
// Only a name with an archive runs Git.
|
|
478
|
+
const published = await Promise.all(submitted.map(({ name }) => isPublished(name)));
|
|
479
|
+
const pending: Omit<GroupedSubmittedChange, "mine" | "author">[] = submitted
|
|
480
|
+
.filter((_, index) => !published[index])
|
|
481
|
+
.map(({ name, record }) => ({
|
|
482
|
+
name,
|
|
483
|
+
group: record.group,
|
|
484
|
+
deliveryGroup: record.deliveryGroup ?? `change/${name}`,
|
|
485
|
+
blocked: Boolean(record.blocked),
|
|
486
|
+
}));
|
|
487
|
+
if (pending.length === 0) return [];
|
|
488
|
+
const folderOf = (name: string): string => `${layout.source}/${name}`;
|
|
489
|
+
const who = await submitters(
|
|
490
|
+
companionPath,
|
|
491
|
+
ref,
|
|
492
|
+
pending.map((change) => folderOf(change.name)),
|
|
493
|
+
local,
|
|
494
|
+
);
|
|
495
|
+
return pending.map((change) => ({ ...change, mine: false, ...who.get(folderOf(change.name)) }));
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** {@link pendingSubmittedChanges} as counts; a group is blocked once, however many changes are. */
|
|
499
|
+
export async function pendingSubmittedCounts(
|
|
500
|
+
companionPath: string,
|
|
501
|
+
local: Readonly<Record<string, unknown>> = {},
|
|
502
|
+
layout: SubmittedLayout = OPENSPEC_LAYOUT,
|
|
503
|
+
): Promise<SubmittedCounts> {
|
|
504
|
+
const changes = await groupedSubmittedChanges(companionPath, local, layout);
|
|
505
|
+
const blocked = new Set(
|
|
506
|
+
changes.filter((change) => change.blocked).map((change) => change.deliveryGroup),
|
|
507
|
+
);
|
|
508
|
+
return {
|
|
509
|
+
submitted: changes.length,
|
|
510
|
+
mine: changes.filter((change) => change.mine).length,
|
|
511
|
+
blocked: blocked.size,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The short operator line: how many submitted changes await publication, how many are the
|
|
517
|
+
* user's own, and the blocked groups; null for none. Studio lists them.
|
|
518
|
+
*/
|
|
519
|
+
export async function pendingSubmittedLine(
|
|
520
|
+
companionPath: string,
|
|
521
|
+
homeDir?: string,
|
|
522
|
+
): Promise<string | null> {
|
|
523
|
+
const { submitted, mine, blocked } = await pendingSubmittedCounts(
|
|
524
|
+
companionPath,
|
|
525
|
+
readSubmittedFolders(companionPath, homeDir),
|
|
526
|
+
);
|
|
527
|
+
if (submitted === 0) return null;
|
|
528
|
+
return [
|
|
529
|
+
`${submitted} submitted awaiting publication`,
|
|
530
|
+
...(mine > 0 ? [`${mine} yours`] : []),
|
|
531
|
+
...(blocked > 0 ? [`${blocked} group${blocked === 1 ? "" : "s"} blocked`] : []),
|
|
532
|
+
].join(" · ");
|
|
533
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { buildCompanionGuidance } from "./companion-guidance";
|
|
1
|
+
import { buildCompanionGuidance, declaredGuidance } from "./companion-guidance";
|
|
2
2
|
import { hasLaunchEnvironment } from "./env";
|
|
3
|
+
import { readFrictionSwitch } from "./friction-switch";
|
|
3
4
|
import { readCompanionPolicy } from "./policy";
|
|
4
5
|
import { resolveProjection } from "./projection";
|
|
6
|
+
import { umbrellaChildrenBlock } from "./umbrella-children";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* The companion guidance for an Unmanaged Session, built from the Projection
|
|
@@ -33,14 +35,17 @@ export function buildProjectedGuidance(
|
|
|
33
35
|
if (!projection) return null;
|
|
34
36
|
|
|
35
37
|
const policy = readCompanionPolicy(projection.companionPath);
|
|
36
|
-
|
|
38
|
+
const guidance = buildCompanionGuidance(
|
|
37
39
|
{
|
|
38
40
|
companionPath: projection.companionPath,
|
|
39
41
|
repository: { id: projection.repositoryId, path: projection.repositoryPath },
|
|
40
42
|
capabilities: policy.enabledCapabilities.map((name) => ({ name })),
|
|
41
43
|
secretGuardrails: policy.secrets.guardrails,
|
|
44
|
+
...declaredGuidance(projection.companionPath),
|
|
42
45
|
},
|
|
43
46
|
/** The projected path, not the running install's: a wrap may be another mate's. */
|
|
44
|
-
{ wrapperBinPath: projection.wrapperBinPath },
|
|
47
|
+
{ wrapperBinPath: projection.wrapperBinPath, friction: readFrictionSwitch(env.HOME) },
|
|
45
48
|
);
|
|
49
|
+
const children = umbrellaChildrenBlock(projection.repositoryPath);
|
|
50
|
+
return children ? `${guidance}\n\n${children}` : guidance;
|
|
46
51
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { resolveSecretPolicy } from "./policy";
|
|
4
|
+
import { isSecretFile } from "./secret-patterns";
|
|
5
|
+
import { listFiles, scanFiles, type SecretFinding } from "./secret-scan";
|
|
6
|
+
|
|
7
|
+
/** Rule id reported for a staged path that is itself a secret file. */
|
|
8
|
+
export const SECRET_FILE_RULE_ID = "mate/secret-file";
|
|
9
|
+
|
|
10
|
+
export type PublicationSecretScan =
|
|
11
|
+
| { skipped: true }
|
|
12
|
+
| { skipped: false; findings: SecretFinding[] };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Scans exactly what a publication would stage: every file under the commit
|
|
16
|
+
* paths that exists on disk (a deleted path has nothing to leak). A staged
|
|
17
|
+
* secret file counts as a finding of its own. Paths are reported relative to
|
|
18
|
+
* the companion; values never leave this function. Throws when the scanner
|
|
19
|
+
* fails, which the engine treats like a finding. `policyPath` is the companion whose
|
|
20
|
+
* policy applies when `companionPath` is a temporary checkout of it.
|
|
21
|
+
*/
|
|
22
|
+
export async function scanPublication(
|
|
23
|
+
companionPath: string,
|
|
24
|
+
commitPaths: readonly string[],
|
|
25
|
+
policyPath: string = companionPath,
|
|
26
|
+
): Promise<PublicationSecretScan> {
|
|
27
|
+
const policy = resolveSecretPolicy(policyPath);
|
|
28
|
+
if (!policy.guardrails) return { skipped: true };
|
|
29
|
+
|
|
30
|
+
const files = (
|
|
31
|
+
await Promise.all(
|
|
32
|
+
commitPaths.map((commitPath) => listFiles(path.join(companionPath, commitPath))),
|
|
33
|
+
)
|
|
34
|
+
).flat();
|
|
35
|
+
const relative = (file: string) => path.relative(companionPath, file).split(path.sep).join("/");
|
|
36
|
+
const secretFiles: SecretFinding[] = files
|
|
37
|
+
.map(relative)
|
|
38
|
+
.filter((file) => isSecretFile(file, policy))
|
|
39
|
+
.map((file) => ({ path: file, line: 0, ruleId: SECRET_FILE_RULE_ID }));
|
|
40
|
+
const contentFindings = (await scanFiles(files)).map((finding) => ({
|
|
41
|
+
...finding,
|
|
42
|
+
path: relative(finding.path),
|
|
43
|
+
}));
|
|
44
|
+
return { skipped: false, findings: [...secretFiles, ...contentFindings] };
|
|
45
|
+
}
|
|
@@ -204,9 +204,10 @@ export interface SecretPathOptions {
|
|
|
204
204
|
windows?: boolean;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
// Read on call, not at import: Studio's browser bundle imports this module and has no `process`.
|
|
208
|
+
const isWindows = () => process.platform === "win32";
|
|
208
209
|
|
|
209
|
-
function normalizePath(filePath: string, { windows =
|
|
210
|
+
function normalizePath(filePath: string, { windows = isWindows() }: SecretPathOptions): string {
|
|
210
211
|
return (windows ? filePath.replaceAll("\\", "/") : filePath).replace(/\/+$/, "");
|
|
211
212
|
}
|
|
212
213
|
|
|
@@ -245,6 +246,9 @@ const ALLOW_SAFE_EXPANSIONS: Readonly<Record<string, readonly string[]>> = {
|
|
|
245
246
|
".env.*": [".env.local", ".env.development", ".env.production", ".env.test", ".env.*.local"],
|
|
246
247
|
};
|
|
247
248
|
|
|
249
|
+
const overlapsAllow = (pattern: string) =>
|
|
250
|
+
DEFAULT_SECRET_ALLOW_PATTERNS.some((allowed) => matchesSecretPattern(allowed, [pattern]));
|
|
251
|
+
|
|
248
252
|
/**
|
|
249
253
|
* The default deny patterns a runtime's own deny rules may carry: every
|
|
250
254
|
* default that can't match an allow-listed file, with an overlapping pattern
|
|
@@ -252,8 +256,6 @@ const ALLOW_SAFE_EXPANSIONS: Readonly<Record<string, readonly string[]>> = {
|
|
|
252
256
|
* projected: once removed from config, nothing would mark their rules as Mate's.
|
|
253
257
|
*/
|
|
254
258
|
export function projectableSecretDenyPatterns(): string[] {
|
|
255
|
-
const overlapsAllow = (pattern: string) =>
|
|
256
|
-
DEFAULT_SECRET_ALLOW_PATTERNS.some((allowed) => matchesSecretPattern(allowed, [pattern]));
|
|
257
259
|
return DEFAULT_SECRET_DENY_PATTERNS.flatMap((pattern) =>
|
|
258
260
|
overlapsAllow(pattern) ? (ALLOW_SAFE_EXPANSIONS[pattern] ?? []) : [pattern],
|
|
259
261
|
).filter((pattern) => !overlapsAllow(pattern));
|
|
@@ -279,7 +281,7 @@ type BraceSequence = BracePart[];
|
|
|
279
281
|
*/
|
|
280
282
|
function parseBraces(
|
|
281
283
|
glob: string,
|
|
282
|
-
{ windows =
|
|
284
|
+
{ windows = isWindows() }: SecretPathOptions,
|
|
283
285
|
): BraceSequence | null {
|
|
284
286
|
const source = windows ? glob.replaceAll("**\\", "**/") : glob;
|
|
285
287
|
let i = 0;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const SECRET_NAME = /TOKEN|SECRET|PASSW|KEY|CREDENTIAL|AUTH/i;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Masks the values of secret-named variables, raw or JSON-escaped: plugin configs interpolate
|
|
5
|
+
* `${VAR}`, so error text may echo one. Short values stay: masking them would garble the text.
|
|
6
|
+
*/
|
|
7
|
+
export function maskSecretValues(text: string, env: Record<string, string | undefined>): string {
|
|
8
|
+
let masked = text;
|
|
9
|
+
for (const [name, value] of Object.entries(env)) {
|
|
10
|
+
if (!value || value.length < 8 || !SECRET_NAME.test(name)) continue;
|
|
11
|
+
for (const form of new Set([JSON.stringify(value).slice(1, -1), value])) {
|
|
12
|
+
masked = masked.split(form).join("***");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return masked;
|
|
16
|
+
}
|