@unbrained/pm-cli 2026.8.19 → 2026.8.21
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 +41 -0
- package/dist/cli/error-guidance.d.ts +20 -0
- package/dist/cli/error-guidance.js +29 -30
- package/dist/cli/register-list-query.js +12 -10
- package/dist/cli/register-structured-mutation.d.ts +2 -0
- package/dist/cli/register-structured-mutation.js +29 -6
- package/dist/cli-bundle/bundle-manifest.json +156 -148
- package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +197 -0
- package/dist/cli-bundle/chunks/{chunk-4NRRH7AM.js → chunk-3AFAUHUE.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7VHZS727.js +5 -0
- package/dist/cli-bundle/chunks/chunk-BKYB45NQ.js +2092 -0
- package/dist/cli-bundle/chunks/{chunk-BHYMXLAE.js → chunk-BUNIEJNE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QXSH7BLM.js → chunk-JSLOFXGA.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-LARJJ3RK.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-TOXJM4WA.js → chunk-LOVTQ52Z.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-N3DSV4CH.js +77 -0
- package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +35 -0
- package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +13 -0
- package/dist/cli-bundle/chunks/register-list-query-F57EWDEF.js +11 -0
- package/dist/cli-bundle/chunks/{register-mutation-AUWVCW4M.js → register-mutation-7IY2D5KO.js} +20 -20
- package/dist/cli-bundle/chunks/{register-operations-PZQPHXW5.js → register-operations-FALL3YTU.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-I4LUHGVW.js → register-setup-HXU7IZZD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2NIY5NKG.js +18 -0
- package/dist/cli-bundle/focused-chunks/{chunk-US7VEYZG.js → chunk-4ERLO7QD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +50 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MCZXYZAF.js → chunk-CKKQSJNN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ZBIQQYMI.js → chunk-F2A56DHV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ESISGDAY.js → chunk-F4YEW5I2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ODHQEECS.js → chunk-FH6DYED3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-FJ22HNRP.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-JEAVFOWM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EXBCLIBU.js → chunk-KDNG7TKQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +155 -0
- package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JDOMQ7VQ.js → chunk-TJ7EMJ46.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-UZE7XUZK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DKPLYW3L.js → chunk-YKBKIEAJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VXDSU5MC.js → chunk-ZOSEELYJ.js} +2 -2
- package/dist/cli-bundle/main.js +12 -12
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +41 -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 +32 -32
- 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 +5 -5
- package/dist/core/output/mutation-projection.js +26 -2
- package/dist/core/shared/constants.d.ts +1 -5
- package/dist/core/shared/constants.js +3 -81
- package/dist/core/shared/errors.d.ts +16 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/shared/item-metadata-contract.d.ts +14 -0
- package/dist/core/shared/item-metadata-contract.js +90 -0
- package/dist/core/store/item-store.d.ts +60 -0
- package/dist/core/store/item-store.js +26 -94
- package/dist/core/store/tracker-preflight.d.ts +7 -0
- package/dist/core/store/tracker-preflight.js +142 -0
- package/dist/sdk/agent/closed-domain-contracts.d.ts +25 -0
- package/dist/sdk/agent/closed-domain-contracts.js +140 -0
- package/dist/sdk/agent/refusal-closure.d.ts +13 -1
- package/dist/sdk/agent/refusal-closure.js +45 -3
- package/dist/sdk/agent/refusal-reachability.d.ts +26 -0
- package/dist/sdk/agent/refusal-reachability.js +26 -2
- package/dist/sdk/agent/tracker-preflight-contracts.d.ts +63 -0
- package/dist/sdk/agent/tracker-preflight-contracts.js +127 -0
- package/dist/sdk/agent-capability-contracts.js +6 -11
- package/dist/sdk/annotations.js +6 -7
- package/dist/sdk/cli-contracts/completeness.js +8 -2
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -2
- package/dist/sdk/cli-contracts/enum-contracts.js +16 -6
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +11 -2
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +19 -2
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +105 -5
- package/dist/sdk/cli-contracts/grammar-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +5 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +7 -3
- package/dist/sdk/cli-contracts/tool-schema.js +7 -2
- package/dist/sdk/cli-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts.js +4 -4
- package/dist/sdk/config.d.ts +5 -0
- package/dist/sdk/config.js +5 -5
- package/dist/sdk/context-intent-runtime.js +7 -4
- package/dist/sdk/contracts.d.ts +2 -0
- package/dist/sdk/contracts.js +4 -2
- package/dist/sdk/core.d.ts +1 -1
- package/dist/sdk/core.js +3 -3
- package/dist/sdk/dependencies.js +5 -7
- package/dist/sdk/dependency-flag-validation.d.ts +1 -1
- package/dist/sdk/dependency-flag-validation.js +10 -4
- package/dist/sdk/environment/tracker-preflight.d.ts +6 -0
- package/dist/sdk/environment/tracker-preflight.js +10 -0
- package/dist/sdk/eval.js +5 -7
- package/dist/sdk/files.js +6 -10
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +110 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +179 -46
- package/dist/sdk/governance/assurance.d.ts +36 -2
- package/dist/sdk/governance/assurance.js +184 -10
- package/dist/sdk/governance/gc.js +5 -6
- package/dist/sdk/governance/health.js +5 -6
- package/dist/sdk/governance/reindex.js +5 -6
- package/dist/sdk/governance/validate.d.ts +1 -2
- package/dist/sdk/governance/validate.js +6 -12
- package/dist/sdk/graph/governance.d.ts +7 -5
- package/dist/sdk/graph/governance.js +32 -16
- package/dist/sdk/graph/run.js +5 -7
- package/dist/sdk/graph/traversal.js +14 -5
- package/dist/sdk/history-compact.js +6 -9
- package/dist/sdk/history-read.js +5 -7
- package/dist/sdk/history-redact.js +5 -6
- package/dist/sdk/history-repair.js +6 -9
- package/dist/sdk/improvement-ledger.js +7 -10
- package/dist/sdk/index.d.ts +7 -3
- package/dist/sdk/index.js +8 -4
- package/dist/sdk/init-agent-guidance.d.ts +5 -3
- package/dist/sdk/init-agent-guidance.js +69 -9
- package/dist/sdk/lifecycle/append.d.ts +0 -5
- package/dist/sdk/lifecycle/append.js +5 -6
- package/dist/sdk/lifecycle/claim.d.ts +0 -5
- package/dist/sdk/lifecycle/claim.js +6 -9
- package/dist/sdk/lifecycle/close-many.d.ts +0 -5
- package/dist/sdk/lifecycle/close-many.js +5 -6
- package/dist/sdk/lifecycle/close.d.ts +0 -5
- package/dist/sdk/lifecycle/close.js +5 -6
- package/dist/sdk/lifecycle/copy.d.ts +0 -5
- package/dist/sdk/lifecycle/copy.js +5 -6
- package/dist/sdk/lifecycle/create.d.ts +0 -5
- package/dist/sdk/lifecycle/create.js +5 -9
- package/dist/sdk/lifecycle/delete.js +5 -6
- package/dist/sdk/lifecycle/focus.d.ts +0 -5
- package/dist/sdk/lifecycle/focus.js +5 -6
- package/dist/sdk/lifecycle/mcp-actions.d.ts +18 -0
- package/dist/sdk/lifecycle/mcp-actions.js +52 -0
- package/dist/sdk/lifecycle/plan.d.ts +0 -5
- package/dist/sdk/lifecycle/plan.js +5 -6
- package/dist/sdk/lifecycle/reopen.d.ts +44 -0
- package/dist/sdk/lifecycle/reopen.js +69 -0
- package/dist/sdk/lifecycle/restore.js +5 -6
- package/dist/sdk/lifecycle/update-many.d.ts +0 -5
- package/dist/sdk/lifecycle/update-many.js +5 -6
- package/dist/sdk/lifecycle/update.d.ts +31 -5
- package/dist/sdk/lifecycle/update.js +140 -19
- package/dist/sdk/linked-artifacts.js +6 -7
- package/dist/sdk/merge/install.js +5 -6
- package/dist/sdk/mutation-events.js +5 -7
- package/dist/sdk/package-import-adapters.js +6 -8
- package/dist/sdk/profile.js +6 -7
- package/dist/sdk/query/activity.js +5 -6
- package/dist/sdk/query/calendar.js +5 -6
- package/dist/sdk/query/get.d.ts +1 -6
- package/dist/sdk/query/get.js +20 -55
- package/dist/sdk/query/history.d.ts +0 -5
- package/dist/sdk/query/history.js +5 -6
- package/dist/sdk/query/list.d.ts +7 -21
- package/dist/sdk/query/list.js +38 -54
- package/dist/sdk/query/projection-contracts.d.ts +33 -0
- package/dist/sdk/query/projection-contracts.js +185 -0
- package/dist/sdk/query/search-contracts.d.ts +2 -1
- package/dist/sdk/query/search-contracts.js +18 -87
- package/dist/sdk/query/search.d.ts +15 -0
- package/dist/sdk/query/search.js +34 -10
- package/dist/sdk/relationship-kinds/contract.d.ts +8 -0
- package/dist/sdk/relationship-kinds/contract.js +13 -13
- package/dist/sdk/relationships.d.ts +1 -1
- package/dist/sdk/relationships.js +20 -2
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime.d.ts +6 -0
- package/dist/sdk/runtime.js +18 -14
- package/dist/sdk/schema-migration.js +6 -7
- package/dist/sdk/schema.js +5 -6
- package/dist/sdk/similarity.d.ts +13 -0
- package/dist/sdk/similarity.js +32 -6
- package/dist/sdk/stats.js +5 -8
- package/dist/sdk/templates.js +5 -6
- package/dist/sdk/test/batch.js +5 -7
- package/dist/sdk/test/execution.js +4 -5
- package/dist/sdk/test/runs.js +5 -7
- package/docs/AGENT_UX_CONTRACTS.md +8 -1
- package/docs/COMMANDS.md +13 -1
- package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -1
- package/docs/README.md +1 -0
- package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +151 -0
- package/docs/RELATIONSHIP_GRAPH.md +92 -10
- package/docs/SDK.md +10 -2
- package/docs/SDK_CONTEXT_INTEGRITY.md +45 -0
- package/docs/SDK_PRIMITIVE_INVENTORY.md +15 -1
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
- package/docs/performance/sdk-entrypoint-import-costs.md +14 -21
- package/marketplace.json +2 -2
- package/package.json +5 -5
- 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 +640 -44
- package/dist/cli-bundle/chunks/chunk-4THEB6PD.js +0 -13
- package/dist/cli-bundle/chunks/chunk-GWMXAQOD.js +0 -197
- package/dist/cli-bundle/chunks/chunk-HVFQTLYM.js +0 -35
- package/dist/cli-bundle/chunks/chunk-OI4XI562.js +0 -5
- package/dist/cli-bundle/chunks/chunk-OIOKV6NO.js +0 -2092
- package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +0 -3
- package/dist/cli-bundle/chunks/chunk-YBMRWW4E.js +0 -77
- package/dist/cli-bundle/chunks/register-list-query-Y56KINDU.js +0 -11
- package/dist/cli-bundle/focused-chunks/chunk-34QBIYZI.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-BJRYFVSH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-EF6ZS5GH.js +0 -50
- package/dist/cli-bundle/focused-chunks/chunk-L623ZPNK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PRHY2IMX.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-RZU5U6Q7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-YBMGXBFV.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-YLVBJ6GF.js +0 -2
|
@@ -19,12 +19,33 @@
|
|
|
19
19
|
* MCP server, and returns the original reference unchanged when nothing is compacted.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
!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]="
|
|
22
|
+
!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]="a3e0573a-01fd-54fb-a568-51c5287b696c")}catch(e){}}();
|
|
23
23
|
const CHANGED_FIELDS_KEY = "changed_fields";
|
|
24
24
|
const CHANGED_FIELD_COUNT_KEY = "changed_field_count";
|
|
25
25
|
const ROWS_KEY = "rows";
|
|
26
26
|
const UPDATE_MANY_MUTATION_MODES = new Set(["apply", "rollback"]);
|
|
27
27
|
const DELETE_OUTCOMES = new Set(["deleted", "would_delete"]);
|
|
28
|
+
const COMPACT_RECURRENCE_TEXT_LIMIT = 256;
|
|
29
|
+
function truncateCompactRecurrenceText(value) {
|
|
30
|
+
if (typeof value !== "string" ||
|
|
31
|
+
value.length <= COMPACT_RECURRENCE_TEXT_LIMIT) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return `${value.slice(0, COMPACT_RECURRENCE_TEXT_LIMIT - 1)}…`;
|
|
35
|
+
}
|
|
36
|
+
function projectCompactRecurrence(value) {
|
|
37
|
+
if (!isPlainObject(value))
|
|
38
|
+
return null;
|
|
39
|
+
const recurrence = { ...value };
|
|
40
|
+
recurrence.reason = truncateCompactRecurrenceText(recurrence.reason);
|
|
41
|
+
if (isPlainObject(recurrence.previous_terminal)) {
|
|
42
|
+
recurrence.previous_terminal = Object.fromEntries(Object.entries(recurrence.previous_terminal).map(([key, entry]) => [
|
|
43
|
+
key,
|
|
44
|
+
truncateCompactRecurrenceText(entry),
|
|
45
|
+
]));
|
|
46
|
+
}
|
|
47
|
+
return recurrence;
|
|
48
|
+
}
|
|
28
49
|
function isPlainObject(value) {
|
|
29
50
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
30
51
|
return false;
|
|
@@ -123,6 +144,9 @@ function projectCompactMutationEnvelope(result) {
|
|
|
123
144
|
: undefined;
|
|
124
145
|
if (closeReason !== undefined)
|
|
125
146
|
compact.close_reason = closeReason;
|
|
147
|
+
const recurrence = projectCompactRecurrence(result.recurrence);
|
|
148
|
+
if (recurrence !== null)
|
|
149
|
+
compact.recurrence = recurrence;
|
|
126
150
|
if (Array.isArray(result.warnings) && result.warnings.length > 0)
|
|
127
151
|
compact.warnings = result.warnings;
|
|
128
152
|
return compact;
|
|
@@ -184,4 +208,4 @@ export function projectMutationResult(result, options = {}) {
|
|
|
184
208
|
return changed ? projected : result;
|
|
185
209
|
}
|
|
186
210
|
//# sourceMappingURL=mutation-projection.js.map
|
|
187
|
-
//# debugId=
|
|
211
|
+
//# debugId=a3e0573a-01fd-54fb-a568-51c5287b696c
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Provides shared primitives and utilities for Constants.
|
|
5
5
|
*/
|
|
6
6
|
import type { BuiltinItemType, GovernancePreset, GovernanceSettings, PmSettings, RuntimeStatusDefinition, RuntimeWorkflowDefinition } from "../../types/index.js";
|
|
7
|
+
export { ITEM_METADATA_KEY_ORDER, ITEM_PROJECT_CONTEXT_KEYS, } from "./item-metadata-contract.js";
|
|
7
8
|
/**
|
|
8
9
|
* Canonical default lifecycle status model and workflow role mapping.
|
|
9
10
|
*
|
|
@@ -28,10 +29,6 @@ export declare const PM_OPTIONAL_TYPE_SUBDIRS: readonly ["decisions", "events",
|
|
|
28
29
|
export declare const PM_REQUIRED_SUBDIRS: readonly ["", "epics", "features", "tasks", "chores", "issues", "schema", "history", "search", "extensions", "locks", "decisions", "events", "reminders", "milestones", "meetings", "plans"];
|
|
29
30
|
/** Public contract for type to folder, shared by SDK and presentation-layer consumers. */
|
|
30
31
|
export declare const TYPE_TO_FOLDER: Record<BuiltinItemType, string>;
|
|
31
|
-
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
32
|
-
export declare const ITEM_PROJECT_CONTEXT_KEYS: readonly ["goal", "objective", "value", "impact", "outcome", "why_now", "parent", "reviewer", "risk", "confidence", "sprint", "release", "blocked_by", "blocked_reason", "unblock_note", "reporter", "severity", "environment", "repro_steps", "resolution", "expected_result", "actual_result"];
|
|
33
|
-
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
34
|
-
export declare const ITEM_METADATA_KEY_ORDER: ReadonlyArray<string>;
|
|
35
32
|
type BuiltinGovernancePreset = Exclude<GovernancePreset, "custom">;
|
|
36
33
|
/** Public contract for governance preset defaults, shared by SDK and presentation-layer consumers. */
|
|
37
34
|
export declare const GOVERNANCE_PRESET_DEFAULTS: Record<BuiltinGovernancePreset, Omit<GovernanceSettings, "preset">>;
|
|
@@ -67,4 +64,3 @@ export type TelemetryErrorCategory = "usage" | "validation" | "conflict" | "runt
|
|
|
67
64
|
export declare const TELEMETRY_ERROR_CATEGORY_BY_CODE: Readonly<Record<string, TelemetryErrorCategory>>;
|
|
68
65
|
/** Implements resolve telemetry error category for the public runtime surface of this module. */
|
|
69
66
|
export declare function resolveTelemetryErrorCategory(errorCode: string | undefined): TelemetryErrorCategory;
|
|
70
|
-
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
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]="70cce114-b8a7-5770-ae42-eec473515709")}catch(e){}}();
|
|
3
3
|
import { createDefaultExtensionGovernancePolicy } from "../extensions/extension-types.js";
|
|
4
|
+
export { ITEM_METADATA_KEY_ORDER, ITEM_PROJECT_CONTEXT_KEYS, } from "./item-metadata-contract.js";
|
|
4
5
|
/**
|
|
5
6
|
* Canonical default lifecycle status model and workflow role mapping.
|
|
6
7
|
*
|
|
@@ -93,85 +94,6 @@ export const TYPE_TO_FOLDER = {
|
|
|
93
94
|
Meeting: "meetings",
|
|
94
95
|
Plan: "plans",
|
|
95
96
|
};
|
|
96
|
-
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
97
|
-
export const ITEM_PROJECT_CONTEXT_KEYS = [
|
|
98
|
-
"goal",
|
|
99
|
-
"objective",
|
|
100
|
-
"value",
|
|
101
|
-
"impact",
|
|
102
|
-
"outcome",
|
|
103
|
-
"why_now",
|
|
104
|
-
"parent",
|
|
105
|
-
"reviewer",
|
|
106
|
-
"risk",
|
|
107
|
-
"confidence",
|
|
108
|
-
"sprint",
|
|
109
|
-
"release",
|
|
110
|
-
"blocked_by",
|
|
111
|
-
"blocked_reason",
|
|
112
|
-
"unblock_note",
|
|
113
|
-
"reporter",
|
|
114
|
-
"severity",
|
|
115
|
-
"environment",
|
|
116
|
-
"repro_steps",
|
|
117
|
-
"resolution",
|
|
118
|
-
"expected_result",
|
|
119
|
-
"actual_result",
|
|
120
|
-
];
|
|
121
|
-
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
122
|
-
export const ITEM_METADATA_KEY_ORDER = [
|
|
123
|
-
"id",
|
|
124
|
-
"title",
|
|
125
|
-
"description",
|
|
126
|
-
"type",
|
|
127
|
-
"pm_format_version",
|
|
128
|
-
"source_type",
|
|
129
|
-
"type_options",
|
|
130
|
-
"status",
|
|
131
|
-
"priority",
|
|
132
|
-
"tags",
|
|
133
|
-
"created_at",
|
|
134
|
-
"updated_at",
|
|
135
|
-
"deadline",
|
|
136
|
-
"reminders",
|
|
137
|
-
"events",
|
|
138
|
-
"closed_at",
|
|
139
|
-
"completed_at",
|
|
140
|
-
"assignee",
|
|
141
|
-
"claim_principal",
|
|
142
|
-
"source_owner",
|
|
143
|
-
"author",
|
|
144
|
-
"estimated_minutes",
|
|
145
|
-
"acceptance_criteria",
|
|
146
|
-
"design",
|
|
147
|
-
"external_ref",
|
|
148
|
-
"definition_of_ready",
|
|
149
|
-
"order",
|
|
150
|
-
...ITEM_PROJECT_CONTEXT_KEYS,
|
|
151
|
-
"affected_version",
|
|
152
|
-
"fixed_version",
|
|
153
|
-
"component",
|
|
154
|
-
"regression",
|
|
155
|
-
"customer_impact",
|
|
156
|
-
"dependencies",
|
|
157
|
-
"comments",
|
|
158
|
-
"notes",
|
|
159
|
-
"learnings",
|
|
160
|
-
"files",
|
|
161
|
-
"tests",
|
|
162
|
-
"test_runs",
|
|
163
|
-
"docs",
|
|
164
|
-
"close_reason",
|
|
165
|
-
"duplicate_of",
|
|
166
|
-
"plan_mode",
|
|
167
|
-
"plan_scope",
|
|
168
|
-
"plan_harness",
|
|
169
|
-
"plan_resume_context",
|
|
170
|
-
"plan_validation",
|
|
171
|
-
"plan_decisions",
|
|
172
|
-
"plan_discoveries",
|
|
173
|
-
"plan_steps",
|
|
174
|
-
];
|
|
175
97
|
/** Public contract for governance preset defaults, shared by SDK and presentation-layer consumers. */
|
|
176
98
|
export const GOVERNANCE_PRESET_DEFAULTS = {
|
|
177
99
|
minimal: {
|
|
@@ -480,4 +402,4 @@ export function resolveTelemetryErrorCategory(errorCode) {
|
|
|
480
402
|
return "unknown";
|
|
481
403
|
}
|
|
482
404
|
//# sourceMappingURL=constants.js.map
|
|
483
|
-
//# debugId=
|
|
405
|
+
//# debugId=70cce114-b8a7-5770-ae42-eec473515709
|
|
@@ -79,6 +79,10 @@ export interface PmCliErrorContext {
|
|
|
79
79
|
check?: string;
|
|
80
80
|
/** Serialization format involved in a parse failure. */
|
|
81
81
|
format?: string;
|
|
82
|
+
/** CLI flag whose supplied value violated a shared mutation grammar. */
|
|
83
|
+
flag?: string;
|
|
84
|
+
/** Supplied scalar value that violated a shared mutation grammar. */
|
|
85
|
+
value?: string;
|
|
82
86
|
/** Item format version involved in a compatibility failure. */
|
|
83
87
|
format_version?: number;
|
|
84
88
|
/** Schema type that determines the shape and validation rules for this value. */
|
|
@@ -99,6 +103,18 @@ export interface PmCliErrorContext {
|
|
|
99
103
|
nextSteps?: string[];
|
|
100
104
|
/** Exact selectors that could not be matched by a lossless removal. */
|
|
101
105
|
unmatched?: string[];
|
|
106
|
+
/** Dependency selectors that matched no stored edge. */
|
|
107
|
+
unmatched_selectors?: Array<{
|
|
108
|
+
id: string;
|
|
109
|
+
kind?: string;
|
|
110
|
+
source_kind?: string;
|
|
111
|
+
}>;
|
|
112
|
+
/** Compact stored dependency identities available when a removal failed. */
|
|
113
|
+
available_dependencies?: Array<{
|
|
114
|
+
id: string;
|
|
115
|
+
kind: string;
|
|
116
|
+
source_kind?: string;
|
|
117
|
+
}>;
|
|
102
118
|
/** Exact verifier findings that caused an integrity-sensitive operation to refuse. */
|
|
103
119
|
verification_errors?: string[];
|
|
104
120
|
/** Local dependency targets that could not be resolved before mutation. */
|
|
@@ -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]="e8873345-5824-5832-9fa3-79719ddc6b58")}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=e8873345-5824-5832-9fa3-79719ddc6b58
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/shared/item-metadata-contract
|
|
3
|
+
*
|
|
4
|
+
* Declares the dependency-free canonical item metadata vocabulary shared by
|
|
5
|
+
* storage, query projections, generated contracts, and package consumers.
|
|
6
|
+
*/
|
|
7
|
+
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
8
|
+
export declare const ITEM_PROJECT_CONTEXT_KEYS: readonly ["goal", "objective", "value", "impact", "outcome", "why_now", "parent", "reviewer", "risk", "confidence", "sprint", "release", "blocked_by", "blocked_reason", "unblock_note", "reporter", "severity", "environment", "repro_steps", "resolution", "expected_result", "actual_result"];
|
|
9
|
+
declare const ITEM_METADATA_KEY_ORDER_VALUES: readonly ["id", "title", "description", "type", "pm_format_version", "source_type", "type_options", "status", "priority", "tags", "created_at", "updated_at", "deadline", "reminders", "events", "closed_at", "completed_at", "assignee", "claim_principal", "source_owner", "author", "estimated_minutes", "acceptance_criteria", "design", "external_ref", "definition_of_ready", "order", "goal", "objective", "value", "impact", "outcome", "why_now", "parent", "reviewer", "risk", "confidence", "sprint", "release", "blocked_by", "blocked_reason", "unblock_note", "reporter", "severity", "environment", "repro_steps", "resolution", "expected_result", "actual_result", "affected_version", "fixed_version", "component", "regression", "customer_impact", "dependencies", "comments", "notes", "learnings", "files", "tests", "test_runs", "docs", "close_reason", "duplicate_of", "plan_mode", "plan_scope", "plan_harness", "plan_resume_context", "plan_validation", "plan_decisions", "plan_discoveries", "plan_steps"];
|
|
10
|
+
/** Literal union of every canonical built-in item metadata key. */
|
|
11
|
+
export type ItemMetadataKey = (typeof ITEM_METADATA_KEY_ORDER_VALUES)[number];
|
|
12
|
+
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
13
|
+
export declare const ITEM_METADATA_KEY_ORDER: ReadonlyArray<string>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/shared/item-metadata-contract
|
|
3
|
+
*
|
|
4
|
+
* Declares the dependency-free canonical item metadata vocabulary shared by
|
|
5
|
+
* storage, query projections, generated contracts, and package consumers.
|
|
6
|
+
*/
|
|
7
|
+
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
8
|
+
|
|
9
|
+
!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]="27c5eac3-4580-5f6f-8ae9-b04d0281766d")}catch(e){}}();
|
|
10
|
+
export const ITEM_PROJECT_CONTEXT_KEYS = [
|
|
11
|
+
"goal",
|
|
12
|
+
"objective",
|
|
13
|
+
"value",
|
|
14
|
+
"impact",
|
|
15
|
+
"outcome",
|
|
16
|
+
"why_now",
|
|
17
|
+
"parent",
|
|
18
|
+
"reviewer",
|
|
19
|
+
"risk",
|
|
20
|
+
"confidence",
|
|
21
|
+
"sprint",
|
|
22
|
+
"release",
|
|
23
|
+
"blocked_by",
|
|
24
|
+
"blocked_reason",
|
|
25
|
+
"unblock_note",
|
|
26
|
+
"reporter",
|
|
27
|
+
"severity",
|
|
28
|
+
"environment",
|
|
29
|
+
"repro_steps",
|
|
30
|
+
"resolution",
|
|
31
|
+
"expected_result",
|
|
32
|
+
"actual_result",
|
|
33
|
+
];
|
|
34
|
+
const ITEM_METADATA_KEY_ORDER_VALUES = [
|
|
35
|
+
"id",
|
|
36
|
+
"title",
|
|
37
|
+
"description",
|
|
38
|
+
"type",
|
|
39
|
+
"pm_format_version",
|
|
40
|
+
"source_type",
|
|
41
|
+
"type_options",
|
|
42
|
+
"status",
|
|
43
|
+
"priority",
|
|
44
|
+
"tags",
|
|
45
|
+
"created_at",
|
|
46
|
+
"updated_at",
|
|
47
|
+
"deadline",
|
|
48
|
+
"reminders",
|
|
49
|
+
"events",
|
|
50
|
+
"closed_at",
|
|
51
|
+
"completed_at",
|
|
52
|
+
"assignee",
|
|
53
|
+
"claim_principal",
|
|
54
|
+
"source_owner",
|
|
55
|
+
"author",
|
|
56
|
+
"estimated_minutes",
|
|
57
|
+
"acceptance_criteria",
|
|
58
|
+
"design",
|
|
59
|
+
"external_ref",
|
|
60
|
+
"definition_of_ready",
|
|
61
|
+
"order",
|
|
62
|
+
...ITEM_PROJECT_CONTEXT_KEYS,
|
|
63
|
+
"affected_version",
|
|
64
|
+
"fixed_version",
|
|
65
|
+
"component",
|
|
66
|
+
"regression",
|
|
67
|
+
"customer_impact",
|
|
68
|
+
"dependencies",
|
|
69
|
+
"comments",
|
|
70
|
+
"notes",
|
|
71
|
+
"learnings",
|
|
72
|
+
"files",
|
|
73
|
+
"tests",
|
|
74
|
+
"test_runs",
|
|
75
|
+
"docs",
|
|
76
|
+
"close_reason",
|
|
77
|
+
"duplicate_of",
|
|
78
|
+
"plan_mode",
|
|
79
|
+
"plan_scope",
|
|
80
|
+
"plan_harness",
|
|
81
|
+
"plan_resume_context",
|
|
82
|
+
"plan_validation",
|
|
83
|
+
"plan_decisions",
|
|
84
|
+
"plan_discoveries",
|
|
85
|
+
"plan_steps",
|
|
86
|
+
];
|
|
87
|
+
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
88
|
+
export const ITEM_METADATA_KEY_ORDER = ITEM_METADATA_KEY_ORDER_VALUES;
|
|
89
|
+
//# sourceMappingURL=item-metadata-contract.js.map
|
|
90
|
+
//# debugId=27c5eac3-4580-5f6f-8ae9-b04d0281766d
|
|
@@ -50,6 +50,66 @@ declare function buildDidYouMeanSuggestions(pmRoot: string, badId: string, idPre
|
|
|
50
50
|
/** Implements build item not found error for the public runtime surface of this module. */
|
|
51
51
|
export declare function buildItemNotFoundError(pmRoot: string, badId: string, idPrefix: string, typeToFolder: Record<string, string>): Promise<PmCliError>;
|
|
52
52
|
declare function bypassesAssigneeConflict(op: string, bypassAssigneeConflict?: boolean): boolean;
|
|
53
|
+
interface ItemMutationResult {
|
|
54
|
+
item: ItemMetadata;
|
|
55
|
+
body: string;
|
|
56
|
+
changedFields: string[];
|
|
57
|
+
warnings: string[];
|
|
58
|
+
}
|
|
59
|
+
interface ItemMutationParams {
|
|
60
|
+
pmRoot: string;
|
|
61
|
+
settings: PmSettings;
|
|
62
|
+
id: string;
|
|
63
|
+
op: string;
|
|
64
|
+
author: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
/** Structured immutable context attached to the appended history entry. */
|
|
67
|
+
historyContext?: Record<string, unknown>;
|
|
68
|
+
force?: boolean;
|
|
69
|
+
bypassAssigneeConflict?: boolean;
|
|
70
|
+
skipNoop?: boolean;
|
|
71
|
+
extensionFieldNames?: readonly string[];
|
|
72
|
+
typeToFolder?: Record<string, string>;
|
|
73
|
+
mutate: (document: ItemDocument) => {
|
|
74
|
+
changedFields: string[];
|
|
75
|
+
warnings?: string[];
|
|
76
|
+
} | Promise<{
|
|
77
|
+
changedFields: string[];
|
|
78
|
+
warnings?: string[];
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/** Mutate one item while attaching structured context to its immutable history event. */
|
|
82
|
+
export declare function mutateItemWithHistoryContext(params: {
|
|
83
|
+
pmRoot: string;
|
|
84
|
+
settings: PmSettings;
|
|
85
|
+
id: string;
|
|
86
|
+
op: string;
|
|
87
|
+
author: string;
|
|
88
|
+
message?: string;
|
|
89
|
+
/** Structured immutable context attached to the appended history entry. */
|
|
90
|
+
historyContext?: Record<string, unknown>;
|
|
91
|
+
force?: boolean;
|
|
92
|
+
bypassAssigneeConflict?: boolean;
|
|
93
|
+
skipNoop?: boolean;
|
|
94
|
+
extensionFieldNames?: readonly string[];
|
|
95
|
+
typeToFolder?: Record<string, string>;
|
|
96
|
+
mutate: (document: ItemDocument) => {
|
|
97
|
+
changedFields: string[];
|
|
98
|
+
warnings?: string[];
|
|
99
|
+
} | Promise<{
|
|
100
|
+
changedFields: string[];
|
|
101
|
+
warnings?: string[];
|
|
102
|
+
}>;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
item: ItemMetadata;
|
|
105
|
+
body: string;
|
|
106
|
+
changedFields: string[];
|
|
107
|
+
warnings: string[];
|
|
108
|
+
}>;
|
|
109
|
+
/** Mutate one item while resolving structured history context after its locked mutation. */
|
|
110
|
+
export declare function mutateItemWithHistoryContextResolver(params: Omit<ItemMutationParams, "historyContext"> & {
|
|
111
|
+
resolveHistoryContext: () => Record<string, unknown> | undefined;
|
|
112
|
+
}): Promise<ItemMutationResult>;
|
|
53
113
|
/** Implements mutate item for the public runtime surface of this module. */
|
|
54
114
|
export declare function mutateItem(params: {
|
|
55
115
|
pmRoot: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Reads and writes tracker storage with format-aware helpers for Item Store.
|
|
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]="f49b5141-f348-5954-a87e-8fd957593113")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnReadHooks, runActiveBeforeMutationHooks, runActiveOnWriteHooks, runActiveServiceOverride, } from "../extensions/index.js";
|
|
@@ -20,8 +20,9 @@ import { acquireLock } from "../lock/lock.js";
|
|
|
20
20
|
import { writeFileAtomic } from "../fs/fs-utils.js";
|
|
21
21
|
import { normalizeItemId, normalizeRawItemId } from "../item/id.js";
|
|
22
22
|
import { acquireItemMetadataDerivedIndexLock, listAllDocumentCandidatesCached, listAllDocumentsCached, listAllDocumentsCachedLight, refreshItemMetadataDerivedIndex, } from "./item-metadata-cache.js";
|
|
23
|
-
import { getHistoryPath, getItemPath, ITEM_FILE_EXTENSIONS
|
|
23
|
+
import { getHistoryPath, getItemPath, ITEM_FILE_EXTENSIONS } from "./paths.js";
|
|
24
24
|
import { resolveGovernanceKnobs } from "./settings.js";
|
|
25
|
+
import { assertReadableTrackerRoot } from "./tracker-preflight.js";
|
|
25
26
|
import { resolveClaimPrincipal } from "../shared/author.js";
|
|
26
27
|
import { nowIso } from "../shared/time.js";
|
|
27
28
|
async function fileExists(targetPath) {
|
|
@@ -60,92 +61,6 @@ function resolveItemFormatSearchOrder(preferredFormat) {
|
|
|
60
61
|
}
|
|
61
62
|
return ["toon", "json_markdown"];
|
|
62
63
|
}
|
|
63
|
-
function trackerRootNotDirectoryError(pmRoot) {
|
|
64
|
-
return new PmCliError(`Tracker root is not a directory at ${pmRoot}.`, EXIT_CODE.USAGE, {
|
|
65
|
-
code: "tracker_root_not_directory",
|
|
66
|
-
reason: "not_a_directory",
|
|
67
|
-
nextSteps: [
|
|
68
|
-
"Pass the tracker directory itself, usually <workspace>/.agents/pm.",
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function trackerRootUnreadableError(pmRoot) {
|
|
73
|
-
return new PmCliError(`Tracker root is not readable at ${pmRoot}.`, EXIT_CODE.GENERIC_FAILURE, {
|
|
74
|
-
code: "tracker_root_unreadable",
|
|
75
|
-
reason: "unreadable",
|
|
76
|
-
nextSteps: [
|
|
77
|
-
"Grant read and directory-search permission to the tracker root, then retry the SDK read.",
|
|
78
|
-
],
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async function assertMissingMetadataRootAncestors(pmRoot) {
|
|
82
|
-
const filesystemRoot = path.parse(path.resolve(pmRoot)).root;
|
|
83
|
-
let ancestor = path.dirname(path.resolve(pmRoot));
|
|
84
|
-
while (ancestor !== filesystemRoot) {
|
|
85
|
-
let ancestorStats;
|
|
86
|
-
try {
|
|
87
|
-
ancestorStats = await fs.stat(ancestor);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
if (isErrno(error, "ENOTDIR")) {
|
|
91
|
-
throw trackerRootNotDirectoryError(pmRoot);
|
|
92
|
-
}
|
|
93
|
-
if (!isErrno(error, "ENOENT")) {
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
ancestor = path.dirname(ancestor);
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (!ancestorStats.isDirectory()) {
|
|
100
|
-
throw trackerRootNotDirectoryError(pmRoot);
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/** Require metadata enumeration to start from a real directory so an invalid source cannot masquerade as an empty tracker. */
|
|
106
|
-
async function assertItemMetadataRoot(pmRoot) {
|
|
107
|
-
let stats;
|
|
108
|
-
try {
|
|
109
|
-
stats = await fs.stat(pmRoot);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
if (isErrno(error, "ENOENT")) {
|
|
113
|
-
await assertMissingMetadataRootAncestors(pmRoot);
|
|
114
|
-
throw new PmCliError(`Tracker root does not exist at ${pmRoot}.`, EXIT_CODE.NOT_FOUND, {
|
|
115
|
-
code: "tracker_root_missing",
|
|
116
|
-
reason: "missing",
|
|
117
|
-
nextSteps: [
|
|
118
|
-
"Confirm the tracker root path and retry the SDK read.",
|
|
119
|
-
"Initialize a tracker before enumerating its item metadata.",
|
|
120
|
-
],
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (isErrno(error, "ENOTDIR")) {
|
|
124
|
-
throw trackerRootNotDirectoryError(pmRoot);
|
|
125
|
-
}
|
|
126
|
-
if (isErrno(error, "EACCES") || isErrno(error, "EPERM")) {
|
|
127
|
-
throw trackerRootUnreadableError(pmRoot);
|
|
128
|
-
}
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
if (!stats.isDirectory()) {
|
|
132
|
-
throw trackerRootNotDirectoryError(pmRoot);
|
|
133
|
-
}
|
|
134
|
-
if (process.platform !== "win32" &&
|
|
135
|
-
((stats.mode & 0o444) === 0 || (stats.mode & 0o111) === 0)) {
|
|
136
|
-
throw trackerRootUnreadableError(pmRoot);
|
|
137
|
-
}
|
|
138
|
-
try {
|
|
139
|
-
const directory = await fs.opendir(pmRoot);
|
|
140
|
-
await directory.close();
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (isErrno(error, "EACCES") || isErrno(error, "EPERM")) {
|
|
144
|
-
throw trackerRootUnreadableError(pmRoot);
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
64
|
/** Implements locate item for the public runtime surface of this module. */
|
|
150
65
|
export async function locateItem(pmRoot, rawId, idPrefix = "pm-", preferredFormat, typeToFolder = TYPE_TO_FOLDER) {
|
|
151
66
|
const normalizedId = normalizeItemId(rawId, idPrefix);
|
|
@@ -189,7 +104,7 @@ export async function readLocatedItem(item, options = {}) {
|
|
|
189
104
|
}
|
|
190
105
|
/** Implements list all item metadata for the public runtime surface of this module. */
|
|
191
106
|
export async function listAllItemMetadata(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
|
|
192
|
-
await
|
|
107
|
+
await assertReadableTrackerRoot(pmRoot);
|
|
193
108
|
const documents = await listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema);
|
|
194
109
|
return documents.map((document) => document.metadata);
|
|
195
110
|
}
|
|
@@ -200,13 +115,13 @@ export async function listAllItemMetadata(pmRoot, preferredFormat, typeToFolder
|
|
|
200
115
|
* read just the light scalar/small fields — see {@link listAllDocumentsCachedLight}.
|
|
201
116
|
*/
|
|
202
117
|
export async function listAllItemMetadataLight(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
|
|
203
|
-
await
|
|
118
|
+
await assertReadableTrackerRoot(pmRoot);
|
|
204
119
|
const documents = await listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema);
|
|
205
120
|
return documents.map((document) => document.metadata);
|
|
206
121
|
}
|
|
207
122
|
/** List item metadata with bodies, optionally bypassing the derived-index fast path when an integrity workflow must re-read authoritative files. */
|
|
208
123
|
export async function listAllItemMetadataWithBody(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema, options = {}) {
|
|
209
|
-
await
|
|
124
|
+
await assertReadableTrackerRoot(pmRoot);
|
|
210
125
|
const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
|
|
211
126
|
includeBody: true,
|
|
212
127
|
forceSourceScan: options.forceSourceScan,
|
|
@@ -377,8 +292,7 @@ async function rollbackMutatedItemWrite(params) {
|
|
|
377
292
|
}
|
|
378
293
|
await writeFileAtomic(params.originalItemPath, params.originalRaw);
|
|
379
294
|
}
|
|
380
|
-
|
|
381
|
-
export async function mutateItem(params) {
|
|
295
|
+
async function mutateItemWithDeferredHistoryContext(params) {
|
|
382
296
|
const prepared = await prepareLockedItem({
|
|
383
297
|
pmRoot: params.pmRoot,
|
|
384
298
|
settings: params.settings,
|
|
@@ -409,6 +323,7 @@ export async function mutateItem(params) {
|
|
|
409
323
|
warnings: [...parseWarnings, ...(mutation.warnings ?? [])],
|
|
410
324
|
};
|
|
411
325
|
}
|
|
326
|
+
const historyContext = params.resolveHistoryContext?.();
|
|
412
327
|
mutableDocument.metadata.updated_at = nowIso();
|
|
413
328
|
const afterDocument = canonicalDocument(mutableDocument, {
|
|
414
329
|
schema: params.settings.schema,
|
|
@@ -469,6 +384,7 @@ export async function mutateItem(params) {
|
|
|
469
384
|
before: beforeDocument,
|
|
470
385
|
after: afterDocument,
|
|
471
386
|
message: params.message,
|
|
387
|
+
context: historyContext,
|
|
472
388
|
});
|
|
473
389
|
try {
|
|
474
390
|
await appendHistoryEntry(historyPath, entry);
|
|
@@ -547,6 +463,22 @@ export async function mutateItem(params) {
|
|
|
547
463
|
await releaseLock();
|
|
548
464
|
}
|
|
549
465
|
}
|
|
466
|
+
/** Mutate one item while attaching structured context to its immutable history event. */
|
|
467
|
+
export async function mutateItemWithHistoryContext(params) {
|
|
468
|
+
const { historyContext, ...mutationParams } = params;
|
|
469
|
+
return mutateItemWithDeferredHistoryContext({
|
|
470
|
+
...mutationParams,
|
|
471
|
+
resolveHistoryContext: () => historyContext,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/** Mutate one item while resolving structured history context after its locked mutation. */
|
|
475
|
+
export async function mutateItemWithHistoryContextResolver(params) {
|
|
476
|
+
return mutateItemWithDeferredHistoryContext(params);
|
|
477
|
+
}
|
|
478
|
+
/** Mutate one item through the compatibility overload while preserving transactional storage and immutable history semantics. */
|
|
479
|
+
export async function mutateItem(params) {
|
|
480
|
+
return mutateItemWithDeferredHistoryContext(params);
|
|
481
|
+
}
|
|
550
482
|
/** Public contract for item store test only, shared by SDK and presentation-layer consumers. */
|
|
551
483
|
export const itemStoreTestOnly = {
|
|
552
484
|
appendWarning,
|
|
@@ -710,4 +642,4 @@ export async function deleteItem(params) {
|
|
|
710
642
|
}
|
|
711
643
|
}
|
|
712
644
|
//# sourceMappingURL=item-store.js.map
|
|
713
|
-
//# debugId=
|
|
645
|
+
//# debugId=f49b5141-f348-5954-a87e-8fd957593113
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PmCliErrorRecoveryPayload } from "../shared/errors.js";
|
|
2
|
+
/** Build the non-interactive, tokenized retry that initializes a selected tracker root. */
|
|
3
|
+
export declare function buildTrackerInitializationRecovery(pmRoot: string): PmCliErrorRecoveryPayload;
|
|
4
|
+
/** Require a tracker root to be a readable directory without requiring initialized settings. */
|
|
5
|
+
export declare function assertReadableTrackerRoot(pmRoot: string): Promise<void>;
|
|
6
|
+
/** Require the selected tracker root and its settings marker before an SDK command reads or mutates project state. */
|
|
7
|
+
export declare function assertInitializedTracker(pmRoot: string): Promise<void>;
|