@unbrained/pm-cli 2026.8.10 → 2026.8.12
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 +153 -100
- package/dist/cli/commander-usage.js +113 -15
- package/dist/cli/error-guidance.d.ts +12 -0
- package/dist/cli/error-guidance.js +147 -29
- package/dist/cli/main.js +38 -19
- package/dist/cli/register-annotations.js +56 -3
- package/dist/cli/register-assurance.d.ts +8 -0
- package/dist/cli/register-assurance.js +52 -0
- package/dist/cli/register-files-lookup.js +14 -3
- package/dist/cli/register-list-query.js +10 -7
- package/dist/cli/register-mutation.js +30 -9
- package/dist/cli/register-operations.js +30 -15
- package/dist/cli-bundle/bundle-manifest.json +155 -155
- package/dist/cli-bundle/chunks/{chunk-TRWXF476.js → chunk-3PS7X6GS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7KL6KMWF.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-EBO7OUUE.js → chunk-BM5YJ2UW.js} +69 -55
- package/dist/cli-bundle/chunks/chunk-D55A5AEN.js +33 -0
- package/dist/cli-bundle/chunks/chunk-KIKDWECH.js +196 -0
- package/dist/cli-bundle/chunks/{chunk-ETML5C6H.js → chunk-KOQMGCTA.js} +47 -47
- package/dist/cli-bundle/chunks/chunk-R76342NV.js +2 -0
- package/dist/cli-bundle/chunks/chunk-RBTK5EZV.js +5 -0
- package/dist/cli-bundle/chunks/chunk-VLUQOIDT.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WLAHPSOX.js +3 -0
- package/dist/cli-bundle/chunks/register-list-query-XPCJRUUD.js +10 -0
- package/dist/cli-bundle/chunks/register-mutation-4RJCBKRS.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-2OGISOVR.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-S3KT2LTH.js → register-setup-LLHAKP2V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2DALMVF7.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-5OQIMELN.js +155 -0
- package/dist/cli-bundle/focused-chunks/chunk-5TAGTDRE.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ECADZMVC.js +18 -0
- package/dist/cli-bundle/focused-chunks/chunk-EJGXRA6B.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FFGSZCPK.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IW43E4XL.js → chunk-GQW4BPUT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ISKOBJCM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-75774JWP.js → chunk-JAFRIWVF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2COZ67XT.js → chunk-KHM2CS2C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-M6RPIXKC.js → chunk-KPSXVBDV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-34SX654S.js → chunk-KTLOKKCQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-LGYK3NUF.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2EXI2DKR.js → chunk-NBLUKITQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NYLOUPOB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Q4T463SD.js +31 -0
- package/dist/cli-bundle/focused-chunks/chunk-QVZVY53N.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DZGAHZZV.js → chunk-RWPAWUOT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UTEWXDEQ.js +17 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7UN6BHHO.js → chunk-YIAXMC3T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZMGWAYH7.js +2 -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 +41 -39
- 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/extensions/reserved-host-flags.js +3 -2
- package/dist/core/history/drift-scan.js +13 -8
- 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/output/output.d.ts +2 -0
- package/dist/core/output/output.js +46 -14
- package/dist/core/session/session-state.d.ts +47 -0
- package/dist/core/session/session-state.js +207 -6
- package/dist/core/shared/author.d.ts +7 -1
- package/dist/core/shared/author.js +66 -46
- 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 +13 -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 +14 -7
- package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
- package/dist/sdk/agent/refusal-reachability.js +72 -0
- package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
- package/dist/sdk/agent/subcommand-recovery.js +84 -0
- package/dist/sdk/cli-bootstrap.d.ts +10 -0
- package/dist/sdk/cli-bootstrap.js +11 -7
- package/dist/sdk/cli-contracts/completeness.js +14 -3
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +20 -2
- 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/runtime-contracts.js +4 -3
- package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +515 -0
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +252 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +99 -2
- package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
- package/dist/sdk/cli-contracts/tool-schema.js +38 -5
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +23 -8
- package/dist/sdk/config.js +9 -3
- package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
- package/dist/sdk/context/semantic-session-attribution.js +83 -0
- package/dist/sdk/context-intent-contracts.js +45 -4
- package/dist/sdk/core-governance.d.ts +3 -1
- package/dist/sdk/core-governance.js +5 -3
- package/dist/sdk/core.d.ts +2 -1
- package/dist/sdk/core.js +3 -2
- package/dist/sdk/error-code-catalog.d.ts +13 -0
- package/dist/sdk/error-code-catalog.js +35 -2
- package/dist/sdk/extension.js +18 -17
- package/dist/sdk/files.d.ts +11 -0
- package/dist/sdk/files.js +82 -24
- 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 +1585 -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 -3121
- package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
- package/dist/sdk/governance/assurance-action-contracts.js +5 -0
- package/dist/sdk/governance/assurance-action.d.ts +70 -0
- package/dist/sdk/governance/assurance-action.js +200 -0
- package/dist/sdk/governance/assurance-limits.d.ts +7 -0
- package/dist/sdk/governance/assurance-limits.js +11 -0
- package/dist/sdk/governance/assurance-mutation-error.d.ts +7 -0
- package/dist/sdk/governance/assurance-mutation-error.js +35 -0
- package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
- package/dist/sdk/governance/assurance-runtime.js +134 -0
- package/dist/sdk/governance/assurance.d.ts +438 -0
- package/dist/sdk/governance/assurance.js +804 -0
- package/dist/sdk/governance/health.d.ts +3 -1
- package/dist/sdk/governance/health.js +21 -4
- 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 +13 -3
- package/dist/sdk/graph/durable-cache.d.ts +1 -1
- package/dist/sdk/graph/durable-cache.js +98 -29
- package/dist/sdk/graph/governance.d.ts +14 -0
- package/dist/sdk/graph/governance.js +34 -9
- package/dist/sdk/graph/run.js +8 -3
- package/dist/sdk/index.d.ts +7 -2
- package/dist/sdk/index.js +9 -4
- package/dist/sdk/lifecycle/claim.js +26 -4
- package/dist/sdk/lifecycle/focus.js +13 -3
- package/dist/sdk/lifecycle/plan.js +8 -3
- package/dist/sdk/merge/driver.d.ts +2 -2
- package/dist/sdk/merge/driver.js +3 -3
- 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/provenance.d.ts +38 -0
- package/dist/sdk/provenance.js +64 -2
- package/dist/sdk/query/activity.d.ts +49 -2
- package/dist/sdk/query/activity.js +183 -37
- package/dist/sdk/query/context.js +19 -8
- 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/runtime-extended-actions.js +22 -5
- package/dist/sdk/runtime-primitives.d.ts +5 -3
- package/dist/sdk/runtime-primitives.js +7 -5
- package/dist/sdk/runtime-stats-options.js +3 -2
- package/dist/sdk/runtime.d.ts +4 -0
- package/dist/sdk/runtime.js +34 -34
- package/dist/sdk/stats.d.ts +36 -3
- package/dist/sdk/stats.js +55 -15
- package/dist/sdk/telemetry.js +7 -4
- package/dist/sdk/test/execution.d.ts +4 -0
- package/dist/sdk/test/execution.js +86 -21
- package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
- package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
- package/dist/sdk/traceability/source-traceability.d.ts +102 -0
- package/dist/sdk/traceability/source-traceability.js +293 -0
- package/dist/types.d.ts +10 -2
- package/dist/types.js +2 -2
- package/docs/ASSURANCE.md +137 -0
- package/docs/COMMANDS.md +29 -8
- package/docs/CONFIGURATION.md +7 -0
- package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
- package/docs/MERGE_SAFETY.md +3 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
- package/docs/README.md +3 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
- package/docs/RELEASING.md +9 -5
- package/docs/SDK.md +12 -1
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +52 -5
- package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
- package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
- package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
- package/docs/TESTING.md +12 -9
- package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
- package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
- package/marketplace.json +2 -2
- package/package.json +7 -7
- 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/extensions/templates/index.ts +9 -3
- 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 +1030 -67
- package/dist/cli-bundle/chunks/chunk-2QYH4QMI.js +0 -30
- package/dist/cli-bundle/chunks/chunk-JUDU4RO4.js +0 -194
- package/dist/cli-bundle/chunks/chunk-JZSNADRR.js +0 -5
- package/dist/cli-bundle/chunks/chunk-MENWVGJW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S4EITGLA.js +0 -3
- package/dist/cli-bundle/chunks/chunk-TIGKWVLA.js +0 -13
- package/dist/cli-bundle/chunks/chunk-TSLDTJLQ.js +0 -2
- package/dist/cli-bundle/chunks/register-list-query-OJ6ZXKV4.js +0 -10
- package/dist/cli-bundle/chunks/register-mutation-DKI7QC7O.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-P5OGMT6I.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-36FTZ2NT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3CQECMKR.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-CHIBMEZR.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-FF4MNAYB.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-GHTN2ILR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-I4YM2I7S.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IMDTEN7K.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-JMVA4HKR.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-KR5RVXLQ.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-KSNJG4KI.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-MXYSIQ56.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-RIIN5V4N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RKWSCYYN.js +0 -2
package/dist/sdk/extension.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm extension 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]="8b0fbe09-2221-5b8e-8712-90a83df19306")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { activateExtensions, createSerialQueue, loadExtensions, nextExtensionReloadToken, } from "../core/extensions/index.js";
|
|
@@ -20,6 +20,7 @@ import { nowIso } from "../core/shared/time.js";
|
|
|
20
20
|
import { resolveGlobalPmRoot, resolvePmRoot } from "../core/store/paths.js";
|
|
21
21
|
import { readSettings, writeSettings } from "../core/store/settings.js";
|
|
22
22
|
import { quoteCommandArg, renderPmCommand } from "./command-line.js";
|
|
23
|
+
import { createUnknownSubcommandError } from "./agent/subcommand-recovery.js";
|
|
23
24
|
import { ensureTypeFolderScaffold } from "./schema.js";
|
|
24
25
|
// Cohesive helper groups now live in ./extension/* sibling modules. They are
|
|
25
26
|
// imported for the command wiring that stays here and re-exported below so
|
|
@@ -321,21 +322,21 @@ const buildUnknownLifecycleActionError = (target, options) => {
|
|
|
321
322
|
return new PmCliError(`One action flag is required. Use one of: ${LIFECYCLE_ACTION_FLAG_HINT}. Bare \`pm package\` and \`pm extension\` default to --explore.`, EXIT_CODE.USAGE);
|
|
322
323
|
}
|
|
323
324
|
const command = `pm ${noun} ${suggestion.flag}`;
|
|
324
|
-
return
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
325
|
+
return createUnknownSubcommandError({
|
|
326
|
+
command_path: noun,
|
|
327
|
+
display_name: `${noun} lifecycle`,
|
|
328
|
+
token_kind: "action",
|
|
329
|
+
token: target,
|
|
330
|
+
allowed: Object.keys(IMPLICIT_EXTENSION_ACTIONS),
|
|
331
|
+
retry_command: command,
|
|
332
|
+
message_suffix: `. Did you mean "${suggestion.flag}"?`,
|
|
333
|
+
fallback_candidates: [
|
|
334
|
+
{
|
|
335
|
+
source: "lifecycle_action",
|
|
336
|
+
command,
|
|
337
|
+
reason: `nearest lifecycle action for "${target}"`,
|
|
338
|
+
},
|
|
339
|
+
],
|
|
339
340
|
});
|
|
340
341
|
};
|
|
341
342
|
// Maps each boolean action flag to the lifecycle action it selects. `scaffold`
|
|
@@ -2190,4 +2191,4 @@ export const _testOnly = {
|
|
|
2190
2191
|
withExtensionInstallLock,
|
|
2191
2192
|
};
|
|
2192
2193
|
//# sourceMappingURL=extension.js.map
|
|
2193
|
-
//# debugId=
|
|
2194
|
+
//# debugId=8b0fbe09-2221-5b8e-8712-90a83df19306
|
package/dist/sdk/files.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GlobalOptions } from "../core/shared/command-types.js";
|
|
2
2
|
import type { ItemDocument, LinkedFile, LinkScope } from "../types/index.js";
|
|
3
3
|
import { type LinkedPathValidation } from "./linked-artifacts.js";
|
|
4
|
+
import { type SourceLineRange, type SourceTraceabilityExplanation, type SourceTraceabilityReceipt } from "./traceability/source-traceability.js";
|
|
4
5
|
/** Documents the files command options payload exchanged by command, SDK, and package integrations. */
|
|
5
6
|
export interface FilesCommandOptions {
|
|
6
7
|
/** Value that configures or reports add for this contract. */
|
|
@@ -112,6 +113,12 @@ export interface FilesLookupOptions {
|
|
|
112
113
|
noTruncate?: boolean;
|
|
113
114
|
/** Fail when any authoritative item cannot be read. */
|
|
114
115
|
strictRead?: boolean;
|
|
116
|
+
/** Include rationale, governing-decision paths, and ambiguity receipts. */
|
|
117
|
+
explain?: boolean;
|
|
118
|
+
/** Optional inclusive line range; implies explain and requires one path. */
|
|
119
|
+
lineRange?: SourceLineRange;
|
|
120
|
+
/** Maximum relationship depth searched for a governing decision. */
|
|
121
|
+
decisionDepth?: number;
|
|
115
122
|
}
|
|
116
123
|
/** Token-efficient item identity returned by reverse linked-file lookup. */
|
|
117
124
|
export interface FilesLookupItem {
|
|
@@ -134,6 +141,8 @@ export interface FilesLookupMatch {
|
|
|
134
141
|
item: FilesLookupItem;
|
|
135
142
|
/** Matching linked-file evidence. */
|
|
136
143
|
files: LinkedFile[];
|
|
144
|
+
/** Optional bounded rationale and line-attribution explanation. */
|
|
145
|
+
traceability?: SourceTraceabilityExplanation;
|
|
137
146
|
}
|
|
138
147
|
/** Reverse linked-file lookup result with bounded output and read provenance. */
|
|
139
148
|
export interface FilesLookupResult {
|
|
@@ -160,6 +169,8 @@ export interface FilesLookupResult {
|
|
|
160
169
|
warnings: string[];
|
|
161
170
|
/** Ordered reverse-traceability matches. */
|
|
162
171
|
matches: FilesLookupMatch[];
|
|
172
|
+
/** Aggregate receipt for an explained source query. */
|
|
173
|
+
traceability_receipt?: SourceTraceabilityReceipt;
|
|
163
174
|
}
|
|
164
175
|
interface TextReference {
|
|
165
176
|
field: string;
|
package/dist/sdk/files.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm files 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]="515cd35c-8e0e-51d4-8ad9-1cea5be8a572")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { pathExists } from "../core/fs/fs-utils.js";
|
|
@@ -20,6 +20,7 @@ import { readSettings } from "../core/store/settings.js";
|
|
|
20
20
|
import { resolveAuthor } from "../core/shared/author.js";
|
|
21
21
|
import { isPathWithinDirectory } from "../core/fs/path-utils.js";
|
|
22
22
|
import { dedupeLinkedArtifacts, normalizeLinkedPath, renameArtifactsResultKey, runLinkedArtifacts, sortLinkedArtifacts, } from "./linked-artifacts.js";
|
|
23
|
+
import { explainSourceTraceability, } from "./traceability/source-traceability.js";
|
|
23
24
|
/** Bounds fuzzy relative-path scanning while preserving full absolute-path discovery. */
|
|
24
25
|
const RELATIVE_REFERENCE_SCAN_MAX_CHARS = 32_768;
|
|
25
26
|
function normalizeCandidatePathForOutput(value) {
|
|
@@ -251,8 +252,51 @@ function projectFilesLookupItem(item) {
|
|
|
251
252
|
updated_at: item.updated_at,
|
|
252
253
|
};
|
|
253
254
|
}
|
|
255
|
+
function compareFilesLookupCandidates(left, right) {
|
|
256
|
+
const byPriority = left.item.priority - right.item.priority;
|
|
257
|
+
if (byPriority !== 0)
|
|
258
|
+
return byPriority;
|
|
259
|
+
const byUpdated = right.item.updated_at.localeCompare(left.item.updated_at);
|
|
260
|
+
return byUpdated === 0
|
|
261
|
+
? left.item.id.localeCompare(right.item.id)
|
|
262
|
+
: byUpdated;
|
|
263
|
+
}
|
|
264
|
+
function matchingFilesLookupCandidates(params) {
|
|
265
|
+
return params.metadata
|
|
266
|
+
.map((item) => ({
|
|
267
|
+
item,
|
|
268
|
+
files: (item.files ?? [])
|
|
269
|
+
.filter((file) => params.paths.includes(normalizeLinkedPath(file.path)) &&
|
|
270
|
+
(params.scope === undefined || file.scope === params.scope))
|
|
271
|
+
.sort((left, right) => {
|
|
272
|
+
const byPath = left.path.localeCompare(right.path);
|
|
273
|
+
return byPath === 0 ? left.scope.localeCompare(right.scope) : byPath;
|
|
274
|
+
}),
|
|
275
|
+
}))
|
|
276
|
+
.filter((match) => match.files.length > 0)
|
|
277
|
+
.sort(compareFilesLookupCandidates);
|
|
278
|
+
}
|
|
279
|
+
async function resolveFilesLookupTraceability(params) {
|
|
280
|
+
if (!params.explain)
|
|
281
|
+
return undefined;
|
|
282
|
+
return explainSourceTraceability({
|
|
283
|
+
workspaceRoot: params.workspaceRoot,
|
|
284
|
+
paths: params.paths,
|
|
285
|
+
candidates: params.matching,
|
|
286
|
+
corpus: params.metadata,
|
|
287
|
+
...(params.lineRange ? { lineRange: params.lineRange } : {}),
|
|
288
|
+
...(params.decisionDepth === undefined
|
|
289
|
+
? {}
|
|
290
|
+
: { decisionDepth: params.decisionDepth }),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
254
293
|
async function queryFilesLookupIndex(params) {
|
|
255
|
-
if ([
|
|
294
|
+
if ([
|
|
295
|
+
params.strictRead,
|
|
296
|
+
params.noTruncate,
|
|
297
|
+
params.explain,
|
|
298
|
+
hasActiveOnReadHooks(),
|
|
299
|
+
].includes(true)) {
|
|
256
300
|
return null;
|
|
257
301
|
}
|
|
258
302
|
const indexState = await readItemMetadataDerivedIndexState(params.pmRoot, [
|
|
@@ -272,32 +316,34 @@ async function queryFilesLookupIndex(params) {
|
|
|
272
316
|
async function queryFilesLookupSource(params) {
|
|
273
317
|
const warnings = [];
|
|
274
318
|
const metadata = await listAllItemMetadata(params.pmRoot, params.settings.item_format, params.typeToFolder, warnings, params.settings.schema);
|
|
275
|
-
const matching =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
.filter((file) => params.paths.includes(normalizeLinkedPath(file.path)) &&
|
|
280
|
-
(params.scope === undefined || file.scope === params.scope))
|
|
281
|
-
.sort((left, right) => {
|
|
282
|
-
const byPath = left.path.localeCompare(right.path);
|
|
283
|
-
return byPath === 0 ? left.scope.localeCompare(right.scope) : byPath;
|
|
284
|
-
}),
|
|
285
|
-
}))
|
|
286
|
-
.filter((match) => match.files.length > 0)
|
|
287
|
-
.sort((left, right) => {
|
|
288
|
-
const byPriority = left.item.priority - right.item.priority;
|
|
289
|
-
if (byPriority !== 0)
|
|
290
|
-
return byPriority;
|
|
291
|
-
const byUpdated = right.item.updated_at.localeCompare(left.item.updated_at);
|
|
292
|
-
return byUpdated === 0
|
|
293
|
-
? left.item.id.localeCompare(right.item.id)
|
|
294
|
-
: byUpdated;
|
|
319
|
+
const matching = matchingFilesLookupCandidates({
|
|
320
|
+
metadata,
|
|
321
|
+
paths: params.paths,
|
|
322
|
+
scope: params.scope,
|
|
295
323
|
});
|
|
296
324
|
const readWarnings = warnings.filter((warning) => /^item_list_(?:item|directory)_read_failed:/u.test(warning));
|
|
297
325
|
if (params.strictRead && readWarnings.length > 0) {
|
|
298
326
|
throw new PmCliError(`Files lookup could not read every item: ${readWarnings.join("; ")}`, EXIT_CODE.GENERIC_FAILURE);
|
|
299
327
|
}
|
|
300
|
-
const
|
|
328
|
+
const traceability = await resolveFilesLookupTraceability({
|
|
329
|
+
explain: params.explain,
|
|
330
|
+
workspaceRoot: params.workspaceRoot,
|
|
331
|
+
paths: params.paths,
|
|
332
|
+
matching,
|
|
333
|
+
metadata,
|
|
334
|
+
lineRange: params.lineRange,
|
|
335
|
+
decisionDepth: params.decisionDepth,
|
|
336
|
+
});
|
|
337
|
+
const ranked = traceability
|
|
338
|
+
? [...matching].sort((left, right) => {
|
|
339
|
+
const byScore = traceability.explanations.get(right.item.id).score -
|
|
340
|
+
traceability.explanations.get(left.item.id).score;
|
|
341
|
+
if (byScore !== 0)
|
|
342
|
+
return byScore;
|
|
343
|
+
return compareFilesLookupCandidates(left, right);
|
|
344
|
+
})
|
|
345
|
+
: matching;
|
|
346
|
+
const page = ranked.slice(params.offset, params.limit === undefined ? undefined : params.offset + params.limit);
|
|
301
347
|
return {
|
|
302
348
|
paths: params.paths,
|
|
303
349
|
total: matching.length,
|
|
@@ -314,7 +360,11 @@ async function queryFilesLookupSource(params) {
|
|
|
314
360
|
matches: page.map((match) => ({
|
|
315
361
|
item: projectFilesLookupItem(match.item),
|
|
316
362
|
files: match.files,
|
|
363
|
+
...(traceability
|
|
364
|
+
? { traceability: traceability.explanations.get(match.item.id) }
|
|
365
|
+
: {}),
|
|
317
366
|
})),
|
|
367
|
+
...(traceability ? { traceability_receipt: traceability.receipt } : {}),
|
|
318
368
|
};
|
|
319
369
|
}
|
|
320
370
|
/** Resolve the pm items that reference one or more source paths. */
|
|
@@ -325,6 +375,9 @@ export async function runFilesLookup(options, global) {
|
|
|
325
375
|
throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
|
|
326
376
|
}
|
|
327
377
|
const paths = await normalizeFilesLookupPaths(options.paths, workspaceRoot);
|
|
378
|
+
if (options.lineRange && paths.length !== 1) {
|
|
379
|
+
throw new PmCliError("Files lookup line attribution requires exactly one source path.", EXIT_CODE.USAGE);
|
|
380
|
+
}
|
|
328
381
|
const settings = await readSettings(pmRoot);
|
|
329
382
|
const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
|
|
330
383
|
const { offset, limit } = resolveFilesLookupWindow(options);
|
|
@@ -337,6 +390,7 @@ export async function runFilesLookup(options, global) {
|
|
|
337
390
|
offset,
|
|
338
391
|
strictRead: options.strictRead === true,
|
|
339
392
|
noTruncate: options.noTruncate === true,
|
|
393
|
+
explain: options.explain === true || options.lineRange !== undefined,
|
|
340
394
|
});
|
|
341
395
|
if (indexed) {
|
|
342
396
|
return {
|
|
@@ -364,6 +418,10 @@ export async function runFilesLookup(options, global) {
|
|
|
364
418
|
limit,
|
|
365
419
|
offset,
|
|
366
420
|
strictRead: options.strictRead === true,
|
|
421
|
+
workspaceRoot,
|
|
422
|
+
explain: options.explain === true || options.lineRange !== undefined,
|
|
423
|
+
lineRange: options.lineRange,
|
|
424
|
+
decisionDepth: options.decisionDepth,
|
|
367
425
|
});
|
|
368
426
|
}
|
|
369
427
|
/** Implements run files discover for the public runtime surface of this module. */
|
|
@@ -479,4 +537,4 @@ export async function runFilesDiscover(id, options, global) {
|
|
|
479
537
|
};
|
|
480
538
|
}
|
|
481
539
|
//# sourceMappingURL=files.js.map
|
|
482
|
-
//# debugId=
|
|
540
|
+
//# debugId=515cd35c-8e0e-51d4-8ad9-1cea5be8a572
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/generated-error-code-catalog-part-1
|
|
3
|
+
*
|
|
4
|
+
* Generated by scripts/generate-error-code-catalog.mjs. Do not edit manually.
|
|
5
|
+
*/
|
|
6
|
+
import type { PmErrorCodeContract } from "../error-code-catalog.js";
|
|
7
|
+
/** Generated partition 1 of the exhaustive error-code catalog. */
|
|
8
|
+
export declare const PM_ERROR_CODE_CATALOG_PART_1: PmErrorCodeContract[];
|