@unbrained/pm-cli 2026.11.3 → 2026.11.5
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/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
- package/.agents/skills/README.md +14 -14
- package/.agents/skills/pm-developer/SKILL.md +16 -16
- package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +14 -14
- package/.agents/skills/pm-developer/references/SCRIPTING_COMPOSITION.md +10 -10
- package/.agents/skills/pm-extensions/SKILL.md +13 -13
- package/.agents/skills/pm-extensions/references/AUTHORING.md +12 -12
- package/.agents/skills/pm-sdk/SKILL.md +27 -27
- package/.agents/skills/pm-sdk/references/SURFACE_MAP.md +32 -32
- package/.agents/skills/pm-test-audit/references/AUDIT.md +1 -1
- package/.agents/skills/pm-user/SKILL.md +35 -35
- package/.claude-plugin/marketplace.json +1 -1
- package/AGENTS.md +9 -9
- package/CHANGELOG.md +19 -0
- package/README.md +13 -13
- package/dist/cli/error-guidance.d.ts +14 -35
- package/dist/cli/error-guidance.js +2 -2
- package/dist/cli/expected-revisions.d.ts +55 -0
- package/dist/cli/expected-revisions.js +2 -0
- package/dist/cli/main.js +2 -2
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2RPORE7M.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-Y7H55PCY.js → chunk-335BZ75D.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5GWEY4P6.js +122 -0
- package/dist/cli-bundle/chunks/chunk-6VRX2CM7.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-5JZMF4M5.js → chunk-7DEKAXVA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-32BCU6HN.js → chunk-7ZRCYESH.js} +47 -46
- package/dist/cli-bundle/chunks/chunk-AUEKTX7V.js +6 -0
- package/dist/cli-bundle/chunks/chunk-D7KYPRK4.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-2CBHQXYJ.js → chunk-DAX3AOFI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JPKIUWLG.js → chunk-F6NDMKZ4.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FRNMQM45.js +2 -0
- package/dist/cli-bundle/chunks/chunk-HNGLDMSZ.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-DEJHTFEF.js → chunk-HRCMORE7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HRFGFIYU.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-5IPXDZKU.js → chunk-JI2GDE4I.js} +66 -66
- package/dist/cli-bundle/chunks/{chunk-MQJXZX3Q.js → chunk-LS3GI3H4.js} +53 -53
- package/dist/cli-bundle/chunks/chunk-OH6WQ7VT.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-TZ3D3DPQ.js → chunk-OJDMJT7Y.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-S4LPZ4TN.js +20 -0
- package/dist/cli-bundle/chunks/chunk-UEGXWXUZ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-XLSHFYXZ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-UYNMKUGA.js → chunk-YKXATU2G.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-OJJVPQY7.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-QEPBUCMY.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-INMM3HHG.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-I6AZA3IX.js → register-list-query-5Y5JKWU5.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-3DAXCLXR.js → register-mutation-WC7OSQID.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-PO63DBZH.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-RRFOS7IT.js +2 -0
- package/dist/cli-bundle/chunks/{stage-7H36OTDJ.js → stage-E3MMV4TV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5PMJOJCZ.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-7KK66ISG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-D4XQOMG4.js → chunk-AHWJPZSJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-LKN2WGGB.js → chunk-C6P6HPCX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-CPMSL4HS.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CZM75DE3.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TYHDZUL4.js → chunk-D2TBEBNW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-E56OXRYH.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-I5FODKYB.js → chunk-F62XGAAY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-G4QP365K.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-G5PJCR7R.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-GS3JC5UU.js +23 -0
- package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LW64TINU.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-M6V7UMWL.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-MC7IE7D7.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-MG7C3JUY.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-F3X6UWMI.js → chunk-MK4HV4JO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZQRCVRGS.js → chunk-NQ7GYFOX.js} +54 -54
- package/dist/cli-bundle/focused-chunks/chunk-O7EI33NP.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RY4QEMAE.js → chunk-RFTJZ5VB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SNOXXRSJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-UPJUTP2V.js +12 -0
- package/dist/cli-bundle/focused-chunks/{chunk-HJ27QLZV.js → chunk-VWWTIX5L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HOXIIZEO.js → chunk-XHOBYCVE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-YMGB2O4E.js +81 -0
- package/dist/cli-bundle/focused-chunks/item-revision-CTDO4H3I.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-AEAYVVHA.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-4WM7TNHZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{stage-4SQHVI3O.js → stage-WV7QXR4C.js} +2 -2
- package/dist/cli-bundle/main.js +25 -25
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +5 -5
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/config/positional-value.d.ts +7 -1
- package/dist/core/config/positional-value.js +1 -1
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/item/literal-mutation-input.d.ts +17 -0
- package/dist/core/item/literal-mutation-input.js +1 -1
- package/dist/core/item/parent-reference-policy.d.ts +8 -4
- package/dist/core/item/parent-reference-policy.js +1 -1
- package/dist/core/item/sprint-release-format.d.ts +2 -1
- package/dist/core/item/sprint-release-format.js +1 -1
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/shared/command-types.d.ts +7 -0
- package/dist/core/store/item-mutation-precondition.d.ts +72 -6
- package/dist/core/store/item-mutation-precondition.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.d.ts +14 -0
- package/dist/core/store/settings.js +5 -4
- package/dist/core/telemetry/policy.d.ts +27 -1
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/runtime.d.ts +18 -7
- package/dist/core/telemetry/runtime.js +4 -4
- package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +11 -0
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +8 -5
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/cli-program.js +1 -1
- package/dist/sdk/config.d.ts +3 -3
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health.d.ts +2 -2
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/history/salvage.js +3 -3
- package/dist/sdk/history-compact.d.ts +7 -1
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-repair.d.ts +2 -1
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/index.d.ts +6 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/init.d.ts +4 -4
- package/dist/sdk/init.js +8 -8
- package/dist/sdk/lifecycle/checkpoint-rollback.d.ts +10 -2
- package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +4 -0
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/close-many.d.ts +11 -2
- package/dist/sdk/lifecycle/close-many.js +1 -1
- package/dist/sdk/lifecycle/close.d.ts +25 -0
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/create.d.ts +7 -5
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/item-revision.d.ts +162 -0
- package/dist/sdk/lifecycle/item-revision.js +2 -0
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.d.ts +628 -4
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/lifecycle/start-blockers.d.ts +52 -0
- package/dist/sdk/lifecycle/start-blockers.js +2 -0
- package/dist/sdk/lifecycle/task-composition.d.ts +11 -0
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/lifecycle/update-many.d.ts +11 -2
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.d.ts +5 -4
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/declared-blockers.d.ts +16 -0
- package/dist/sdk/query/declared-blockers.js +2 -0
- package/dist/sdk/query/get.d.ts +7 -0
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime/mutation-value-validation.js +1 -1
- package/dist/sdk/runtime-input.d.ts +12 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -0
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +10 -0
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/telemetry.d.ts +1 -1
- package/dist/sdk/telemetry.js +2 -2
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/execution.js +2 -2
- package/dist/sdk/test/linked-command-detection.js +1 -1
- package/dist/sdk/workspace-transaction.d.ts +17 -6
- package/dist/sdk/workspace-transaction.js +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +48 -48
- package/docs/AGENT_OUTPUT_ENCODINGS.md +20 -20
- package/docs/ASSURANCE.md +10 -10
- package/docs/BOUNDED_CONTEXT_READS.md +3 -3
- package/docs/CLAUDE_CODE_PLUGIN.md +1 -1
- package/docs/CLI_GRAMMAR.md +2 -2
- package/docs/COMMANDS.md +144 -32
- package/docs/COMMAND_NAMESPACES.md +1 -1
- package/docs/CONFIGURATION.md +82 -70
- package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +2 -2
- package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +5 -5
- package/docs/CORPUS_SHAPES.md +1 -1
- package/docs/DEPENDENCY_KIND_CONTRACT.md +6 -6
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +5 -5
- package/docs/ECOSYSTEM_PLANNING_REVIEW.md +3 -3
- package/docs/EXTENSION_AUTHOR_CONTRACTS.md +4 -4
- package/docs/HISTORY_ATTESTATION.md +1 -1
- package/docs/HISTORY_MAINTENANCE.md +1 -1
- package/docs/LIFECYCLE_COMMANDS.md +1 -1
- package/docs/MCP_2026_07_28.md +16 -16
- package/docs/MCP_2026_07_28_CONFORMANCE.md +19 -19
- package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +22 -22
- package/docs/MCP_SKILLS_AND_APPS.md +1 -1
- package/docs/MERGE_SAFETY.md +6 -6
- package/docs/MUTATION_INTEGRITY.md +5 -5
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +14 -14
- package/docs/PACKED_FIRST_RUN.md +1 -1
- package/docs/QUICKSTART.md +10 -10
- package/docs/README.md +21 -21
- package/docs/READ_OUTPUT_CONTRACTS.md +9 -9
- package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +1 -1
- package/docs/RELEASING.md +19 -10
- package/docs/SCRIPTING.md +10 -10
- package/docs/SDK.md +183 -38
- package/docs/SDK_ARTIFACT_OUTPUT.md +1 -1
- package/docs/SDK_PRIMITIVE_INVENTORY.md +2 -2
- package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +7 -7
- package/docs/TESTING.md +1 -1
- package/docs/WORKFLOW_POLICIES.md +2 -2
- package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +8 -8
- package/docs/agent-task-token-baseline.json +1 -1
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +112 -112
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +13 -4
- package/docs/performance/cli-transport-overhead.md +7 -7
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/README.md +5 -5
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/GAP_REPORT.md +16 -16
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/README.md +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/GAP_REPORT.md +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/README.md +6 -6
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-7ZEFHFAU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-B6UTLYLM.js +0 -3
- package/dist/cli-bundle/chunks/chunk-HBKD5HZB.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L6LCLC37.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NR4KABHC.js +0 -31
- package/dist/cli-bundle/chunks/chunk-PWD5RY2D.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XRMYA4R7.js +0 -20
- package/dist/cli-bundle/chunks/chunk-YWS4XV4I.js +0 -6
- package/dist/cli-bundle/chunks/chunk-ZOAJNPBL.js +0 -129
- package/dist/cli-bundle/chunks/item-transaction-ZHLJTBD7.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-ZQMRMGIB.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-G3QGGQ5Z.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-LDXHMNOT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3XGKBVJ3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4HY6EGPB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AK2CI2GI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HUXZCPWT.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-IKXJ57XA.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-MOY6KZGJ.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-PWUTFKSI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PZRB7IXH.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-WSYPVBKS.js +0 -80
- package/dist/cli-bundle/focused-chunks/chunk-WXLG7HZ5.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-WZDFCVLX.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-YGO3FWA2.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-YVLAP3BL.js +0 -23
- package/dist/cli-bundle/focused-chunks/chunk-ZYXQACPB.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-PZ2FQ6B2.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-XOOK6XFH.js +0 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
|
|
2
|
+
import type { GovernanceStartBlockerEnforcement,ItemMetadata,PmSettings } from "../../types/index.js";
|
|
3
|
+
/** Enforcement applied when `governance.start_blocker_enforcement` is unset. */
|
|
4
|
+
export declare const START_BLOCKER_ENFORCEMENT_DEFAULT:GovernanceStartBlockerEnforcement;
|
|
5
|
+
/** Typed refusal for starting an item whose declared blocker is still open. */
|
|
6
|
+
export declare const START_BLOCKED_REFUSAL_CODE = "start_blocked_by_open_dependency";
|
|
7
|
+
/**
|
|
8
|
+
* Whether a status change moves an item into the effective start status from
|
|
9
|
+
* another status. The effective status is the one start-task writes, including
|
|
10
|
+
* its registered fallback when the workflow names `open` or a removed status.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isStartTransition(fromStatus:string | undefined,toStatus:string | undefined,registry:RuntimeStatusRegistry):boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Admit or refuse starting `metadata` against its currently open declared
|
|
15
|
+
* blockers. Returns warnings for admitted starts; throws the typed refusal
|
|
16
|
+
* under `strict` enforcement without `force`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function admitStartWithOpenBlockers(params:{
|
|
19
|
+
pmRoot:string;
|
|
20
|
+
settings:PmSettings;
|
|
21
|
+
metadata:ItemMetadata;
|
|
22
|
+
force?:boolean;
|
|
23
|
+
}):Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Judge a status change already applied to `metadata`: a move into progress
|
|
26
|
+
* from `fromStatus` goes through {@link admitStartWithOpenBlockers}; any other
|
|
27
|
+
* change, or a caller that did not request a start, is admitted without a read.
|
|
28
|
+
*/
|
|
29
|
+
export declare function admitStartTransition(params:{
|
|
30
|
+
pmRoot:string;
|
|
31
|
+
settings:PmSettings;
|
|
32
|
+
metadata:ItemMetadata;
|
|
33
|
+
fromStatus:string | undefined;
|
|
34
|
+
registry:RuntimeStatusRegistry;
|
|
35
|
+
force?:boolean;
|
|
36
|
+
requested?:boolean;
|
|
37
|
+
}):Promise<string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Run an explicit claim-then-update start composition. Its claim judges the
|
|
40
|
+
* start under the claim's own item lock, before writing ownership; the status
|
|
41
|
+
* update judges again under its own lock, so a blocker opened in between still
|
|
42
|
+
* refuses (the composition then releases the claim it took).
|
|
43
|
+
*/
|
|
44
|
+
export declare function runAsExplicitStart<T>(operation:() => Promise<T>):Promise<T>;
|
|
45
|
+
/** Judge the start an enclosing explicit start composition will make, inside the claim's locked mutation. */
|
|
46
|
+
export declare function admitExplicitStartClaim(params:{
|
|
47
|
+
pmRoot:string;
|
|
48
|
+
settings:PmSettings;
|
|
49
|
+
metadata:ItemMetadata;
|
|
50
|
+
registry:RuntimeStatusRegistry;
|
|
51
|
+
force?:boolean;
|
|
52
|
+
}):Promise<string[]>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a49a1fae-4705-55b4-b4d7-8aa2b4fbfe89")}catch{}})();import{AsyncLocalStorage}from"node:async_hooks";import{getActiveExtensionRegistrations}from"../../core/extensions/index.js";import{normalizeItemId}from"../../core/item/id.js";import{renderPmCommand}from"../../core/shared/command-line.js";import{normalizeStatusForRegistry}from"../../core/item/status.js";import{resolveItemTypeRegistry}from"../../core/item/type-registry.js";import{EXIT_CODE}from"../../core/shared/constants.js";import{PmCliError}from"../../core/shared/errors.js";import{isPmCliExpectedError}from"../errors.js";import{resolveDeclaredBlockers}from"../query/declared-blockers.js";import{resolveStartTaskInProgressStatus}from"../start-task-status.js";import{normalizeItemReference}from"../dependency-provenance.js";import{resolveCanonicalRelationshipKind}from"../relationships.js";const START_BLOCKER_ENFORCEMENT_DEFAULT="strict",START_BLOCKED_REFUSAL_CODE="start_blocked_by_open_dependency";function isStartTransition(fromStatus,toStatus,registry){if(toStatus===void 0)return!1;const inProgress=normalizeStatusForRegistry(resolveStartTaskInProgressStatus(registry),registry);return normalizeStatusForRegistry(toStatus,registry)===inProgress&&normalizeStatusForRegistry(fromStatus??"",registry)!==inProgress}function sameBlocker(reference,blockerId,idPrefix){const canonical=value=>normalizeItemId(value.trim(),idPrefix).toLowerCase();return canonical(reference)===canonical(blockerId)}function unblockCommand(metadata,blockerId,idPrefix){const dependencies=metadata.dependencies??[],edges=dependencies.filter(dependency=>dependency.kind==="blocked_by");if(dependencies.some(dependency=>dependency.kind!=="blocked_by"&&resolveCanonicalRelationshipKind(dependency.kind)==="blocked_by"&&sameBlocker(dependency.id,blockerId,idPrefix)))return renderPmCommand(["get",metadata.id,"--fields","blocked_by,dependencies"]);if(!(typeof metadata.blocked_by=="string"&&sameBlocker(metadata.blocked_by,blockerId,idPrefix))){const matching=edges.filter(dependency=>sameBlocker(dependency.id,blockerId,idPrefix));return matching.length===1&&matching.every(dependency=>dependency.id===normalizeItemReference(dependency.id,idPrefix,void 0))?renderPmCommand(["update",metadata.id,"--dep-remove",`id=${matching[0].id},kind=blocked_by`]):renderPmCommand(["get",metadata.id,"--fields","blocked_by,dependencies"])}const literal=value=>value.trim().toLowerCase();return edges.every(dependency=>literal(dependency.id)===literal(String(metadata.blocked_by)))?renderPmCommand(["update",metadata.id,"--unset","blocked_by"]):renderPmCommand(["get",metadata.id,"--fields","blocked_by,dependencies"])}const UNVERIFIABLE_BLOCKER_CODES=new Set(["item_document_invalid","item_document_encoding_invalid","item_format_version_unsupported","item_identity_ambiguous","item_identity_conflict"]);async function readOpenBlockers(params,admitUnverifiable){try{return(await resolveDeclaredBlockers(params)).filter(blocker=>!blocker.resolved)}catch(error){const code=isPmCliExpectedError(error)?error.context.code:void 0;if(!admitUnverifiable||typeof code!="string"||!UNVERIFIABLE_BLOCKER_CODES.has(code))throw error;return code}}async function admitStartWithOpenBlockers(params){const enforcement=params.settings.governance.start_blocker_enforcement??START_BLOCKER_ENFORCEMENT_DEFAULT;if(enforcement==="off")return[];const typeToFolder=resolveItemTypeRegistry(params.settings,getActiveExtensionRegistrations()).type_to_folder,id=params.metadata.id,open=await readOpenBlockers({pmRoot:params.pmRoot,settings:params.settings,typeToFolder,metadata:params.metadata},enforcement==="warn"||params.force===!0);if(typeof open=="string")return[`start_blocker_unverifiable:${id}:${open}`];if(open.length===0)return[];const ids=open.map(blocker=>blocker.id).join(",");if(enforcement==="warn")return[`start_with_open_blockers:${id}:${ids}`];if(params.force===!0)return[`start_blocker_override:${id}:${ids}`];throw new PmCliError(`Cannot start ${id}: ${open.length===1?"its blocker":`${open.length} of its blockers`} ${ids} ${open.length===1?"is":"are"} still open.`,EXIT_CODE.CONFLICT,{code:"start_blocked_by_open_dependency",item_id:id,required:`Finish or close the open blocker${open.length===1?"":"s"} first, remove the blocked_by edge if it no longer applies, or start anyway with --force.`,why:"Starting work that a declared blocker still gates would leave an in-progress item that validate reports as non_blocked_status_has_blocked_by. governance.start_blocker_enforcement (strict by default) governs this check.",nextSteps:[...open.filter(blocker=>blocker.external!==!0).slice(0,3).map(blocker=>renderPmCommand(["get",blocker.id])),unblockCommand(params.metadata,open[0].id,params.settings.id_prefix),"pm next"],details:{enforcement,open_blockers:open.map(blocker=>({id:blocker.id,title:blocker.title,status:blocker.status,external:blocker.external===!0}))}})}async function admitStartTransition(params){if(params.requested===!1||!isStartTransition(params.fromStatus,params.metadata.status,params.registry))return[];const warnings=await admitStartWithOpenBlockers(params),recorded=explicitStarts.getStore()?.warnings??new Set;return warnings.filter(warning=>!recorded.has(warning))}const explicitStarts=new AsyncLocalStorage;function runAsExplicitStart(operation){return explicitStarts.run({warnings:new Set},operation)}async function admitExplicitStartClaim(params){const pending=explicitStarts.getStore();if(pending===void 0)return[];const warnings=isStartTransition(params.metadata.status,resolveStartTaskInProgressStatus(params.registry),params.registry)?await admitStartWithOpenBlockers(params):[];for(const warning of warnings)pending.warnings.add(warning);return warnings}export{START_BLOCKED_REFUSAL_CODE,START_BLOCKER_ENFORCEMENT_DEFAULT,admitExplicitStartClaim,admitStartTransition,admitStartWithOpenBlockers,isStartTransition,runAsExplicitStart};
|
|
2
|
+
//# sourceMappingURL=start-blockers.js.map
|
|
@@ -13,6 +13,17 @@ next?:boolean;
|
|
|
13
13
|
export declare function finishComposition<T>(id:string,completed:"claim" | "update" | "close",operation:() => Promise<T>):Promise<T>;
|
|
14
14
|
/** Claim explicit work and advance it through the workspace's configured workflow. */
|
|
15
15
|
export declare function runStartTask(id:string,options:TaskCompositionOptions,global:GlobalOptions):Promise<StartTaskResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Compensate the one refusal a start's own claim cannot have judged: a blocker
|
|
18
|
+
* opened after the claim committed. When this start took the item from no
|
|
19
|
+
* owner, release that claim before refusing, so the start leaves no ownership;
|
|
20
|
+
* every other failure keeps the partial-state error unchanged.
|
|
21
|
+
*/
|
|
22
|
+
export declare function releaseRefusedStartClaim(error:unknown,claim:{
|
|
23
|
+
item:Record<string,unknown>;
|
|
24
|
+
previous_assignee:string | null;
|
|
25
|
+
claimed_by:string;
|
|
26
|
+
},global:GlobalOptions,author:string | undefined):Promise<unknown>;
|
|
16
27
|
/** Return work to its configured open status, then release ownership. */
|
|
17
28
|
export declare function runPauseTask(id:string,options:TaskCompositionOptions,global:GlobalOptions):Promise<PauseTaskResult>;
|
|
18
29
|
/** Record all close evidence before releasing assignment metadata. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="35d9d28d-68f5-5a6d-b3e8-02424b81a4d4")}catch{}})();import{PmCliError}from"../../core/shared/errors.js";import{EXIT_CODE}from"../../core/shared/constants.js";import{resolveRuntimeStatusRegistry}from"../../core/schema/runtime-schema.js";import{resolvePmRoot}from"../../core/store/paths.js";import{readSettings}from"../../core/store/settings.js";import{runClaim,runRelease}from"./claim.js";import{resolveReleaseHandoff}from"./release-handoff.js";import{runClose}from"./close.js";import{runUpdate}from"./update.js";import{resolveStartTaskInProgressStatus}from"../start-task-status.js";import{runAsExplicitStart,START_BLOCKED_REFUSAL_CODE}from"./start-blockers.js";import{runWithItemMutationPrecondition}from"../../core/store/item-mutation-precondition.js";import{mutationOptionsWithOverrides}from"../runtime-input.js";async function finishComposition(id,completed,operation){try{return await operation()}catch(error){const context=error instanceof PmCliError?error.context:{},failure=new PmCliError(error instanceof Error?error.message:String(error),error instanceof PmCliError?error.exitCode:EXIT_CODE.GENERIC_FAILURE,{...context,item_id:id,why:`${completed} completed for ${id} before the following step failed. No rollback was performed.${context.why?` ${context.why}`:""}`,nextSteps:[`Inspect the persisted state with pm get ${id} and pm history ${id} before retrying the failed step.`,...context.nextSteps??[]]});throw failure.cause=error,failure}}async function runStartTask(id,options,global2){if(options.next===!0||options.ifAvailable===!0)throw new PmCliError("--start cannot be combined with --next or --if-available for an explicit item",EXIT_CODE.USAGE,{code:"invalid_argument_value",required:"Remove --next and --if-available when starting an explicit item.",nextSteps:["Remove --next and --if-available, keep the explicit item ID and other supplied arguments, then retry."]});const settings=await readSettings(resolvePmRoot(process.cwd(),global2.path)),status=resolveStartTaskInProgressStatus(resolveRuntimeStatusRegistry(settings.schema));return runAsExplicitStart(async()=>{const claim=await runClaim(id,options.force===!0,global2,mutationOptionsWithOverrides(options,{},["start"])),canonicalId=claim.item.id,update=await finishComposition(canonicalId,"claim",()=>runUpdate(canonicalId,mutationOptionsWithOverrides(options,{status},["assignee","start","next","ifAvailable","maxAttempts"]),global2)).catch(async error=>{throw await releaseRefusedStartClaim(error,claim,global2,options.author)});return{id:canonicalId,action:"start_task",claim,update}})}async function releaseRefusedStartClaim(error,claim,global2,author){if(!(error instanceof PmCliError)||error.code!==START_BLOCKED_REFUSAL_CODE||claim.previous_assignee!==null)return error;const id=String(claim.item.id);try{await runWithItemMutationPrecondition({pmRoot:resolvePmRoot(process.cwd(),global2.path),id,validate:document=>{if(document.metadata.assignee!==claim.claimed_by||document.metadata.claim_principal!==claim.item.claim_principal)throw new PmCliError("The claim this start took is no longer its own.",EXIT_CODE.CONFLICT)}},()=>runRelease(id,!1,global2,{author,message:"Release the claim: a blocker opened before its start could be recorded"}))}catch{return error}const refusal=error.cause instanceof PmCliError?error.cause:error;return new PmCliError(refusal.message,refusal.exitCode,{...refusal.context,why:`${refusal.context.why??""} A blocker opened after this start's claim, so the claim was released and no ownership remains.`.trim()})}async function runPauseTask(id,options,global2){const settings=await readSettings(resolvePmRoot(process.cwd(),global2.path)),registry=resolveRuntimeStatusRegistry(settings.schema);resolveReleaseHandoff({...options,pause:!0},registry);const status=registry.open_status,update=await runUpdate(id,mutationOptionsWithOverrides(options,{status},["assignee","pause"]),global2),canonicalId=update.item.id,release=await finishComposition(canonicalId,"update",()=>runRelease(canonicalId,options.force===!0,global2,options));return{id:canonicalId,action:"pause_task",update,release}}async function runCloseTask(id,reason,options,global2){const close=await runClose(id,reason,options,global2),canonicalId=close.item.id,release=await finishComposition(canonicalId,"close",()=>runRelease(canonicalId,options.force===!0,global2,options));return{id:canonicalId,action:"close_task",close,release}}export{finishComposition,releaseRefusedStartClaim,runCloseTask,runPauseTask,runStartTask};
|
|
2
2
|
//# sourceMappingURL=task-composition.js.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli/commands/update-many
|
|
3
|
+
*
|
|
4
|
+
* Implements the pm update many command surface and its agent-facing runtime behavior.
|
|
5
|
+
*/
|
|
6
|
+
import { type ItemRevisionConflictRowFields } from "./item-revision.js";
|
|
7
|
+
import { type DependentRevisionConflict } from "./close.js";
|
|
1
8
|
import { type RuntimeFieldRegistry,type RuntimeStatusRegistry,type GlobalOptions } from "../runtime-primitives.js";
|
|
2
9
|
import type { ItemStatus,PmSettings } from "../../types/index.js";
|
|
3
10
|
import { hasListFilters } from "../query/list-filter-shared.js";
|
|
@@ -31,14 +38,16 @@ id:string;
|
|
|
31
38
|
changes:PlannedChange[];
|
|
32
39
|
warnings?:string[];
|
|
33
40
|
}
|
|
34
|
-
interface UpdateManyApplyResultRow {
|
|
41
|
+
interface UpdateManyApplyResultRow extends ItemRevisionConflictRowFields {
|
|
35
42
|
id:string;
|
|
36
43
|
status:"updated" | "failed" | "skipped";
|
|
37
44
|
changed_fields?:string[];
|
|
38
45
|
warnings?:string[];
|
|
39
46
|
error?:string;
|
|
47
|
+
/** A guarded dependent whose auto-unblock refused after this row's close committed. */
|
|
48
|
+
dependent_revision_conflict?:DependentRevisionConflict;
|
|
40
49
|
}
|
|
41
|
-
interface UpdateManyRollbackResultRow {
|
|
50
|
+
interface UpdateManyRollbackResultRow extends ItemRevisionConflictRowFields {
|
|
42
51
|
id:string;
|
|
43
52
|
status:"restored" | "failed" | "skipped";
|
|
44
53
|
changed_fields?:string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="86acbe76-ed18-52be-b561-4819c648e88e")}catch{}})();import{assertInitializedTracker}from"../environment/tracker-preflight.js";import{withCheckpointMutation}from"../../core/checkpoint/mutation-context.js";import{resolveCheckpointRollbackId}from"../../core/checkpoint/mutation-checkpoint.js";import{rollbackMutationCheckpoint}from"./checkpoint-rollback.js";import{createCheckpointId,loadMutationCheckpoint,writeMutationCheckpoint,toItemRecord,applyAcceptanceCriteriaMutations,applyTagRemovals,mergeAdditiveTags,parseOptionalNonNegativeInteger,parseTags,splitAcceptanceCriteria,resolvePriority,normalizeStatusInput,resolveItemTypeRegistry,resolveTypeName,collectRuntimeUpdateFieldValues,buildInvalidTypeError,resolveItemTypesFilePath,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,EXIT_CODE,PmCliError,toErrorMessage,stableValueEquals,nowIso,preserveMutationStdinTokenLiterals,transferMutationStdinTokenPolicy,resolveIsoOrRelative,getActiveExtensionRegistrations,collectRegisteredItemFieldNames,resolvePmRoot,readSettings,resolveAuthor}from"../runtime-primitives.js";import{assertDependencyTargetsResolvable}from"../dependency-flag-validation.js";import{parseStatusFilterCsv}from"../../core/item/status-filter.js";import{hasListFilters}from"../query/list-filter-shared.js";import{runList}from"../query/list.js";import{assertUpdateMutationOptionCombinations,assertUpdateUnsetFieldsSupported,parseDependencyAdditions,resolveUpdateTransportOptions,runUpdate}from"./update.js";import{derivePmBulkMutationEffect}from"../cli-contracts/command-exit-contracts.js";const UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION=2,UPDATE_MANY_CHECKPOINT_SUBDIR="update-many",NON_MUTATION_UPDATE_OPTION_KEYS=new Set(["author","message","force","ownershipMetadataBypass","ownershipDependencyBypass","allowUnresolvedDeps"]),UPDATE_MANY_MUTATION_FLAG_GUIDANCE=["--status","--priority","--type","--tags","--description","--body","--deadline","--estimate","--assignee","--dep","--dep-remove","--comment","--note","--learning","--file","--test","--doc","--replace-deps","--replace-tests","--replace-files","--replace-docs","--unset","--clear-*"].join(", "),UPDATE_OPTION_TO_ITEM_KEY={title:"title",description:"description",body:"body",status:"status",closeReason:"close_reason",priority:"priority",type:"type",deadline:"deadline",estimatedMinutes:"estimated_minutes",acceptanceCriteria:"acceptance_criteria",definitionOfReady:"definition_of_ready",order:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",whyNow:"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blockedBy:"blocked_by",blockedReason:"blocked_reason",unblockNote:"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",reproSteps:"repro_steps",resolution:"resolution",expectedResult:"expected_result",actualResult:"actual_result",affectedVersion:"affected_version",fixedVersion:"fixed_version",component:"component",regression:"regression",customerImpact:"customer_impact"},COLLECTION_MUTATION_PLAN_DEFINITIONS=[{field:"dependencies",addKey:"dep",removeKey:"depRemove",clearKey:"clearDeps",replaceKey:"replaceDeps"},{field:"comments",addKey:"comment",clearKey:"clearComments"},{field:"notes",addKey:"note",clearKey:"clearNotes"},{field:"learnings",addKey:"learning",clearKey:"clearLearnings"},{field:"files",addKey:"file",clearKey:"clearFiles",replaceKey:"replaceFiles"},{field:"tests",addKey:"test",clearKey:"clearTests",replaceKey:"replaceTests"},{field:"docs",addKey:"doc",clearKey:"clearDocs",replaceKey:"replaceDocs"},{field:"reminders",addKey:"reminder",clearKey:"clearReminders"},{field:"events",addKey:"event",clearKey:"clearEvents"},{field:"type_options",addKey:"typeOption",clearKey:"clearTypeOptions"}],sanitizeUpdateOptionsForSummary=options=>{const summary={};for(const[key,value]of Object.entries(options))NON_MUTATION_UPDATE_OPTION_KEYS.has(key)||value!==void 0&&(summary[key]=value);return summary},hasAnyUpdateMutationInput=options=>Object.keys(sanitizeUpdateOptionsForSummary(options)).length>0,trimPreviewValue=value=>typeof value=="string"?value.trim():value,normalizeIntegerPreviewValue=value=>{const trimmed=String(value).trim(),parsed=Number(trimmed);return Number.isInteger(parsed)?parsed:trimmed},normalizeNumericPreviewValue=value=>{const trimmed=String(value).trim(),parsed=Number(trimmed);return Number.isFinite(parsed)?parsed:trimmed},normalizeRegressionPreviewValue=value=>{const normalized=String(value).trim().toLowerCase();return new Map([["true",!0],["1",!0],["false",!1],["0",!1]]).get(normalized)??trimPreviewValue(value)},PREVIEW_VALUE_NORMALIZERS={priority:normalizeIntegerPreviewValue,estimatedMinutes:normalizeNumericPreviewValue,order:normalizeNumericPreviewValue,rank:normalizeNumericPreviewValue,regression:normalizeRegressionPreviewValue},toComparablePreviewValue=(optionKey,value)=>{if(value!==void 0)return(PREVIEW_VALUE_NORMALIZERS[optionKey]??trimPreviewValue)(value)},areValuesEqual=(left,right)=>stableValueEquals(left,right),normalizeCollectionBeforeValue=(field,value)=>value!==void 0?value:field==="type_options"?{}:[],collectionValueCount=(field,value)=>Array.isArray(value)?value.length:field==="type_options"&&value&&typeof value=="object"?Object.keys(value).length:0,resolveCollectionMutationOperation=params=>params.replace?"replace":params.clear?"clear_or_reset":params.removeCount>0?"merge_remove":"append",readOptionalUpdateValue=(update,key)=>key===void 0?void 0:update[key],updateArrayValueCount=value=>Array.isArray(value)?value.length:0,buildCollectionMutationPlan=(definition,row,update)=>{const addValues=update[definition.addKey],removeValues=readOptionalUpdateValue(update,definition.removeKey),addCount=updateArrayValueCount(addValues),removeCount=updateArrayValueCount(removeValues),clear=update[definition.clearKey]===!0,replace=readOptionalUpdateValue(update,definition.replaceKey)===!0;if(![clear,replace,addCount>0,removeCount>0].includes(!0))return;const before=normalizeCollectionBeforeValue(definition.field,row[definition.field]);return{field:definition.field,before,after:{operation:resolveCollectionMutationOperation({replace,clear,removeCount}),clear,replace,add_count:addCount,remove_count:removeCount,before_count:collectionValueCount(definition.field,before)}}},buildCollectionMutationPlans=(row,update)=>{const changes=[];for(const definition of COLLECTION_MUTATION_PLAN_DEFINITIONS){const plan=buildCollectionMutationPlan(definition,row,update);plan!==void 0&&changes.push(plan)}return changes},normalizeExistingTags=value=>Array.isArray(value)?value.filter(tag=>typeof tag=="string"):[],buildTagMutationPlan=(row,update)=>{if(![update.tags!==void 0,updateArrayValueCount(update.addTags)>0,updateArrayValueCount(update.removeTags)>0].includes(!0))return;const existing=normalizeExistingTags(row.tags),baseTags=update.tags===void 0?existing:parseTags(update.tags),withAdditions=mergeAdditiveTags(baseTags,update.addTags),after=applyTagRemovals(withAdditions,update.removeTags).slice().sort((a,b)=>a.localeCompare(b)),before=existing.slice().sort((a,b)=>a.localeCompare(b));if(!areValuesEqual(before,after))return{field:"tags",before:existing,after}},buildAcceptanceCriteriaMutationPlan=(row,update)=>{const before=row.acceptance_criteria,mutation=applyAcceptanceCriteriaMutations(splitAcceptanceCriteria(before),update.addAc,update.removeAc);if(mutation.unmatchedRemovals.length>0)throw new PmCliError(`Acceptance criteria removal did not match: ${mutation.unmatchedRemovals.join(", ")}`,EXIT_CODE.NOT_FOUND,{code:"acceptance_criteria_remove_unmatched",reason:"exact_match_not_found",field:"acceptance_criteria",unmatched:mutation.unmatchedRemovals});const after=mutation.criteria.join("; ");if(!areValuesEqual(typeof before=="string"?before:"",after))return{field:"acceptance_criteria",before,after}},appendScalarMutationPlans=(changes,row,update)=>{for(const[optionKey,itemKey]of Object.entries(UPDATE_OPTION_TO_ITEM_KEY)){const candidate=update[optionKey];if(candidate===void 0)continue;const before=row[itemKey],after=toComparablePreviewValue(optionKey,candidate);areValuesEqual(before,after)||changes.push({field:itemKey,before,after})}},appendRuntimeFieldMutationPlans=(changes,row,update,runtimeFieldRegistry)=>{const runtimeFieldUpdates=collectRuntimeUpdateFieldValues(update,runtimeFieldRegistry,["update_many"]);for(const[field,after]of Object.entries(runtimeFieldUpdates)){const before=row[field];areValuesEqual(before,after)||changes.push({field,before,after})}},appendUnsetMutationPlans=(changes,row,unset,runtimeFieldRegistry)=>{if(unset===void 0||unset.length===0)return;const fields=assertUpdateUnsetFieldsSupported(unset,runtimeFieldRegistry,collectRegisteredItemFieldNames(getActiveExtensionRegistrations()),["update_many"]);for(const field of fields){const before=row[field];before!==void 0&&changes.push({field,before,after:null})}},buildPlannedItemDiff=(item,runtimeFieldRegistry,update={})=>{const row=toItemRecord(item),changes=[],tagPlan=buildTagMutationPlan(row,update);if(tagPlan&&changes.push(tagPlan),appendScalarMutationPlans(changes,row,update),updateArrayValueCount(update.addAc)>0||updateArrayValueCount(update.removeAc)>0){const acceptanceCriteriaChange=buildAcceptanceCriteriaMutationPlan(row,update);acceptanceCriteriaChange!==void 0&&changes.push(acceptanceCriteriaChange)}return changes.push(...buildCollectionMutationPlans(row,update)),appendRuntimeFieldMutationPlans(changes,row,update,runtimeFieldRegistry),appendUnsetMutationPlans(changes,row,update.unset,runtimeFieldRegistry),{id:item.id,changes}},normalizeStatusFilter=(value,statusRegistry)=>parseStatusFilterCsv(value,statusRegistry,{strict:!0,flagLabel:"--filter-status"}),rejectBlankIdsFilter=list=>{if(list?.ids!=null&&String(list.ids).trim().length===0)throw new PmCliError("--ids requires at least one non-empty item ID",EXIT_CODE.USAGE)},PLANNED_UPDATE_VALIDATORS=[({update})=>{update.priority!==void 0&&resolvePriority(update.priority)},({update,settings})=>{update.unset!==void 0&&update.unset.length>0&&assertUpdateUnsetFieldsSupported(update.unset,resolveRuntimeFieldRegistry(settings.schema),collectRegisteredItemFieldNames(getActiveExtensionRegistrations()),["update_many"])},({update,settings,pmRoot})=>{if(update.type===void 0)return;const typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations());if(!resolveTypeName(update.type,typeRegistry))throw new PmCliError(buildInvalidTypeError(update.type,typeRegistry.types,resolveItemTypesFilePath(pmRoot,settings.schema)),EXIT_CODE.USAGE)},({update,statusRegistry})=>{if(update.status!==void 0&&!normalizeStatusInput(update.status,statusRegistry)){const allowedStatuses=statusRegistry.definitions.map(definition=>definition.id);throw new PmCliError(`Invalid status value "${update.status}". Allowed: ${allowedStatuses.join(", ")}`,EXIT_CODE.USAGE,{code:"invalid_argument_value",field:"status",value:update.status,allowed:allowedStatuses})}},({update})=>{update.deadline!==void 0&&resolveIsoOrRelative(update.deadline,new Date,"deadline")},({update})=>{update.estimatedMinutes!==void 0&&parseOptionalNonNegativeInteger(update.estimatedMinutes,"estimated-minutes")}],assertPlannedUpdateValuesValid=(update,settings,statusRegistry,pmRoot)=>{const context={update,settings,statusRegistry,pmRoot};for(const validate of PLANNED_UPDATE_VALIDATORS)validate(context)},runUpdateManyRollback=async params=>{const checkpoint=await loadMutationCheckpoint(params.pmRoot,UPDATE_MANY_CHECKPOINT_SUBDIR,params.rollbackId,UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION),restoreMessage=params.options.update?.message??`Rollback update-many checkpoint ${checkpoint.id}`,rollback=await rollbackMutationCheckpoint(params.pmRoot,checkpoint,{author:params.options.update?.author,message:restoreMessage,force:params.options.update?.force}),skipped=rollback.rows.filter(row=>row.status==="skipped").length;return{...derivePmBulkMutationEffect({applied:rollback.restored_ids.length,skipped,failed:rollback.failed_count,unmatched:0}),mode:"rollback",matched_count:checkpoint.items.length,dry_run:!1,rollback_checkpoint_id:checkpoint.id,checkpoint:{id:checkpoint.id,created_at:checkpoint.created_at,path:checkpoint.path,rollback_command:`pm update-many --rollback ${checkpoint.id}`},restored_count:rollback.restored_ids.length,skipped_count:skipped,failed_count:rollback.failed_count,rows:rollback.rows,ids:rollback.restored_ids}},writeUpdateManyCheckpoint=async params=>{const checkpointPayload={schema_version:UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION,rollback_strategy:"guarded_inverse",id:params.checkpointId,created_at:params.nowValue,author:resolveAuthor(params.options.update?.author,"unknown"),status_filter:params.statusFilter??null,list_filters:params.filters,update_options:params.updateSummary,items:params.checkpointItems},checkpointPath=await writeMutationCheckpoint(params.pmRoot,UPDATE_MANY_CHECKPOINT_SUBDIR,params.checkpointId,checkpointPayload);return{id:params.checkpointId,created_at:params.nowValue,path:checkpointPath,rollback_command:`pm update-many --rollback ${params.checkpointId}`}},collectUnmatchedRequestedIds=(rawIds,existingItems)=>{if(rawIds==null)return;const requested=[...new Set(String(rawIds).split(",").map(entry=>entry.trim()).filter(entry=>entry.length>0))],existing=new Set(existingItems.map(item=>item.id));return requested.filter(id=>!existing.has(id))},buildUnmatchedIdFields=plan=>plan.unmatchedIds===void 0?{}:{unmatched_ids:plan.unmatchedIds,unmatched_count:plan.unmatchedIds.length},loadUpdateManyRuntimeContext=async global2=>{const pmRoot=resolvePmRoot(process.cwd(),global2.path);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot);return{pmRoot,settings,statusRegistry:resolveRuntimeStatusRegistry(settings.schema),runtimeFieldRegistry:resolveRuntimeFieldRegistry(settings.schema)}},runRequestedUpdateManyRollback=params=>{if(params.options.dryRun===!0)throw new PmCliError("--dry-run cannot be combined with --rollback",EXIT_CODE.USAGE);if(hasListFilters(params.options.list,params.options.status))throw new PmCliError("Rollback mode does not accept filter options",EXIT_CODE.USAGE);if(Object.keys(params.updateSummary).length>0)throw new PmCliError("Rollback mode does not accept update mutation flags",EXIT_CODE.USAGE);return runUpdateManyRollback({pmRoot:params.runtime.pmRoot,rollbackId:params.rollbackId,options:params.options,global:params.global})},buildUpdateManyPlan=async params=>{normalizeStatusFilter(params.options.status,params.runtime.statusRegistry);const listed=await runList(void 0,{...params.options.list,status:params.options.status,compact:void 0,brief:void 0,fields:void 0,includeBody:!0,full:!0},params.global),planned=listed.items.map(item=>{const diff=buildPlannedItemDiff(item,params.runtime.runtimeFieldRegistry,params.options.update);return params.dependencyWarnings.length===0?diff:{...diff,warnings:[...params.dependencyWarnings]}}),existenceItems=params.options.list?.ids==null?[]:(await runList(void 0,{ids:params.options.list.ids,noTruncate:!0,full:!0},params.global)).items;return{listed,planned,actionable:planned.filter(row=>row.changes.length>0),updateSummary:params.updateSummary,unmatchedIds:collectUnmatchedRequestedIds(params.options.list?.ids,existenceItems)}},buildUpdateManyDryRunResult=plan=>({outcome:"effect",exit_code:EXIT_CODE.SUCCESS,mode:"dry_run",matched_count:plan.listed.items.length,dry_run:!0,filters:plan.listed.filters,planned_update_options:plan.updateSummary,item_plans:plan.planned,ids:[],...buildUnmatchedIdFields(plan)}),buildUpdateManyNoopResult=plan=>({...derivePmBulkMutationEffect({applied:0,skipped:plan.listed.items.length,failed:0,unmatched:plan.unmatchedIds?.length??0}),mode:"apply",matched_count:plan.listed.items.length,dry_run:!1,filters:plan.listed.filters,planned_update_options:plan.updateSummary,updated_count:0,skipped_count:plan.listed.items.length,failed_count:0,rows:plan.planned.map(row=>({id:row.id,status:"skipped"})),ids:[],...buildUnmatchedIdFields(plan)}),applyUpdateManyRows=async params=>{const rows=[],updatedIds=[],updateMessage=params.options.update.message??`update-many apply ${params.checkpointId}`,actionableById=new Set(params.plans.filter(row=>row.changes.length>0).map(row=>row.id));for(const item of params.items){if(!actionableById.has(item.id)){rows.push({id:item.id,status:"skipped"});continue}try{const rowUpdateOptions=preserveMutationStdinTokenLiterals(transferMutationStdinTokenPolicy(params.options.update,{...params.options.update,message:updateMessage,runtimeFieldCommands:["update_many"]})),result=await withCheckpointMutation({pmRoot:params.pmRoot,itemId:item.id,checkpointId:params.checkpointId},()=>runUpdate(item.id,rowUpdateOptions,params.global));rows.push({id:item.id,status:"updated",changed_fields:result.changed_fields,warnings:result.warnings}),updatedIds.push(item.id)}catch(error){rows.push({id:item.id,status:"failed",error:toErrorMessage(error)})}}return{rows,updatedIds}},applyUpdateManyPlan=async params=>{if(params.plan.actionable.length===0)return buildUpdateManyNoopResult(params.plan);const nowValue=nowIso(),checkpointId=createCheckpointId(UPDATE_MANY_CHECKPOINT_SUBDIR,nowValue),actionableById=new Set(params.plan.actionable.map(row=>row.id)),checkpointItems=params.plan.listed.items.filter(item=>actionableById.has(item.id)).map(item=>({id:item.id,target_updated_at:item.updated_at})),checkpointInfo=params.options.checkpoint===!1?void 0:await writeUpdateManyCheckpoint({pmRoot:params.runtime.pmRoot,checkpointId,nowValue,options:params.options,statusFilter:params.options.status,filters:params.plan.listed.filters,updateSummary:params.plan.updateSummary,checkpointItems}),applied=await applyUpdateManyRows({pmRoot:params.runtime.pmRoot,items:params.plan.listed.items,plans:params.plan.planned,options:params.options,global:params.global,checkpointId}),countStatus=status=>applied.rows.filter(row=>row.status===status).length,updatedCount=countStatus("updated"),skippedCount=countStatus("skipped"),failedCount=countStatus("failed");return{...derivePmBulkMutationEffect({applied:updatedCount,skipped:skippedCount,failed:failedCount,unmatched:params.plan.unmatchedIds?.length??0}),mode:"apply",matched_count:params.plan.listed.items.length,dry_run:!1,filters:params.plan.listed.filters,planned_update_options:params.plan.updateSummary,...checkpointInfo?{checkpoint:checkpointInfo}:{},updated_count:updatedCount,skipped_count:skippedCount,failed_count:failedCount,rows:applied.rows,ids:applied.updatedIds,...buildUnmatchedIdFields(params.plan)}},runUpdateMany=async(options,global2)=>{const rollbackId=resolveCheckpointRollbackId(options.rollback),runtime=await loadUpdateManyRuntimeContext(global2);rollbackId===void 0&&(options={...options,update:preserveMutationStdinTokenLiterals(await resolveUpdateTransportOptions(options.update))});const updateSummary=sanitizeUpdateOptionsForSummary(options.update);if(rejectBlankIdsFilter(options.list),rollbackId!==void 0)return runRequestedUpdateManyRollback({runtime,rollbackId,options,global:global2,updateSummary});if(!hasAnyUpdateMutationInput(options.update)&&options.dryRun!==!0)throw new PmCliError(`No update-many mutation flags provided. Add at least one mutation flag (for example: ${UPDATE_MANY_MUTATION_FLAG_GUIDANCE}), or pass --dry-run for a filter-only preview.`,EXIT_CODE.USAGE);assertPlannedUpdateValuesValid(options.update,runtime.settings,runtime.statusRegistry,runtime.pmRoot),assertUpdateMutationOptionCombinations(options.update);const dependencyWarnings=await assertDependencyTargetsResolvable({pmRoot:runtime.pmRoot,dependencies:parseDependencyAdditions(options.update.dep,runtime.settings.id_prefix,nowIso(),resolveAuthor(options.update.author,runtime.settings.author_default)).additions,idPrefix:runtime.settings.id_prefix,itemFormat:runtime.settings.item_format,typeToFolder:resolveItemTypeRegistry(runtime.settings,getActiveExtensionRegistrations()).type_to_folder,allowUnresolved:options.update.allowUnresolvedDeps}),plan=await buildUpdateManyPlan({options,global:global2,runtime,updateSummary,dependencyWarnings});return await assertDependencyTargetsResolvable({pmRoot:runtime.pmRoot,dependencies:parseDependencyAdditions(options.update.dep,runtime.settings.id_prefix,nowIso(),resolveAuthor(options.update.author,runtime.settings.author_default)).additions,idPrefix:runtime.settings.id_prefix,itemFormat:runtime.settings.item_format,typeToFolder:resolveItemTypeRegistry(runtime.settings,getActiveExtensionRegistrations()).type_to_folder,allowUnresolved:options.update.allowUnresolvedDeps,holders:plan.listed.items.map(item=>({id:item.id,createdAt:item.created_at})),schema:runtime.settings.schema}),options.dryRun===!0?buildUpdateManyDryRunResult(plan):applyUpdateManyPlan({runtime,options,global:global2,plan})},_testOnlyUpdateManyCommand={assertPlannedUpdateValuesValid,buildCollectionMutationPlans,buildPlannedItemDiff,buildTagMutationPlan,collectionValueCount,hasAnyUpdateMutationInput,hasListFilters,normalizeStatusFilter,normalizeCollectionBeforeValue,normalizeExistingTags,rejectBlankIdsFilter,sanitizeUpdateOptionsForSummary,toComparablePreviewValue};export{_testOnlyUpdateManyCommand,runUpdateMany};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="06b0780c-92aa-5b21-a4bb-0abb54b74b2f")}catch{}})();import{itemRevisionConflictRowFields}from"./item-revision.js";import{assertInitializedTracker}from"../environment/tracker-preflight.js";import{withCheckpointMutation}from"../../core/checkpoint/mutation-context.js";import{resolveCheckpointRollbackId}from"../../core/checkpoint/mutation-checkpoint.js";import{rollbackMutationCheckpoint}from"./checkpoint-rollback.js";import{committedCloseDependentConflict}from"./close.js";import{createCheckpointId,loadMutationCheckpoint,writeMutationCheckpoint,toItemRecord,applyAcceptanceCriteriaMutations,applyTagRemovals,mergeAdditiveTags,parseOptionalNonNegativeInteger,parseTags,splitAcceptanceCriteria,resolvePriority,normalizeStatusInput,resolveItemTypeRegistry,resolveTypeName,collectRuntimeUpdateFieldValues,buildInvalidTypeError,resolveItemTypesFilePath,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,EXIT_CODE,PmCliError,toErrorMessage,stableValueEquals,nowIso,preserveMutationStdinTokenLiterals,transferMutationStdinTokenPolicy,resolveIsoOrRelative,getActiveExtensionRegistrations,collectRegisteredItemFieldNames,resolvePmRoot,readSettings,resolveAuthor}from"../runtime-primitives.js";import{assertDependencyTargetsResolvable}from"../dependency-flag-validation.js";import{parseStatusFilterCsv}from"../../core/item/status-filter.js";import{hasListFilters}from"../query/list-filter-shared.js";import{runList}from"../query/list.js";import{assertUpdateMutationOptionCombinations,assertUpdateUnsetFieldsSupported,parseDependencyAdditions,resolveUpdateTransportOptions,runUpdate}from"./update.js";import{derivePmBulkMutationEffect}from"../cli-contracts/command-exit-contracts.js";const UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION=2,UPDATE_MANY_CHECKPOINT_SUBDIR="update-many",NON_MUTATION_UPDATE_OPTION_KEYS=new Set(["author","message","force","ownershipMetadataBypass","ownershipDependencyBypass","allowUnresolvedDeps"]),UPDATE_MANY_MUTATION_FLAG_GUIDANCE=["--status","--priority","--type","--tags","--description","--body","--deadline","--estimate","--assignee","--dep","--dep-remove","--comment","--note","--learning","--file","--test","--doc","--replace-deps","--replace-tests","--replace-files","--replace-docs","--unset","--clear-*"].join(", "),UPDATE_OPTION_TO_ITEM_KEY={title:"title",description:"description",body:"body",status:"status",closeReason:"close_reason",priority:"priority",type:"type",deadline:"deadline",estimatedMinutes:"estimated_minutes",acceptanceCriteria:"acceptance_criteria",definitionOfReady:"definition_of_ready",order:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",whyNow:"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blockedBy:"blocked_by",blockedReason:"blocked_reason",unblockNote:"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",reproSteps:"repro_steps",resolution:"resolution",expectedResult:"expected_result",actualResult:"actual_result",affectedVersion:"affected_version",fixedVersion:"fixed_version",component:"component",regression:"regression",customerImpact:"customer_impact"},COLLECTION_MUTATION_PLAN_DEFINITIONS=[{field:"dependencies",addKey:"dep",removeKey:"depRemove",clearKey:"clearDeps",replaceKey:"replaceDeps"},{field:"comments",addKey:"comment",clearKey:"clearComments"},{field:"notes",addKey:"note",clearKey:"clearNotes"},{field:"learnings",addKey:"learning",clearKey:"clearLearnings"},{field:"files",addKey:"file",clearKey:"clearFiles",replaceKey:"replaceFiles"},{field:"tests",addKey:"test",clearKey:"clearTests",replaceKey:"replaceTests"},{field:"docs",addKey:"doc",clearKey:"clearDocs",replaceKey:"replaceDocs"},{field:"reminders",addKey:"reminder",clearKey:"clearReminders"},{field:"events",addKey:"event",clearKey:"clearEvents"},{field:"type_options",addKey:"typeOption",clearKey:"clearTypeOptions"}],sanitizeUpdateOptionsForSummary=options=>{const summary={};for(const[key,value]of Object.entries(options))NON_MUTATION_UPDATE_OPTION_KEYS.has(key)||value!==void 0&&(summary[key]=value);return summary},hasAnyUpdateMutationInput=options=>Object.keys(sanitizeUpdateOptionsForSummary(options)).length>0,trimPreviewValue=value=>typeof value=="string"?value.trim():value,normalizeIntegerPreviewValue=value=>{const trimmed=String(value).trim(),parsed=Number(trimmed);return Number.isInteger(parsed)?parsed:trimmed},normalizeNumericPreviewValue=value=>{const trimmed=String(value).trim(),parsed=Number(trimmed);return Number.isFinite(parsed)?parsed:trimmed},normalizeRegressionPreviewValue=value=>{const normalized=String(value).trim().toLowerCase();return new Map([["true",!0],["1",!0],["false",!1],["0",!1]]).get(normalized)??trimPreviewValue(value)},PREVIEW_VALUE_NORMALIZERS={priority:normalizeIntegerPreviewValue,estimatedMinutes:normalizeNumericPreviewValue,order:normalizeNumericPreviewValue,rank:normalizeNumericPreviewValue,regression:normalizeRegressionPreviewValue},toComparablePreviewValue=(optionKey,value)=>{if(value!==void 0)return(PREVIEW_VALUE_NORMALIZERS[optionKey]??trimPreviewValue)(value)},areValuesEqual=(left,right)=>stableValueEquals(left,right),normalizeCollectionBeforeValue=(field,value)=>value!==void 0?value:field==="type_options"?{}:[],collectionValueCount=(field,value)=>Array.isArray(value)?value.length:field==="type_options"&&value&&typeof value=="object"?Object.keys(value).length:0,resolveCollectionMutationOperation=params=>params.replace?"replace":params.clear?"clear_or_reset":params.removeCount>0?"merge_remove":"append",readOptionalUpdateValue=(update,key)=>key===void 0?void 0:update[key],updateArrayValueCount=value=>Array.isArray(value)?value.length:0,buildCollectionMutationPlan=(definition,row,update)=>{const addValues=update[definition.addKey],removeValues=readOptionalUpdateValue(update,definition.removeKey),addCount=updateArrayValueCount(addValues),removeCount=updateArrayValueCount(removeValues),clear=update[definition.clearKey]===!0,replace=readOptionalUpdateValue(update,definition.replaceKey)===!0;if(![clear,replace,addCount>0,removeCount>0].includes(!0))return;const before=normalizeCollectionBeforeValue(definition.field,row[definition.field]);return{field:definition.field,before,after:{operation:resolveCollectionMutationOperation({replace,clear,removeCount}),clear,replace,add_count:addCount,remove_count:removeCount,before_count:collectionValueCount(definition.field,before)}}},buildCollectionMutationPlans=(row,update)=>{const changes=[];for(const definition of COLLECTION_MUTATION_PLAN_DEFINITIONS){const plan=buildCollectionMutationPlan(definition,row,update);plan!==void 0&&changes.push(plan)}return changes},normalizeExistingTags=value=>Array.isArray(value)?value.filter(tag=>typeof tag=="string"):[],buildTagMutationPlan=(row,update)=>{if(![update.tags!==void 0,updateArrayValueCount(update.addTags)>0,updateArrayValueCount(update.removeTags)>0].includes(!0))return;const existing=normalizeExistingTags(row.tags),baseTags=update.tags===void 0?existing:parseTags(update.tags),withAdditions=mergeAdditiveTags(baseTags,update.addTags),after=applyTagRemovals(withAdditions,update.removeTags).slice().sort((a,b)=>a.localeCompare(b)),before=existing.slice().sort((a,b)=>a.localeCompare(b));if(!areValuesEqual(before,after))return{field:"tags",before:existing,after}},buildAcceptanceCriteriaMutationPlan=(row,update)=>{const before=row.acceptance_criteria,mutation=applyAcceptanceCriteriaMutations(splitAcceptanceCriteria(before),update.addAc,update.removeAc);if(mutation.unmatchedRemovals.length>0)throw new PmCliError(`Acceptance criteria removal did not match: ${mutation.unmatchedRemovals.join(", ")}`,EXIT_CODE.NOT_FOUND,{code:"acceptance_criteria_remove_unmatched",reason:"exact_match_not_found",field:"acceptance_criteria",unmatched:mutation.unmatchedRemovals});const after=mutation.criteria.join("; ");if(!areValuesEqual(typeof before=="string"?before:"",after))return{field:"acceptance_criteria",before,after}},appendScalarMutationPlans=(changes,row,update)=>{for(const[optionKey,itemKey]of Object.entries(UPDATE_OPTION_TO_ITEM_KEY)){const candidate=update[optionKey];if(candidate===void 0)continue;const before=row[itemKey],after=toComparablePreviewValue(optionKey,candidate);areValuesEqual(before,after)||changes.push({field:itemKey,before,after})}},appendRuntimeFieldMutationPlans=(changes,row,update,runtimeFieldRegistry)=>{const runtimeFieldUpdates=collectRuntimeUpdateFieldValues(update,runtimeFieldRegistry,["update_many"]);for(const[field,after]of Object.entries(runtimeFieldUpdates)){const before=row[field];areValuesEqual(before,after)||changes.push({field,before,after})}},appendUnsetMutationPlans=(changes,row,unset,runtimeFieldRegistry)=>{if(unset===void 0||unset.length===0)return;const fields=assertUpdateUnsetFieldsSupported(unset,runtimeFieldRegistry,collectRegisteredItemFieldNames(getActiveExtensionRegistrations()),["update_many"]);for(const field of fields){const before=row[field];before!==void 0&&changes.push({field,before,after:null})}},buildPlannedItemDiff=(item,runtimeFieldRegistry,update={})=>{const row=toItemRecord(item),changes=[],tagPlan=buildTagMutationPlan(row,update);if(tagPlan&&changes.push(tagPlan),appendScalarMutationPlans(changes,row,update),updateArrayValueCount(update.addAc)>0||updateArrayValueCount(update.removeAc)>0){const acceptanceCriteriaChange=buildAcceptanceCriteriaMutationPlan(row,update);acceptanceCriteriaChange!==void 0&&changes.push(acceptanceCriteriaChange)}return changes.push(...buildCollectionMutationPlans(row,update)),appendRuntimeFieldMutationPlans(changes,row,update,runtimeFieldRegistry),appendUnsetMutationPlans(changes,row,update.unset,runtimeFieldRegistry),{id:item.id,changes}},normalizeStatusFilter=(value,statusRegistry)=>parseStatusFilterCsv(value,statusRegistry,{strict:!0,flagLabel:"--filter-status"}),rejectBlankIdsFilter=list=>{if(list?.ids!=null&&String(list.ids).trim().length===0)throw new PmCliError("--ids requires at least one non-empty item ID",EXIT_CODE.USAGE)},PLANNED_UPDATE_VALIDATORS=[({update})=>{update.priority!==void 0&&resolvePriority(update.priority)},({update,settings})=>{update.unset!==void 0&&update.unset.length>0&&assertUpdateUnsetFieldsSupported(update.unset,resolveRuntimeFieldRegistry(settings.schema),collectRegisteredItemFieldNames(getActiveExtensionRegistrations()),["update_many"])},({update,settings,pmRoot})=>{if(update.type===void 0)return;const typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations());if(!resolveTypeName(update.type,typeRegistry))throw new PmCliError(buildInvalidTypeError(update.type,typeRegistry.types,resolveItemTypesFilePath(pmRoot,settings.schema)),EXIT_CODE.USAGE)},({update,statusRegistry})=>{if(update.status!==void 0&&!normalizeStatusInput(update.status,statusRegistry)){const allowedStatuses=statusRegistry.definitions.map(definition=>definition.id);throw new PmCliError(`Invalid status value "${update.status}". Allowed: ${allowedStatuses.join(", ")}`,EXIT_CODE.USAGE,{code:"invalid_argument_value",field:"status",value:update.status,allowed:allowedStatuses})}},({update})=>{update.deadline!==void 0&&resolveIsoOrRelative(update.deadline,new Date,"deadline")},({update})=>{update.estimatedMinutes!==void 0&&parseOptionalNonNegativeInteger(update.estimatedMinutes,"estimated-minutes")}],assertPlannedUpdateValuesValid=(update,settings,statusRegistry,pmRoot)=>{const context={update,settings,statusRegistry,pmRoot};for(const validate of PLANNED_UPDATE_VALIDATORS)validate(context)},runUpdateManyRollback=async params=>{const checkpoint=await loadMutationCheckpoint(params.pmRoot,UPDATE_MANY_CHECKPOINT_SUBDIR,params.rollbackId,UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION),restoreMessage=params.options.update?.message??`Rollback update-many checkpoint ${checkpoint.id}`,rollback=await rollbackMutationCheckpoint(params.pmRoot,checkpoint,{author:params.options.update?.author,message:restoreMessage,force:params.options.update?.force}),skipped=rollback.rows.filter(row=>row.status==="skipped").length;return{...derivePmBulkMutationEffect({applied:rollback.restored_ids.length,skipped,failed:rollback.failed_count,unmatched:0}),mode:"rollback",matched_count:checkpoint.items.length,dry_run:!1,rollback_checkpoint_id:checkpoint.id,checkpoint:{id:checkpoint.id,created_at:checkpoint.created_at,path:checkpoint.path,rollback_command:`pm update-many --rollback ${checkpoint.id}`},restored_count:rollback.restored_ids.length,skipped_count:skipped,failed_count:rollback.failed_count,rows:rollback.rows,ids:rollback.restored_ids}},writeUpdateManyCheckpoint=async params=>{const checkpointPayload={schema_version:UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION,rollback_strategy:"guarded_inverse",id:params.checkpointId,created_at:params.nowValue,author:resolveAuthor(params.options.update?.author,"unknown"),status_filter:params.statusFilter??null,list_filters:params.filters,update_options:params.updateSummary,items:params.checkpointItems},checkpointPath=await writeMutationCheckpoint(params.pmRoot,UPDATE_MANY_CHECKPOINT_SUBDIR,params.checkpointId,checkpointPayload);return{id:params.checkpointId,created_at:params.nowValue,path:checkpointPath,rollback_command:`pm update-many --rollback ${params.checkpointId}`}},collectUnmatchedRequestedIds=(rawIds,existingItems)=>{if(rawIds==null)return;const requested=[...new Set(String(rawIds).split(",").map(entry=>entry.trim()).filter(entry=>entry.length>0))],existing=new Set(existingItems.map(item=>item.id));return requested.filter(id=>!existing.has(id))},buildUnmatchedIdFields=plan=>plan.unmatchedIds===void 0?{}:{unmatched_ids:plan.unmatchedIds,unmatched_count:plan.unmatchedIds.length},loadUpdateManyRuntimeContext=async global2=>{const pmRoot=resolvePmRoot(process.cwd(),global2.path);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot);return{pmRoot,settings,statusRegistry:resolveRuntimeStatusRegistry(settings.schema),runtimeFieldRegistry:resolveRuntimeFieldRegistry(settings.schema)}},runRequestedUpdateManyRollback=params=>{if(params.options.dryRun===!0)throw new PmCliError("--dry-run cannot be combined with --rollback",EXIT_CODE.USAGE);if(hasListFilters(params.options.list,params.options.status))throw new PmCliError("Rollback mode does not accept filter options",EXIT_CODE.USAGE);if(Object.keys(params.updateSummary).length>0)throw new PmCliError("Rollback mode does not accept update mutation flags",EXIT_CODE.USAGE);return runUpdateManyRollback({pmRoot:params.runtime.pmRoot,rollbackId:params.rollbackId,options:params.options,global:params.global})},buildUpdateManyPlan=async params=>{normalizeStatusFilter(params.options.status,params.runtime.statusRegistry);const listed=await runList(void 0,{...params.options.list,status:params.options.status,compact:void 0,brief:void 0,fields:void 0,includeBody:!0,full:!0},params.global),planned=listed.items.map(item=>{const diff=buildPlannedItemDiff(item,params.runtime.runtimeFieldRegistry,params.options.update);return params.dependencyWarnings.length===0?diff:{...diff,warnings:[...params.dependencyWarnings]}}),existenceItems=params.options.list?.ids==null?[]:(await runList(void 0,{ids:params.options.list.ids,noTruncate:!0,full:!0},params.global)).items;return{listed,planned,actionable:planned.filter(row=>row.changes.length>0),updateSummary:params.updateSummary,unmatchedIds:collectUnmatchedRequestedIds(params.options.list?.ids,existenceItems)}},buildUpdateManyDryRunResult=plan=>({outcome:"effect",exit_code:EXIT_CODE.SUCCESS,mode:"dry_run",matched_count:plan.listed.items.length,dry_run:!0,filters:plan.listed.filters,planned_update_options:plan.updateSummary,item_plans:plan.planned,ids:[],...buildUnmatchedIdFields(plan)}),buildUpdateManyNoopResult=plan=>({...derivePmBulkMutationEffect({applied:0,skipped:plan.listed.items.length,failed:0,unmatched:plan.unmatchedIds?.length??0}),mode:"apply",matched_count:plan.listed.items.length,dry_run:!1,filters:plan.listed.filters,planned_update_options:plan.updateSummary,updated_count:0,skipped_count:plan.listed.items.length,failed_count:0,rows:plan.planned.map(row=>({id:row.id,status:"skipped"})),ids:[],...buildUnmatchedIdFields(plan)}),applyUpdateManyRows=async params=>{const rows=[],updatedIds=[],updateMessage=params.options.update.message??`update-many apply ${params.checkpointId}`,actionableById=new Set(params.plans.filter(row=>row.changes.length>0).map(row=>row.id));for(const item of params.items){if(!actionableById.has(item.id)){rows.push({id:item.id,status:"skipped"});continue}try{const rowUpdateOptions=preserveMutationStdinTokenLiterals(transferMutationStdinTokenPolicy(params.options.update,{...params.options.update,message:updateMessage,runtimeFieldCommands:["update_many"]})),result=await withCheckpointMutation({pmRoot:params.pmRoot,itemId:item.id,checkpointId:params.checkpointId},()=>runUpdate(item.id,rowUpdateOptions,params.global));rows.push({id:item.id,status:"updated",changed_fields:result.changed_fields,warnings:result.warnings}),updatedIds.push(item.id)}catch(error){const committed=await committedCloseDependentConflict(error,item.id,params.pmRoot);if(committed!==void 0){rows.push({id:item.id,status:"updated",...committed}),updatedIds.push(item.id);continue}rows.push({id:item.id,status:"failed",error:toErrorMessage(error),...await itemRevisionConflictRowFields(error,params.pmRoot)})}}return{rows,updatedIds}},applyUpdateManyPlan=async params=>{if(params.plan.actionable.length===0)return buildUpdateManyNoopResult(params.plan);const nowValue=nowIso(),checkpointId=createCheckpointId(UPDATE_MANY_CHECKPOINT_SUBDIR,nowValue),actionableById=new Set(params.plan.actionable.map(row=>row.id)),checkpointItems=params.plan.listed.items.filter(item=>actionableById.has(item.id)).map(item=>({id:item.id,target_updated_at:item.updated_at})),checkpointInfo=params.options.checkpoint===!1?void 0:await writeUpdateManyCheckpoint({pmRoot:params.runtime.pmRoot,checkpointId,nowValue,options:params.options,statusFilter:params.options.status,filters:params.plan.listed.filters,updateSummary:params.plan.updateSummary,checkpointItems}),applied=await applyUpdateManyRows({pmRoot:params.runtime.pmRoot,items:params.plan.listed.items,plans:params.plan.planned,options:params.options,global:params.global,checkpointId}),countStatus=status=>applied.rows.filter(row=>row.status===status).length,updatedCount=countStatus("updated"),skippedCount=countStatus("skipped"),failedCount=countStatus("failed");return{...derivePmBulkMutationEffect({applied:updatedCount,skipped:skippedCount,failed:failedCount,unmatched:params.plan.unmatchedIds?.length??0}),mode:"apply",matched_count:params.plan.listed.items.length,dry_run:!1,filters:params.plan.listed.filters,planned_update_options:params.plan.updateSummary,...checkpointInfo?{checkpoint:checkpointInfo}:{},updated_count:updatedCount,skipped_count:skippedCount,failed_count:failedCount,rows:applied.rows,ids:applied.updatedIds,...buildUnmatchedIdFields(params.plan)}},runUpdateMany=async(options,global2)=>{const rollbackId=resolveCheckpointRollbackId(options.rollback),runtime=await loadUpdateManyRuntimeContext(global2);rollbackId===void 0&&(options={...options,update:preserveMutationStdinTokenLiterals(await resolveUpdateTransportOptions(options.update))});const updateSummary=sanitizeUpdateOptionsForSummary(options.update);if(rejectBlankIdsFilter(options.list),rollbackId!==void 0)return runRequestedUpdateManyRollback({runtime,rollbackId,options,global:global2,updateSummary});if(!hasAnyUpdateMutationInput(options.update)&&options.dryRun!==!0)throw new PmCliError(`No update-many mutation flags provided. Add at least one mutation flag (for example: ${UPDATE_MANY_MUTATION_FLAG_GUIDANCE}), or pass --dry-run for a filter-only preview.`,EXIT_CODE.USAGE);assertPlannedUpdateValuesValid(options.update,runtime.settings,runtime.statusRegistry,runtime.pmRoot),assertUpdateMutationOptionCombinations(options.update);const dependencyWarnings=await assertDependencyTargetsResolvable({pmRoot:runtime.pmRoot,dependencies:parseDependencyAdditions(options.update.dep,runtime.settings.id_prefix,nowIso(),resolveAuthor(options.update.author,runtime.settings.author_default)).additions,idPrefix:runtime.settings.id_prefix,itemFormat:runtime.settings.item_format,typeToFolder:resolveItemTypeRegistry(runtime.settings,getActiveExtensionRegistrations()).type_to_folder,allowUnresolved:options.update.allowUnresolvedDeps}),plan=await buildUpdateManyPlan({options,global:global2,runtime,updateSummary,dependencyWarnings});return await assertDependencyTargetsResolvable({pmRoot:runtime.pmRoot,dependencies:parseDependencyAdditions(options.update.dep,runtime.settings.id_prefix,nowIso(),resolveAuthor(options.update.author,runtime.settings.author_default)).additions,idPrefix:runtime.settings.id_prefix,itemFormat:runtime.settings.item_format,typeToFolder:resolveItemTypeRegistry(runtime.settings,getActiveExtensionRegistrations()).type_to_folder,allowUnresolved:options.update.allowUnresolvedDeps,holders:plan.listed.items.map(item=>({id:item.id,createdAt:item.created_at})),schema:runtime.settings.schema}),options.dryRun===!0?buildUpdateManyDryRunResult(plan):applyUpdateManyPlan({runtime,options,global:global2,plan})},_testOnlyUpdateManyCommand={assertPlannedUpdateValuesValid,buildCollectionMutationPlans,buildPlannedItemDiff,buildTagMutationPlan,collectionValueCount,hasAnyUpdateMutationInput,hasListFilters,normalizeStatusFilter,normalizeCollectionBeforeValue,normalizeExistingTags,rejectBlankIdsFilter,sanitizeUpdateOptionsForSummary,toComparablePreviewValue};export{_testOnlyUpdateManyCommand,runUpdateMany};
|
|
2
2
|
//# sourceMappingURL=update-many.js.map
|
|
@@ -2,6 +2,7 @@ import { resolveItemTypeRegistry,type RuntimeFieldRegistry,type RuntimeStatusReg
|
|
|
2
2
|
import { enforceTypeWorkflowTransition } from "./workflow-transition.js";
|
|
3
3
|
import type { Dependency,ItemDocument } from "../../types/index.js";
|
|
4
4
|
import { parseDocs,parseFiles,parseLogSeed,parseTests } from "./create.js";
|
|
5
|
+
import { type UpdateNullClearableOptionKey,type WithNullClears } from "./shared-unset-fields.js";
|
|
5
6
|
import type { MutationMetadataCommandOptions,SharedLinkedResourceClearOptions,SharedLinkedResourceOptions } from "./mutation-command-options.js";
|
|
6
7
|
/** Documents the update command options payload exchanged by command, SDK, and package integrations. */
|
|
7
8
|
export interface UpdateCommandOptions extends MutationMetadataCommandOptions,SharedLinkedResourceOptions,SharedLinkedResourceClearOptions {
|
|
@@ -54,7 +55,7 @@ runtimeFieldCommands?:Array<"update" | "update_many">;
|
|
|
54
55
|
[key:string]:unknown;
|
|
55
56
|
}
|
|
56
57
|
/** Presentation-neutral input accepted by the SDK-owned update operation. */
|
|
57
|
-
export type UpdateOperationOptions = UpdateCommandOptions
|
|
58
|
+
export type UpdateOperationOptions = WithNullClears<UpdateCommandOptions,UpdateNullClearableOptionKey>;
|
|
58
59
|
/** Documents the update result payload exchanged by command, SDK, and package integrations. */
|
|
59
60
|
export interface UpdateResult {
|
|
60
61
|
/** Value that configures or reports item for this contract. */
|
|
@@ -181,15 +182,15 @@ settings:Awaited<ReturnType<typeof readSettings>>;
|
|
|
181
182
|
typeRegistry:ReturnType<typeof resolveItemTypeRegistry>;
|
|
182
183
|
}
|
|
183
184
|
/** Resolve update stdin tokens once while preserving transport-marked literals. */
|
|
184
|
-
export declare function resolveUpdateTransportOptions(
|
|
185
|
+
export declare function resolveUpdateTransportOptions(input:UpdateOperationOptions):Promise<UpdateCommandOptions>;
|
|
185
186
|
/** Validate mutually exclusive and required update mutation option combinations. */
|
|
186
187
|
export declare function assertUpdateMutationOptionCombinations(options:UpdateCommandOptions):void;
|
|
187
188
|
type UpdateStatusMutationContext = Pick<UpdateMutationContext,"options" | "statusRegistry" | "clearItemMetadataKeys" | "nowIso">;
|
|
188
189
|
declare function applyStatusAndCloseReasonMutations(document:ItemDocument,context:UpdateStatusMutationContext,previousStatusNormalized:string,changedFields:string[]):void;
|
|
189
190
|
/** Implements run update for the public runtime surface of this module. */
|
|
190
|
-
export declare function runUpdate(id:string,options:
|
|
191
|
+
export declare function runUpdate(id:string,options:UpdateOperationOptions,global:GlobalOptions):Promise<UpdateResult>;
|
|
191
192
|
/** Execute a recurrence transition through the exact atomic update pipeline. */
|
|
192
|
-
export declare function runReopenUpdate(id:string,options:
|
|
193
|
+
export declare function runReopenUpdate(id:string,options:UpdateOperationOptions,global:GlobalOptions,recurrenceReason:string):Promise<ReopenUpdateResult>;
|
|
193
194
|
/** Public contract for test only update command, shared by SDK and presentation-layer consumers. */
|
|
194
195
|
export declare const _testOnlyUpdateCommand:{
|
|
195
196
|
applyStatusAndCloseReasonMutations:typeof applyStatusAndCloseReasonMutations;
|