@unbrained/pm-cli 2026.9.25 → 2026.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/README.md +1 -0
- package/.agents/skills/pm-developer/SKILL.md +3 -0
- package/.agents/skills/pm-test-audit/LICENSE.txt +21 -0
- package/.agents/skills/pm-test-audit/SKILL.md +103 -0
- package/.agents/skills/pm-test-audit/references/AUDIT.md +54 -0
- package/.agents/skills/pm-test-audit/references/CAMPAIGN.md +47 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +28 -1
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.js +1 -1
- package/dist/cli/main.js +2 -2
- package/dist/cli/register-list-query.js +2 -2
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/selection.d.ts +3 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli/schema/registration.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +155 -147
- package/dist/cli-bundle/chunks/chunk-3BTJ66CB.js +238 -0
- package/dist/cli-bundle/chunks/{chunk-5AP67ZXH.js → chunk-4SLLCDFL.js} +39 -39
- package/dist/cli-bundle/chunks/{chunk-GAU55CWI.js → chunk-4UPZLUT2.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-25KTCTBL.js → chunk-6OJVQ7SW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-445ARBKY.js → chunk-7TAGYNFP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GOWZEBTH.js → chunk-AUS6USO4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YDIGMRLZ.js → chunk-IEP3VAT5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3IB4THWX.js → chunk-JX6WCCHL.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-LC6WEA5U.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CZ3VJJEA.js → chunk-LKGQUZ5M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-P7ZSJOWH.js → chunk-OKVDVERQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-COFQCKF4.js → chunk-TSF2LPIH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YABJDOOX.js → chunk-V5UGBYHN.js} +3 -3
- package/dist/cli-bundle/chunks/{register-list-query-IZ7ZVTDE.js → register-list-query-6PAJ4PBU.js} +4 -4
- package/dist/cli-bundle/chunks/{register-mutation-IPAZTFDZ.js → register-mutation-RZCXZXYS.js} +4 -4
- package/dist/cli-bundle/chunks/{register-operations-APN33LNI.js → register-operations-GK6VU2H2.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-ASEMNMBF.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KRIHJH5U.js → chunk-6J2YCGSN.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-XKH2FC5D.js → chunk-6UNKK3UH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NRHTXBTI.js → chunk-DQ3MB7BO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PMPFLA6X.js → chunk-E7LYK7V5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GZD4ZYIB.js +20 -0
- package/dist/cli-bundle/focused-chunks/chunk-KMPKKSA6.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TLF6N56J.js → chunk-LBDWUHQD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UIFVIE5F.js → chunk-MILJCOFJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MK5AKKHK.js → chunk-NETVXIH5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Q355NPLH.js → chunk-NWRVNHAD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IXNNMP2R.js → chunk-NZAG7OKB.js} +12 -12
- package/dist/cli-bundle/focused-chunks/{chunk-OY3VHCTX.js → chunk-OJKJFDIG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-OJRX6G22.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NVVB2HJC.js → chunk-PDVL7QYU.js} +16 -16
- package/dist/cli-bundle/focused-chunks/{chunk-O7MIBEMK.js → chunk-QO4MTAEA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ABA3KRPY.js → chunk-SMADBUPL.js} +2 -2
- package/dist/cli-bundle/main.js +21 -21
- 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 +20 -20
- 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 +46 -46
- 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 +8 -8
- package/dist/core/search/embedding-batches.d.ts +47 -15
- package/dist/core/search/embedding-batches.js +1 -1
- package/dist/core/search/eval-thresholds.d.ts +14 -0
- package/dist/core/search/eval-thresholds.js +2 -0
- package/dist/core/search/eval.d.ts +4 -1
- package/dist/core/search/eval.js +1 -1
- package/dist/core/search/http-client.d.ts +7 -0
- package/dist/core/search/http-client.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/completion/shared.d.ts +1 -1
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/eval.d.ts +19 -17
- package/dist/sdk/eval.js +1 -1
- package/dist/sdk/extension/static-inventory.d.ts +54 -0
- package/dist/sdk/extension/static-inventory.js +2 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/reindex.d.ts +4 -1
- package/dist/sdk/governance/reindex.js +2 -2
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query.d.ts +3 -0
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/read-output/provenance.d.ts +20 -0
- package/dist/sdk/read-output/provenance.js +2 -0
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime/schema-preview.d.ts +2 -0
- package/dist/sdk/runtime/schema-preview.js +2 -0
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +2 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/docs/CLI_GRAMMAR.md +31 -0
- package/docs/CODEX_PLUGIN.md +8 -0
- package/docs/EXTENSION_LIFECYCLE.md +18 -0
- package/docs/README.md +1 -0
- package/docs/RELEASING.md +51 -2
- package/docs/SEARCH_QUALITY.md +116 -0
- package/docs/agent-task-token-baseline.json +4 -4
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
- package/docs/generated/AGENT_COMMAND_SURFACE.md +5 -1
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +4 -0
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +14 -7
- package/marketplace.json +2 -2
- package/package.json +2 -2
- 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-claude/README.md +5 -1
- package/plugins/pm-claude/package.json +2 -2
- package/plugins/pm-claude/skills/pm-audit/SKILL.md +14 -103
- package/plugins/pm-claude/skills/pm-audit/agents/openai.yaml +4 -0
- package/plugins/pm-claude/skills/pm-developer/SKILL.md +20 -143
- package/plugins/pm-claude/skills/pm-developer/agents/openai.yaml +4 -0
- package/plugins/pm-claude/skills/pm-planner/SKILL.md +16 -167
- package/plugins/pm-claude/skills/pm-planner/agents/openai.yaml +4 -0
- package/plugins/pm-claude/skills/pm-release/SKILL.md +18 -102
- package/plugins/pm-claude/skills/pm-release/agents/openai.yaml +4 -0
- package/plugins/pm-claude/skills/pm-workflow/SKILL.md +25 -156
- package/plugins/pm-claude/skills/pm-workflow/agents/openai.yaml +4 -0
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/README.md +10 -2
- package/plugins/pm-codex/mcp.json +11 -0
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +45 -0
- package/plugins/pm-codex/skills/pm-audit/SKILL.md +21 -0
- package/plugins/pm-codex/skills/pm-audit/agents/openai.yaml +4 -0
- package/plugins/pm-codex/skills/pm-auditor/SKILL.md +5 -40
- package/plugins/pm-codex/skills/pm-auditor/agents/openai.yaml +3 -5
- package/plugins/pm-codex/skills/pm-developer/SKILL.md +26 -0
- package/plugins/pm-codex/skills/pm-developer/agents/openai.yaml +4 -0
- package/plugins/pm-codex/skills/pm-native/SKILL.md +7 -87
- package/plugins/pm-codex/skills/pm-native/agents/openai.yaml +3 -5
- package/plugins/pm-codex/skills/pm-planner/SKILL.md +22 -0
- package/plugins/pm-codex/skills/pm-planner/agents/openai.yaml +4 -0
- package/plugins/pm-codex/skills/pm-release/SKILL.md +17 -38
- package/plugins/pm-codex/skills/pm-release/agents/openai.yaml +2 -4
- package/plugins/pm-codex/skills/pm-workflow/SKILL.md +39 -0
- package/plugins/pm-codex/skills/pm-workflow/agents/openai.yaml +4 -0
- package/dist/cli-bundle/chunks/chunk-JDHWZYZU.js +0 -238
- package/dist/cli-bundle/chunks/register-setup-HPHIKG5U.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HQPTDJLF.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-V2X37U6J.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Y2M4QLAA.js +0 -20
|
@@ -1,38 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module core/search/embedding-batches
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Bounds embedding requests independently of per-input truncation and preserves
|
|
5
|
+
* input ordering through retries and adaptive splits.
|
|
5
6
|
*/
|
|
6
7
|
import type { PmSettings } from "../../types/index.js";
|
|
7
8
|
import type { EmbeddingProviderConfig } from "./providers.js";
|
|
8
|
-
/**
|
|
9
|
+
/** Completed vectors and execution evidence returned only after every input succeeds. */
|
|
9
10
|
export interface EmbeddingBatchExecutionResult {
|
|
10
|
-
/**
|
|
11
|
+
/** One vector for each input position, including repeated input text. */
|
|
11
12
|
vectors: number[][];
|
|
12
|
-
/**
|
|
13
|
+
/** Truncation, retry, and split diagnostics; never contains source input text. */
|
|
13
14
|
warnings: string[];
|
|
15
|
+
/** Actual provider work, including retries and adaptive splits. */
|
|
16
|
+
receipt?: EmbeddingBatchReceipt;
|
|
14
17
|
}
|
|
15
|
-
/**
|
|
18
|
+
/** Bounded summary of actual provider work; histogram keys are successful request sizes. */
|
|
19
|
+
export interface EmbeddingBatchReceipt {
|
|
20
|
+
/** Provider and model used for this execution, without endpoint or credentials. */
|
|
21
|
+
provider: string;
|
|
22
|
+
/** Model requested from the provider. */
|
|
23
|
+
model: string;
|
|
24
|
+
/** Maximum encoded JSON request size, including model and escaping. */
|
|
25
|
+
max_request_bytes: number;
|
|
26
|
+
/** Whether the request ceiling was supplied by the caller or the runtime. */
|
|
27
|
+
limit_source: "caller" | "default";
|
|
28
|
+
/** Number of requests planned before adaptive splitting. */
|
|
29
|
+
planned_batches: number;
|
|
30
|
+
/** Total HTTP attempts, including unsuccessful requests. */
|
|
31
|
+
requests: number;
|
|
32
|
+
/** Requests that returned validated vectors. */
|
|
33
|
+
successful_batches: number;
|
|
34
|
+
/** Failed requests subdivided into smaller requests. */
|
|
35
|
+
split_batches: number;
|
|
36
|
+
/** Additional attempts of the same batch after a transient failure. */
|
|
37
|
+
retries: number;
|
|
38
|
+
/** Successful request count by number of input positions. */
|
|
39
|
+
batch_size_histogram: Record<string, number>;
|
|
40
|
+
/** Wall-clock duration including provider time and retry backoff. */
|
|
41
|
+
elapsed_ms: number;
|
|
42
|
+
/** Completed input positions divided by elapsed seconds. */
|
|
43
|
+
inputs_per_second: number;
|
|
44
|
+
}
|
|
45
|
+
/** Progress across planned batches; actual HTTP work is reported separately in the receipt. */
|
|
16
46
|
export interface EmbeddingBatchProgressEvent {
|
|
17
|
-
/**
|
|
47
|
+
/** One-based index of the current planned batch. */
|
|
18
48
|
batch_index: number;
|
|
19
|
-
/**
|
|
49
|
+
/** Number of planned batches before adaptive splitting. */
|
|
20
50
|
batch_total: number;
|
|
21
|
-
/**
|
|
51
|
+
/** Number of input positions in the current planned batch. */
|
|
22
52
|
batch_size: number;
|
|
23
|
-
/**
|
|
53
|
+
/** Input positions successfully embedded before or after this event. */
|
|
24
54
|
completed_inputs: number;
|
|
25
|
-
/**
|
|
55
|
+
/** Total input positions in this execution. */
|
|
26
56
|
total_inputs: number;
|
|
27
|
-
/**
|
|
57
|
+
/** Optional attempt counter for callers extending progress reporting. */
|
|
28
58
|
attempt?: number;
|
|
29
|
-
/**
|
|
59
|
+
/** Whether dispatch is starting or the complete planned batch has succeeded. */
|
|
30
60
|
phase: "start" | "complete";
|
|
31
61
|
}
|
|
32
|
-
/**
|
|
62
|
+
/** Host controls for progress reporting and transport payload bounds. */
|
|
33
63
|
export interface EmbeddingBatchExecutionOptions {
|
|
34
|
-
/**
|
|
64
|
+
/** Observe planned-batch boundaries without receiving input text. */
|
|
35
65
|
onProgress?: (event: EmbeddingBatchProgressEvent) => void;
|
|
66
|
+
/** Positive JSON payload byte ceiling, independent of per-input corpus truncation; defaults to 256 KiB. */
|
|
67
|
+
maxRequestBytes?: number;
|
|
36
68
|
}
|
|
37
|
-
/**
|
|
69
|
+
/** Execute count- and byte-bounded batches in order. Reject impossible inputs before dispatch, retry transient failures, and subdivide size or timeout failures without returning partial vectors. */
|
|
38
70
|
export declare function executeEmbeddingBatchesWithRetry(provider: EmbeddingProviderConfig, settings: PmSettings, inputs: string[], options?: EmbeddingBatchExecutionOptions): Promise<EmbeddingBatchExecutionResult>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="
|
|
1
|
+
!(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]="dff1d04a-bad4-51d7-ab46-41e49387a44d")}catch(e2){}})();import{executeEmbeddingRequest}from"./providers.js";import{SearchHttpError}from"./http-client.js";import{toErrorMessage}from"../shared/primitives.js";import{SEMANTIC_CORPUS_TRUNCATION_SUFFIX,resolveSemanticCorpusCharacterLimit}from"./corpus.js";function resolveBatchRuntime(settings,maxInputCharacters,maxRequestBytes){const batchSizeCandidate=settings.search.embedding_batch_size;const timeoutMsCandidate=settings.search.embedding_timeout_ms;const maxRetriesCandidate=settings.search.scanner_max_batch_retries;const batchSize=Number.isFinite(batchSizeCandidate)&&batchSizeCandidate>0?Math.max(1,Math.floor(batchSizeCandidate)):1;const timeoutMs=Number.isFinite(timeoutMsCandidate)&&timeoutMsCandidate>0?Math.max(1,Math.floor(timeoutMsCandidate)):3e4;const maxRetries=Number.isFinite(maxRetriesCandidate)&&maxRetriesCandidate>=0?Math.floor(maxRetriesCandidate):0;return{batchSize,timeoutMs,maxRetries,maxRequestBytes,maxInputCharacters}}function createBatches(provider,inputs,batchSize,maxRequestBytes){const batches=[];let currentBatch=[];const envelopeBytes=Buffer.byteLength(JSON.stringify({model:provider.model,input:[]}));let currentBytes=envelopeBytes;for(const input of inputs){const inputBytes=Buffer.byteLength(JSON.stringify(input.trim()));if(envelopeBytes+inputBytes>maxRequestBytes){throw new RangeError(`Embedding input exceeds request byte ceiling ${maxRequestBytes}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`)}const separatorBytes=currentBatch.length>0?1:0;if(currentBatch.length>=batchSize||currentBytes+separatorBytes+inputBytes>maxRequestBytes){batches.push(currentBatch);currentBatch=[];currentBytes=envelopeBytes}currentBytes+=inputBytes+(currentBatch.length>0?1:0);currentBatch.push(input)}batches.push(currentBatch);return batches}function truncateInputForRuntime(input,maxInputCharacters){if(!Number.isFinite(maxInputCharacters)||maxInputCharacters<=0||input.length<=maxInputCharacters){return input}const keepLength=Math.max(0,maxInputCharacters-SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length);return`${input.slice(0,keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`.slice(0,maxInputCharacters)}function isEmbeddingTimeoutError(error){const message=toErrorMessage(error).toLowerCase();return message.includes("timed out")||message.includes("timeout")}function buildEmbeddingFailureMessage(provider,batchLabel,batchSize,timeoutMs,attempts,error){const base=`Embedding batch ${batchLabel} failed after ${attempts} attempt(s): ${toErrorMessage(error)}`;const details=`provider=${provider.name} model=${provider.model} batch_size=${batchSize} timeout_ms=${timeoutMs}`;if(!isEmbeddingTimeoutError(error)){return`${base} (${details})`}return`${base} (${details}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`}function resolveSplitReason(error){if(error instanceof SearchHttpError)return error.status===413?"payload_too_large":null;return isEmbeddingTimeoutError(error)?"timeout":null}async function executeBatchWithAdaptiveSplit(provider,batch,batchLabel,timeoutMs,maxRetries,warnings,receipt){let lastError=null;for(let attempt=0;attempt<=maxRetries;attempt+=1){try{receipt.requests+=1;const batchVectors=await executeEmbeddingRequest(provider,batch,{timeout_ms:timeoutMs});if(attempt>0){warnings.push(`search_embedding_batch_retry_succeeded:batch=${batchLabel}:attempt=${attempt+1}:size=${batch.length}`)}receipt.successful_batches+=1;receipt.batch_size_histogram[batch.length]=(receipt.batch_size_histogram[batch.length]??0)+1;return batchVectors}catch(error){lastError=error;const splitReason=resolveSplitReason(error);if(splitReason!==null&&batch.length>1){receipt.split_batches+=1;const midpoint=Math.ceil(batch.length/2);const left=batch.slice(0,midpoint);const right=batch.slice(midpoint);warnings.push(`search_embedding_batch_split_after_${splitReason}:batch=${batchLabel}:size=${batch.length}:parts=${left.length}|${right.length}`);return[...await executeBatchWithAdaptiveSplit(provider,left,`${batchLabel}.1`,timeoutMs,maxRetries,warnings,receipt),...await executeBatchWithAdaptiveSplit(provider,right,`${batchLabel}.2`,timeoutMs,maxRetries,warnings,receipt)]}if(attempt<maxRetries){receipt.retries+=1;const delayMs=Math.min(1e3*2**attempt,8e3);await new Promise(resolve=>setTimeout(resolve,delayMs))}}}throw new Error(buildEmbeddingFailureMessage(provider,batchLabel,batch.length,timeoutMs,maxRetries+1,lastError))}async function executeEmbeddingBatchesWithRetry(provider,settings,inputs,options={}){if(inputs.length===0){return{vectors:[],warnings:[]}}const startedAt=performance.now();const maxRequestBytes=options.maxRequestBytes??262144;if(!Number.isSafeInteger(maxRequestBytes)||maxRequestBytes<=0){throw new RangeError("maxRequestBytes must be a positive safe integer")}const receipt={provider:provider.name,model:provider.model,max_request_bytes:maxRequestBytes,limit_source:options.maxRequestBytes===void 0?"default":"caller",planned_batches:0,requests:0,successful_batches:0,split_batches:0,retries:0,batch_size_histogram:{},elapsed_ms:0,inputs_per_second:0};const warnings=[];const corpusLimitResolution=resolveSemanticCorpusCharacterLimit(provider.name,settings.search.embedding_corpus_max_characters);if(corpusLimitResolution.warning){warnings.push(corpusLimitResolution.warning)}const runtime=resolveBatchRuntime(settings,corpusLimitResolution.maxCharacters,maxRequestBytes);let truncatedInputCount=0;const normalizedInputs=inputs.map(input=>{if(input.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");const normalized=truncateInputForRuntime(input,runtime.maxInputCharacters);if(normalized.length<input.length){truncatedInputCount+=1}return normalized});if(truncatedInputCount>0){warnings.push(`search_embedding_input_truncated:count=${truncatedInputCount}:max_characters=${runtime.maxInputCharacters}`)}const batches=createBatches(provider,normalizedInputs,runtime.batchSize,runtime.maxRequestBytes);receipt.planned_batches=batches.length;const vectors=[];let completedInputs=0;for(let batchIndex=0;batchIndex<batches.length;batchIndex+=1){const batch=batches[batchIndex];options.onProgress?.({batch_index:batchIndex+1,batch_total:batches.length,batch_size:batch.length,completed_inputs:completedInputs,total_inputs:normalizedInputs.length,phase:"start"});vectors.push(...await executeBatchWithAdaptiveSplit(provider,batch,String(batchIndex+1),runtime.timeoutMs,runtime.maxRetries,warnings,receipt));completedInputs+=batch.length;options.onProgress?.({batch_index:batchIndex+1,batch_total:batches.length,batch_size:batch.length,completed_inputs:completedInputs,total_inputs:normalizedInputs.length,phase:"complete"})}receipt.elapsed_ms=Math.max(1,performance.now()-startedAt);receipt.inputs_per_second=inputs.length*1e3/receipt.elapsed_ms;return{vectors,warnings,receipt}}export{executeEmbeddingBatchesWithRetry};
|
|
2
2
|
//# sourceMappingURL=embedding-batches.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/search/eval-thresholds
|
|
3
|
+
*
|
|
4
|
+
* Validates and evaluates per-query retrieval floors independently of aggregate
|
|
5
|
+
* scores. Shared by the public evaluator and repository quality gates.
|
|
6
|
+
*/
|
|
7
|
+
/** Ranking metrics eligible for a declared quality floor. */
|
|
8
|
+
export declare const EVAL_METRIC_NAMES: readonly ["ndcg", "mrr", "precision", "recall"];
|
|
9
|
+
/** Optional normalized lower bounds; omitted metrics impose no constraint. */
|
|
10
|
+
export type EvalMetricFloors = Partial<Record<typeof EVAL_METRIC_NAMES[number], number>>;
|
|
11
|
+
/** Reject malformed or misspelled floors rather than silently weakening a quality contract. */
|
|
12
|
+
export declare function parseEvalMetricFloors(value: unknown): EvalMetricFloors;
|
|
13
|
+
/** Compare unrounded metrics to validated floors and return stable, actionable violations. */
|
|
14
|
+
export declare function evaluateMetricFloors(metrics: Record<typeof EVAL_METRIC_NAMES[number], number>, floors: EvalMetricFloors): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!(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]="b152a753-033c-593f-8b81-feb68b0a895f")}catch(e2){}})();const EVAL_METRIC_NAMES=["ndcg","mrr","precision","recall"];function parseEvalMetricFloors(value){if(typeof value!=="object"||value===null||Array.isArray(value)){throw new TypeError("Eval minimum must be an object of metric floors")}const result={};for(const[key,floor]of Object.entries(value)){if(!EVAL_METRIC_NAMES.some(metric=>metric===key)){throw new TypeError(`Unknown eval minimum metric: ${key}`)}if(typeof floor!=="number"||!Number.isFinite(floor)||floor<0||floor>1){throw new TypeError(`Eval minimum.${key} must be a finite number in [0, 1]`)}result[key]=floor}return result}function evaluateMetricFloors(metrics,floors){const validated=parseEvalMetricFloors(floors);const violations=[];for(const metric of EVAL_METRIC_NAMES){const minimum=validated[metric];if(minimum===void 0)continue;const actual=metrics[metric];if(!Number.isFinite(actual)||actual<0||actual>1){violations.push(`${metric}:invalid`)}else if(actual<minimum){violations.push(`${metric}:${actual}<${minimum}`)}}return violations}export{EVAL_METRIC_NAMES,evaluateMetricFloors,parseEvalMetricFloors};
|
|
2
|
+
//# sourceMappingURL=eval-thresholds.js.map
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* not. This keeps the golden set cheap to curate while still supporting the
|
|
14
14
|
* graded-discount behavior of DCG (earlier hits are worth more).
|
|
15
15
|
*/
|
|
16
|
+
import { type EvalMetricFloors } from "./eval-thresholds.js";
|
|
16
17
|
/** Retrieval mode a golden query is evaluated under. Mirrors the `pm search` mode surface; omitting it on a query defers to the eval run's default mode. */
|
|
17
18
|
export type EvalSearchMode = "keyword" | "semantic" | "hybrid";
|
|
18
19
|
/** Default cutoff (`@k`) used for every metric when the caller does not override it. */
|
|
@@ -24,7 +25,7 @@ export declare const EVAL_QUERY_SET_CONTRACT: {
|
|
|
24
25
|
readonly schema: "https://schema.unbrained.dev/pm/eval-query-set/v1";
|
|
25
26
|
readonly accepted_top_level: readonly ["array", "object"];
|
|
26
27
|
readonly required_query_fields: readonly ["query", "relevant_ids"];
|
|
27
|
-
readonly optional_fields: readonly ["mode", "description"];
|
|
28
|
+
readonly optional_fields: readonly ["mode", "description", "minimum"];
|
|
28
29
|
readonly modes: readonly ["keyword", "semantic", "hybrid"];
|
|
29
30
|
};
|
|
30
31
|
/** Copy-ready minimal query set shared by help, diagnostics, and integrations. */
|
|
@@ -46,6 +47,8 @@ export interface EvalQuery {
|
|
|
46
47
|
mode?: EvalSearchMode;
|
|
47
48
|
/** Value that configures or reports description for this contract. */
|
|
48
49
|
description?: string;
|
|
50
|
+
/** Per-query floors applied before rounding, independently of the aggregate gate. */
|
|
51
|
+
minimum?: EvalMetricFloors;
|
|
49
52
|
}
|
|
50
53
|
/** A parsed, validated golden-query set. */
|
|
51
54
|
export interface EvalQuerySet {
|
package/dist/core/search/eval.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="
|
|
1
|
+
!(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]="451970e8-8403-5527-b795-a873241c015e")}catch(e2){}})();import{parseEvalMetricFloors}from"./eval-thresholds.js";const DEFAULT_EVAL_K=10;const EVAL_QUERY_SET_SCHEMA_ID="https://schema.unbrained.dev/pm/eval-query-set/v1";const EVAL_QUERY_SET_CONTRACT={schema:EVAL_QUERY_SET_SCHEMA_ID,accepted_top_level:["array","object"],required_query_fields:["query","relevant_ids"],optional_fields:["mode","description","minimum"],modes:["keyword","semantic","hybrid"]};const EVAL_QUERY_SET_EXAMPLE={schema:EVAL_QUERY_SET_SCHEMA_ID,queries:[{query:"offline search",relevant_ids:["pm-75k9"],mode:"keyword"}]};class EvalQuerySetError extends Error{constructor(message){super(message);this.name="EvalQuerySetError"}}const VALID_EVAL_MODES=new Set(["keyword","semantic","hybrid"]);function dcgAtK(relevanceGains,k){let dcg=0;const limit=Math.min(k,relevanceGains.length);for(let index=0;index<limit;index+=1){dcg+=relevanceGains[index]/Math.log2(index+2)}return dcg}function ndcgAtK(rankedIds,relevantIds,k){if(relevantIds.size===0){return 0}const gains=rankedIds.map(id=>relevantIds.has(id)?1:0);const dcg=dcgAtK(gains,k);const idealGains=Array.from({length:relevantIds.size},()=>1);const idealDcg=dcgAtK(idealGains,k);return idealDcg===0?0:dcg/idealDcg}function reciprocalRankAtK(rankedIds,relevantIds,k){const limit=Math.min(k,rankedIds.length);for(let index=0;index<limit;index+=1){if(relevantIds.has(rankedIds[index])){return 1/(index+1)}}return 0}function countRelevantInTopK(rankedIds,relevantIds,k){const limit=Math.min(k,rankedIds.length);let hits=0;for(let index=0;index<limit;index+=1){if(relevantIds.has(rankedIds[index])){hits+=1}}return hits}function precisionAtK(rankedIds,relevantIds,k){if(k<=0){return 0}return countRelevantInTopK(rankedIds,relevantIds,k)/k}function recallAtK(rankedIds,relevantIds,k){if(relevantIds.size===0){return 0}return countRelevantInTopK(rankedIds,relevantIds,k)/relevantIds.size}function evaluateRanking(rankedIds,relevantIds,k){return{ndcg:ndcgAtK(rankedIds,relevantIds,k),mrr:reciprocalRankAtK(rankedIds,relevantIds,k),precision:precisionAtK(rankedIds,relevantIds,k),recall:recallAtK(rankedIds,relevantIds,k),relevant_total:relevantIds.size,retrieved_relevant:countRelevantInTopK(rankedIds,relevantIds,k)}}function aggregateEvalMetrics(perQuery){const queryCount=perQuery.length;if(queryCount===0){return{ndcg:0,mrr:0,precision:0,recall:0,query_count:0}}const sum=perQuery.reduce((accumulator,metrics)=>({ndcg:accumulator.ndcg+metrics.ndcg,mrr:accumulator.mrr+metrics.mrr,precision:accumulator.precision+metrics.precision,recall:accumulator.recall+metrics.recall}),{ndcg:0,mrr:0,precision:0,recall:0});return{ndcg:sum.ndcg/queryCount,mrr:sum.mrr/queryCount,precision:sum.precision/queryCount,recall:sum.recall/queryCount,query_count:queryCount}}function parseEvalQueryEntry(raw,index){if(typeof raw!=="object"||raw===null){throw new EvalQuerySetError(`Eval query at index ${index} must be an object`)}const entry=raw;const query=typeof entry.query==="string"?entry.query.trim():"";if(query.length===0){throw new EvalQuerySetError(`Eval query at index ${index} must have a non-empty "query" string`)}if(!Array.isArray(entry.relevant_ids)){throw new EvalQuerySetError(`Eval query at index ${index} must have a "relevant_ids" array`)}if(entry.relevant_ids.some(value=>typeof value!=="string")){throw new EvalQuerySetError(`Eval query at index ${index} must have a "relevant_ids" array of strings`)}const relevantIds=[...new Set(entry.relevant_ids.map(value=>value.trim()).filter(value=>value.length>0))];if(relevantIds.length===0){throw new EvalQuerySetError(`Eval query at index ${index} must list at least one relevant id`)}if(entry.mode!==void 0&&(typeof entry.mode!=="string"||!VALID_EVAL_MODES.has(entry.mode))){throw new EvalQuerySetError(`Eval query at index ${index} has an invalid mode (expected keyword|semantic|hybrid)`)}return{query,relevant_ids:relevantIds,...entry.minimum===void 0?{}:{minimum:parseEvalMetricFloors(entry.minimum)},...entry.mode!==void 0?{mode:entry.mode}:{},...typeof entry.description==="string"&&entry.description.trim().length>0?{description:entry.description.trim()}:{}}}function parseEvalQuerySet(raw){const rawSchema=typeof raw==="object"&&raw!==null&&!Array.isArray(raw)?raw.schema:void 0;if(rawSchema!==void 0&&rawSchema!==EVAL_QUERY_SET_SCHEMA_ID){throw new EvalQuerySetError(`Unsupported eval query set schema; expected "${EVAL_QUERY_SET_SCHEMA_ID}"`)}const rawQueries=Array.isArray(raw)?raw:typeof raw==="object"&&raw!==null?raw.queries:void 0;if(!Array.isArray(rawQueries)){throw new EvalQuerySetError('Eval query set must be an array of queries or an object with a "queries" array')}if(rawQueries.length===0){throw new EvalQuerySetError("Eval query set must contain at least one query")}return{schema:EVAL_QUERY_SET_SCHEMA_ID,queries:rawQueries.map((entry,index)=>parseEvalQueryEntry(entry,index))}}export{DEFAULT_EVAL_K,EVAL_QUERY_SET_CONTRACT,EVAL_QUERY_SET_EXAMPLE,EVAL_QUERY_SET_SCHEMA_ID,EvalQuerySetError,aggregateEvalMetrics,dcgAtK,evaluateRanking,ndcgAtK,parseEvalQuerySet,precisionAtK,recallAtK,reciprocalRankAtK};
|
|
2
2
|
//# sourceMappingURL=eval.js.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/** HTTP failure with a status code that schedulers can classify without parsing provider text. */
|
|
2
|
+
export declare class SearchHttpError extends Error {
|
|
3
|
+
/** HTTP status returned by the provider, retained independently of its response body. */
|
|
4
|
+
readonly status: number;
|
|
5
|
+
/** Preserve the existing user-facing message and the machine-readable HTTP status. */
|
|
6
|
+
constructor(message: string, status: number);
|
|
7
|
+
}
|
|
1
8
|
/** Documents the search http response payload exchanged by command, SDK, and package integrations. */
|
|
2
9
|
export interface SearchHttpResponse {
|
|
3
10
|
/** Whether the operation completed without a blocking failure. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="
|
|
1
|
+
!(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]="01b280e5-31b5-532d-b569-67aab828358a")}catch(e2){}})();import{toErrorMessage}from"../shared/primitives.js";const DEFAULT_SEARCH_HTTP_TIMEOUT_MS=3e4;class SearchHttpError extends Error{status;constructor(message,status){super(message);this.name="SearchHttpError";this.status=status}}function normalizeSearchHttpTimeoutMs(timeoutMs,requestLabel,defaultTimeoutMs=DEFAULT_SEARCH_HTTP_TIMEOUT_MS){const resolved=timeoutMs??defaultTimeoutMs;if(!Number.isFinite(resolved)||resolved<=0){throw new Error(`${requestLabel} timeout must be a positive finite number`)}return Math.floor(resolved)}function resolveSearchHttpFetcher(fetcher,requestLabel){if(fetcher){return fetcher}if(typeof globalThis.fetch==="function"){return globalThis.fetch.bind(globalThis)}throw new Error(`${requestLabel} execution requires a fetch implementation`)}async function readFailedSearchHttpResponseBody(response){try{return(await response.text()).replaceAll(/\s+/g," ").trim()}catch(error){return`(failed to read response body: ${toErrorMessage(error)})`}}async function executeSearchJsonRequest(options){const controller=new AbortController;const timeoutHandle=setTimeout(()=>{controller.abort()},options.timeoutMs);try{let response;try{response=await options.fetcher(options.endpoint,{method:options.method,headers:options.headers,body:JSON.stringify(options.body),signal:controller.signal})}catch(error){if(error instanceof Error&&error.name==="AbortError"){throw new Error(`${options.requestLabel} timed out after ${options.timeoutMs}ms`)}throw new Error(`${options.requestLabel} execution failed: ${toErrorMessage(error)}`)}if(!response.ok){const responseBody=await readFailedSearchHttpResponseBody(response);const detail=responseBody.length>0?`: ${responseBody}`:"";throw new SearchHttpError(`${options.requestLabel} failed with status ${response.status} ${response.statusText}${detail}`,response.status)}try{return await response.json()}catch(error){throw new Error(`${options.responseLabel} JSON parse failed: ${toErrorMessage(error)}`)}}finally{clearTimeout(timeoutHandle)}}export{SearchHttpError,executeSearchJsonRequest,normalizeSearchHttpTimeoutMs,readFailedSearchHttpResponseBody,resolveSearchHttpFetcher};
|
|
2
2
|
//# sourceMappingURL=http-client.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="235bac43-67ba-5fad-9ec2-e392aeb7feda")}catch(e2){}})();import{PM_CORE_COMMAND_NAMES}from"./cli-contracts/enum-contracts.js";import{PM_COMMAND_ALIAS_CONTRACTS,PM_NAMESPACED_COMMAND_ALIASES,resolvePmCommandOperation}from"./cli-contracts/command-aliases.js";const CORE_COMMANDS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate"]);const STANDARD_COMMANDS=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]);const COMMANDS_BY_FAMILY=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])});const EXTENSION_COMMANDS=new Set(["extension","install","package","packages","upgrade"]);function resolvePmCommandCapabilityFamily(command){const normalized=resolvePmCommandOperation(command.trim().toLowerCase());if(normalized==="ops")return"quality";for(const[family,commands]of Object.entries(COMMANDS_BY_FAMILY)){if(commands.has(normalized))return family}return EXTENSION_COMMANDS.has(normalized)?"extensions":"internal"}const PM_COMMAND_CAPABILITY_CONTRACTS=Object.freeze([...PM_CORE_COMMAND_NAMES.flatMap(command=>command==="item"?["item","item-reopen"]:[command,...PM_NAMESPACED_COMMAND_ALIASES.filter(alias=>alias.alias===command).map(alias=>alias.canonical)]).map(command=>({command,tier:CORE_COMMANDS.has(resolvePmCommandOperation(command))?"core":STANDARD_COMMANDS.has(resolvePmCommandOperation(command))?"standard":"full",family:resolvePmCommandCapabilityFamily(command)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]);const PM_COMMAND_VISIBILITY_CONTRACTS=PM_COMMAND_CAPABILITY_CONTRACTS;const PM_CORE_HELP_BUDGET=Object.freeze({max_lines:50,max_utf8_bytes:6e3});const PM_CORE_HELP_OPTION_FLAGS=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);function measurePmCoreHelp(text){const lines=text===""?0:text.split(/\r?\n/).length;const utf8Bytes=Buffer.byteLength(text,"utf8");return{lines,utf8_bytes:utf8Bytes,within_budget:lines<=PM_CORE_HELP_BUDGET.max_lines&&utf8Bytes<=PM_CORE_HELP_BUDGET.max_utf8_bytes}}const TIER_ORDER={core:0,standard:1,full:2,internal:3};const COMMAND_TIER_BY_NAME=new Map(PM_COMMAND_VISIBILITY_CONTRACTS.map(({command,tier})=>[command,tier]));function resolvePmCommandVisibilityTier(command,extensionTier="standard"){return COMMAND_TIER_BY_NAME.get(command.trim().toLowerCase())??COMMAND_TIER_BY_NAME.get(resolvePmCommandOperation(command.trim().toLowerCase()))??extensionTier}function listPmCommandsForTier(tier){return listPmCommandsForTierFromContracts(tier,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmCommandsForTierFromContracts(tier,contracts){const maximum=TIER_ORDER[tier];return contracts.filter(entry=>entry.tier!=="internal"&&TIER_ORDER[entry.tier]<=maximum).map(entry=>entry.command)}function listPmCommandsForFamily(family){return listPmCommandsForFamilyFromContracts(family,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmCommandsForFamilyFromContracts(family,contracts){return contracts.filter(entry=>entry.family===family).map(entry=>entry.command)}const CAPABILITY_FAMILY_ORDER=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"];const CAPABILITY_ROUTING_EXCLUDED_ALIASES=new Set([...PM_COMMAND_ALIAS_CONTRACTS.filter(alias=>alias.hidden).map(alias=>alias.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function listPmCommandCapabilityGroups(contracts=PM_COMMAND_CAPABILITY_CONTRACTS){return CAPABILITY_FAMILY_ORDER.map(family=>({family,commands:listPmCommandsForFamilyFromContracts(family,contracts).filter(command=>contracts.find(entry=>entry.command===command)?.tier!=="internal"&&!CAPABILITY_ROUTING_EXCLUDED_ALIASES.has(command))})).filter(({commands})=>commands.length>0)}const PM_MCP_TOOL_COMMAND_CONTRACTS=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});function listPmMcpToolsForProfile(availableTools,profile){return listPmMcpToolsForProfileFromContracts(availableTools,profile,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmMcpToolsForProfileFromContracts(availableTools,profile,contracts){if(profile==="full")return[...availableTools];const visibleCommands=new Set(listPmCommandsForTierFromContracts(profile,contracts));return availableTools.filter(tool=>{const command=PM_MCP_TOOL_COMMAND_CONTRACTS[tool];return command!==void 0&&visibleCommands.has(command)})}const PM_MCP_RESOURCE_CONTRACTS=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]);const PM_MCP_PROMPT_CONTRACTS=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:true},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:false}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:true}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:true},{name:"evidence",description:"Exact verification and outcome evidence.",required:true}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);function renderPmCommandVisibilityMarkdown(){return renderPmCommandVisibilityMarkdownFromContracts(PM_COMMAND_CAPABILITY_CONTRACTS)}function renderPmCommandVisibilityMarkdownFromContracts(contracts){const rows=contracts.map(({command,tier,family})=>`| \`${command}\` | ${tier} | ${family} |`);return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...rows,""].join("\n")}function renderPmCapabilityRoutingMarkdown(contracts=PM_COMMAND_CAPABILITY_CONTRACTS){const rows=listPmCommandCapabilityGroups(contracts).map(({family,commands})=>`| ${family} | ${commands.map(command=>`\`${command}\``).join(", ")} |`);return["# Generated agent capability routing","","Tracker: `pm-kxci8x`.","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Capability family | Commands |","| --- | --- |",...rows,""].join("\n")}export{PM_COMMAND_CAPABILITY_CONTRACTS,PM_COMMAND_VISIBILITY_CONTRACTS,PM_CORE_HELP_BUDGET,PM_CORE_HELP_OPTION_FLAGS,PM_MCP_PROMPT_CONTRACTS,PM_MCP_RESOURCE_CONTRACTS,PM_MCP_TOOL_COMMAND_CONTRACTS,listPmCommandCapabilityGroups,listPmCommandsForFamily,listPmCommandsForFamilyFromContracts,listPmCommandsForTier,listPmCommandsForTierFromContracts,listPmMcpToolsForProfile,listPmMcpToolsForProfileFromContracts,measurePmCoreHelp,renderPmCapabilityRoutingMarkdown,renderPmCommandVisibilityMarkdown,renderPmCommandVisibilityMarkdownFromContracts,resolvePmCommandCapabilityFamily,resolvePmCommandVisibilityTier};
|
|
1
|
+
!(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]="e8c34bbe-eab3-5dcf-9436-410c9c69feee")}catch(e2){}})();import{PM_CORE_COMMAND_NAMES}from"./cli-contracts/enum-contracts.js";import{PM_COMMAND_ALIAS_CONTRACTS,PM_NAMESPACED_COMMAND_ALIASES,resolvePmCommandOperation}from"./cli-contracts/command-aliases.js";const CORE_COMMANDS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]);const STANDARD_COMMANDS=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]);const COMMANDS_BY_FAMILY=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])});const EXTENSION_COMMANDS=new Set(["extension","install","package","packages","upgrade"]);function resolvePmCommandCapabilityFamily(command){const normalized=resolvePmCommandOperation(command.trim().toLowerCase());if(normalized==="ops")return"quality";for(const[family,commands]of Object.entries(COMMANDS_BY_FAMILY)){if(commands.has(normalized))return family}return EXTENSION_COMMANDS.has(normalized)?"extensions":"internal"}const PM_COMMAND_CAPABILITY_CONTRACTS=Object.freeze([...PM_CORE_COMMAND_NAMES.flatMap(command=>command==="item"?["item","item-reopen"]:[command,...PM_NAMESPACED_COMMAND_ALIASES.filter(alias=>alias.alias===command).map(alias=>alias.canonical)]).map(command=>({command,tier:CORE_COMMANDS.has(resolvePmCommandOperation(command))?"core":STANDARD_COMMANDS.has(resolvePmCommandOperation(command))?"standard":"full",family:resolvePmCommandCapabilityFamily(command)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]);const PM_COMMAND_VISIBILITY_CONTRACTS=PM_COMMAND_CAPABILITY_CONTRACTS;const PM_CORE_HELP_BUDGET=Object.freeze({max_lines:50,max_utf8_bytes:6e3});const PM_CORE_HELP_OPTION_FLAGS=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);function measurePmCoreHelp(text){const lines=text===""?0:text.split(/\r?\n/).length;const utf8Bytes=Buffer.byteLength(text,"utf8");return{lines,utf8_bytes:utf8Bytes,within_budget:lines<=PM_CORE_HELP_BUDGET.max_lines&&utf8Bytes<=PM_CORE_HELP_BUDGET.max_utf8_bytes}}const TIER_ORDER={core:0,standard:1,full:2,internal:3};const COMMAND_TIER_BY_NAME=new Map(PM_COMMAND_VISIBILITY_CONTRACTS.map(({command,tier})=>[command,tier]));function resolvePmCommandVisibilityTier(command,extensionTier="standard"){return COMMAND_TIER_BY_NAME.get(command.trim().toLowerCase())??COMMAND_TIER_BY_NAME.get(resolvePmCommandOperation(command.trim().toLowerCase()))??extensionTier}function listPmCommandsForTier(tier){return listPmCommandsForTierFromContracts(tier,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmCommandsForTierFromContracts(tier,contracts){const maximum=TIER_ORDER[tier];return contracts.filter(entry=>entry.tier!=="internal"&&TIER_ORDER[entry.tier]<=maximum).map(entry=>entry.command)}function listPmCommandsForFamily(family){return listPmCommandsForFamilyFromContracts(family,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmCommandsForFamilyFromContracts(family,contracts){return contracts.filter(entry=>entry.family===family).map(entry=>entry.command)}const CAPABILITY_FAMILY_ORDER=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"];const CAPABILITY_ROUTING_EXCLUDED_ALIASES=new Set([...PM_COMMAND_ALIAS_CONTRACTS.filter(alias=>alias.hidden).map(alias=>alias.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function listPmCommandCapabilityGroups(contracts=PM_COMMAND_CAPABILITY_CONTRACTS){return CAPABILITY_FAMILY_ORDER.map(family=>({family,commands:listPmCommandsForFamilyFromContracts(family,contracts).filter(command=>contracts.find(entry=>entry.command===command)?.tier!=="internal"&&!CAPABILITY_ROUTING_EXCLUDED_ALIASES.has(command))})).filter(({commands})=>commands.length>0)}const PM_MCP_TOOL_COMMAND_CONTRACTS=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});function listPmMcpToolsForProfile(availableTools,profile){return listPmMcpToolsForProfileFromContracts(availableTools,profile,PM_COMMAND_CAPABILITY_CONTRACTS)}function listPmMcpToolsForProfileFromContracts(availableTools,profile,contracts){if(profile==="full")return[...availableTools];const visibleCommands=new Set(listPmCommandsForTierFromContracts(profile,contracts));return availableTools.filter(tool=>{const command=PM_MCP_TOOL_COMMAND_CONTRACTS[tool];return command!==void 0&&visibleCommands.has(command)})}const PM_MCP_RESOURCE_CONTRACTS=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]);const PM_MCP_PROMPT_CONTRACTS=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:true},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:false}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:true}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:true},{name:"evidence",description:"Exact verification and outcome evidence.",required:true}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);function renderPmCommandVisibilityMarkdown(){return renderPmCommandVisibilityMarkdownFromContracts(PM_COMMAND_CAPABILITY_CONTRACTS)}function renderPmCommandVisibilityMarkdownFromContracts(contracts){const rows=contracts.map(({command,tier,family})=>`| \`${command}\` | ${tier} | ${family} |`);return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...rows,""].join("\n")}function renderPmCapabilityRoutingMarkdown(contracts=PM_COMMAND_CAPABILITY_CONTRACTS){const rows=listPmCommandCapabilityGroups(contracts).map(({family,commands})=>`| ${family} | ${commands.map(command=>`\`${command}\``).join(", ")} |`);return["# Generated agent capability routing","","Tracker: `pm-kxci8x`.","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Capability family | Commands |","| --- | --- |",...rows,""].join("\n")}export{PM_COMMAND_CAPABILITY_CONTRACTS,PM_COMMAND_VISIBILITY_CONTRACTS,PM_CORE_HELP_BUDGET,PM_CORE_HELP_OPTION_FLAGS,PM_MCP_PROMPT_CONTRACTS,PM_MCP_RESOURCE_CONTRACTS,PM_MCP_TOOL_COMMAND_CONTRACTS,listPmCommandCapabilityGroups,listPmCommandsForFamily,listPmCommandsForFamilyFromContracts,listPmCommandsForTier,listPmCommandsForTierFromContracts,listPmMcpToolsForProfile,listPmMcpToolsForProfileFromContracts,measurePmCoreHelp,renderPmCapabilityRoutingMarkdown,renderPmCommandVisibilityMarkdown,renderPmCommandVisibilityMarkdownFromContracts,resolvePmCommandCapabilityFamily,resolvePmCommandVisibilityTier};
|
|
2
2
|
//# sourceMappingURL=agent-capability-contracts.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="
|
|
1
|
+
!(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]="c42420db-459b-5ce7-a9b5-e6d44873253a")}catch(e2){}})();const PM_HISTORY_COMMAND_ALIASES=[["history-redact","history redact"],["history-repair","history repair"],["history-compact","history compact"],["activity","history activity"],["restore","history restore"]].map(([alias,canonical])=>({alias,canonical,canonical_argv:canonical.split(" "),lifecycle:"permanent",hidden:true,registration:"commander",owner:"pm-tqel"}));const PM_CONTEXT_OPS_COMMAND_ALIASES=[...["next","focus"].map(alias=>({alias,canonical:`context ${alias}`,owner:"pm-kcs4"})),...["stats","health","validate","gc","telemetry","eval","test-all"].map(alias=>({alias,canonical:`ops ${alias}`,owner:"pm-6apl"})),...["normalize","reindex"].map(alias=>({alias,canonical:`ops ${alias}`,owner:"pm-3i9q8g"})),{alias:"events",canonical:"history events",owner:"pm-3i9q8g"}].map(entry=>({...entry,canonical_argv:entry.canonical.split(" "),lifecycle:"permanent",hidden:true,registration:"bootstrap"}));const PM_BULK_LIFECYCLE_COMMAND_ALIASES=[["update-many","update many"],["close-many","close many"],["delete","close delete"]].map(([alias,canonical])=>({alias,canonical,canonical_argv:canonical.split(" "),lifecycle:"permanent",hidden:true,registration:"bootstrap",owner:"pm-ik19"}));const PM_RELOCATED_COMMAND_ALIASES=[...PM_CONTEXT_OPS_COMMAND_ALIASES,...PM_BULK_LIFECYCLE_COMMAND_ALIASES,...["init","config","schema","profile"].map(alias=>({alias,canonical:`workspace ${alias}`,canonical_argv:["workspace",alias],lifecycle:"permanent",hidden:true,registration:"bootstrap",owner:"pm-npr3"})),...[...["comments","notes","learnings","files","docs","deps","append","test"].map(facet=>[facet,`item ${facet}`,"pm-yql1"]),["test-runs-worker","item test worker","pm-lp4j"],...["statuses","tags","types"].map(facet=>[`completion-${facet}`,`completion ${facet}`,"pm-szdc"]),["history-author-acknowledge","history acknowledge","pm-djyvbk"],["copy","item copy","pm-m6g87m"],["merge","workspace merge","pm-m6g87m"],["duplicates","item duplicates","pm-fmy9ih"],["dedupe-audit","item duplicates audit","pm-fmy9ih"],["dedupe-merge","item duplicates merge","pm-fmy9ih"],["comments-audit","item audit-comments","pm-fmy9ih"],["search-advanced","search advanced","pm-wfskfn"],...["meet","event","remind"].map(command=>[command,`calendar ${command}`,"pm-o3fh"])].map(([alias,canonical,owner])=>({alias,canonical,canonical_argv:canonical.split(" "),lifecycle:"permanent",hidden:true,registration:"bootstrap",owner}))];const PM_NAMESPACED_COMMAND_ALIASES=[{alias:"history-attest",canonical:"history attest",canonical_argv:["history","attest"],lifecycle:"permanent",hidden:true,registration:"commander",owner:"pm-3z0k"},...PM_HISTORY_COMMAND_ALIASES,...PM_RELOCATED_COMMAND_ALIASES,...["discover","lookup"].map(action=>({alias:`files ${action}`,canonical:`item files ${action}`,canonical_argv:["item","files",action],lifecycle:"permanent",hidden:true,registration:"bootstrap",owner:"pm-yql1"}))];function findPmNamespacedCommand(tokens){let matched;for(const alias of PM_NAMESPACED_COMMAND_ALIASES){if(alias.canonical_argv.length<=(matched?.canonical_argv.length??0))continue;if(alias.canonical_argv.every((token,index)=>token===(index===0&&tokens[index]==="ctx"?"context":tokens[index])))matched=alias}return matched}function resolvePmCommandOperation(command){const normalized=command.trim().replace(/\s+/gu," ");return PM_NAMESPACED_COMMAND_ALIASES.find(alias=>alias.canonical===normalized.replace(/^ctx /u,"context "))?.alias??normalized}function resolvePmHistoryOperation(command){return resolvePmCommandOperation(command)}const PM_COMMAND_ALIAS_CONTRACTS=[...PM_NAMESPACED_COMMAND_ALIASES,...[["ctx","context"],["packages","package"]].map(([alias,canonical])=>({alias,canonical,canonical_argv:[canonical],lifecycle:"permanent",hidden:false,registration:"commander",owner:"pm-pbyu"})),...[["start-task","claim","--start"],["pause-task","release","--pause"],["close-task","close","--release-assignment"]].map(([alias,canonical,flag])=>({alias,canonical,canonical_argv:[canonical,flag],lifecycle:"deprecated",hidden:true,registration:"commander",owner:"pm-eq4x"})),{alias:"tests",canonical:"item test",canonical_argv:["item","test"],lifecycle:"permanent",hidden:false,registration:"bootstrap",owner:"pm-u4t9gp"},...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([alias,canonical])=>({alias,canonical:["comments","notes","learnings"].includes(canonical)?`item ${canonical}`:canonical,canonical_argv:["comments","notes","learnings"].includes(canonical)?["item",canonical]:[canonical],lifecycle:"permanent",hidden:false,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","packages catalog"],["packages scaffold","packages init"]].map(([alias,canonical])=>({alias,canonical,canonical_argv:canonical.split(" "),lifecycle:"permanent",hidden:false,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:true,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([alias,status])=>({alias,canonical:"list",canonical_argv:["list","--status",status],lifecycle:"deprecated",hidden:true,registration:"commander",owner:"pm-pfqi"})),...[["extension","package"],["install","package install"],["upgrade","package upgrade"]].map(([alias,canonical])=>({alias,canonical,canonical_argv:canonical.split(" "),lifecycle:"deprecated",hidden:true,registration:"commander",owner:"pm-tnud"}))];const EXECUTABLE_COMMAND_ALIASES=Object.fromEntries(PM_COMMAND_ALIAS_CONTRACTS.filter(contract=>contract.registration==="bootstrap").map(contract=>[contract.alias,contract.canonical]));function resolvePmCommandAlias(alias){const normalized=alias.trim().toLowerCase();return PM_COMMAND_ALIAS_CONTRACTS.find(contract=>contract.alias===normalized)}function renderPmCommandAliasMigrationHint(contract){return`Deprecated command \`${contract.alias}\`; use \`pm ${contract.canonical_argv.join(" ")}\`.`}export{EXECUTABLE_COMMAND_ALIASES,PM_BULK_LIFECYCLE_COMMAND_ALIASES,PM_COMMAND_ALIAS_CONTRACTS,PM_CONTEXT_OPS_COMMAND_ALIASES,PM_HISTORY_COMMAND_ALIASES,PM_NAMESPACED_COMMAND_ALIASES,PM_RELOCATED_COMMAND_ALIASES,findPmNamespacedCommand,renderPmCommandAliasMigrationHint,resolvePmCommandAlias,resolvePmCommandOperation,resolvePmHistoryOperation};
|
|
2
2
|
//# sourceMappingURL=command-aliases.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(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]="733ce7b1-de7b-53b9-83bb-deefd930d8ec")}catch(e2){}})();import{resolvePmCommandAlias,PM_HISTORY_COMMAND_ALIASES,PM_RELOCATED_COMMAND_ALIASES,resolvePmHistoryOperation}from"./command-aliases.js";const PM_CLI_GRAMMAR_NOUNS=["item","list","context","search","graph","history","workspace","package","ops","plan","contracts","help"];const PM_CLI_SHARED_VERBS=["acknowledge","activate","add","adopt","adopt-all","catalog","compact","complete","create","deactivate","delete","describe","doctor","edit","explore","import","init","inspect","install","list","manage","migrate","mutate","read","redact","reload","remove","reopen","repair","restore","run","show","uninstall","upgrade","verify"];function positionalSlot(name,valueKind,required,options={}){return{name,required,variadic:options.variadic===true,value_kind:valueKind,polymorphic:options.polymorphic===true}}function positionalActionVerb(action){const phrase=action.replaceAll("-"," ");return`${phrase.charAt(0).toUpperCase()}${phrase.slice(1)}`}const ITEM_ID=positionalSlot("id","item_id",true);const OPTIONAL_ITEM_ID=positionalSlot("id","item_id",false);const OPTIONAL_TEXT=positionalSlot("text","string",false);const PLAN_ITEM_ID=positionalSlot("plan-id","item_id",true);const PLAN_STEP=positionalSlot("step","string",true);const PLAN_CREATE_FLAGS=["--acceptance-criteria","--actual-result","--affected-version","--assignee","--blocked-by","--blocked-reason","--blocks","--body","--claim","--comment","--component","--confidence","--create-mode","--customer-impact","--deadline","--definition-of-ready","--description","--doc","--environment","--estimate","--event","--expected-result","--fixed-version","--file","--from-search","--goal","--harness","--impact","--learning","--message","--mode","--note","--objective","--order","--outcome","--parent","--priority","--rank","--related","--release","--reminder","--reporter","--repro-steps","--resolution","--resume-context","--reviewer","--risk","--scope","--severity","--sprint","--status","--step","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-replacement","--step-status","--step-title","--tags","--template","--test","--title","--type-option","--unblock-note","--value","--why-now"];const PLAN_STEP_FLAGS=["--allow-multiple-active","--depends-on","--file","--force","--message","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-status","--step-title","--test"];const PLAN_STEP_ACTION_DESCRIPTIONS={"update-step":"Update one declared Plan step.","complete-step":"Complete one declared Plan step.","block-step":"Block one declared Plan step.","remove-step":"Remove one declared Plan step.",link:"Link one dependency to a declared Plan step.",unlink:"Unlink one dependency from a declared Plan step."};const PM_POSITIONAL_ACTION_CONTRACTS=[{command:"plan create",parent:"plan",action:"create",slots:[positionalSlot("title","string",false,{polymorphic:true})],accepted_flags:PLAN_CREATE_FLAGS,description:"Create a Plan item and optionally seed its ordered steps.",example:'pm plan create --title "Refactor lock retry"'},{command:"plan show",parent:"plan",action:"show",slots:[PLAN_ITEM_ID],accepted_flags:["--depth","--fields"],description:"Read one Plan item with a bounded plan projection.",example:"pm plan show pm-a1b2 --depth standard"},{command:"plan add-step",parent:"plan",action:"add-step",slots:[PLAN_ITEM_ID],accepted_flags:PLAN_STEP_FLAGS,description:"Append one ordered step to a Plan item.",example:'pm plan add-step pm-a1b2 --step-title "Run tests"'},...Object.entries(PLAN_STEP_ACTION_DESCRIPTIONS).map(([action,description])=>({command:`plan ${action}`,parent:"plan",action,slots:[PLAN_ITEM_ID,PLAN_STEP],accepted_flags:PLAN_STEP_FLAGS,description,example:`pm plan ${action} pm-a1b2 plan-step-001`})),{command:"plan reorder-step",parent:"plan",action:"reorder-step",slots:[PLAN_ITEM_ID,PLAN_STEP,positionalSlot("new-order","integer",true)],accepted_flags:["--force","--message"],description:"Move one Plan step to a declared integer order.",example:"pm plan reorder-step pm-a1b2 plan-step-001 2"},...["decision","discovery","validation","resume","approve","materialize"].map(action=>({command:`plan ${action}`,parent:"plan",action,slots:[PLAN_ITEM_ID],accepted_flags:PLAN_STEP_FLAGS,description:`${positionalActionVerb(action)} for one Plan item.`,example:`pm plan ${action} pm-a1b2`})),...["list","show","put","remove"].map(action=>({command:`assurance ${action}`,parent:"assurance",action,slots:[positionalSlot("kind","string",true),...action==="list"?[]:[positionalSlot("id","string",true)]],accepted_flags:action==="put"?["--author","--definition","--message"]:action==="remove"?["--author","--message"]:[],description:`${positionalActionVerb(action)} assurance declarations by kind.`,example:action==="list"?"pm assurance list measurement":`pm assurance ${action} measurement example-id`})),{command:"assurance run",parent:"assurance",action:"run",slots:[positionalSlot("gate-id","string",true)],accepted_flags:["--dry-run","--trigger","--tree"],description:"Evaluate one assurance gate for a lifecycle trigger.",example:"pm assurance run tracker-context-quality --trigger ci --dry-run"},{command:"assurance verdicts",parent:"assurance",action:"verdicts",slots:[positionalSlot("gate-id","string",false)],accepted_flags:["--gate","--limit"],description:"List bounded assurance verdict history.",example:"pm assurance verdicts --limit 20"},...["presets","apply"].map(action=>({command:`assurance ${action}`,parent:"assurance",action,slots:[positionalSlot("preset","string",action==="apply")],accepted_flags:["--author","--message","--owner"],description:action==="apply"?"Apply one assurance adoption preset.":"List available assurance adoption presets.",example:action==="apply"?"pm assurance apply software-delivery --owner <pm-item-id>":"pm assurance presets"})),{command:"assurance derive",parent:"assurance",action:"derive",slots:[],accepted_flags:["--apply","--author","--message","--owner"],description:"Derive assurance proposals from current project context.",example:"pm assurance derive --owner pm-a1b2"},{command:"assurance promote",parent:"assurance",action:"promote",slots:[positionalSlot("assertion-id","string",true)],accepted_flags:["--author","--enforcement","--message"],description:"Promote one assertion into a warning or blocking gate.",example:"pm assurance promote assertion-id --enforcement warn"},{command:"assurance risk",parent:"assurance",action:"risk",slots:[],accepted_flags:["--definition"],description:"Analyze bounded defect-recurrence risk for a proposed change.",example:`pm assurance risk --definition '{"change":{"files":[]}}'`},{command:"assurance lineages",parent:"assurance",action:"lineages",slots:[],accepted_flags:["--definition"],description:"Measure all recorded recurrence lineages with bounded evidence rows.",example:`pm assurance lineages --definition '{"policy":{"version":1,"evidence_epoch":"2026-01-01T00:00:00.000Z","families":[]}}'`},{command:"workspace position",parent:"workspace",action:"position",slots:[],accepted_flags:[],description:"Read bounded merge-fence, receipt, history-drift, and next-action readiness.",example:"pm workspace position"},{command:"workspace snapshot create",parent:"workspace snapshot",action:"create",slots:[positionalSlot("name","string",false)],accepted_flags:[],description:"Capture authoritative tracker state as an immutable snapshot.",example:"pm workspace snapshot create before-migration"},{command:"workspace snapshot list",parent:"workspace snapshot",action:"list",slots:[],accepted_flags:[],description:"List immutable workspace snapshots and named references.",example:"pm workspace snapshot list"},{command:"workspace snapshot inspect",parent:"workspace snapshot",action:"inspect",slots:[positionalSlot("target","string",true)],accepted_flags:[],description:"Inspect one workspace snapshot target.",example:"pm workspace snapshot inspect before-migration"},{command:"workspace snapshot restore",parent:"workspace snapshot",action:"restore",slots:[positionalSlot("target","string",true)],accepted_flags:["--author","--dry-run","--force","--message"],description:"Restore an immutable workspace snapshot with explicit recovery controls.",example:"pm workspace snapshot restore before-migration --dry-run"},{command:"workspace snapshot delete",parent:"workspace snapshot",action:"delete",slots:[positionalSlot("target","string",true)],accepted_flags:[],description:"Delete one workspace snapshot target.",example:"pm workspace snapshot delete before-migration"}];const POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY=[...PM_POSITIONAL_ACTION_CONTRACTS].sort((left,right)=>right.command.length-left.command.length);const EXPLICIT_POSITIONAL_SLOTS=new Map([["append",[ITEM_ID,OPTIONAL_TEXT]],["assurance",[positionalSlot("action","action",true),positionalSlot("kind","string",false),positionalSlot("id","string",false)]],["beads import",[positionalSlot("file","string",false)]],["changelog export",[positionalSlot("file","string",false)]],["claim",[OPTIONAL_ITEM_ID]],["close",[ITEM_ID,OPTIONAL_TEXT]],["close-task",[ITEM_ID,positionalSlot("reason","string",false)]],["comments",[ITEM_ID,OPTIONAL_TEXT]],["completion",[positionalSlot("shell","string",false)]],["config",[positionalSlot("scope","string",false,{polymorphic:true}),positionalSlot("action","action",false),positionalSlot("key","string",false),positionalSlot("value","string",false,{polymorphic:true})]],["copy",[ITEM_ID]],["create",[positionalSlot("type-or-title","string",false,{polymorphic:true}),positionalSlot("title","string",false)]],["delete",[ITEM_ID]],["deps",[ITEM_ID]],["docs",[ITEM_ID]],["event",[positionalSlot("title","string",true)]],["files",[ITEM_ID]],["files discover",[ITEM_ID]],["files lookup",[positionalSlot("paths","string",true,{variadic:true})]],["focus",[OPTIONAL_ITEM_ID]],["get",[ITEM_ID]],["graph",[positionalSlot("subcommand","action",true),OPTIONAL_ITEM_ID,positionalSlot("target","item_id",false)]],["guide",[positionalSlot("topic","string",false)]],["history",[ITEM_ID]],["history-compact",[OPTIONAL_ITEM_ID]],["history-redact",[ITEM_ID]],["history-repair",[OPTIONAL_ITEM_ID]],["init",[positionalSlot("prefix-or-path","string",false,{polymorphic:true})]],["item complete",[ITEM_ID,positionalSlot("reason","string",false)]],["item reopen",[ITEM_ID,positionalSlot("reason","string",true)]],["learnings",[ITEM_ID,OPTIONAL_TEXT]],["meet",[positionalSlot("title","string",true)]],["merge",[positionalSlot("subcommand","action",true),positionalSlot("artifact","string",false),positionalSlot("base","string",false),positionalSlot("ours","string",false),positionalSlot("theirs","string",false)]],["notes",[ITEM_ID,OPTIONAL_TEXT]],["package",[positionalSlot("target","string",false,{polymorphic:true})]],["package list",[]],["package scaffold",[positionalSlot("target","string",true)]],["package upgrade",[positionalSlot("target","string",false)]],["packages",[positionalSlot("target","string",false,{polymorphic:true})]],["packages list",[]],["packages scaffold",[positionalSlot("target","string",true)]],["packages upgrade",[positionalSlot("target","string",false)]],["pause-task",[ITEM_ID]],["plan",[positionalSlot("subcommand","action",true),positionalSlot("id","item_id",false,{polymorphic:true}),positionalSlot("step","string",false),positionalSlot("new-order","integer",false)]],["profile",[positionalSlot("subcommand","action",true),positionalSlot("name","string",false)]],["release",[ITEM_ID]],["remind",[positionalSlot("title","string",true)]],["restore",[ITEM_ID,positionalSlot("target","string",true)]],["schema",[positionalSlot("subcommand","action",true),positionalSlot("name","string",false)]],["search-advanced",[positionalSlot("keywords","string",true,{variadic:true})]],["search",[positionalSlot("keywords","string",true,{variadic:true})]],["start-task",[ITEM_ID]],["telemetry",[positionalSlot("namespace-or-subcommand","action",false,{polymorphic:true}),positionalSlot("subcommand","action",false)]],["test",[ITEM_ID]],["test-runs-worker",[positionalSlot("runId","string",true)]],["update",[ITEM_ID]],["workspace snapshot",[positionalSlot("action","action",true),positionalSlot("target","string",false)]],...["activate","adopt","deactivate","init","uninstall"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("target","string",true)]])),...["describe"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("target","string",false)]])),...["install"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("targets","string",false,{variadic:true})]])),["vcs abandon",[ITEM_ID]],["vcs create",[positionalSlot("title","string",true)]],["vcs merge",[ITEM_ID]],["vcs propose",[ITEM_ID]],["vcs ref-create",[positionalSlot("name","string",true)]],["vcs show",[ITEM_ID]]]);function normalizePositionalCommandPath(command){return command.trim().toLowerCase().replace(/\s+/gu," ")}function resolvePmCommandPositionalContract(command){const normalized=normalizePositionalCommandPath(command);const direct=PM_COMMAND_POSITIONAL_CONTRACTS.find(contract=>contract.command===normalized);if(direct)return direct;const canonical=resolvePmCommandAlias(normalized)?.canonical;if(!canonical)return void 0;return PM_COMMAND_POSITIONAL_CONTRACTS.find(contract=>contract.command===canonical)}function resolvePmPositionalActionContract(command){const normalized=normalizePositionalCommandPath(command);return POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY.find(contract=>contract.command===normalized||normalized.startsWith(`${contract.command} `))}function formatPmPositionalActionFlagTip(acceptedFlags){return`Applicable flags: ${acceptedFlags.length>0?acceptedFlags.join(", "):"none"}.`}function destinationRows(noun,target,disposition,owner,commands){return commands.map(command=>({command,noun,target,disposition,owner}))}const PM_COMMAND_DESTINATION_CONTRACTS=[...destinationRows("item","item","target_noun","pm-pbyu",["item","item complete","item mutate","item reopen"]),...destinationRows("item","item","consolidation","pm-yql1",["append","close-many","close-task","comments","copy","delete","deps","docs","files","learnings","notes","pause-task","start-task","test","update-many"]),...["claim","close","create","get","release","update"].map(command=>({command,noun:"item",target:command,disposition:"keep_as_is",owner:"pm-pbyu",reason:"Permanent high-frequency item operations retain concise root spellings under the accepted hot-path grammar policy."})),...destinationRows("item","item files","target_noun","pm-yql1",["files discover","files lookup","item files discover","item files lookup"]),...destinationRows("item","item test worker","consolidation","pm-lp4j",["test-runs-worker"]),...destinationRows("list","list","target_noun","pm-pfqi",["list"]),...destinationRows("list","list --group-by","consolidation","pm-xkgq",["aggregate"]),...destinationRows("context","context","target_noun","pm-pbyu",["context"]),...destinationRows("context","context","consolidation","pm-kcs4",["ctx","focus","next"]),...destinationRows("context","context next","consolidation","pm-kcs4",["ctx next"]),...destinationRows("context","context focus","consolidation","pm-kcs4",["ctx focus"]),...destinationRows("search","search","target_noun","pm-pbyu",["search"]),...destinationRows("search","search","package_owned","package:search-advanced",["reindex","search-advanced"]),...destinationRows("item","item duplicates","consolidation","pm-fmy9ih",["duplicates"]),...destinationRows("item","item duplicates","package_owned","pm-fmy9ih",["dedupe-audit","dedupe-merge","comments-audit"]),...destinationRows("graph","graph","target_noun","pm-pbyu",["graph"]),...destinationRows("history","history","target_noun","pm-pbyu",["history"]),...destinationRows("history","history attest","target_noun","pm-3z0k",["history attest"]),...destinationRows("history","history attest","consolidation","pm-3z0k",["history-attest"]),...PM_HISTORY_COMMAND_ALIASES.flatMap(({alias,canonical})=>[...destinationRows("history",canonical,"target_noun","pm-tqel",[canonical]),...destinationRows("history",canonical,"consolidation","pm-tqel",[alias])]),...destinationRows("history","history","consolidation","pm-tqel",["events","merge"]),...destinationRows("history","history acknowledge","consolidation","pm-djyvbk",["history-author-acknowledge"]),...destinationRows("history","history","package_owned","package:builtin-vcs-exemplar",["vcs abandon","vcs create","vcs log","vcs merge","vcs propose","vcs ref-create","vcs show"]),...destinationRows("workspace","workspace","target_noun","pm-pbyu",["workspace","workspace position","workspace snapshot","workspace snapshot create","workspace snapshot delete","workspace snapshot inspect","workspace snapshot list","workspace snapshot restore"]),...destinationRows("workspace","workspace init","consolidation","pm-npr3",["init"]),...destinationRows("package","package","target_noun","pm-pbyu",["package","package activate","package adopt","package adopt-all","package catalog","package deactivate","package describe","package doctor","package explore","package init","package install","package list","package manage","package migrate","package reload","package scaffold","package uninstall","package upgrade"]),...destinationRows("package","package","consolidation","pm-tnud",["extension activate","extension adopt","extension adopt-all","extension catalog","extension deactivate","extension describe","extension doctor","extension explore","extension init","extension install","extension manage","extension migrate","extension reload","extension uninstall","packages","packages activate","packages adopt","packages adopt-all","packages catalog","packages deactivate","packages describe","packages doctor","packages explore","packages init","packages install","packages list","packages manage","packages migrate","packages reload","packages scaffold","packages uninstall","packages upgrade"]),...destinationRows("package","package","package_owned","package:beads",["beads import"]),...destinationRows("package","package","package_owned","package:pm-changelog",["changelog export","changelog generate"]),...destinationRows("package","package calendar","package_owned","pm-o3fh",["event","meet","remind"]),...destinationRows("ops","ops","target_noun","pm-6apl",["ops"]),...destinationRows("ops","ops normalize","package_owned","package:pm-governance-audit",["normalize"]),...destinationRows("ops","ops","consolidation","pm-6apl",["eval","gc","health","stats","telemetry","test-all","validate"]),...destinationRows("ops","ops","consolidation","pm-npr3",["config","profile","schema"]),...["assurance",...PM_POSITIONAL_ACTION_CONTRACTS.filter(({parent})=>parent==="assurance").map(({command})=>command)].map(command=>({command,noun:"ops",target:command,disposition:"keep_as_is",owner:"pm-djyvbk",reason:"Assurance manages durable measurement, assertion, gate, and verdict data; retain its established domain surface independently of operational diagnostics."})),...destinationRows("plan","plan","target_noun","pm-pbyu",["plan"]),...destinationRows("plan","plan","target_noun","pm-2tan",PM_POSITIONAL_ACTION_CONTRACTS.filter(({parent})=>parent==="plan").map(({command})=>command)),...destinationRows("contracts","contracts","target_noun","pm-pbyu",["contracts"]),...destinationRows("help","help","target_noun","pm-pbyu",["help"]),...destinationRows("help","help","package_owned","package:builtin-guide-shell",["completion","completion-statuses","completion-tags","completion-types","guide"])].flatMap(entry=>{const alias=PM_RELOCATED_COMMAND_ALIASES.find(candidate=>candidate.alias===entry.command);if(!alias)return[entry];const noun=PM_CLI_GRAMMAR_NOUNS.find(candidate=>candidate===alias.canonical_argv[0])??entry.noun;return[{...entry,noun,target:alias.canonical,owner:alias.owner},{...entry,command:alias.canonical,noun,target:alias.canonical,owner:alias.owner,disposition:entry.disposition==="package_owned"?"package_owned":"target_noun"}]});const PM_COMMAND_POSITIONAL_CONTRACTS=[...new Set(PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command))].map(command=>({command,slots:resolvePmPositionalActionContract(command)?.slots??EXPLICIT_POSITIONAL_SLOTS.get(resolvePmHistoryOperation(command))??[]}));const PM_CLI_GRAMMAR_CONTRACT={nouns:PM_CLI_GRAMMAR_NOUNS,shared_verbs:PM_CLI_SHARED_VERBS,scope_before_verb:true,visible_top_level_ceiling:69,ceiling_raise_requires_pm_item:true,positional_shape_budget:21};function verifyExplicitPositionalSlotCensus(explicitCommands,destinationCommands){const destinations=new Set(destinationCommands);return[...new Set(explicitCommands)].filter(command=>!destinations.has(command)).map(command=>({code:"positional_signature_mismatch",command,detail:`Positional signature ${command} has no destination declaration.`}))}function positionalShapeKey(slots){return slots.map(({required,variadic,value_kind:valueKind,polymorphic})=>`${required?"r":"o"}:${variadic?"v":"s"}:${valueKind}:${polymorphic?"p":"m"}`).join("|")}function positionalSignatureKey(slots){return slots.map(({name,required,variadic,value_kind:valueKind,polymorphic})=>`${name}:${required?"r":"o"}:${variadic?"v":"s"}:${valueKind}:${polymorphic?"p":"m"}`).join("|")}function duplicatePositionalSignatureFindings(contracts,surface){const counts=new Map;for(const{command}of contracts){const normalized=normalizePositionalCommandPath(command);counts.set(normalized,(counts.get(normalized)??0)+1)}return[...counts.entries()].filter(([,count])=>count>1).map(([command,count])=>({code:"positional_signature_mismatch",command,detail:`${count} ${surface} positional signatures exist for ${command}; exactly one is required.`}))}function verifyPmCommandPositionalContracts(observed,options={}){const declared=options.declared??PM_COMMAND_POSITIONAL_CONTRACTS;const positionalShapeBudget=options.positionalShapeBudget??PM_CLI_GRAMMAR_CONTRACT.positional_shape_budget;const declaredByCommand=new Map(declared.map(contract=>[normalizePositionalCommandPath(contract.command),contract]));const observedByCommand=new Map(observed.map(contract=>[normalizePositionalCommandPath(contract.command),contract]));const findings=[...duplicatePositionalSignatureFindings(declared,"declared"),...duplicatePositionalSignatureFindings(observed,"observed"),...options.declared===void 0?[...verifyExplicitPositionalSlotCensus(EXPLICIT_POSITIONAL_SLOTS.keys(),PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command)),...verifyExplicitPositionalSlotCensus(PM_POSITIONAL_ACTION_CONTRACTS.map(({command})=>command),PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command))]:[]];for(const contract of declaredByCommand.values()){const normalizedCommand=normalizePositionalCommandPath(contract.command);const actual=observedByCommand.get(normalizedCommand);if(!actual){findings.push({code:"missing_observed_signature",command:contract.command,detail:`No observed positional signature exists for ${contract.command}.`})}else if(positionalSignatureKey(actual.slots)!==positionalSignatureKey(contract.slots)){findings.push({code:"positional_signature_mismatch",command:contract.command,detail:`Observed positional signature for ${contract.command} differs from its declared SDK contract: observed=${positionalSignatureKey(actual.slots)||"<none>"}; declared=${positionalSignatureKey(contract.slots)||"<none>"}.`})}}for(const contract of observedByCommand.values()){if(!declaredByCommand.has(normalizePositionalCommandPath(contract.command))){findings.push({code:"stale_observed_signature",command:contract.command,detail:`Observed positional signature ${contract.command} has no declaration.`})}}const positionalShapeCount=new Set(declared.map(({slots})=>positionalShapeKey(slots))).size;if(positionalShapeCount>positionalShapeBudget){findings.push({code:"positional_shape_budget_exceeded",command:"*",detail:`Distinct positional shape count ${positionalShapeCount} exceeds budget ${positionalShapeBudget}.`})}findings.sort((left,right)=>left.command!==right.command?left.command.localeCompare(right.command):left.code.localeCompare(right.code));return{ok:findings.length===0,declared_command_count:declared.length,observed_command_count:observed.length,positional_shape_count:positionalShapeCount,positional_shape_budget:positionalShapeBudget,findings}}function validateCommandDestinations(commands,destinationsByCommand,nounSet){return commands.flatMap(command=>{const destinations=destinationsByCommand.get(command)??[];if(destinations.length===0){const separatorIndex=command.indexOf(" ");const root=separatorIndex===-1?command:command.slice(0,separatorIndex);return[{code:"missing_destination",spelling:command,message:`Command \`${command}\` has no destination census row.`,nearest_target:nounSet.has(root)?root:`ops ${command}`}]}const duplicateFinding=destinations.length>1?[{code:"duplicate_destination",spelling:command,message:`Command \`${command}\` has ${destinations.length} destination rows.`,nearest_target:destinations[0].target}]:[];return destinations.reduce((findings,destination)=>{if(destination.disposition==="keep_as_is"&&(destination.reason?.trim().length??0)===0){findings.push({code:"missing_destination",spelling:command,message:`Command \`${command}\` is kept as-is without a documented reason.`,nearest_target:destination.target})}if(!nounSet.has(destination.noun)){findings.push({code:"unknown_noun",spelling:command,message:`Command \`${command}\` names undeclared noun \`${destination.noun}\`.`,nearest_target:destination.target})}return findings},duplicateFinding)})}function validateDestinationCensus(commandSet,destinations){return destinations.filter(destination=>destination.disposition!=="package_owned"&&!commandSet.has(destination.command)).map(destination=>({code:"stale_destination",spelling:destination.command,message:`Destination row \`${destination.command}\` is absent from live contracts.`,nearest_target:destination.target}))}function validateAliasTargets(aliases,commandSet){return aliases.filter(alias=>!commandSet.has(alias.canonical)).map(alias=>({code:"alias_target_missing",spelling:alias.alias,message:`Alias \`${alias.alias}\` targets missing canonical command \`${alias.canonical}\`.`,nearest_target:alias.canonical_argv.join(" ")}))}function verifyPmCliGrammar(commands,aliases=[],destinations=PM_COMMAND_DESTINATION_CONTRACTS){const normalizedCommands=[...new Set(commands.map(command=>command.trim()))].filter(command=>command.length>0).sort((left,right)=>left.localeCompare(right));const commandSet=new Set(normalizedCommands);const nounSet=new Set(PM_CLI_GRAMMAR_NOUNS);const destinationsByCommand=new Map;for(const destination of destinations){const entries=destinationsByCommand.get(destination.command)??[];entries.push(destination);destinationsByCommand.set(destination.command,entries)}const findings=[...validateCommandDestinations(normalizedCommands,destinationsByCommand,nounSet),...validateDestinationCensus(commandSet,destinations),...validateAliasTargets(aliases.filter(alias=>commandSet.has(alias.alias)||!(destinationsByCommand.get(alias.canonical)??[]).some(destination=>destination.disposition==="package_owned")),commandSet)];const hiddenAliasNames=new Set(aliases.filter(alias=>alias.hidden).map(alias=>alias.alias));const visibleTopLevelCount=new Set(normalizedCommands.filter(command=>!command.includes(" ")&&!hiddenAliasNames.has(command)&&!(destinationsByCommand.get(command)??[]).some(destination=>destination.disposition==="package_owned"))).size;if(visibleTopLevelCount>PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling){findings.push({code:"visible_surface_ceiling_exceeded",spelling:String(visibleTopLevelCount),message:`Visible non-package top-level command count ${visibleTopLevelCount} exceeds ceiling ${PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling}.`,nearest_target:"Declare the noun placement and tracked waiver before raising the ceiling."})}return{ok:findings.length===0,command_count:normalizedCommands.length,destination_count:destinations.length,hidden_alias_count:aliases.filter(alias=>alias.hidden).length,visible_top_level_count:visibleTopLevelCount,visible_top_level_ceiling:PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling,findings}}export{PM_CLI_GRAMMAR_CONTRACT,PM_CLI_GRAMMAR_NOUNS,PM_CLI_SHARED_VERBS,PM_COMMAND_DESTINATION_CONTRACTS,PM_COMMAND_POSITIONAL_CONTRACTS,PM_POSITIONAL_ACTION_CONTRACTS,formatPmPositionalActionFlagTip,positionalShapeKey,positionalSignatureKey,resolvePmCommandPositionalContract,resolvePmPositionalActionContract,verifyExplicitPositionalSlotCensus,verifyPmCliGrammar,verifyPmCommandPositionalContracts};
|
|
1
|
+
!(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]="d78f489d-2ce1-5806-a17e-0c6c049ad0f0")}catch(e2){}})();import{resolvePmCommandAlias,PM_HISTORY_COMMAND_ALIASES,PM_RELOCATED_COMMAND_ALIASES,resolvePmHistoryOperation}from"./command-aliases.js";const PM_CLI_GRAMMAR_NOUNS=["item","list","context","search","graph","history","workspace","package","ops","plan","contracts","help"];const PM_CLI_SHARED_VERBS=["acknowledge","activate","add","adopt","adopt-all","catalog","compact","complete","create","deactivate","delete","describe","doctor","edit","explore","import","init","inspect","install","list","manage","migrate","mutate","read","redact","reload","remove","reopen","repair","restore","run","show","uninstall","upgrade","verify"];function positionalSlot(name,valueKind,required,options={}){return{name,required,variadic:options.variadic===true,value_kind:valueKind,polymorphic:options.polymorphic===true}}function positionalActionVerb(action){const phrase=action.replaceAll("-"," ");return`${phrase.charAt(0).toUpperCase()}${phrase.slice(1)}`}const ITEM_ID=positionalSlot("id","item_id",true);const OPTIONAL_ITEM_ID=positionalSlot("id","item_id",false);const OPTIONAL_TEXT=positionalSlot("text","string",false);const PLAN_ITEM_ID=positionalSlot("plan-id","item_id",true);const PLAN_STEP=positionalSlot("step","string",true);const PLAN_CREATE_FLAGS=["--acceptance-criteria","--actual-result","--affected-version","--assignee","--blocked-by","--blocked-reason","--blocks","--body","--claim","--comment","--component","--confidence","--create-mode","--customer-impact","--deadline","--definition-of-ready","--description","--doc","--environment","--estimate","--event","--expected-result","--fixed-version","--file","--from-search","--goal","--harness","--impact","--learning","--message","--mode","--note","--objective","--order","--outcome","--parent","--priority","--rank","--related","--release","--reminder","--reporter","--repro-steps","--resolution","--resume-context","--reviewer","--risk","--scope","--severity","--sprint","--status","--step","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-replacement","--step-status","--step-title","--tags","--template","--test","--title","--type-option","--unblock-note","--value","--why-now"];const PLAN_STEP_FLAGS=["--allow-multiple-active","--depends-on","--file","--force","--message","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-status","--step-title","--test"];const PLAN_STEP_ACTION_DESCRIPTIONS={"update-step":"Update one declared Plan step.","complete-step":"Complete one declared Plan step.","block-step":"Block one declared Plan step.","remove-step":"Remove one declared Plan step.",link:"Link one dependency to a declared Plan step.",unlink:"Unlink one dependency from a declared Plan step."};const PM_POSITIONAL_ACTION_CONTRACTS=[{command:"plan create",parent:"plan",action:"create",slots:[positionalSlot("title","string",false,{polymorphic:true})],accepted_flags:PLAN_CREATE_FLAGS,description:"Create a Plan item and optionally seed its ordered steps.",example:'pm plan create --title "Refactor lock retry"'},{command:"plan show",parent:"plan",action:"show",slots:[PLAN_ITEM_ID],accepted_flags:["--depth","--fields"],description:"Read one Plan item with a bounded plan projection.",example:"pm plan show pm-a1b2 --depth standard"},{command:"plan add-step",parent:"plan",action:"add-step",slots:[PLAN_ITEM_ID],accepted_flags:PLAN_STEP_FLAGS,description:"Append one ordered step to a Plan item.",example:'pm plan add-step pm-a1b2 --step-title "Run tests"'},...Object.entries(PLAN_STEP_ACTION_DESCRIPTIONS).map(([action,description])=>({command:`plan ${action}`,parent:"plan",action,slots:[PLAN_ITEM_ID,PLAN_STEP],accepted_flags:PLAN_STEP_FLAGS,description,example:`pm plan ${action} pm-a1b2 plan-step-001`})),{command:"plan reorder-step",parent:"plan",action:"reorder-step",slots:[PLAN_ITEM_ID,PLAN_STEP,positionalSlot("new-order","integer",true)],accepted_flags:["--force","--message"],description:"Move one Plan step to a declared integer order.",example:"pm plan reorder-step pm-a1b2 plan-step-001 2"},...["decision","discovery","validation","resume","approve","materialize"].map(action=>({command:`plan ${action}`,parent:"plan",action,slots:[PLAN_ITEM_ID],accepted_flags:PLAN_STEP_FLAGS,description:`${positionalActionVerb(action)} for one Plan item.`,example:`pm plan ${action} pm-a1b2`})),...["list","show","put","remove"].map(action=>({command:`assurance ${action}`,parent:"assurance",action,slots:[positionalSlot("kind","string",true),...action==="list"?[]:[positionalSlot("id","string",true)]],accepted_flags:action==="put"?["--author","--definition","--message"]:action==="remove"?["--author","--message"]:[],description:`${positionalActionVerb(action)} assurance declarations by kind.`,example:action==="list"?"pm assurance list measurement":`pm assurance ${action} measurement example-id`})),{command:"assurance run",parent:"assurance",action:"run",slots:[positionalSlot("gate-id","string",true)],accepted_flags:["--dry-run","--trigger","--tree"],description:"Evaluate one assurance gate for a lifecycle trigger.",example:"pm assurance run tracker-context-quality --trigger ci --dry-run"},{command:"assurance verdicts",parent:"assurance",action:"verdicts",slots:[positionalSlot("gate-id","string",false)],accepted_flags:["--gate","--limit"],description:"List bounded assurance verdict history.",example:"pm assurance verdicts --limit 20"},...["presets","apply"].map(action=>({command:`assurance ${action}`,parent:"assurance",action,slots:[positionalSlot("preset","string",action==="apply")],accepted_flags:["--author","--message","--owner"],description:action==="apply"?"Apply one assurance adoption preset.":"List available assurance adoption presets.",example:action==="apply"?"pm assurance apply software-delivery --owner <pm-item-id>":"pm assurance presets"})),{command:"assurance derive",parent:"assurance",action:"derive",slots:[],accepted_flags:["--apply","--author","--message","--owner"],description:"Derive assurance proposals from current project context.",example:"pm assurance derive --owner pm-a1b2"},{command:"assurance promote",parent:"assurance",action:"promote",slots:[positionalSlot("assertion-id","string",true)],accepted_flags:["--author","--enforcement","--message"],description:"Promote one assertion into a warning or blocking gate.",example:"pm assurance promote assertion-id --enforcement warn"},{command:"assurance risk",parent:"assurance",action:"risk",slots:[],accepted_flags:["--definition"],description:"Analyze bounded defect-recurrence risk for a proposed change.",example:`pm assurance risk --definition '{"change":{"files":[]}}'`},{command:"assurance lineages",parent:"assurance",action:"lineages",slots:[],accepted_flags:["--definition"],description:"Measure all recorded recurrence lineages with bounded evidence rows.",example:`pm assurance lineages --definition '{"policy":{"version":1,"evidence_epoch":"2026-01-01T00:00:00.000Z","families":[]}}'`},{command:"workspace position",parent:"workspace",action:"position",slots:[],accepted_flags:[],description:"Read bounded merge-fence, receipt, history-drift, and next-action readiness.",example:"pm workspace position"},{command:"workspace snapshot create",parent:"workspace snapshot",action:"create",slots:[positionalSlot("name","string",false)],accepted_flags:[],description:"Capture authoritative tracker state as an immutable snapshot.",example:"pm workspace snapshot create before-migration"},{command:"workspace snapshot list",parent:"workspace snapshot",action:"list",slots:[],accepted_flags:[],description:"List immutable workspace snapshots and named references.",example:"pm workspace snapshot list"},{command:"workspace snapshot inspect",parent:"workspace snapshot",action:"inspect",slots:[positionalSlot("target","string",true)],accepted_flags:[],description:"Inspect one workspace snapshot target.",example:"pm workspace snapshot inspect before-migration"},{command:"workspace snapshot restore",parent:"workspace snapshot",action:"restore",slots:[positionalSlot("target","string",true)],accepted_flags:["--author","--dry-run","--force","--message"],description:"Restore an immutable workspace snapshot with explicit recovery controls.",example:"pm workspace snapshot restore before-migration --dry-run"},{command:"workspace snapshot delete",parent:"workspace snapshot",action:"delete",slots:[positionalSlot("target","string",true)],accepted_flags:[],description:"Delete one workspace snapshot target.",example:"pm workspace snapshot delete before-migration"}];const POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY=[...PM_POSITIONAL_ACTION_CONTRACTS].sort((left,right)=>right.command.length-left.command.length);const EXPLICIT_POSITIONAL_SLOTS=new Map([["append",[ITEM_ID,OPTIONAL_TEXT]],["assurance",[positionalSlot("action","action",true),positionalSlot("kind","string",false),positionalSlot("id","string",false)]],["beads import",[positionalSlot("file","string",false)]],["changelog export",[positionalSlot("file","string",false)]],["claim",[OPTIONAL_ITEM_ID]],["close",[ITEM_ID,OPTIONAL_TEXT]],["close-task",[ITEM_ID,positionalSlot("reason","string",false)]],["comments",[ITEM_ID,OPTIONAL_TEXT]],["completion",[positionalSlot("shell","string",false)]],["config",[positionalSlot("scope","string",false,{polymorphic:true}),positionalSlot("action","action",false),positionalSlot("key","string",false),positionalSlot("value","string",false,{polymorphic:true})]],["copy",[ITEM_ID]],["create",[positionalSlot("type-or-title","string",false,{polymorphic:true}),positionalSlot("title","string",false)]],["delete",[ITEM_ID]],["deps",[ITEM_ID]],["docs",[ITEM_ID]],["event",[positionalSlot("title","string",true)]],["files",[ITEM_ID]],["files discover",[ITEM_ID]],["files lookup",[positionalSlot("paths","string",true,{variadic:true})]],["focus",[OPTIONAL_ITEM_ID]],["get",[ITEM_ID]],["graph",[positionalSlot("subcommand","action",true),OPTIONAL_ITEM_ID,positionalSlot("target","item_id",false)]],["guide",[positionalSlot("topic","string",false)]],["history",[ITEM_ID]],["history-compact",[OPTIONAL_ITEM_ID]],["history-redact",[ITEM_ID]],["history-repair",[OPTIONAL_ITEM_ID]],["init",[positionalSlot("prefix-or-path","string",false,{polymorphic:true})]],["item complete",[ITEM_ID,positionalSlot("reason","string",false)]],["item reopen",[ITEM_ID,positionalSlot("reason","string",true)]],["learnings",[ITEM_ID,OPTIONAL_TEXT]],["meet",[positionalSlot("title","string",true)]],["merge",[positionalSlot("subcommand","action",true),positionalSlot("artifact","string",false),positionalSlot("base","string",false),positionalSlot("ours","string",false),positionalSlot("theirs","string",false)]],["notes",[ITEM_ID,OPTIONAL_TEXT]],["package",[positionalSlot("target","string",false,{polymorphic:true})]],["package list",[]],["package inventory",[positionalSlot("name","string",false)]],["package scaffold",[positionalSlot("target","string",true)]],["package upgrade",[positionalSlot("target","string",false)]],["packages",[positionalSlot("target","string",false,{polymorphic:true})]],["packages list",[]],["packages inventory",[positionalSlot("name","string",false)]],["packages scaffold",[positionalSlot("target","string",true)]],["packages upgrade",[positionalSlot("target","string",false)]],["pause-task",[ITEM_ID]],["plan",[positionalSlot("subcommand","action",true),positionalSlot("id","item_id",false,{polymorphic:true}),positionalSlot("step","string",false),positionalSlot("new-order","integer",false)]],["profile",[positionalSlot("subcommand","action",true),positionalSlot("name","string",false)]],["release",[ITEM_ID]],["remind",[positionalSlot("title","string",true)]],["restore",[ITEM_ID,positionalSlot("target","string",true)]],["schema",[positionalSlot("subcommand","action",true),positionalSlot("name","string",false)]],["search-advanced",[positionalSlot("keywords","string",true,{variadic:true})]],["search",[positionalSlot("keywords","string",true,{variadic:true})]],["start-task",[ITEM_ID]],["templates save",[positionalSlot("name","string",true)]],["templates show",[positionalSlot("name","string",true)]],["telemetry",[positionalSlot("namespace-or-subcommand","action",false,{polymorphic:true}),positionalSlot("subcommand","action",false)]],["test",[ITEM_ID]],["test-runs-worker",[positionalSlot("runId","string",true)]],["update",[ITEM_ID]],["workspace snapshot",[positionalSlot("action","action",true),positionalSlot("target","string",false)]],...["activate","adopt","deactivate","init","uninstall"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("target","string",true)]])),...["describe"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("target","string",false)]])),...["install"].flatMap(action=>["extension","package","packages"].map(root=>[`${root} ${action}`,[positionalSlot("targets","string",false,{variadic:true})]])),["vcs abandon",[ITEM_ID]],["vcs create",[positionalSlot("title","string",true)]],["vcs merge",[ITEM_ID]],["vcs propose",[ITEM_ID]],["vcs ref-create",[positionalSlot("name","string",true)]],["vcs show",[ITEM_ID]]]);function normalizePositionalCommandPath(command){return command.trim().toLowerCase().replace(/\s+/gu," ")}function resolvePmCommandPositionalContract(command){const normalized=normalizePositionalCommandPath(command);const direct=PM_COMMAND_POSITIONAL_CONTRACTS.find(contract=>contract.command===normalized);if(direct)return direct;const canonical=resolvePmCommandAlias(normalized)?.canonical;if(!canonical)return void 0;return PM_COMMAND_POSITIONAL_CONTRACTS.find(contract=>contract.command===canonical)}function resolvePmPositionalActionContract(command){const normalized=normalizePositionalCommandPath(command);return POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY.find(contract=>contract.command===normalized||normalized.startsWith(`${contract.command} `))}function formatPmPositionalActionFlagTip(acceptedFlags){return`Applicable flags: ${acceptedFlags.length>0?acceptedFlags.join(", "):"none"}.`}function destinationRows(noun,target,disposition,owner,commands){return commands.map(command=>({command,noun,target,disposition,owner}))}const PM_COMMAND_DESTINATION_CONTRACTS=[...destinationRows("item","item","target_noun","pm-pbyu",["item","item complete","item mutate","item reopen"]),...destinationRows("item","item","consolidation","pm-yql1",["append","close-many","close-task","comments","copy","delete","deps","docs","files","learnings","notes","pause-task","start-task","test","update-many"]),...["claim","close","create","get","release","update"].map(command=>({command,noun:"item",target:command,disposition:"keep_as_is",owner:"pm-pbyu",reason:"Permanent high-frequency item operations retain concise root spellings under the accepted hot-path grammar policy."})),...destinationRows("item","item files","target_noun","pm-yql1",["files discover","files lookup","item files discover","item files lookup"]),...destinationRows("item","item test worker","consolidation","pm-lp4j",["test-runs-worker"]),...destinationRows("list","list","target_noun","pm-pfqi",["list"]),...destinationRows("list","list --group-by","consolidation","pm-xkgq",["aggregate"]),...destinationRows("context","context","target_noun","pm-pbyu",["context"]),...destinationRows("context","context","consolidation","pm-kcs4",["ctx","focus","next"]),...destinationRows("context","context next","consolidation","pm-kcs4",["ctx next"]),...destinationRows("context","context focus","consolidation","pm-kcs4",["ctx focus"]),...destinationRows("search","search","target_noun","pm-pbyu",["search"]),...destinationRows("search","search","package_owned","package:search-advanced",["reindex","search-advanced"]),...destinationRows("item","item duplicates","consolidation","pm-fmy9ih",["duplicates"]),...destinationRows("item","item duplicates","package_owned","pm-fmy9ih",["dedupe-audit","dedupe-merge","comments-audit"]),...destinationRows("graph","graph","target_noun","pm-pbyu",["graph"]),...destinationRows("history","history","target_noun","pm-pbyu",["history"]),...destinationRows("history","history attest","target_noun","pm-3z0k",["history attest"]),...destinationRows("history","history attest","consolidation","pm-3z0k",["history-attest"]),...PM_HISTORY_COMMAND_ALIASES.flatMap(({alias,canonical})=>[...destinationRows("history",canonical,"target_noun","pm-tqel",[canonical]),...destinationRows("history",canonical,"consolidation","pm-tqel",[alias])]),...destinationRows("history","history","consolidation","pm-tqel",["events","merge"]),...destinationRows("history","history acknowledge","consolidation","pm-djyvbk",["history-author-acknowledge"]),...destinationRows("history","history","package_owned","package:builtin-vcs-exemplar",["vcs abandon","vcs create","vcs log","vcs merge","vcs propose","vcs ref-create","vcs show"]),...destinationRows("workspace","workspace","target_noun","pm-pbyu",["workspace","workspace position","workspace snapshot","workspace snapshot create","workspace snapshot delete","workspace snapshot inspect","workspace snapshot list","workspace snapshot restore"]),...destinationRows("workspace","workspace init","consolidation","pm-npr3",["init"]),...destinationRows("package","package","target_noun","pm-pbyu",["package","package activate","package adopt","package adopt-all","package catalog","package deactivate","package describe","package doctor","package explore","package init","package install","package inventory","package list","package manage","package migrate","package reload","package scaffold","package uninstall","package upgrade"]),...destinationRows("package","package","consolidation","pm-tnud",["extension activate","extension adopt","extension adopt-all","extension catalog","extension deactivate","extension describe","extension doctor","extension explore","extension init","extension install","extension manage","extension migrate","extension reload","extension uninstall","packages","packages activate","packages adopt","packages adopt-all","packages catalog","packages deactivate","packages describe","packages doctor","packages explore","packages init","packages install","packages inventory","packages list","packages manage","packages migrate","packages reload","packages scaffold","packages uninstall","packages upgrade"]),...destinationRows("package","package","package_owned","package:beads",["beads import"]),...destinationRows("package","package","package_owned","package:pm-changelog",["changelog export","changelog generate"]),...destinationRows("package","package calendar","package_owned","pm-o3fh",["event","meet","remind"]),...destinationRows("ops","ops","target_noun","pm-6apl",["ops"]),...destinationRows("ops","ops normalize","package_owned","package:pm-governance-audit",["normalize"]),...destinationRows("ops","ops","consolidation","pm-6apl",["eval","gc","health","stats","telemetry","test-all","validate"]),...destinationRows("workspace","workspace","consolidation","pm-npr3",["config","profile","schema"]),...["assurance",...PM_POSITIONAL_ACTION_CONTRACTS.filter(({parent})=>parent==="assurance").map(({command})=>command)].map(command=>({command,noun:"ops",target:command,disposition:"keep_as_is",owner:"pm-djyvbk",reason:"Assurance manages durable measurement, assertion, gate, and verdict data; retain its established domain surface independently of operational diagnostics."})),...destinationRows("plan","plan","target_noun","pm-pbyu",["plan"]),...destinationRows("plan","plan","target_noun","pm-2tan",PM_POSITIONAL_ACTION_CONTRACTS.filter(({parent})=>parent==="plan").map(({command})=>command)),...destinationRows("contracts","contracts","target_noun","pm-pbyu",["contracts"]),...destinationRows("help","help","target_noun","pm-pbyu",["help"]),...destinationRows("workspace","templates","package_owned","package:builtin-templates",["templates","templates list","templates save","templates show"]),...destinationRows("help","help","package_owned","package:builtin-guide-shell",["completion","completion-statuses","completion-tags","completion-types","guide"])].flatMap(entry=>{const alias=PM_RELOCATED_COMMAND_ALIASES.find(candidate=>candidate.alias===entry.command);if(!alias)return[entry];const noun=PM_CLI_GRAMMAR_NOUNS.find(candidate=>candidate===alias.canonical_argv[0])??entry.noun;return[{...entry,noun,target:alias.canonical,owner:alias.owner},{...entry,command:alias.canonical,noun,target:alias.canonical,owner:alias.owner,disposition:entry.disposition==="package_owned"?"package_owned":"target_noun"}]});const PM_COMMAND_POSITIONAL_CONTRACTS=[...new Set(PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command))].map(command=>({command,slots:resolvePmPositionalActionContract(command)?.slots??EXPLICIT_POSITIONAL_SLOTS.get(resolvePmHistoryOperation(command))??[]}));const PM_CLI_GRAMMAR_CONTRACT={nouns:PM_CLI_GRAMMAR_NOUNS,shared_verbs:PM_CLI_SHARED_VERBS,scope_before_verb:true,visible_top_level_ceiling:69,ceiling_raise_requires_pm_item:true,positional_shape_budget:21};function verifyExplicitPositionalSlotCensus(explicitCommands,destinationCommands){const destinations=new Set(destinationCommands);return[...new Set(explicitCommands)].filter(command=>!destinations.has(command)).map(command=>({code:"positional_signature_mismatch",command,detail:`Positional signature ${command} has no destination declaration.`}))}function positionalShapeKey(slots){return slots.map(({required,variadic,value_kind:valueKind,polymorphic})=>`${required?"r":"o"}:${variadic?"v":"s"}:${valueKind}:${polymorphic?"p":"m"}`).join("|")}function positionalSignatureKey(slots){return slots.map(({name,required,variadic,value_kind:valueKind,polymorphic})=>`${name}:${required?"r":"o"}:${variadic?"v":"s"}:${valueKind}:${polymorphic?"p":"m"}`).join("|")}function duplicatePositionalSignatureFindings(contracts,surface){const counts=new Map;for(const{command}of contracts){const normalized=normalizePositionalCommandPath(command);counts.set(normalized,(counts.get(normalized)??0)+1)}return[...counts.entries()].filter(([,count])=>count>1).map(([command,count])=>({code:"positional_signature_mismatch",command,detail:`${count} ${surface} positional signatures exist for ${command}; exactly one is required.`}))}function verifyPmCommandPositionalContracts(observed,options={}){const declared=options.declared??PM_COMMAND_POSITIONAL_CONTRACTS;const positionalShapeBudget=options.positionalShapeBudget??PM_CLI_GRAMMAR_CONTRACT.positional_shape_budget;const declaredByCommand=new Map(declared.map(contract=>[normalizePositionalCommandPath(contract.command),contract]));const observedByCommand=new Map(observed.map(contract=>[normalizePositionalCommandPath(contract.command),contract]));const findings=[...duplicatePositionalSignatureFindings(declared,"declared"),...duplicatePositionalSignatureFindings(observed,"observed"),...options.declared===void 0?[...verifyExplicitPositionalSlotCensus(EXPLICIT_POSITIONAL_SLOTS.keys(),PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command)),...verifyExplicitPositionalSlotCensus(PM_POSITIONAL_ACTION_CONTRACTS.map(({command})=>command),PM_COMMAND_DESTINATION_CONTRACTS.map(({command})=>command))]:[]];for(const contract of declaredByCommand.values()){const normalizedCommand=normalizePositionalCommandPath(contract.command);const actual=observedByCommand.get(normalizedCommand);if(!actual){findings.push({code:"missing_observed_signature",command:contract.command,detail:`No observed positional signature exists for ${contract.command}.`})}else if(positionalSignatureKey(actual.slots)!==positionalSignatureKey(contract.slots)){findings.push({code:"positional_signature_mismatch",command:contract.command,detail:`Observed positional signature for ${contract.command} differs from its declared SDK contract: observed=${positionalSignatureKey(actual.slots)||"<none>"}; declared=${positionalSignatureKey(contract.slots)||"<none>"}.`})}}for(const contract of observedByCommand.values()){if(!declaredByCommand.has(normalizePositionalCommandPath(contract.command))){findings.push({code:"stale_observed_signature",command:contract.command,detail:`Observed positional signature ${contract.command} has no declaration.`})}}const positionalShapeCount=new Set(declared.map(({slots})=>positionalShapeKey(slots))).size;if(positionalShapeCount>positionalShapeBudget){findings.push({code:"positional_shape_budget_exceeded",command:"*",detail:`Distinct positional shape count ${positionalShapeCount} exceeds budget ${positionalShapeBudget}.`})}findings.sort((left,right)=>left.command!==right.command?left.command.localeCompare(right.command):left.code.localeCompare(right.code));return{ok:findings.length===0,declared_command_count:declared.length,observed_command_count:observed.length,positional_shape_count:positionalShapeCount,positional_shape_budget:positionalShapeBudget,findings}}function validateCommandDestinations(commands,destinationsByCommand,nounSet){return commands.flatMap(command=>{const destinations=destinationsByCommand.get(command)??[];if(destinations.length===0){const separatorIndex=command.indexOf(" ");const root=separatorIndex===-1?command:command.slice(0,separatorIndex);return[{code:"missing_destination",spelling:command,message:`Command \`${command}\` has no destination census row.`,nearest_target:nounSet.has(root)?root:`ops ${command}`}]}const duplicateFinding=destinations.length>1?[{code:"duplicate_destination",spelling:command,message:`Command \`${command}\` has ${destinations.length} destination rows.`,nearest_target:destinations[0].target}]:[];return destinations.reduce((findings,destination)=>{if(destination.disposition==="keep_as_is"&&(destination.reason?.trim().length??0)===0){findings.push({code:"missing_destination",spelling:command,message:`Command \`${command}\` is kept as-is without a documented reason.`,nearest_target:destination.target})}if(!nounSet.has(destination.noun)){findings.push({code:"unknown_noun",spelling:command,message:`Command \`${command}\` names undeclared noun \`${destination.noun}\`.`,nearest_target:destination.target})}return findings},duplicateFinding)})}function validateDestinationCensus(commandSet,destinations){return destinations.filter(destination=>destination.disposition!=="package_owned"&&!commandSet.has(destination.command)).map(destination=>({code:"stale_destination",spelling:destination.command,message:`Destination row \`${destination.command}\` is absent from live contracts.`,nearest_target:destination.target}))}function validateAliasTargets(aliases,commandSet){return aliases.filter(alias=>!commandSet.has(alias.canonical)).map(alias=>({code:"alias_target_missing",spelling:alias.alias,message:`Alias \`${alias.alias}\` targets missing canonical command \`${alias.canonical}\`.`,nearest_target:alias.canonical_argv.join(" ")}))}function verifyPmCliGrammar(commands,aliases=[],destinations=PM_COMMAND_DESTINATION_CONTRACTS){const normalizedCommands=[...new Set(commands.map(command=>command.trim()))].filter(command=>command.length>0).sort((left,right)=>left.localeCompare(right));const commandSet=new Set(normalizedCommands);const nounSet=new Set(PM_CLI_GRAMMAR_NOUNS);const destinationsByCommand=new Map;for(const destination of destinations){const entries=destinationsByCommand.get(destination.command)??[];entries.push(destination);destinationsByCommand.set(destination.command,entries)}const findings=[...validateCommandDestinations(normalizedCommands,destinationsByCommand,nounSet),...validateDestinationCensus(commandSet,destinations),...validateAliasTargets(aliases.filter(alias=>commandSet.has(alias.alias)||!(destinationsByCommand.get(alias.canonical)??[]).some(destination=>destination.disposition==="package_owned")),commandSet)];const hiddenAliasNames=new Set(aliases.filter(alias=>alias.hidden).map(alias=>alias.alias));const visibleTopLevelCount=new Set(normalizedCommands.filter(command=>!command.includes(" ")&&!hiddenAliasNames.has(command)&&!(destinationsByCommand.get(command)??[]).some(destination=>destination.disposition==="package_owned"))).size;if(visibleTopLevelCount>PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling){findings.push({code:"visible_surface_ceiling_exceeded",spelling:String(visibleTopLevelCount),message:`Visible non-package top-level command count ${visibleTopLevelCount} exceeds ceiling ${PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling}.`,nearest_target:"Declare the noun placement and tracked waiver before raising the ceiling."})}return{ok:findings.length===0,command_count:normalizedCommands.length,destination_count:destinations.length,hidden_alias_count:aliases.filter(alias=>alias.hidden).length,visible_top_level_count:visibleTopLevelCount,visible_top_level_ceiling:PM_CLI_GRAMMAR_CONTRACT.visible_top_level_ceiling,findings}}export{PM_CLI_GRAMMAR_CONTRACT,PM_CLI_GRAMMAR_NOUNS,PM_CLI_SHARED_VERBS,PM_COMMAND_DESTINATION_CONTRACTS,PM_COMMAND_POSITIONAL_CONTRACTS,PM_POSITIONAL_ACTION_CONTRACTS,formatPmPositionalActionFlagTip,positionalShapeKey,positionalSignatureKey,resolvePmCommandPositionalContract,resolvePmPositionalActionContract,verifyExplicitPositionalSlotCensus,verifyPmCliGrammar,verifyPmCommandPositionalContracts};
|
|
2
2
|
//# sourceMappingURL=grammar-contracts.js.map
|
|
@@ -83,7 +83,7 @@ declare const CLOSE_MUTATION_FLAGS: string;
|
|
|
83
83
|
declare const CLOSE_TASK_MUTATION_FLAGS: string;
|
|
84
84
|
declare const RELEASE_MUTATION_FLAGS: string;
|
|
85
85
|
declare const CLAIM_MUTATION_FLAGS: string;
|
|
86
|
-
declare const COMMAND_COMPLETION_DESCRIPTIONS: readonly [readonly ["init", "Initialize pm storage for the current workspace"], readonly ["config", "Read or update pm settings"], readonly ["package", "Manage package lifecycle operations"], readonly ["packages", "Alias for package"], readonly ["create", "Create a new project management item"], readonly ["item", "Manage item evidence, links, tests, and duplication"], readonly ["copy", "Copy an existing item to a new ID"], readonly ["focus", "Set/clear/show the session focused parent for new items"], readonly ["list", "List active items with optional filters"], readonly ["aggregate", "Aggregate grouped item counts and numeric stats for governance queries"], readonly ["duplicates", "Find bounded duplicate clusters across lifecycle statuses"], readonly ["guide", "Browse local progressive-disclosure guides"], readonly ["calendar", "Show calendar views for deadlines and reminders"], readonly ["cal", "Alias for calendar"], readonly ["context", "Show a token-efficient project context snapshot"], readonly ["ctx", "Alias for context"], readonly ["get", "Show item details by ID"], readonly ["next", "Recommend the next actionable (unblocked, ready) work item"], readonly ["search", "Search items with keyword, semantic, or hybrid modes"], readonly ["reindex", "Rebuild search artifacts"], readonly ["history", "Show item history entries"], readonly ["history-compact", "Compact history streams into a synthetic baseline + retained tail"], readonly ["history-redact", "Redact sensitive literals/patterns and recompute history hashes"], readonly ["history-repair", "Re-anchor a drifted history chain so pm health/validate report ok"], readonly ["schema", "Manage custom item types and statuses in .agents/pm/schema/*.json"], readonly ["profile", "List, show, apply, and lint project profiles (archetype schema/config/template/package bundles)"], readonly ["plan", "Agent-optimized Plan item workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"], readonly ["activity", "Show recent activity across items"], readonly ["restore", "Restore an item to an earlier state"], readonly ["update", "Update item fields and metadata"], readonly ["update-many", "Bulk-update matched items with dry-run and rollback checkpoints"], readonly ["close", "Close an item (reason requirement follows governance settings)"], readonly ["close-many", "Bulk-close matched items with an optional shared reason and rollback checkpoint"], readonly ["delete", "Delete an item and record the change"], readonly ["append", "Append text to an item body"], readonly ["comments", "List or add comments for an item"], readonly ["notes", "List or add notes for an item"], readonly ["learnings", "List or add learnings for an item"], readonly ["files", "Manage linked files"], readonly ["docs", "Manage linked docs"], readonly ["deps", "Show dependency relationships for an item"], readonly ["graph", "Bounded graph traversal, analytics, and governance-audit queries"], readonly ["test", "Manage linked tests and optionally run them"], readonly ["test-all", "Run linked tests across matching items"], readonly ["test-runs", "Manage background linked-test runs"], readonly ["stats", "Show project tracker statistics"], readonly ["health", "Show project tracker health checks"], readonly ["validate", "Run standalone validation checks"], readonly ["gc", "Clean optional cache artifacts"], readonly ["contracts", "Show machine-readable command and schema contracts"], readonly ["claim", "Claim an item for active work"], readonly ["release", "Release the active claim for an item"], readonly ["start-task", "Lifecycle alias to claim and set in_progress"], readonly ["pause-task", "Lifecycle alias to reopen and release claim"], readonly ["close-task", "Lifecycle alias to close and release claim"], readonly ["meet", "Shortcut to create a Meeting with scheduling defaults"], readonly ["event", "Shortcut to create an Event with scheduling defaults"], readonly ["remind", "Shortcut to create a Reminder from a point in time"], readonly ["templates", "Manage reusable create templates"], readonly ["completion", "Generate shell completion"], readonly ["help", "Display help for a command"]];
|
|
86
|
+
declare const COMMAND_COMPLETION_DESCRIPTIONS: readonly [readonly ["workspace", "Workspace initialization, customization, state and snapshots"], readonly ["init", "Initialize pm storage for the current workspace"], readonly ["config", "Read or update pm settings"], readonly ["package", "Manage package lifecycle operations"], readonly ["packages", "Alias for package"], readonly ["create", "Create a new project management item"], readonly ["item", "Manage item evidence, links, tests, and duplication"], readonly ["copy", "Copy an existing item to a new ID"], readonly ["focus", "Set/clear/show the session focused parent for new items"], readonly ["list", "List active items with optional filters"], readonly ["aggregate", "Aggregate grouped item counts and numeric stats for governance queries"], readonly ["duplicates", "Find bounded duplicate clusters across lifecycle statuses"], readonly ["guide", "Browse local progressive-disclosure guides"], readonly ["calendar", "Show calendar views for deadlines and reminders"], readonly ["cal", "Alias for calendar"], readonly ["context", "Show a token-efficient project context snapshot"], readonly ["ctx", "Alias for context"], readonly ["get", "Show item details by ID"], readonly ["next", "Recommend the next actionable (unblocked, ready) work item"], readonly ["search", "Search items with keyword, semantic, or hybrid modes"], readonly ["reindex", "Rebuild search artifacts"], readonly ["history", "Show item history entries"], readonly ["history-compact", "Compact history streams into a synthetic baseline + retained tail"], readonly ["history-redact", "Redact sensitive literals/patterns and recompute history hashes"], readonly ["history-repair", "Re-anchor a drifted history chain so pm health/validate report ok"], readonly ["schema", "Manage custom item types and statuses in .agents/pm/schema/*.json"], readonly ["profile", "List, show, apply, and lint project profiles (archetype schema/config/template/package bundles)"], readonly ["plan", "Agent-optimized Plan item workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"], readonly ["activity", "Show recent activity across items"], readonly ["restore", "Restore an item to an earlier state"], readonly ["update", "Update item fields and metadata"], readonly ["update-many", "Bulk-update matched items with dry-run and rollback checkpoints"], readonly ["close", "Close an item (reason requirement follows governance settings)"], readonly ["close-many", "Bulk-close matched items with an optional shared reason and rollback checkpoint"], readonly ["delete", "Delete an item and record the change"], readonly ["append", "Append text to an item body"], readonly ["comments", "List or add comments for an item"], readonly ["notes", "List or add notes for an item"], readonly ["learnings", "List or add learnings for an item"], readonly ["files", "Manage linked files"], readonly ["docs", "Manage linked docs"], readonly ["deps", "Show dependency relationships for an item"], readonly ["graph", "Bounded graph traversal, analytics, and governance-audit queries"], readonly ["test", "Manage linked tests and optionally run them"], readonly ["test-all", "Run linked tests across matching items"], readonly ["test-runs", "Manage background linked-test runs"], readonly ["stats", "Show project tracker statistics"], readonly ["health", "Show project tracker health checks"], readonly ["validate", "Run standalone validation checks"], readonly ["gc", "Clean optional cache artifacts"], readonly ["contracts", "Show machine-readable command and schema contracts"], readonly ["claim", "Claim an item for active work"], readonly ["release", "Release the active claim for an item"], readonly ["start-task", "Lifecycle alias to claim and set in_progress"], readonly ["pause-task", "Lifecycle alias to reopen and release claim"], readonly ["close-task", "Lifecycle alias to close and release claim"], readonly ["meet", "Shortcut to create a Meeting with scheduling defaults"], readonly ["event", "Shortcut to create an Event with scheduling defaults"], readonly ["remind", "Shortcut to create a Reminder from a point in time"], readonly ["templates", "Manage reusable create templates"], readonly ["completion", "Generate shell completion"], readonly ["help", "Display help for a command"]];
|
|
87
87
|
declare const GLOBAL_FLAGS: string;
|
|
88
88
|
declare const GLOBAL_COMPLETION_VALUE_PATTERNS: string;
|
|
89
89
|
declare const GLOBAL_COMPLETION_INLINE_PATTERNS: string;
|