@unbrained/pm-cli 2026.8.7 → 2026.8.8
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-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +35 -0
- package/dist/cli/main.js +4 -3
- package/dist/cli/register-annotations.d.ts +11 -0
- package/dist/cli/register-annotations.js +195 -0
- package/dist/cli/register-history-author.js +7 -30
- package/dist/cli/register-mutation.js +25 -206
- package/dist/cli/runtime-compatibility-boundary.d.ts +17 -0
- package/dist/cli/runtime-compatibility-boundary.js +43 -0
- package/dist/cli-bundle/bundle-manifest.json +155 -691
- package/dist/cli-bundle/chunks/chunk-2ZMXX3Q6.js +2068 -0
- package/dist/cli-bundle/chunks/chunk-ALDHXLPS.js +3 -0
- package/dist/cli-bundle/chunks/chunk-CBLA33YK.js +8 -0
- package/dist/cli-bundle/chunks/chunk-GKA54IJM.js +5 -0
- package/dist/cli-bundle/chunks/chunk-KRY7SRUO.js +2 -0
- package/dist/cli-bundle/chunks/chunk-MNJ4NNSY.js +26 -0
- package/dist/cli-bundle/chunks/chunk-NUXRRNAB.js +77 -0
- package/dist/cli-bundle/chunks/chunk-OJPCFDDY.js +13 -0
- package/dist/cli-bundle/chunks/chunk-PFSD3DAN.js +194 -0
- package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SQ7QZFQ6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-FJZCJ67O.js → register-list-query-WFZAMJHZ.js} +8 -8
- package/dist/cli-bundle/chunks/register-mutation-SOKKOTHQ.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-5XQETS6E.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-2HL5ZHMK.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-54EU2UVO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VZFU2R4M.js → chunk-5FLBTZJQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5GJ57YKN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-HNL6IFGS.js → chunk-ANTMGYLI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-CMDS3KYT.js +14 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NBJKQP4S.js → chunk-DMKOMTTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CIXVQPB7.js → chunk-F5B3HBEZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-R2LEMEV5.js → chunk-FI6DWU2M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3K4XV2BF.js → chunk-FNOKJG6N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RW5IYD4J.js → chunk-FPDYXZBK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QHRTT7WT.js → chunk-GWI6YIKJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MHMTKV5V.js → chunk-HCUC62AB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MOTJFQ3F.js → chunk-HGNKPSCB.js} +12 -12
- package/dist/cli-bundle/focused-chunks/{chunk-4VJQTS3P.js → chunk-IAS7PMLG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TIKDBG4D.js → chunk-PL2EYDJK.js} +27 -27
- package/dist/cli-bundle/focused-chunks/chunk-SM2PJGP3.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RPNYG5MO.js → chunk-TCSAPH33.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-U646T7Z6.js +18 -0
- package/dist/cli-bundle/focused-chunks/chunk-YKPE4PPY.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YZEZAPJK.js → chunk-YSAHYUXX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-73JUDYXT.js → chunk-ZOLDTUU7.js} +2 -2
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +38 -38
- 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 +1 -1
- 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 +2 -1
- package/dist/cli.js +14 -4
- package/dist/core/output/output.js +9 -2
- package/dist/core/sentry/helpers.d.ts +10 -0
- package/dist/core/sentry/helpers.js +59 -4
- package/dist/core/shared/constants.d.ts +2 -0
- package/dist/core/shared/constants.js +4 -2
- package/dist/sdk/annotations.d.ts +40 -0
- package/dist/sdk/annotations.js +61 -9
- package/dist/sdk/author-attribution.d.ts +12 -0
- package/dist/sdk/author-attribution.js +73 -11
- package/dist/sdk/cli-contracts/command-exit-contracts.d.ts +118 -0
- package/dist/sdk/cli-contracts/command-exit-contracts.js +152 -0
- package/dist/sdk/cli-contracts/completeness.js +5 -3
- package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +11 -0
- package/dist/sdk/cli-contracts/runtime-contracts.js +29 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +15 -2
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +6 -3
- package/dist/sdk/comments.d.ts +7 -0
- package/dist/sdk/comments.js +2 -2
- package/dist/sdk/completion.js +9 -5
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +3 -2
- package/dist/sdk/environment/host-environment-errors.d.ts +27 -0
- package/dist/sdk/environment/host-environment-errors.js +124 -0
- package/dist/sdk/environment/project-runtime-compatibility.d.ts +65 -0
- package/dist/sdk/environment/project-runtime-compatibility.js +385 -0
- package/dist/sdk/environment/source-context.d.ts +23 -0
- package/dist/sdk/environment/source-context.js +29 -0
- package/dist/sdk/error-code-catalog.d.ts +6 -0
- package/dist/sdk/error-code-catalog.js +62 -8
- package/dist/sdk/generated-error-code-catalog.js +629 -3
- package/dist/sdk/governance/health.d.ts +11 -3
- package/dist/sdk/governance/health.js +5 -5
- package/dist/sdk/index.d.ts +7 -3
- package/dist/sdk/index.js +9 -5
- package/dist/sdk/learnings.d.ts +15 -0
- package/dist/sdk/learnings.js +2 -2
- package/dist/sdk/lifecycle/close-many.d.ts +6 -1
- package/dist/sdk/lifecycle/close-many.js +43 -5
- package/dist/sdk/lifecycle/update-many.d.ts +2 -1
- package/dist/sdk/lifecycle/update-many.js +29 -5
- package/dist/sdk/merge/index.d.ts +1 -1
- package/dist/sdk/merge/index.js +3 -3
- package/dist/sdk/merge/install.d.ts +21 -0
- package/dist/sdk/merge/install.js +50 -20
- package/dist/sdk/notes.d.ts +7 -0
- package/dist/sdk/notes.js +2 -2
- package/dist/sdk/read-output-contracts.js +83 -4
- package/dist/sdk/runtime.d.ts +1 -1
- package/dist/sdk/runtime.js +9 -25
- package/dist/sdk/test/execution.js +4 -2
- package/dist/sdk/test/parsers.js +5 -2
- package/dist/sdk/workspace-snapshot.d.ts +9 -0
- package/dist/sdk/workspace-snapshot.js +48 -16
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +11 -4
- package/docs/README.md +1 -0
- package/docs/RELEASING.md +27 -2
- package/docs/SCRIPTING.md +27 -1
- package/docs/SDK_CONTEXT_INTEGRITY.md +66 -0
- package/docs/SDK_RUNTIME_BOUNDARIES.md +58 -0
- package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
- package/docs/TESTING.md +17 -0
- package/marketplace.json +2 -2
- package/package.json +5 -3
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- 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/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/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +529 -34
- package/dist/cli-bundle/chunks/append-7BXBFDGD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-2AXF3VSK.js +0 -2
- package/dist/cli-bundle/chunks/chunk-2XS43CCV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +0 -8
- package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +0 -8
- package/dist/cli-bundle/chunks/chunk-4MTI7XOV.js +0 -5
- package/dist/cli-bundle/chunks/chunk-6BX5UDCN.js +0 -3
- package/dist/cli-bundle/chunks/chunk-6QPO7KLR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-7MXHZHSQ.js +0 -5
- package/dist/cli-bundle/chunks/chunk-7ZPMJW4U.js +0 -2
- package/dist/cli-bundle/chunks/chunk-A6KGKEWT.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AGYNSNCI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +0 -5
- package/dist/cli-bundle/chunks/chunk-B4KLBBMN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-BXCSXK4J.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CALJHNBL.js +0 -23
- package/dist/cli-bundle/chunks/chunk-CFIGP5LY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CHOQ2VAW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CS6MRHG7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CUGNQQKH.js +0 -2
- package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +0 -164
- package/dist/cli-bundle/chunks/chunk-E2ZSLTOP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-FB7G2HY2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-H5Y5YE6A.js +0 -2
- package/dist/cli-bundle/chunks/chunk-H5Y6UV6E.js +0 -2
- package/dist/cli-bundle/chunks/chunk-H7KGWPDF.js +0 -2
- package/dist/cli-bundle/chunks/chunk-HFSD77TQ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-HX2GTA6L.js +0 -2
- package/dist/cli-bundle/chunks/chunk-J2IEKAVR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-JC6FKIFM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-K44PYFXH.js +0 -2
- package/dist/cli-bundle/chunks/chunk-K4KGEEBT.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +0 -21
- package/dist/cli-bundle/chunks/chunk-KL6IEBV2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KWQZDZSS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KZ4X3DGU.js +0 -3
- package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +0 -13
- package/dist/cli-bundle/chunks/chunk-LEPJJ6QC.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ME2JJ4LA.js +0 -3
- package/dist/cli-bundle/chunks/chunk-NE5VRDAI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NG6OXIBR.js +0 -19
- package/dist/cli-bundle/chunks/chunk-NYIGHWQY.js +0 -8
- package/dist/cli-bundle/chunks/chunk-NZ75GNSA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PCJWJNC2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PD3225AM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PDEGKG7P.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +0 -56
- package/dist/cli-bundle/chunks/chunk-RSIC5OPE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-TPKN3S7S.js +0 -2
- package/dist/cli-bundle/chunks/chunk-TPXAXTCO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +0 -2
- package/dist/cli-bundle/chunks/chunk-UQLZQVFW.js +0 -55
- package/dist/cli-bundle/chunks/chunk-VT3Z5G7D.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WSJEIGJF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-WYNUU7ZW.js +0 -2008
- package/dist/cli-bundle/chunks/chunk-YGPNCCXZ.js +0 -2
- package/dist/cli-bundle/chunks/close-CMY3BAUG.js +0 -2
- package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +0 -2
- package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +0 -2
- package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +0 -2
- package/dist/cli-bundle/chunks/create-I5DVV4YG.js +0 -2
- package/dist/cli-bundle/chunks/delete-RL3JACSW.js +0 -2
- package/dist/cli-bundle/chunks/deps-S7UBCECS.js +0 -2
- package/dist/cli-bundle/chunks/docs-ZZNVBBYO.js +0 -2
- package/dist/cli-bundle/chunks/files-27C337VT.js +0 -2
- package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +0 -2
- package/dist/cli-bundle/chunks/history-compact-HJQK67CZ.js +0 -2
- package/dist/cli-bundle/chunks/history-redact-PWC6PDWA.js +0 -2
- package/dist/cli-bundle/chunks/history-repair-N3CY4WBF.js +0 -2
- package/dist/cli-bundle/chunks/learnings-4FH23XDT.js +0 -2
- package/dist/cli-bundle/chunks/profile-5Y5XXH5N.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-YGYPW3BL.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +0 -2
- package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +0 -2
- package/dist/cli-bundle/chunks/schema-EQGKBYXJ.js +0 -2
- package/dist/cli-bundle/chunks/update-QVTYOD6I.js +0 -2
- package/dist/cli-bundle/chunks/update-many-DJSBU525.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2ECLECMK.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-4EX25PXM.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-DQ6FKGL3.js +0 -14
- package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +0 -2
package/dist/cli.js
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* Bootstraps the executable pm CLI entrypoint and startup optimizations.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="81ec2fa2-c616-5978-999d-b76d5f45bafe")}catch(e){}}();
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import * as nodeModule from "node:module";
|
|
11
11
|
import os from "node:os";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
import { runCliWithBundleIntegrity
|
|
14
|
+
import { runCliWithBundleIntegrity } from "./cli/bundle-integrity.js";
|
|
15
|
+
import { runRuntimeCompatibleCli } from "./cli/runtime-compatibility-boundary.js";
|
|
15
16
|
import { pruneCompileCacheGenerations, resolveCompileCacheGeneration, } from "./sdk/compile-cache.js";
|
|
16
17
|
function enableNodeCompileCache() {
|
|
17
18
|
const { enableCompileCache } = nodeModule;
|
|
@@ -90,7 +91,16 @@ export const _testOnly = {
|
|
|
90
91
|
if (!printFastVersionIfRequested()) {
|
|
91
92
|
enableNodeCompileCache();
|
|
92
93
|
const cliEntrypointPath = fileURLToPath(import.meta.url);
|
|
93
|
-
|
|
94
|
+
const executingVersion = readPackageVersionForPath(cliEntrypointPath);
|
|
95
|
+
const invocationArgv = process.argv.slice(2);
|
|
96
|
+
await runRuntimeCompatibleCli({
|
|
97
|
+
executingVersion,
|
|
98
|
+
projectRoot: process.cwd(),
|
|
99
|
+
argv: invocationArgv,
|
|
100
|
+
allowStale: process.env.PM_ALLOW_STALE_CLI === "1",
|
|
101
|
+
run: () => runCliWithBundleIntegrity(invocationArgv, cliEntrypointPath, () => import("./cli-bundle/main.js"), process.stderr.write.bind(process.stderr)),
|
|
102
|
+
writeError: process.stderr.write.bind(process.stderr),
|
|
103
|
+
});
|
|
94
104
|
}
|
|
95
105
|
//# sourceMappingURL=cli.js.map
|
|
96
|
-
//# debugId=
|
|
106
|
+
//# debugId=81ec2fa2-c616-5978-999d-b76d5f45bafe
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Formats compact human and machine output for Output.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b52d2756-f640-5f53-981f-05fa23fa1718")}catch(e){}}();
|
|
8
8
|
import { getActiveCommandContext, runActiveCommandOverride, runActiveRendererOverride, runActiveServiceOverrideSync, setActiveCommandResult, } from "../extensions/index.js";
|
|
9
9
|
import { EXIT_CODE } from "../shared/constants.js";
|
|
10
10
|
import { isHostOutputSuppressed } from "./output-control.js";
|
|
@@ -12,6 +12,7 @@ import { projectMutationResult } from "./mutation-projection.js";
|
|
|
12
12
|
import { attachReadOutputContracts } from "../../sdk/context-intent-contracts.js";
|
|
13
13
|
import { attachOutputTokenAccounting } from "../../sdk/output-token-accounting.js";
|
|
14
14
|
import { resolveReadOutputEncoding } from "../../sdk/read-output-contracts.js";
|
|
15
|
+
const DECLARED_PROCESS_EXIT_CODES = new Set(Object.values(EXIT_CODE));
|
|
15
16
|
const NATIVE_OUTPUT_MARKER = "__pm_native_output";
|
|
16
17
|
let streamErrorHandlersInstalled = false;
|
|
17
18
|
function isPlainObject(value) {
|
|
@@ -388,6 +389,12 @@ export function formatOutput(result, options) {
|
|
|
388
389
|
}
|
|
389
390
|
/** Implements print result for the public runtime surface of this module. */
|
|
390
391
|
export function printResult(result, options) {
|
|
392
|
+
if (isPlainObject(result) &&
|
|
393
|
+
Number.isInteger(result.exit_code) &&
|
|
394
|
+
DECLARED_PROCESS_EXIT_CODES.has(Number(result.exit_code)) &&
|
|
395
|
+
(process.exitCode === undefined || process.exitCode === EXIT_CODE.SUCCESS)) {
|
|
396
|
+
process.exitCode = Number(result.exit_code);
|
|
397
|
+
}
|
|
391
398
|
const projected = options.idOnly
|
|
392
399
|
? projectMutationResult(result, { idOnly: true })
|
|
393
400
|
: options.fullChangedFields
|
|
@@ -417,4 +424,4 @@ export const outputTestOnly = {
|
|
|
417
424
|
renderToonValue,
|
|
418
425
|
};
|
|
419
426
|
//# sourceMappingURL=output.js.map
|
|
420
|
-
//# debugId=
|
|
427
|
+
//# debugId=b52d2756-f640-5f53-981f-05fa23fa1718
|
|
@@ -15,6 +15,16 @@ export declare function sentryFinishCommandSpan(ok: boolean, error?: string, met
|
|
|
15
15
|
command_resolution?: TelemetryCommandResolution;
|
|
16
16
|
resolution_stage?: TelemetryResolutionStage;
|
|
17
17
|
}): void;
|
|
18
|
+
/**
|
|
19
|
+
* Tag value recorded when a captured error declares no canonical pm error code.
|
|
20
|
+
*
|
|
21
|
+
* The release reliability gate classifies Sentry issues from the `pm.error_code`
|
|
22
|
+
* and `pm.exit_code` tags and fails closed when either is absent. Emitting this
|
|
23
|
+
* sentinel keeps the producer side of that contract total: an undeclared runtime
|
|
24
|
+
* fault is still classifiable (and still blocks, because it resolves to no
|
|
25
|
+
* catalog contract) instead of being unjudgeable for lack of a tag.
|
|
26
|
+
*/
|
|
27
|
+
export declare const UNCLASSIFIED_CAPTURED_ERROR_CODE = "unclassified_runtime_error";
|
|
18
28
|
/** Implements sentry capture cli error for the public runtime surface of this module. */
|
|
19
29
|
export declare function sentryCaptureCliError(error: unknown): void;
|
|
20
30
|
/** Implements sentry log cli usage error for the public runtime surface of this module. */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Integrates Sentry instrumentation and release diagnostics for Helpers.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ffe56aed-b794-5bf4-99fd-e3c5fe065163")}catch(e){}}();
|
|
8
8
|
import { getSentry } from "./instrument.js";
|
|
9
9
|
import { PmCliError } from "../shared/errors.js";
|
|
10
10
|
import { EXIT_CODE } from "../shared/constants.js";
|
|
@@ -110,6 +110,60 @@ export function sentryFinishCommandSpan(ok, error, metadata) {
|
|
|
110
110
|
activeCommandSpan.end();
|
|
111
111
|
activeCommandSpan = undefined;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Tag value recorded when a captured error declares no canonical pm error code.
|
|
115
|
+
*
|
|
116
|
+
* The release reliability gate classifies Sentry issues from the `pm.error_code`
|
|
117
|
+
* and `pm.exit_code` tags and fails closed when either is absent. Emitting this
|
|
118
|
+
* sentinel keeps the producer side of that contract total: an undeclared runtime
|
|
119
|
+
* fault is still classifiable (and still blocks, because it resolves to no
|
|
120
|
+
* catalog contract) instead of being unjudgeable for lack of a tag.
|
|
121
|
+
*/
|
|
122
|
+
export const UNCLASSIFIED_CAPTURED_ERROR_CODE = "unclassified_runtime_error";
|
|
123
|
+
/**
|
|
124
|
+
* Reads the declared error contract carried by a thrown value, if any.
|
|
125
|
+
*
|
|
126
|
+
* There is deliberately no `PmCliError` special case: `shouldCaptureCliError`
|
|
127
|
+
* rejects every `PmCliError` before capture, so such a branch would be
|
|
128
|
+
* unreachable — and a `PmCliError` carries a public `code` and a numeric
|
|
129
|
+
* `exitCode`, so the general path below would classify it identically anyway.
|
|
130
|
+
*/
|
|
131
|
+
function readCapturedErrorContract(error) {
|
|
132
|
+
const candidate = typeof error === "object" && error !== null
|
|
133
|
+
? error
|
|
134
|
+
: undefined;
|
|
135
|
+
const hasDeclaredExitCode = typeof candidate?.exitCode === "number";
|
|
136
|
+
const exitCode = hasDeclaredExitCode
|
|
137
|
+
? Math.trunc(candidate?.exitCode)
|
|
138
|
+
: EXIT_CODE.GENERIC_FAILURE;
|
|
139
|
+
// A declared pm code always travels with a numeric exit code. Requiring both
|
|
140
|
+
// halves keeps a Node errno error (string `code`, no `exitCode`) from being
|
|
141
|
+
// reported as though it were a catalog contract.
|
|
142
|
+
const hasDeclaredErrorCode = typeof candidate?.code === "string" &&
|
|
143
|
+
candidate.code.length > 0 &&
|
|
144
|
+
hasDeclaredExitCode;
|
|
145
|
+
return {
|
|
146
|
+
error_code: hasDeclaredErrorCode
|
|
147
|
+
? candidate?.code
|
|
148
|
+
: UNCLASSIFIED_CAPTURED_ERROR_CODE,
|
|
149
|
+
exit_code: exitCode,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Builds the contract tags every captured event carries.
|
|
154
|
+
*
|
|
155
|
+
* These are attached to the event itself rather than to the ambient scope
|
|
156
|
+
* because the scope writer (`sentryFinishCommandSpan`) returns early when no
|
|
157
|
+
* command span is active, and the unknown-error path captures before that
|
|
158
|
+
* writer runs.
|
|
159
|
+
*/
|
|
160
|
+
function buildCapturedErrorTags(error) {
|
|
161
|
+
const contract = readCapturedErrorContract(error);
|
|
162
|
+
return {
|
|
163
|
+
"pm.error_code": contract.error_code,
|
|
164
|
+
"pm.exit_code": String(contract.exit_code),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
113
167
|
/** Implements sentry capture cli error for the public runtime surface of this module. */
|
|
114
168
|
export function sentryCaptureCliError(error) {
|
|
115
169
|
if (!shouldCaptureCliError(error))
|
|
@@ -117,6 +171,7 @@ export function sentryCaptureCliError(error) {
|
|
|
117
171
|
const Sentry = getSentry();
|
|
118
172
|
if (!Sentry)
|
|
119
173
|
return;
|
|
174
|
+
const tags = buildCapturedErrorTags(error);
|
|
120
175
|
if (error instanceof Error) {
|
|
121
176
|
const extras = {};
|
|
122
177
|
if ("exitCode" in error &&
|
|
@@ -127,10 +182,10 @@ export function sentryCaptureCliError(error) {
|
|
|
127
182
|
typeof error.context === "object") {
|
|
128
183
|
extras.error_context = error.context;
|
|
129
184
|
}
|
|
130
|
-
Sentry.captureException(error, { extra: extras });
|
|
185
|
+
Sentry.captureException(error, { extra: extras, tags });
|
|
131
186
|
}
|
|
132
187
|
else {
|
|
133
|
-
Sentry.captureException(new Error(String(error)));
|
|
188
|
+
Sentry.captureException(new Error(String(error)), { tags });
|
|
134
189
|
}
|
|
135
190
|
}
|
|
136
191
|
/** Implements sentry log cli usage error for the public runtime surface of this module. */
|
|
@@ -215,4 +270,4 @@ export async function sentryFlush(timeoutMs = 3000) {
|
|
|
215
270
|
}
|
|
216
271
|
}
|
|
217
272
|
//# sourceMappingURL=helpers.js.map
|
|
218
|
-
//# debugId=
|
|
273
|
+
//# debugId=ffe56aed-b794-5bf4-99fd-e3c5fe065163
|
|
@@ -58,6 +58,8 @@ export declare const EXIT_CODE: {
|
|
|
58
58
|
readonly NOT_FOUND: 3;
|
|
59
59
|
readonly CONFLICT: 4;
|
|
60
60
|
readonly DEPENDENCY_FAILED: 5;
|
|
61
|
+
readonly NO_EFFECT: 6;
|
|
62
|
+
readonly PARTIAL_EFFECT: 7;
|
|
61
63
|
};
|
|
62
64
|
/** Restricts telemetry error category values accepted by command, SDK, and storage contracts. */
|
|
63
65
|
export type TelemetryErrorCategory = "usage" | "validation" | "conflict" | "runtime" | "unknown";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="36b908f0-ea19-5adc-8ccd-320ad3c3b1fe")}catch(e){}}();
|
|
3
3
|
import { createDefaultExtensionGovernancePolicy } from "../extensions/extension-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Canonical default lifecycle status model and workflow role mapping.
|
|
@@ -421,6 +421,8 @@ export const EXIT_CODE = {
|
|
|
421
421
|
NOT_FOUND: 3,
|
|
422
422
|
CONFLICT: 4,
|
|
423
423
|
DEPENDENCY_FAILED: 5,
|
|
424
|
+
NO_EFFECT: 6,
|
|
425
|
+
PARTIAL_EFFECT: 7,
|
|
424
426
|
};
|
|
425
427
|
/** Public contract for telemetry error category by code, shared by SDK and presentation-layer consumers. */
|
|
426
428
|
export const TELEMETRY_ERROR_CATEGORY_BY_CODE = Object.freeze({
|
|
@@ -475,4 +477,4 @@ export function resolveTelemetryErrorCategory(errorCode) {
|
|
|
475
477
|
return "unknown";
|
|
476
478
|
}
|
|
477
479
|
//# sourceMappingURL=constants.js.map
|
|
478
|
-
//# debugId=
|
|
480
|
+
//# debugId=36b908f0-ea19-5adc-8ccd-320ad3c3b1fe
|
|
@@ -23,7 +23,45 @@ export interface AnnotationCommandOptions {
|
|
|
23
23
|
force?: boolean;
|
|
24
24
|
/** Whether list results include paging metadata. */
|
|
25
25
|
includeMeta?: boolean;
|
|
26
|
+
/** Return the complete collection after a mutation instead of the bounded mutation receipt. */
|
|
27
|
+
fullHistory?: boolean;
|
|
26
28
|
}
|
|
29
|
+
/** Identifies the single annotation mutation represented by a bounded response. */
|
|
30
|
+
export interface AnnotationMutationReceipt {
|
|
31
|
+
/** Mutation applied to the annotation collection. */
|
|
32
|
+
action: "add" | "edit" | "delete";
|
|
33
|
+
/** Stable one-based collection position targeted by the mutation. */
|
|
34
|
+
entry_index: number;
|
|
35
|
+
/** Number of stored entries changed by the mutation. */
|
|
36
|
+
changed_count: 1;
|
|
37
|
+
/** Whether the response includes the complete post-mutation collection. */
|
|
38
|
+
full_history_included: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Transport-neutral selectors that restore a complete annotation collection. */
|
|
41
|
+
export interface AnnotationHistoryRestoration {
|
|
42
|
+
/** Stable semantic selector shared by every transport. */
|
|
43
|
+
selector: "full_history";
|
|
44
|
+
/** Equivalent CLI flag. */
|
|
45
|
+
cli_flag: "--full-history";
|
|
46
|
+
/** Equivalent direct SDK option. */
|
|
47
|
+
sdk_option: "fullHistory";
|
|
48
|
+
/** Equivalent MCP tool option. */
|
|
49
|
+
mcp_option: "full";
|
|
50
|
+
}
|
|
51
|
+
/** Describes annotation history withheld from a bounded mutation response. */
|
|
52
|
+
export interface AnnotationOmissionReceipt {
|
|
53
|
+
/** Whether any historical collection entries were withheld. */
|
|
54
|
+
has_omissions: boolean;
|
|
55
|
+
/** Number of independently restorable field groups withheld. */
|
|
56
|
+
omitted_field_group_count: number;
|
|
57
|
+
/** Omitted groups and the transport-neutral selectors that restore them. */
|
|
58
|
+
omitted_field_groups: Array<{
|
|
59
|
+
name: string;
|
|
60
|
+
restore_with: AnnotationHistoryRestoration;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
/** Map transport-level `full` onto the SDK annotation history option. */
|
|
64
|
+
export declare function normalizeAnnotationTransportOptions(options: Record<string, unknown>): Record<string, unknown>;
|
|
27
65
|
/** Presentation-layer inputs accepted by the shared annotation source resolver. */
|
|
28
66
|
export interface AnnotationSourceOptions {
|
|
29
67
|
/** Inline annotation text or the stdin token (`-`). */
|
|
@@ -93,6 +131,8 @@ export type AnnotationCommandResult<TKey extends string, TEntry extends Annotati
|
|
|
93
131
|
returned_count?: number;
|
|
94
132
|
has_more?: boolean;
|
|
95
133
|
limit?: number;
|
|
134
|
+
mutation_receipt?: AnnotationMutationReceipt;
|
|
135
|
+
omission_receipt?: AnnotationOmissionReceipt;
|
|
96
136
|
};
|
|
97
137
|
/** Implements limit annotation entries for the public runtime surface of this module. */
|
|
98
138
|
export declare function limitAnnotationEntries<TEntry>(values: TEntry[], limit: number | undefined): TEntry[];
|
package/dist/sdk/annotations.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm annotation command command surface and its agent-facing runtime behavior.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="13cf8bd9-0aee-5838-a6eb-de9f87ddfac7")}catch(e){}}();
|
|
8
8
|
import { readFile } from "node:fs/promises";
|
|
9
9
|
import { pathExists } from "../core/fs/fs-utils.js";
|
|
10
10
|
import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
|
|
@@ -18,6 +18,15 @@ import { resolveAuthor } from "../core/shared/author.js";
|
|
|
18
18
|
import { locateItem, mutateItem, readLocatedItem, } from "../core/store/item-store.js";
|
|
19
19
|
import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
|
|
20
20
|
import { readSettings } from "../core/store/settings.js";
|
|
21
|
+
/** Map transport-level `full` onto the SDK annotation history option. */
|
|
22
|
+
export function normalizeAnnotationTransportOptions(options) {
|
|
23
|
+
const normalized = {
|
|
24
|
+
...options,
|
|
25
|
+
...(options.full === true ? { fullHistory: true } : {}),
|
|
26
|
+
};
|
|
27
|
+
delete normalized.full;
|
|
28
|
+
return normalized;
|
|
29
|
+
}
|
|
21
30
|
/** Reject mutation of canonical structured events while allowing ordinary annotations. */
|
|
22
31
|
function assertAnnotationEntryMutable(entry, operation) {
|
|
23
32
|
if (typeof entry === "object" &&
|
|
@@ -249,7 +258,10 @@ export async function runAnnotationCommand(id, options, global, config) {
|
|
|
249
258
|
wrapOwnershipConflict(error, config.conflictGuidance);
|
|
250
259
|
}
|
|
251
260
|
const allEntries = readAnnotationEntries(result.item, config.collectionKey);
|
|
252
|
-
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true
|
|
261
|
+
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true, {
|
|
262
|
+
action: "delete",
|
|
263
|
+
entryIndex: config.input.index,
|
|
264
|
+
}, options.fullHistory === true);
|
|
253
265
|
}
|
|
254
266
|
const rawText = config.input.rawValue ?? config.input.value ?? "";
|
|
255
267
|
assertAnnotationAddValueIsNotFlagLike(rawText, config);
|
|
@@ -289,7 +301,11 @@ export async function runAnnotationCommand(id, options, global, config) {
|
|
|
289
301
|
wrapOwnershipConflict(error, config.conflictGuidance);
|
|
290
302
|
}
|
|
291
303
|
const allEntries = readAnnotationEntries(result.item, config.collectionKey);
|
|
292
|
-
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true
|
|
304
|
+
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true, {
|
|
305
|
+
action: "edit",
|
|
306
|
+
entryIndex: config.input.index,
|
|
307
|
+
entry: allEntries[config.input.index - 1],
|
|
308
|
+
}, options.fullHistory === true);
|
|
293
309
|
}
|
|
294
310
|
let result;
|
|
295
311
|
try {
|
|
@@ -315,7 +331,11 @@ export async function runAnnotationCommand(id, options, global, config) {
|
|
|
315
331
|
wrapOwnershipConflict(error, config.conflictGuidance);
|
|
316
332
|
}
|
|
317
333
|
const allEntries = readAnnotationEntries(result.item, config.collectionKey);
|
|
318
|
-
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true
|
|
334
|
+
return renderAnnotationResult(result.item.id, config.collectionKey, allEntries, limit, options.includeMeta === true, {
|
|
335
|
+
action: "add",
|
|
336
|
+
entryIndex: allEntries.length,
|
|
337
|
+
entry: allEntries.at(-1),
|
|
338
|
+
}, options.fullHistory === true);
|
|
319
339
|
}
|
|
320
340
|
/** Implements resolve annotation index for the public runtime surface of this module. */
|
|
321
341
|
export function resolveAnnotationIndex(oneBasedIndex, count, collectionKey) {
|
|
@@ -330,21 +350,53 @@ export function resolveAnnotationIndex(oneBasedIndex, count, collectionKey) {
|
|
|
330
350
|
}
|
|
331
351
|
return oneBasedIndex - 1;
|
|
332
352
|
}
|
|
333
|
-
function renderAnnotationResult(id, collectionKey, allEntries, limit, includeMeta) {
|
|
334
|
-
const entries =
|
|
353
|
+
function renderAnnotationResult(id, collectionKey, allEntries, limit, includeMeta, mutation, fullHistory = false) {
|
|
354
|
+
const entries = mutation === undefined || fullHistory
|
|
355
|
+
? limitAnnotationEntries(allEntries, mutation !== undefined && fullHistory ? undefined : limit)
|
|
356
|
+
: mutation.entry === undefined
|
|
357
|
+
? []
|
|
358
|
+
: [mutation.entry];
|
|
359
|
+
const historyOmitted = mutation !== undefined && entries.length < allEntries.length;
|
|
335
360
|
return {
|
|
336
361
|
id,
|
|
337
362
|
[collectionKey]: entries,
|
|
338
363
|
count: entries.length,
|
|
339
|
-
...(includeMeta
|
|
364
|
+
...([includeMeta, mutation !== undefined].includes(true)
|
|
340
365
|
? {
|
|
341
366
|
total_count: allEntries.length,
|
|
342
367
|
returned_count: entries.length,
|
|
343
|
-
has_more: entries.length < allEntries.length,
|
|
368
|
+
has_more: historyOmitted || entries.length < allEntries.length,
|
|
344
369
|
...(limit !== undefined ? { limit } : {}),
|
|
345
370
|
}
|
|
346
371
|
: {}),
|
|
372
|
+
...(mutation === undefined
|
|
373
|
+
? {}
|
|
374
|
+
: {
|
|
375
|
+
mutation_receipt: {
|
|
376
|
+
action: mutation.action,
|
|
377
|
+
entry_index: mutation.entryIndex,
|
|
378
|
+
changed_count: 1,
|
|
379
|
+
full_history_included: !historyOmitted,
|
|
380
|
+
},
|
|
381
|
+
omission_receipt: {
|
|
382
|
+
has_omissions: historyOmitted,
|
|
383
|
+
omitted_field_group_count: historyOmitted ? 1 : 0,
|
|
384
|
+
omitted_field_groups: historyOmitted
|
|
385
|
+
? [
|
|
386
|
+
{
|
|
387
|
+
name: `${collectionKey}_history`,
|
|
388
|
+
restore_with: {
|
|
389
|
+
selector: "full_history",
|
|
390
|
+
cli_flag: "--full-history",
|
|
391
|
+
sdk_option: "fullHistory",
|
|
392
|
+
mcp_option: "full",
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
]
|
|
396
|
+
: [],
|
|
397
|
+
},
|
|
398
|
+
}),
|
|
347
399
|
};
|
|
348
400
|
}
|
|
349
401
|
//# sourceMappingURL=annotations.js.map
|
|
350
|
-
//# debugId=
|
|
402
|
+
//# debugId=13cf8bd9-0aee-5838-a6eb-de9f87ddfac7
|
|
@@ -52,6 +52,18 @@ export interface AcknowledgeUnknownAuthorEventsOptions {
|
|
|
52
52
|
/** Evidence-backed rationale for the attribution. */
|
|
53
53
|
reason: string;
|
|
54
54
|
}
|
|
55
|
+
/** Resolve the mutually exclusive CLI and SDK acknowledgment selectors. */
|
|
56
|
+
export declare function resolveUnknownAuthorAcknowledgmentSelector(rawEvents: readonly string[], allActionable: boolean): {
|
|
57
|
+
events: UnknownAuthorHistoryEvent[];
|
|
58
|
+
all_actionable: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** Parse user-facing item or workspace history coordinates into SDK events. */
|
|
61
|
+
export declare function parseUnknownAuthorHistoryEventCoordinates(values: readonly string[]): UnknownAuthorHistoryEvent[];
|
|
62
|
+
/** Normalize an untyped transport payload and execute author acknowledgment. */
|
|
63
|
+
export declare function acknowledgeUnknownAuthorHistoryEventsFromTransport(pmRoot: string, input: Record<string, unknown>): Promise<{
|
|
64
|
+
acknowledged: number;
|
|
65
|
+
history_path: string;
|
|
66
|
+
}>;
|
|
55
67
|
/**
|
|
56
68
|
* Append an audited disposition for immutable unknown-author events without
|
|
57
69
|
* rewriting their original streams.
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Provides reusable diagnostics for mutation-author provenance in tracker history.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4fd16197-979e-5269-bed7-f2fb0e2038c2")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
|
-
import { appendWorkspaceAuditEvent } from "../core/history/workspace-history.js";
|
|
10
|
+
import { appendWorkspaceAuditEvent, WORKSPACE_HISTORY_ID, } from "../core/history/workspace-history.js";
|
|
11
11
|
import { readSettings } from "../core/store/settings.js";
|
|
12
12
|
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
13
13
|
import { PmCliError } from "../core/shared/errors.js";
|
|
14
|
+
import { readRuntimeString, readRuntimeStringArray } from "./runtime-input.js";
|
|
14
15
|
/**
|
|
15
16
|
* Refuse an acknowledgment argument as a classified usage error.
|
|
16
17
|
*
|
|
@@ -22,8 +23,8 @@ import { PmCliError } from "../core/shared/errors.js";
|
|
|
22
23
|
* keeps expected validation out of the error channel without masking genuine
|
|
23
24
|
* failures, which retain their own exit codes.
|
|
24
25
|
*/
|
|
25
|
-
function refuseAuthorAcknowledgmentArgument(message,
|
|
26
|
-
throw new PmCliError(message, EXIT_CODE.USAGE,
|
|
26
|
+
function refuseAuthorAcknowledgmentArgument(message, context) {
|
|
27
|
+
throw new PmCliError(message, EXIT_CODE.USAGE, context);
|
|
27
28
|
}
|
|
28
29
|
/** First release-governance anchor after which unknown authors require remediation. */
|
|
29
30
|
export const HISTORY_AUTHOR_ATTRIBUTION_BASELINE = "2026-07-15T06:22:12.276Z";
|
|
@@ -203,6 +204,63 @@ export const scanHistoryAuthorAttribution = async (pmRoot, sampleLimit = 20, inc
|
|
|
203
204
|
...(includeActionableEvents ? { actionable_events: actionableEvents } : {}),
|
|
204
205
|
};
|
|
205
206
|
};
|
|
207
|
+
/** Resolve the mutually exclusive CLI and SDK acknowledgment selectors. */
|
|
208
|
+
export function resolveUnknownAuthorAcknowledgmentSelector(rawEvents, allActionable) {
|
|
209
|
+
const hasExplicitEvents = rawEvents.length > 0;
|
|
210
|
+
if (hasExplicitEvents && allActionable) {
|
|
211
|
+
refuseAuthorAcknowledgmentArgument("Specify exactly one selector: repeat --event or pass --all-actionable.", {
|
|
212
|
+
code: "history_author_acknowledge_selector_conflict",
|
|
213
|
+
required: "Exactly one of --event or --all-actionable",
|
|
214
|
+
examples: [
|
|
215
|
+
'pm history-author-acknowledge --event pm-a1b2:4 --attributed-author agent --reviewer maintainer --reason "Verified provenance"',
|
|
216
|
+
'pm history-author-acknowledge --all-actionable --attributed-author import-agent --reviewer maintainer --reason "Reviewed the complete actionable set"',
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (!hasExplicitEvents && !allActionable) {
|
|
221
|
+
refuseAuthorAcknowledgmentArgument("Specify exactly one selector: repeat --event or pass --all-actionable.", {
|
|
222
|
+
code: "history_author_acknowledge_selector_required",
|
|
223
|
+
required: "Exactly one of --event or --all-actionable",
|
|
224
|
+
examples: [
|
|
225
|
+
'pm history-author-acknowledge --event pm-a1b2:4 --attributed-author agent --reviewer maintainer --reason "Verified provenance"',
|
|
226
|
+
'pm history-author-acknowledge --all-actionable --attributed-author import-agent --reviewer maintainer --reason "Reviewed the complete actionable set"',
|
|
227
|
+
],
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
events: parseUnknownAuthorHistoryEventCoordinates(rawEvents),
|
|
232
|
+
all_actionable: allActionable,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/** Parse user-facing item or workspace history coordinates into SDK events. */
|
|
236
|
+
export function parseUnknownAuthorHistoryEventCoordinates(values) {
|
|
237
|
+
return values.map((value) => {
|
|
238
|
+
const separator = value.lastIndexOf(":");
|
|
239
|
+
const itemId = value.slice(0, separator).trim();
|
|
240
|
+
const line = Number(value.slice(separator + 1));
|
|
241
|
+
const validItemId = itemId === WORKSPACE_HISTORY_ID || /^[a-z0-9][a-z0-9-]*$/iu.test(itemId);
|
|
242
|
+
if (separator < 1 ||
|
|
243
|
+
!validItemId ||
|
|
244
|
+
!Number.isSafeInteger(line) ||
|
|
245
|
+
line < 1) {
|
|
246
|
+
refuseAuthorAcknowledgmentArgument(`history-author-acknowledge --event expects <item-id>:<one-based-line>, received "${value}".`, { code: "history_author_acknowledge_target_unreadable" });
|
|
247
|
+
}
|
|
248
|
+
return { item_id: itemId, line };
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/** Normalize an untyped transport payload and execute author acknowledgment. */
|
|
252
|
+
export function acknowledgeUnknownAuthorHistoryEventsFromTransport(pmRoot, input) {
|
|
253
|
+
const selector = resolveUnknownAuthorAcknowledgmentSelector(readRuntimeStringArray(input.historyEvent), input.allActionable === true || input.all_actionable === true);
|
|
254
|
+
return acknowledgeUnknownAuthorHistoryEvents(pmRoot, {
|
|
255
|
+
events: selector.events,
|
|
256
|
+
all_actionable: selector.all_actionable,
|
|
257
|
+
attributed_author: readRuntimeString(input, "attributedAuthor") ??
|
|
258
|
+
readRuntimeString(input, "attributed_author") ??
|
|
259
|
+
"",
|
|
260
|
+
reviewer: readRuntimeString(input, "reviewer") ?? "",
|
|
261
|
+
reason: readRuntimeString(input, "reason") ?? "",
|
|
262
|
+
});
|
|
263
|
+
}
|
|
206
264
|
/**
|
|
207
265
|
* Append an audited disposition for immutable unknown-author events without
|
|
208
266
|
* rewriting their original streams.
|
|
@@ -213,8 +271,11 @@ export async function acknowledgeUnknownAuthorHistoryEvents(pmRoot, options) {
|
|
|
213
271
|
const reason = options.reason.trim();
|
|
214
272
|
const explicitEvents = options.events ?? [];
|
|
215
273
|
const selectorCount = Number(options.all_actionable === true) + Number(explicitEvents.length > 0);
|
|
274
|
+
if (selectorCount === 0) {
|
|
275
|
+
refuseAuthorAcknowledgmentArgument("Specify exactly one selector: events or all_actionable.", { code: "history_author_acknowledge_selector_required" });
|
|
276
|
+
}
|
|
216
277
|
if (selectorCount > 1) {
|
|
217
|
-
refuseAuthorAcknowledgmentArgument("Author acknowledgment accepts either explicit events or all_actionable, not both.", "history_author_acknowledge_selector_conflict");
|
|
278
|
+
refuseAuthorAcknowledgmentArgument("Author acknowledgment accepts either explicit events or all_actionable, not both.", { code: "history_author_acknowledge_selector_conflict" });
|
|
218
279
|
}
|
|
219
280
|
const selectedEvents = options.all_actionable === true
|
|
220
281
|
? (await scanHistoryAuthorAttribution(pmRoot, 0, true))
|
|
@@ -229,7 +290,7 @@ export async function acknowledgeUnknownAuthorHistoryEvents(pmRoot, options) {
|
|
|
229
290
|
reason.length > 0,
|
|
230
291
|
].includes(false);
|
|
231
292
|
if (requiredValuesMissing) {
|
|
232
|
-
refuseAuthorAcknowledgmentArgument("Author acknowledgment requires events, reviewer, attributed_author, and reason.", "history_author_acknowledge_required_values_missing");
|
|
293
|
+
refuseAuthorAcknowledgmentArgument("Author acknowledgment requires events, reviewer, attributed_author, and reason.", { code: "history_author_acknowledge_required_values_missing" });
|
|
233
294
|
}
|
|
234
295
|
const uniqueEvents = [
|
|
235
296
|
...new Map(selectedEvents.map((event) => [
|
|
@@ -239,12 +300,13 @@ export async function acknowledgeUnknownAuthorHistoryEvents(pmRoot, options) {
|
|
|
239
300
|
].sort((left, right) => left.item_id.localeCompare(right.item_id) || left.line - right.line);
|
|
240
301
|
for (const event of uniqueEvents) {
|
|
241
302
|
const invalidCoordinate = [
|
|
242
|
-
|
|
303
|
+
event.item_id === WORKSPACE_HISTORY_ID ||
|
|
304
|
+
/^[a-z0-9][a-z0-9-]*$/i.test(event.item_id),
|
|
243
305
|
Number.isSafeInteger(event.line),
|
|
244
306
|
event.line >= 1,
|
|
245
307
|
].includes(false);
|
|
246
308
|
if (invalidCoordinate) {
|
|
247
|
-
refuseAuthorAcknowledgmentArgument(`Unknown-author acknowledgment target ${event.item_id}:${event.line} is not readable.`, "history_author_acknowledge_target_unreadable");
|
|
309
|
+
refuseAuthorAcknowledgmentArgument(`Unknown-author acknowledgment target ${event.item_id}:${event.line} is not readable.`, { code: "history_author_acknowledge_target_unreadable" });
|
|
248
310
|
}
|
|
249
311
|
let parsed;
|
|
250
312
|
try {
|
|
@@ -253,10 +315,10 @@ export async function acknowledgeUnknownAuthorHistoryEvents(pmRoot, options) {
|
|
|
253
315
|
parsed = JSON.parse(line ?? "");
|
|
254
316
|
}
|
|
255
317
|
catch {
|
|
256
|
-
refuseAuthorAcknowledgmentArgument(`Unknown-author acknowledgment target ${event.item_id}:${event.line} is not readable.`, "history_author_acknowledge_target_unreadable");
|
|
318
|
+
refuseAuthorAcknowledgmentArgument(`Unknown-author acknowledgment target ${event.item_id}:${event.line} is not readable.`, { code: "history_author_acknowledge_target_unreadable" });
|
|
257
319
|
}
|
|
258
320
|
if (classifyHistoryAuthorEvent(parsed) !== "actionable_unknown") {
|
|
259
|
-
refuseAuthorAcknowledgmentArgument(`Author acknowledgment target ${event.item_id}:${event.line} is not an actionable unknown-author event.`, "history_author_acknowledge_target_not_actionable");
|
|
321
|
+
refuseAuthorAcknowledgmentArgument(`Author acknowledgment target ${event.item_id}:${event.line} is not an actionable unknown-author event.`, { code: "history_author_acknowledge_target_not_actionable" });
|
|
260
322
|
}
|
|
261
323
|
}
|
|
262
324
|
const settings = await readSettings(pmRoot);
|
|
@@ -280,4 +342,4 @@ export async function acknowledgeUnknownAuthorHistoryEvents(pmRoot, options) {
|
|
|
280
342
|
};
|
|
281
343
|
}
|
|
282
344
|
//# sourceMappingURL=author-attribution.js.map
|
|
283
|
-
//# debugId=
|
|
345
|
+
//# debugId=4fd16197-979e-5269-bed7-f2fb0e2038c2
|