@unbrained/pm-cli 2026.8.11 → 2026.8.13
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 +74 -21
- package/dist/cli/commander-usage.js +37 -11
- package/dist/cli/error-guidance.d.ts +2 -0
- package/dist/cli/error-guidance.js +82 -19
- package/dist/cli/main.js +35 -19
- package/dist/cli/register-annotations.js +56 -3
- package/dist/cli/register-assurance.js +28 -17
- package/dist/cli/register-list-query.js +10 -7
- package/dist/cli/register-operations.js +16 -6
- package/dist/cli-bundle/bundle-manifest.json +163 -163
- package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
- package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
- package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
- package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
- package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
- package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
- package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
- package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
- package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
- package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
- package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
- 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 +42 -41
- 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 -2
- package/dist/core/checkpoint/checkpoint-gc.js +7 -12
- package/dist/core/extensions/activation-summary-markdown.js +5 -4
- package/dist/core/extensions/activation-summary.d.ts +2 -0
- package/dist/core/extensions/activation-summary.js +6 -2
- package/dist/core/extensions/capability-usage.d.ts +1 -1
- package/dist/core/extensions/capability-usage.js +4 -3
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +6 -2
- package/dist/core/extensions/extension-registries.js +3 -2
- package/dist/core/extensions/extension-types.d.ts +83 -1
- package/dist/core/extensions/extension-types.js +3 -2
- package/dist/core/extensions/loader.d.ts +2 -8
- package/dist/core/extensions/loader.js +53 -144
- package/dist/core/extensions/registration-values.d.ts +43 -0
- package/dist/core/extensions/registration-values.js +210 -0
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/extensions/runtime-registrations.d.ts +3 -1
- package/dist/core/extensions/runtime-registrations.js +12 -2
- package/dist/core/fs/fs-utils.d.ts +2 -0
- package/dist/core/fs/fs-utils.js +7 -3
- package/dist/core/history/drift-cache.js +4 -3
- package/dist/core/history/drift-scan.js +16 -17
- package/dist/core/history/history.d.ts +8 -0
- package/dist/core/history/history.js +57 -7
- package/dist/core/history/replay.d.ts +9 -1
- package/dist/core/history/replay.js +48 -13
- package/dist/core/lock/lock-gc.js +8 -13
- package/dist/core/lock/lock.js +5 -4
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +46 -14
- package/dist/core/search/vector-stores.js +6 -11
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/errors.d.ts +5 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/item-metadata-cache.d.ts +1 -1
- package/dist/core/store/item-metadata-cache.js +16 -9
- package/dist/core/telemetry/runtime.d.ts +6 -0
- package/dist/core/telemetry/runtime.js +101 -30
- package/dist/sdk/agent/command-recovery.d.ts +2 -0
- package/dist/sdk/agent/command-recovery.js +10 -2
- package/dist/sdk/annotations.js +4 -4
- package/dist/sdk/cli-bootstrap.d.ts +2 -0
- package/dist/sdk/cli-bootstrap.js +6 -2
- package/dist/sdk/cli-contracts/completeness.js +10 -3
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
- package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
- package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
- package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
- package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
- package/dist/sdk/cli-contracts/tool-schema.js +22 -4
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/comments.js +4 -3
- package/dist/sdk/compile-cache.js +4 -3
- package/dist/sdk/completion.js +16 -7
- package/dist/sdk/compose.d.ts +3 -1
- package/dist/sdk/compose.js +16 -2
- package/dist/sdk/context-intent-contracts.js +45 -4
- package/dist/sdk/context-signal-store.js +4 -3
- package/dist/sdk/core.d.ts +1 -0
- package/dist/sdk/core.js +3 -2
- package/dist/sdk/extension/install-runtime.js +4 -4
- package/dist/sdk/extension/managed-state.js +4 -3
- package/dist/sdk/extension-contracts.d.ts +1 -1
- package/dist/sdk/flag-invocation-contracts.js +5 -6
- package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
- package/dist/sdk/generated-error-code-catalog.js +6 -3140
- package/dist/sdk/governance/assurance-action.d.ts +27 -3
- package/dist/sdk/governance/assurance-action.js +117 -31
- package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
- package/dist/sdk/governance/assurance-mutation-error.js +58 -0
- package/dist/sdk/governance/assurance-presets.d.ts +54 -0
- package/dist/sdk/governance/assurance-presets.js +136 -0
- package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
- package/dist/sdk/governance/assurance-runtime.js +118 -14
- package/dist/sdk/governance/assurance.d.ts +51 -6
- package/dist/sdk/governance/assurance.js +321 -67
- package/dist/sdk/governance/gc.js +5 -11
- package/dist/sdk/governance/health.d.ts +3 -1
- package/dist/sdk/governance/health.js +24 -7
- package/dist/sdk/governance/validate-item-reader.js +3 -3
- package/dist/sdk/governance/validate.d.ts +2 -0
- package/dist/sdk/governance/validate.js +15 -5
- package/dist/sdk/graph/durable-cache.d.ts +1 -1
- package/dist/sdk/graph/durable-cache.js +156 -29
- package/dist/sdk/graph/governance-contracts.d.ts +12 -0
- package/dist/sdk/graph/governance-contracts.js +27 -0
- package/dist/sdk/graph/governance.d.ts +44 -2
- package/dist/sdk/graph/governance.js +156 -12
- package/dist/sdk/guide.js +4 -4
- package/dist/sdk/index.d.ts +3 -2
- package/dist/sdk/index.js +5 -4
- package/dist/sdk/lifecycle/claim.js +10 -3
- package/dist/sdk/linked-artifacts.d.ts +2 -0
- package/dist/sdk/linked-artifacts.js +29 -4
- package/dist/sdk/merge/driver.d.ts +2 -2
- package/dist/sdk/merge/driver.js +3 -3
- package/dist/sdk/merge/install.js +5 -4
- package/dist/sdk/merge/receipts.d.ts +6 -4
- package/dist/sdk/merge/receipts.js +7 -5
- package/dist/sdk/merge/three-way.d.ts +2 -2
- package/dist/sdk/merge/three-way.js +3 -3
- package/dist/sdk/output-projection.d.ts +9 -1
- package/dist/sdk/output-projection.js +45 -9
- package/dist/sdk/query/activity.d.ts +49 -2
- package/dist/sdk/query/activity.js +185 -38
- package/dist/sdk/query/get.js +19 -2
- package/dist/sdk/read-output-contracts.d.ts +5 -1
- package/dist/sdk/read-output-contracts.js +17 -2
- package/dist/sdk/read-output-session.d.ts +2 -0
- package/dist/sdk/read-output-session.js +12 -5
- package/dist/sdk/relationship-history.js +5 -5
- package/dist/sdk/runtime-primitives.d.ts +3 -3
- package/dist/sdk/runtime-primitives.js +5 -5
- package/dist/sdk/runtime-stats-options.js +3 -2
- package/dist/sdk/runtime.js +5 -9
- package/dist/sdk/schema-migration.js +4 -4
- package/dist/sdk/stats.d.ts +36 -3
- package/dist/sdk/stats.js +55 -15
- package/dist/sdk/test/execution.d.ts +4 -0
- package/dist/sdk/test/execution.js +88 -23
- package/dist/sdk/workspace-memory.js +4 -4
- package/dist/sdk/workspace-snapshot.js +8 -14
- package/dist/sdk/workspace-transaction-gc.js +4 -9
- package/dist/sdk/workspace-transaction.js +4 -4
- package/dist/sdk/workspace.js +4 -3
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -2
- package/docs/ASSURANCE.md +170 -14
- package/docs/COMMANDS.md +29 -8
- package/docs/CONFIGURATION.md +9 -0
- package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
- package/docs/EXTENSIONS.md +11 -12
- package/docs/MERGE_SAFETY.md +3 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
- package/docs/README.md +2 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
- package/docs/RELATIONSHIP_GRAPH.md +15 -0
- package/docs/SDK.md +17 -3
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
- package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
- package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
- package/docs/TESTING.md +24 -15
- package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
- package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
- package/marketplace.json +2 -2
- package/package.json +6 -6
- 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 +384 -83
- package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
- package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
- package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
- package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
- package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
- package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
- package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Implements append-only history and replay behavior for Replay.
|
|
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]="a1283470-00c7-5e91-8676-e1c1a667537f")}catch(e){}}();
|
|
8
8
|
import jsonPatch from "fast-json-patch";
|
|
9
9
|
import { ITEM_METADATA_KEY_ORDER } from "../shared/constants.js";
|
|
10
10
|
import { canonicalDocument } from "../item/item-format.js";
|
|
11
11
|
import { toItemRecord } from "../item/item-record.js";
|
|
12
12
|
import { orderObject, sha256Hex, stableStringify, } from "../shared/serialization.js";
|
|
13
|
-
import {
|
|
13
|
+
import { CURRENT_HISTORY_ITEM_HASH_VERSION, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, hashDocumentForVersion, } from "./history.js";
|
|
14
14
|
/** Public contract for empty replay document, shared by SDK and presentation-layer consumers. */
|
|
15
15
|
export const EMPTY_REPLAY_DOCUMENT = {
|
|
16
16
|
metadata: {},
|
|
@@ -21,11 +21,11 @@ export function cloneEmptyReplayDocument() {
|
|
|
21
21
|
return structuredClone(EMPTY_REPLAY_DOCUMENT);
|
|
22
22
|
}
|
|
23
23
|
/** Implements replay hash for the public runtime surface of this module. */
|
|
24
|
-
export function replayHash(document) {
|
|
24
|
+
export function replayHash(document, version = CURRENT_HISTORY_ITEM_HASH_VERSION) {
|
|
25
25
|
if (Object.keys(document.metadata).length === 0 ||
|
|
26
26
|
Array.isArray(document.metadata.tags)) {
|
|
27
27
|
try {
|
|
28
|
-
return
|
|
28
|
+
return hashDocumentForVersion(replayToItemDocument(document), version);
|
|
29
29
|
}
|
|
30
30
|
catch {
|
|
31
31
|
// Fall through when another malformed legacy field cannot be canonicalized.
|
|
@@ -124,14 +124,20 @@ export function tryApplyReplayPatch(current, patch) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
/** Deterministically verify a history chain: each entry's before_hash must equal the prior replayed after_hash, the patch must strictly apply, and the recorded after_hash must equal the replayed result. */
|
|
127
|
-
|
|
127
|
+
/** Verify a chain and report the explicit or auto-detected item hash epoch. */
|
|
128
|
+
export function verifyHistoryChainWithVersion(entries) {
|
|
128
129
|
let replay = cloneEmptyReplayDocument();
|
|
130
|
+
let detectedVersion;
|
|
129
131
|
for (let index = 0; index < entries.length; index += 1) {
|
|
130
132
|
const entry = entries[index];
|
|
131
|
-
|
|
133
|
+
const explicitVersion = entry.item_hash_version;
|
|
134
|
+
if (explicitVersion !== undefined &&
|
|
135
|
+
!SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(explicitVersion)) {
|
|
132
136
|
return {
|
|
133
137
|
ok: false,
|
|
134
|
-
errors: [
|
|
138
|
+
errors: [
|
|
139
|
+
`verify_failed:unsupported_item_hash_version:${String(explicitVersion)}:entry_${index + 1}`,
|
|
140
|
+
],
|
|
135
141
|
};
|
|
136
142
|
}
|
|
137
143
|
const applied = tryApplyReplayPatch(replay, entry.patch);
|
|
@@ -141,15 +147,38 @@ export function verifyHistoryChain(entries) {
|
|
|
141
147
|
errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],
|
|
142
148
|
};
|
|
143
149
|
}
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
const candidates = explicitVersion === undefined
|
|
151
|
+
? [CURRENT_HISTORY_ITEM_HASH_VERSION, 1]
|
|
152
|
+
: [explicitVersion];
|
|
153
|
+
const beforeMatches = candidates.filter((version) => replayHash(replay, version) === entry.before_hash);
|
|
154
|
+
if (beforeMatches.length === 0) {
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const version = beforeMatches.find((candidate) => replayHash(applied.document, candidate) === entry.after_hash);
|
|
161
|
+
if (version === undefined) {
|
|
146
162
|
return {
|
|
147
163
|
ok: false,
|
|
148
164
|
errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],
|
|
149
165
|
};
|
|
150
166
|
}
|
|
167
|
+
replay = applied.document;
|
|
168
|
+
detectedVersion = version;
|
|
151
169
|
}
|
|
152
|
-
return {
|
|
170
|
+
return {
|
|
171
|
+
ok: true,
|
|
172
|
+
errors: [],
|
|
173
|
+
...(detectedVersion === undefined
|
|
174
|
+
? {}
|
|
175
|
+
: { item_hash_version: detectedVersion }),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Deterministically verify a history chain while preserving the legacy result shape. */
|
|
179
|
+
export function verifyHistoryChain(entries) {
|
|
180
|
+
const result = verifyHistoryChainWithVersion(entries);
|
|
181
|
+
return { ok: result.ok, errors: result.errors };
|
|
153
182
|
}
|
|
154
183
|
function tryApplySingleOp(document, op) {
|
|
155
184
|
try {
|
|
@@ -192,6 +221,11 @@ export function lenientApplyReplayPatch(current, patch) {
|
|
|
192
221
|
}
|
|
193
222
|
/** Re-anchor a drifted history chain: replay every entry from empty, recompute the before/after hashes, and only rewrite a patch when the original op set no longer strictly applies (legacy drift). Clean entries keep their patch verbatim so the on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain. */
|
|
194
223
|
export function reanchorHistoryEntries(entries) {
|
|
224
|
+
const unsupportedIndex = entries.findIndex((entry) => entry.item_hash_version !== undefined &&
|
|
225
|
+
!SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(entry.item_hash_version));
|
|
226
|
+
if (unsupportedIndex >= 0) {
|
|
227
|
+
throw new TypeError(`unsupported_item_hash_version:${String(entries[unsupportedIndex]?.item_hash_version)}:entry_${unsupportedIndex + 1}`);
|
|
228
|
+
}
|
|
195
229
|
let replay = cloneEmptyReplayDocument();
|
|
196
230
|
const rewritten = [];
|
|
197
231
|
const details = [];
|
|
@@ -201,7 +235,7 @@ export function reanchorHistoryEntries(entries) {
|
|
|
201
235
|
let skippedOps = 0;
|
|
202
236
|
for (let index = 0; index < entries.length; index += 1) {
|
|
203
237
|
const entry = entries[index];
|
|
204
|
-
const beforeHash = replayHash(replay);
|
|
238
|
+
const beforeHash = replayHash(replay, CURRENT_HISTORY_ITEM_HASH_VERSION);
|
|
205
239
|
const strict = tryApplyReplayPatch(replay, entry.patch);
|
|
206
240
|
let next;
|
|
207
241
|
let outPatch;
|
|
@@ -223,7 +257,7 @@ export function reanchorHistoryEntries(entries) {
|
|
|
223
257
|
skippedOps += entrySkipped;
|
|
224
258
|
entriesPatchRepaired += 1;
|
|
225
259
|
}
|
|
226
|
-
const afterHash = replayHash(next);
|
|
260
|
+
const afterHash = replayHash(next, CURRENT_HISTORY_ITEM_HASH_VERSION);
|
|
227
261
|
const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;
|
|
228
262
|
if (rehashed) {
|
|
229
263
|
entriesRehashed += 1;
|
|
@@ -233,6 +267,7 @@ export function reanchorHistoryEntries(entries) {
|
|
|
233
267
|
patch: outPatch,
|
|
234
268
|
before_hash: beforeHash,
|
|
235
269
|
after_hash: afterHash,
|
|
270
|
+
item_hash_version: CURRENT_HISTORY_ITEM_HASH_VERSION,
|
|
236
271
|
});
|
|
237
272
|
details.push({
|
|
238
273
|
index: index + 1,
|
|
@@ -261,4 +296,4 @@ export function historyEntriesToRaw(entries) {
|
|
|
261
296
|
return `${entries.map((entry) => JSON.stringify(entry)).join("\n")}\n`;
|
|
262
297
|
}
|
|
263
298
|
//# sourceMappingURL=replay.js.map
|
|
264
|
-
//# debugId=
|
|
299
|
+
//# debugId=a1283470-00c7-5e91-8676-e1c1a667537f
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* Zero ttl means any lock older than 0 ms is stale. Negative ttl means always stale.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
!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]="
|
|
12
|
+
!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]="79f9ccbd-48d1-5eb3-82ae-3dd62427041c")}catch(e){}}();
|
|
13
|
+
import { isFileMissingError } from "../fs/fs-utils.js";
|
|
13
14
|
import fs from "node:fs/promises";
|
|
14
15
|
import path from "node:path";
|
|
15
16
|
function parseLock(raw) {
|
|
@@ -34,12 +35,6 @@ function parseLock(raw) {
|
|
|
34
35
|
}
|
|
35
36
|
return { id, owner, created_at, ttl_seconds };
|
|
36
37
|
}
|
|
37
|
-
function isErrno(error, code) {
|
|
38
|
-
return (typeof error === "object" &&
|
|
39
|
-
error !== null &&
|
|
40
|
-
"code" in error &&
|
|
41
|
-
error.code === code);
|
|
42
|
-
}
|
|
43
38
|
/** Pure classification of one lock file's raw content against `nowMs`. This is the single staleness/parse policy shared by `pm gc --scope locks` (which acts on it) and the `pm health` locks check (which only reports it). */
|
|
44
39
|
export function classifyLockContent(file, raw, nowMs) {
|
|
45
40
|
const lock = parseLock(raw);
|
|
@@ -108,7 +103,7 @@ export async function scanLockHealth(pmRoot, now) {
|
|
|
108
103
|
dirEntries = rawDir.filter((f) => f.endsWith(".lock")).sort();
|
|
109
104
|
}
|
|
110
105
|
catch (error) {
|
|
111
|
-
if (
|
|
106
|
+
if (isFileMissingError(error)) {
|
|
112
107
|
return scan;
|
|
113
108
|
}
|
|
114
109
|
throw error;
|
|
@@ -119,7 +114,7 @@ export async function scanLockHealth(pmRoot, now) {
|
|
|
119
114
|
raw = await fs.readFile(path.join(locksDir, file), "utf8");
|
|
120
115
|
}
|
|
121
116
|
catch (readError) {
|
|
122
|
-
if (
|
|
117
|
+
if (isFileMissingError(readError)) {
|
|
123
118
|
// Disappeared between readdir and readFile — treat as a ghost; skip quietly.
|
|
124
119
|
continue;
|
|
125
120
|
}
|
|
@@ -159,7 +154,7 @@ export async function runLockGc(pmRoot, options) {
|
|
|
159
154
|
dirEntries = raw.filter((f) => f.endsWith(".lock")).sort();
|
|
160
155
|
}
|
|
161
156
|
catch (error) {
|
|
162
|
-
if (
|
|
157
|
+
if (isFileMissingError(error)) {
|
|
163
158
|
return result;
|
|
164
159
|
}
|
|
165
160
|
throw error;
|
|
@@ -179,7 +174,7 @@ export async function runLockGc(pmRoot, options) {
|
|
|
179
174
|
raw = await fs.readFile(absPath, "utf8");
|
|
180
175
|
}
|
|
181
176
|
catch (readError) {
|
|
182
|
-
if (
|
|
177
|
+
if (isFileMissingError(readError)) {
|
|
183
178
|
// Disappeared between readdir and readFile — treat as a ghost; skip quietly.
|
|
184
179
|
result.scanned -= 1;
|
|
185
180
|
continue;
|
|
@@ -223,7 +218,7 @@ export async function runLockGc(pmRoot, options) {
|
|
|
223
218
|
await fs.unlink(absPath);
|
|
224
219
|
}
|
|
225
220
|
catch (unlinkError) {
|
|
226
|
-
if (!
|
|
221
|
+
if (!isFileMissingError(unlinkError)) {
|
|
227
222
|
result.warnings.push(`lock_remove_failed:${file}`);
|
|
228
223
|
result.retained.push(relPath);
|
|
229
224
|
result.entries.push(classified.entry);
|
|
@@ -243,4 +238,4 @@ export async function runLockGc(pmRoot, options) {
|
|
|
243
238
|
return result;
|
|
244
239
|
}
|
|
245
240
|
//# sourceMappingURL=lock-gc.js.map
|
|
246
|
-
//# debugId=
|
|
241
|
+
//# debugId=79f9ccbd-48d1-5eb3-82ae-3dd62427041c
|
package/dist/core/lock/lock.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Coordinates tracker lock ownership and cleanup for Lock.
|
|
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]="a9ad8a9f-de6e-5bce-8685-844f1129d5fb")}catch(e){}}();
|
|
8
|
+
import { isFileMissingError } from "../fs/fs-utils.js";
|
|
8
9
|
import fs from "node:fs/promises";
|
|
9
10
|
import path from "node:path";
|
|
10
11
|
import { randomUUID } from "node:crypto";
|
|
@@ -70,7 +71,7 @@ async function readLockInfo(lockPath) {
|
|
|
70
71
|
return parseLockInfo(raw);
|
|
71
72
|
}
|
|
72
73
|
catch (error) {
|
|
73
|
-
if (
|
|
74
|
+
if (isFileMissingError(error)) {
|
|
74
75
|
return {
|
|
75
76
|
info: null,
|
|
76
77
|
warnings: [],
|
|
@@ -294,7 +295,7 @@ async function removeExpiredStaleCleanupGate(gatePath) {
|
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
catch (error) {
|
|
297
|
-
return
|
|
298
|
+
return isFileMissingError(error);
|
|
298
299
|
}
|
|
299
300
|
const owner = await readStaleCleanupGateOwner(gatePath);
|
|
300
301
|
if (owner !== null &&
|
|
@@ -446,4 +447,4 @@ export async function acquireLock(pmRoot, id, ttlSeconds, owner, force = false,
|
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
449
|
//# sourceMappingURL=lock.js.map
|
|
449
|
-
//# debugId=
|
|
450
|
+
//# debugId=a9ad8a9f-de6e-5bce-8685-844f1129d5fb
|
|
@@ -24,6 +24,8 @@ export interface OutputOptions {
|
|
|
24
24
|
outputFormat?: "toon" | "json";
|
|
25
25
|
/** Caller-carried cross-call budget and served-item state. */
|
|
26
26
|
outputSession?: string;
|
|
27
|
+
/** Include machine-readable row location and row-encoding metadata. */
|
|
28
|
+
outputRowContract?: boolean;
|
|
27
29
|
/** Fallback output format used when callers do not provide an override. */
|
|
28
30
|
defaultOutputFormat?: "toon" | "json";
|
|
29
31
|
/** Value that configures or reports command for this contract. */
|
|
@@ -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]="5aaf8b90-5b95-5102-9ea4-b877c696d593")}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
|
+
import { encode as encodeToon } from "@toon-format/toon";
|
|
15
16
|
const DECLARED_PROCESS_EXIT_CODES = new Set(Object.values(EXIT_CODE));
|
|
16
17
|
const NATIVE_OUTPUT_MARKER = "__pm_native_output";
|
|
17
18
|
let streamErrorHandlersInstalled = false;
|
|
@@ -114,6 +115,44 @@ function renderScalar(value) {
|
|
|
114
115
|
return "null";
|
|
115
116
|
return JSON.stringify(value);
|
|
116
117
|
}
|
|
118
|
+
function isToonPrimitive(value) {
|
|
119
|
+
return (value === null ||
|
|
120
|
+
typeof value === "string" ||
|
|
121
|
+
typeof value === "number" ||
|
|
122
|
+
typeof value === "boolean");
|
|
123
|
+
}
|
|
124
|
+
function tabularObjectArray(value) {
|
|
125
|
+
if (value.length === 0 || !value.every(isPlainObject))
|
|
126
|
+
return false;
|
|
127
|
+
const keys = Object.keys(value[0]);
|
|
128
|
+
return (keys.length > 0 &&
|
|
129
|
+
value.every((entry) => Object.keys(entry).length === keys.length &&
|
|
130
|
+
keys.every((key) => Object.hasOwn(entry, key) && isToonPrimitive(entry[key]))));
|
|
131
|
+
}
|
|
132
|
+
function indentToon(encoded, depth) {
|
|
133
|
+
const indent = " ".repeat(depth);
|
|
134
|
+
return encoded
|
|
135
|
+
.split("\n")
|
|
136
|
+
.map((line) => `${indent}${line}`)
|
|
137
|
+
.join("\n");
|
|
138
|
+
}
|
|
139
|
+
/** Render one object field while preserving nested and tabular TOON structure. */
|
|
140
|
+
function renderToonObjectEntry(key, entry, depth) {
|
|
141
|
+
const indent = " ".repeat(depth);
|
|
142
|
+
if (!isPlainObject(entry) && !Array.isArray(entry)) {
|
|
143
|
+
return `${indent}${key}: ${renderScalar(entry)}`;
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(entry) && entry.length === 0) {
|
|
146
|
+
return `${indent}${key}: []`;
|
|
147
|
+
}
|
|
148
|
+
if (Array.isArray(entry) && tabularObjectArray(entry)) {
|
|
149
|
+
return indentToon(encodeToon({ [key]: entry }), depth);
|
|
150
|
+
}
|
|
151
|
+
if (isPlainObject(entry) && Object.keys(entry).length === 0) {
|
|
152
|
+
return `${indent}${key}: {}`;
|
|
153
|
+
}
|
|
154
|
+
return `${indent}${key}:\n${renderToonValue(entry, depth + 1)}`;
|
|
155
|
+
}
|
|
117
156
|
function compactToonValue(value) {
|
|
118
157
|
if (value === null || value === undefined) {
|
|
119
158
|
return undefined;
|
|
@@ -147,6 +186,9 @@ function renderToonValue(value, depth) {
|
|
|
147
186
|
if (Array.isArray(value)) {
|
|
148
187
|
if (value.length === 0)
|
|
149
188
|
return "[]";
|
|
189
|
+
if (tabularObjectArray(value)) {
|
|
190
|
+
return indentToon(encodeToon(value), depth);
|
|
191
|
+
}
|
|
150
192
|
return value
|
|
151
193
|
.map((entry) => {
|
|
152
194
|
if (!isPlainObject(entry) && !Array.isArray(entry)) {
|
|
@@ -167,18 +209,7 @@ function renderToonValue(value, depth) {
|
|
|
167
209
|
if (entries.length === 0)
|
|
168
210
|
return "{}";
|
|
169
211
|
return entries
|
|
170
|
-
.map(([key, entry]) =>
|
|
171
|
-
if (!isPlainObject(entry) && !Array.isArray(entry)) {
|
|
172
|
-
return `${indent}${key}: ${renderScalar(entry)}`;
|
|
173
|
-
}
|
|
174
|
-
if (Array.isArray(entry) && entry.length === 0) {
|
|
175
|
-
return `${indent}${key}: []`;
|
|
176
|
-
}
|
|
177
|
-
if (isPlainObject(entry) && Object.keys(entry).length === 0) {
|
|
178
|
-
return `${indent}${key}: {}`;
|
|
179
|
-
}
|
|
180
|
-
return `${indent}${key}:\n${renderToonValue(entry, depth + 1)}`;
|
|
181
|
-
})
|
|
212
|
+
.map(([key, entry]) => renderToonObjectEntry(key, entry, depth))
|
|
182
213
|
.join("\n");
|
|
183
214
|
}
|
|
184
215
|
return `${indent}${renderScalar(value)}`;
|
|
@@ -335,6 +366,7 @@ function formatEffectiveOutput(effectiveResult, nativeOutput, options) {
|
|
|
335
366
|
["outputBudget", options.outputBudget],
|
|
336
367
|
["outputFormat", options.outputFormat],
|
|
337
368
|
["outputSession", options.outputSession],
|
|
369
|
+
["outputRowContract", options.outputRowContract],
|
|
338
370
|
].filter((entry) => entry[1] !== undefined)),
|
|
339
371
|
};
|
|
340
372
|
const format = resolveReadOutputEncoding(command ?? "", commandOptions) ??
|
|
@@ -424,4 +456,4 @@ export const outputTestOnly = {
|
|
|
424
456
|
renderToonValue,
|
|
425
457
|
};
|
|
426
458
|
//# sourceMappingURL=output.js.map
|
|
427
|
-
//# debugId=
|
|
459
|
+
//# debugId=5aaf8b90-5b95-5102-9ea4-b877c696d593
|
|
@@ -1,10 +1,10 @@
|
|
|
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]="98c8d03c-bdde-5ac4-b80d-395d885f7442")}catch(e){}}();
|
|
3
3
|
import { mkdir, readFile, stat, unlink } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
import { executeSearchJsonRequest, normalizeSearchHttpTimeoutMs, resolveSearchHttpFetcher, } from "./http-client.js";
|
|
6
6
|
import { isFiniteNumberArray, toErrorMessage, toNonEmptyString, trimTrailingSlashes, } from "../shared/primitives.js";
|
|
7
|
-
import { writeFileAtomic } from "../fs/fs-utils.js";
|
|
7
|
+
import { isFileMissingError, writeFileAtomic } from "../fs/fs-utils.js";
|
|
8
8
|
const DEFAULT_COLLECTION = "pm_items";
|
|
9
9
|
const COLLECTION_SANITIZE_PATTERN = /[^a-zA-Z0-9_-]/g;
|
|
10
10
|
const MAX_COLLECTION_NAME_LENGTH = 128;
|
|
@@ -200,11 +200,6 @@ function getLanceDbLocalTableKey(storePath, table) {
|
|
|
200
200
|
function getLanceDbSnapshotPath(storePath, table) {
|
|
201
201
|
return join(resolve(storePath), LANCE_DB_LOCAL_SNAPSHOT_DIR, `${table}.json`);
|
|
202
202
|
}
|
|
203
|
-
function isNodeErrorWithCode(error, code) {
|
|
204
|
-
return (typeof error === "object" &&
|
|
205
|
-
error !== null &&
|
|
206
|
-
error.code === code);
|
|
207
|
-
}
|
|
208
203
|
function normalizeSnapshotRecord(entry, index, snapshotPath) {
|
|
209
204
|
const id = toNonEmptyString(entry.id);
|
|
210
205
|
if (!id) {
|
|
@@ -261,7 +256,7 @@ async function readLanceDbSnapshotStats(snapshotPath) {
|
|
|
261
256
|
return { mtimeMs: stats.mtimeMs, size: stats.size };
|
|
262
257
|
}
|
|
263
258
|
catch (error) {
|
|
264
|
-
if (!
|
|
259
|
+
if (!isFileMissingError(error)) {
|
|
265
260
|
throw error;
|
|
266
261
|
}
|
|
267
262
|
return null;
|
|
@@ -306,7 +301,7 @@ async function loadLanceDbLocalTable(storePath, table) {
|
|
|
306
301
|
loaded = parseLanceDbSnapshot(snapshotPath, table, raw);
|
|
307
302
|
}
|
|
308
303
|
catch (error) {
|
|
309
|
-
if (!
|
|
304
|
+
if (!isFileMissingError(error)) {
|
|
310
305
|
throw error;
|
|
311
306
|
}
|
|
312
307
|
}
|
|
@@ -331,7 +326,7 @@ async function removeSnapshotFile(snapshotPath) {
|
|
|
331
326
|
await unlink(snapshotPath);
|
|
332
327
|
}
|
|
333
328
|
catch (error) {
|
|
334
|
-
if (!
|
|
329
|
+
if (!isFileMissingError(error)) {
|
|
335
330
|
throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`);
|
|
336
331
|
}
|
|
337
332
|
}
|
|
@@ -667,4 +662,4 @@ export async function executeVectorReset(store, knownIds = [], options = {}, vec
|
|
|
667
662
|
return await executeVectorDelete(store, idsToDelete, options);
|
|
668
663
|
}
|
|
669
664
|
//# sourceMappingURL=vector-stores.js.map
|
|
670
|
-
//# debugId=
|
|
665
|
+
//# debugId=98c8d03c-bdde-5ac4-b80d-395d885f7442
|
|
@@ -29,6 +29,8 @@ export interface GlobalOptions {
|
|
|
29
29
|
outputFormat?: "toon" | "json";
|
|
30
30
|
/** Caller-carried cross-call budget and served-item state. */
|
|
31
31
|
outputSession?: string;
|
|
32
|
+
/** Include the machine-readable row selector and TOON encoding contract. */
|
|
33
|
+
outputRowContract?: boolean;
|
|
32
34
|
/** Filesystem path used for path resolution. */
|
|
33
35
|
path?: string;
|
|
34
36
|
/** Value that configures or reports no extensions for this contract. */
|
|
@@ -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]="044af354-3047-5fd4-ae65-458a259dedca")}catch(e){}}();
|
|
3
3
|
export {};
|
|
4
4
|
//# sourceMappingURL=command-types.js.map
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=044af354-3047-5fd4-ae65-458a259dedca
|
|
@@ -11,6 +11,11 @@ export interface PmCliErrorRecoveryPayload {
|
|
|
11
11
|
attempted_command?: string;
|
|
12
12
|
/** Value that configures or reports normalized args for this contract. */
|
|
13
13
|
normalized_args?: string[];
|
|
14
|
+
/** Positional tokens paired with their parser roles for unambiguous recovery. */
|
|
15
|
+
parsed_positionals?: Array<{
|
|
16
|
+
role: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}>;
|
|
14
19
|
/** Value that configures or reports provided fields for this contract. */
|
|
15
20
|
provided_fields?: string[];
|
|
16
21
|
/** Value that configures or reports missing for this contract. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Implements the exported pm cli error runtime abstraction for core/shared/errors.ts. */
|
|
2
2
|
|
|
3
|
-
!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]="
|
|
3
|
+
!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]="62fb0ba7-643f-5b33-870b-df875559610a")}catch(e){}}();
|
|
4
4
|
export class PmCliError extends Error {
|
|
5
5
|
/** Value that configures or reports exit code for this contract. */
|
|
6
6
|
exitCode;
|
|
@@ -18,4 +18,4 @@ export class PmCliError extends Error {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=errors.js.map
|
|
21
|
-
//# debugId=
|
|
21
|
+
//# debugId=62fb0ba7-643f-5b33-870b-df875559610a
|
|
@@ -83,7 +83,7 @@ export interface ListCacheOptions {
|
|
|
83
83
|
includeBody?: boolean;
|
|
84
84
|
/** When false, heavy collection fields (comments/notes/learnings/files/tests/ test_runs/docs) are neither loaded from nor written to the separate collections cache, and are absent from the returned metadata. Light-only callers (`pm list` compact, stats, deps, activity, calendar, close) skip the large collections cache entirely. Defaults to true so any caller that does read those fields stays correct. */
|
|
85
85
|
includeCollections?: boolean;
|
|
86
|
-
/** Force canonical item enumeration and
|
|
86
|
+
/** Force canonical item enumeration and authoritative file reads even when stat-matched cache tiers or a fresh derived index are available. Validation, repair, migration, and equivalence tests use this correctness path. */
|
|
87
87
|
forceSourceScan?: boolean;
|
|
88
88
|
/** Minimum item count required before the directory-signature derived-index fast path is used. Defaults to 500 so small workspaces preserve per-file external-edit detection; tests and specialized SDK hosts may lower it explicitly. */
|
|
89
89
|
derivedIndexMinimumItems?: number;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Reads and writes tracker storage with format-aware helpers for the item metadata cache.
|
|
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]="8b8c705a-8d80-576f-8642-f6f686cdbed9")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -12,7 +12,7 @@ import { getActiveExtensionRegistrations, hasActiveOnReadHooks, runActiveOnReadH
|
|
|
12
12
|
import { collectRegisteredItemFieldNames } from "../extensions/item-fields.js";
|
|
13
13
|
import { parseItemDocument } from "../item/item-format.js";
|
|
14
14
|
import { evictOldestMemoEntries } from "../shared/memo.js";
|
|
15
|
-
import { writeFileAtomic } from "../fs/fs-utils.js";
|
|
15
|
+
import { isFileMissingError, writeFileAtomic } from "../fs/fs-utils.js";
|
|
16
16
|
import { acquireLock } from "../lock/lock.js";
|
|
17
17
|
import { ITEM_FILE_EXTENSIONS, getItemFormatFromPath } from "./paths.js";
|
|
18
18
|
import { rebuildItemMetadataQueryIndex, removeItemMetadataQueryIndex, updateItemMetadataQueryIndex, } from "./item-metadata-query-index.js";
|
|
@@ -257,7 +257,8 @@ async function loadBodyCache(pmRoot, contextFingerprint) {
|
|
|
257
257
|
};
|
|
258
258
|
const cachePath = getBodyCachePath(pmRoot);
|
|
259
259
|
const active = await loadEnvelopeMemoized(cachePath, parse);
|
|
260
|
-
return contextFingerprint &&
|
|
260
|
+
return contextFingerprint &&
|
|
261
|
+
active?.context_fingerprint !== contextFingerprint
|
|
261
262
|
? await loadEnvelopeMemoized(getContextCachePath(cachePath, contextFingerprint), parse)
|
|
262
263
|
: active;
|
|
263
264
|
}
|
|
@@ -274,7 +275,8 @@ async function loadCollectionsCache(pmRoot, contextFingerprint) {
|
|
|
274
275
|
};
|
|
275
276
|
const cachePath = getCollectionsCachePath(pmRoot);
|
|
276
277
|
const active = await loadEnvelopeMemoized(cachePath, parse);
|
|
277
|
-
return contextFingerprint &&
|
|
278
|
+
return contextFingerprint &&
|
|
279
|
+
active?.context_fingerprint !== contextFingerprint
|
|
278
280
|
? await loadEnvelopeMemoized(getContextCachePath(cachePath, contextFingerprint), parse)
|
|
279
281
|
: active;
|
|
280
282
|
}
|
|
@@ -440,7 +442,7 @@ async function readItemDirectoryFiles(pmRoot, folder, warnings) {
|
|
|
440
442
|
if (typeof error === "object" &&
|
|
441
443
|
error !== null &&
|
|
442
444
|
"code" in error &&
|
|
443
|
-
error
|
|
445
|
+
!isFileMissingError(error)) {
|
|
444
446
|
appendWarning(warnings, `item_list_directory_read_failed:${folder}`);
|
|
445
447
|
}
|
|
446
448
|
return { folder, dirPath, files: [] };
|
|
@@ -518,12 +520,16 @@ async function readCachedDocumentParts(filePath, relativePath, context) {
|
|
|
518
520
|
const itemFormat = getItemFormatFromPath(filePath);
|
|
519
521
|
await dispatchCachedDocumentReadHooks(filePath, context.warnings, context.dispatchReadHooks);
|
|
520
522
|
const cachedEntry = context.previousEntries[relativePath];
|
|
521
|
-
const metadataCached =
|
|
523
|
+
const metadataCached = !context.forceSourceRead &&
|
|
524
|
+
cachedEntry !== undefined &&
|
|
522
525
|
statMatches(cachedEntry, mtimeMs, ctimeMs, size);
|
|
523
526
|
const cachedBody = context.previousBodies[relativePath];
|
|
524
|
-
const bodyCached =
|
|
527
|
+
const bodyCached = !context.forceSourceRead &&
|
|
528
|
+
cachedBody !== undefined &&
|
|
529
|
+
statMatches(cachedBody, mtimeMs, ctimeMs, size);
|
|
525
530
|
const cachedCollections = context.previousCollections[relativePath];
|
|
526
|
-
const collectionsCached =
|
|
531
|
+
const collectionsCached = !context.forceSourceRead &&
|
|
532
|
+
cachedCollections !== undefined &&
|
|
527
533
|
statMatches(cachedCollections, mtimeMs, ctimeMs, size);
|
|
528
534
|
const needRead = !metadataCached ||
|
|
529
535
|
(context.includeBody && !bodyCached) ||
|
|
@@ -1028,6 +1034,7 @@ export async function listAllDocumentCandidatesCached(pmRoot, preferredFormat, t
|
|
|
1028
1034
|
extensionFieldNames,
|
|
1029
1035
|
includeBody,
|
|
1030
1036
|
includeCollections,
|
|
1037
|
+
forceSourceRead: options.forceSourceScan === true,
|
|
1031
1038
|
dispatchReadHooks,
|
|
1032
1039
|
previousEntries,
|
|
1033
1040
|
previousBodies,
|
|
@@ -1107,4 +1114,4 @@ export async function listAllDocumentsCachedLight(pmRoot, preferredFormat, typeT
|
|
|
1107
1114
|
}));
|
|
1108
1115
|
}
|
|
1109
1116
|
//# sourceMappingURL=item-metadata-cache.js.map
|
|
1110
|
-
//# debugId=
|
|
1117
|
+
//# debugId=8b8c705a-8d80-576f-8642-f6f686cdbed9
|
|
@@ -171,6 +171,10 @@ declare function sanitizeValue(value: unknown, keyHint?: string, captureLevel?:
|
|
|
171
171
|
declare function sanitizeCommandArgs(args: string[], captureLevel?: Exclude<TelemetryCaptureLevel, "minimal">): string[];
|
|
172
172
|
declare function normalizeCaptureLevel(value: string | undefined): TelemetryCaptureLevel;
|
|
173
173
|
declare function parseBooleanTrueLike(value: string | undefined): boolean;
|
|
174
|
+
/** Resolve the background event and OTLP request timeout within the flush-lock safety envelope. */
|
|
175
|
+
declare function resolveTelemetryHttpTimeoutMs(): number;
|
|
176
|
+
/** POST a JSON payload with one total timeout that covers DNS, connection, TLS, and response completion. */
|
|
177
|
+
declare function postTelemetryJson(endpoint: string, headers: Record<string, string>, body: string): Promise<number>;
|
|
174
178
|
declare function normalizePmVersion(value: string | undefined): string;
|
|
175
179
|
declare function normalizeTelemetryErrorCode(value: string | undefined): string | undefined;
|
|
176
180
|
declare function normalizeTelemetryExitCode(exitCode: number | undefined, ok: boolean): number;
|
|
@@ -335,11 +339,13 @@ export declare const _testOnly: {
|
|
|
335
339
|
looksLikeEmailToken: typeof looksLikeEmailToken;
|
|
336
340
|
otelSpansQueuePath: typeof otelSpansQueuePath;
|
|
337
341
|
parseBooleanTrueLike: typeof parseBooleanTrueLike;
|
|
342
|
+
postTelemetryJson: typeof postTelemetryJson;
|
|
338
343
|
parsePendingOtelSpanLines: typeof parsePendingOtelSpanLines;
|
|
339
344
|
prunePendingOtelSpans: typeof prunePendingOtelSpans;
|
|
340
345
|
reconcilePendingOtelSpansAfterFlush: typeof reconcilePendingOtelSpansAfterFlush;
|
|
341
346
|
retentionCutoffMs: typeof retentionCutoffMs;
|
|
342
347
|
resolveOtelTracesEndpoint: typeof resolveOtelTracesEndpoint;
|
|
348
|
+
resolveTelemetryHttpTimeoutMs: typeof resolveTelemetryHttpTimeoutMs;
|
|
343
349
|
rewritePendingOtelSpans: typeof rewritePendingOtelSpans;
|
|
344
350
|
normalizeForHash: typeof normalizeForHash;
|
|
345
351
|
normalizeCaptureLevel: typeof normalizeCaptureLevel;
|