@unbrained/pm-cli 2026.9.8 → 2026.9.10
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/pm-user/SKILL.md +2 -2
- package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +1 -1
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +38 -2
- package/dist/cli/command-namespaces.d.ts +9 -0
- package/dist/cli/command-namespaces.js +2 -0
- package/dist/cli/help-content.js +1 -1
- package/dist/cli/help-json-payload.d.ts +5 -1
- package/dist/cli/help-json-payload.js +2 -2
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/register-list-query.js +4 -4
- package/dist/cli/register-mutation.d.ts +0 -5
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli/register-operations.d.ts +0 -5
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +154 -154
- package/dist/cli-bundle/chunks/chunk-4SFBH77G.js +2233 -0
- package/dist/cli-bundle/chunks/{chunk-LEZOUXG6.js → chunk-74RGSPLL.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7WIHZI2M.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-JAAEYHUA.js → chunk-EOCKPCEY.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GLQMKUGP.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-FLDWYEND.js → chunk-I6XT3DLQ.js} +62 -60
- package/dist/cli-bundle/chunks/chunk-MACGGTLQ.js +29 -0
- package/dist/cli-bundle/chunks/chunk-NKOYVKFM.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-YVEQ2AMO.js → chunk-P6BEYAON.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-G5ADGQ2D.js → chunk-PYUITRSV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-T3AMFUCN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-XOD2PCB6.js → chunk-TSWEX72T.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YKQTETJI.js +235 -0
- package/dist/cli-bundle/chunks/{register-list-query-KSK3R63M.js → register-list-query-CUIW7SSE.js} +7 -7
- package/dist/cli-bundle/chunks/register-mutation-5F5CYUWZ.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-XIZPLPQY.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-BQ5SVD4B.js → register-setup-JVGPCAIL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RXT4P5QH.js → chunk-26O2WB73.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5YU75QLV.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EE5QSM4Z.js → chunk-7N5MRONP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-B2CMFYRZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OPFHFGDD.js → chunk-CRY5MHEI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-COPBO5HW.js → chunk-F6WKFXBT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HJVARYM3.js → chunk-FHUARRMA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3WRPWLA7.js → chunk-M36SF4GE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-OROZM37I.js +177 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7MBUII7U.js → chunk-PNGYYQY7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SL5YVVPV.js +58 -0
- package/dist/cli-bundle/focused-chunks/chunk-TPOL4TWE.js +9 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RMWES4M6.js → chunk-U5SHHU7E.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-XSMA2W6Q.js +12 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZAWAL2CG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZDNAWWQI.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DUN4IXYN.js → chunk-ZJHYQOTM.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +29 -29
- 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 +42 -42
- 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 +10 -10
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/policy/workflow-policy-schema.d.ts +312 -0
- package/dist/core/policy/workflow-policy-schema.js +2 -0
- package/dist/core/policy/workflow-policy-store.d.ts +24 -0
- package/dist/core/policy/workflow-policy-store.js +2 -0
- package/dist/core/policy/workflow-policy.d.ts +139 -0
- package/dist/core/policy/workflow-policy.js +2 -0
- package/dist/core/shared/constants.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.js +1 -1
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.d.ts +11 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +4 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -0
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/completion.js +375 -347
- 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/validate.d.ts +3 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/governance/workflow-completeness.d.ts +32 -0
- package/dist/sdk/governance/workflow-completeness.js +2 -0
- package/dist/sdk/governance/workflow-policy.d.ts +47 -0
- package/dist/sdk/governance/workflow-policy.js +4 -0
- package/dist/sdk/governance.d.ts +1 -0
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.d.ts +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
- package/dist/sdk/lifecycle/mcp-actions.js +1 -1
- package/dist/sdk/lifecycle/recurrence-parsers.d.ts +1 -1
- package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/task-composition.d.ts +17 -0
- package/dist/sdk/lifecycle/task-composition.js +2 -0
- package/dist/sdk/lifecycle/update.js +1 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/search-contracts.d.ts +27 -0
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/query/search.d.ts +6 -4
- package/dist/sdk/query/search.js +2 -2
- package/dist/sdk/query/workspace-contracts.d.ts +3 -0
- package/dist/sdk/query/workspace-contracts.js +2 -0
- package/dist/sdk/read-output-contracts.d.ts +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-public-contracts.d.ts +2 -1
- package/dist/sdk/runtime.d.ts +73 -9
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/schema.d.ts +2 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -1
- package/docs/COMMANDS.md +36 -24
- package/docs/COMMAND_NAMESPACES.md +65 -0
- package/docs/CONFIGURATION.md +12 -1
- package/docs/LIFECYCLE_COMMANDS.md +77 -0
- package/docs/README.md +3 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +5 -0
- package/docs/TESTING.md +10 -0
- package/docs/WORKFLOW_POLICIES.md +129 -0
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +6 -6
- package/docs/generated/AGENT_COMMAND_SURFACE.md +19 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +23 -5
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +11 -5
- package/marketplace.json +2 -2
- package/package.json +5 -5
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/README.md +4 -2
- 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/README.md +6 -4
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3BZZA6A3.js +0 -5
- package/dist/cli-bundle/chunks/chunk-AMRDVX36.js +0 -235
- package/dist/cli-bundle/chunks/chunk-DAM4CBBR.js +0 -2202
- package/dist/cli-bundle/chunks/chunk-KR3RP4FH.js +0 -3
- package/dist/cli-bundle/chunks/chunk-NSAPNEYH.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QOEKOECV.js +0 -29
- package/dist/cli-bundle/chunks/chunk-RHSFOMHU.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-IQ5C7U6O.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-DWVHR2NC.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IAUOUGVR.js +0 -177
- package/dist/cli-bundle/focused-chunks/chunk-KOOMJ54F.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-MZDXX7JY.js +0 -56
- package/dist/cli-bundle/focused-chunks/chunk-QHNETP77.js +0 -9
- package/dist/cli-bundle/focused-chunks/chunk-SDOL6FM2.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-SQV4AAUC.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WE3IUNIW.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-YALOUBWJ.js +0 -2
|
@@ -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]="f248824b-d56a-52ec-ac50-8b69b5ab1c99")}catch(e2){}})();import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{acquireLock}from"../core/lock/lock.js";import{parseTags}from"../core/item/parse.js";import{normalizeStatusInput}from"../core/item/status.js";import{serializeItemDocument}from"../core/item/item-format.js";import{getHistoryPath}from"../core/store/paths.js";import{removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{runActiveOnWriteHooks}from"../core/extensions/index.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{assertInitializedTracker}from"./environment/tracker-preflight.js";function toNonEmptyImportString(value){if(typeof value!=="string"){return void 0}const trimmed=value.trim();return trimmed.length>0?trimmed:void 0}function toEstimatedMinutesValue(value){if(typeof value==="number"&&Number.isFinite(value)&&value>=0){return value}if(typeof value==="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isFinite(parsed)&&parsed>=0){return parsed}}return void 0}function toImportPriority(value){if(typeof value==="number"&&Number.isInteger(value)&&value>=0&&value<=4){return value}if(typeof value==="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isInteger(parsed)&&parsed>=0&&parsed<=4){return parsed}}return 2}function toImportTags(value){if(Array.isArray(value)){const tags=value.filter(entry=>typeof entry==="string").map(entry=>entry.trim().toLowerCase()).filter(entry=>entry.length>0);return Array.from(new Set(tags)).sort((left,right)=>left.localeCompare(right))}if(typeof value==="string"){return parseTags(value)}return[]}function toImportStatus(value){const normalized=toNonEmptyImportString(value);if(normalized){const canonical=normalizeStatusInput(normalized);if(canonical){return canonical}}return"open"}function toImportInteger(value){if(typeof value==="number"&&Number.isInteger(value)){return value}if(typeof value!=="string"||value.trim().length===0){return void 0}const parsed=Number(value);return Number.isInteger(parsed)?parsed:void 0}function toImportBoolean(value){if(typeof value==="boolean"){return value}if(typeof value==="number"){return value===1?true:value===0?false:void 0}if(typeof value!=="string"){return void 0}const normalized=value.trim().toLowerCase();if(normalized==="true"||normalized==="1"){return true}return normalized==="false"||normalized==="0"?false:void 0}function toImportStringList(value){if(!Array.isArray(value)){return void 0}const entries=value.map(entry=>toNonEmptyImportString(entry)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportStringMap(value){return toImportValueMap(value,toNonEmptyImportString)}function toImportNumberMap(value){return toImportValueMap(value,toImportFiniteNumber)}function toImportConfidence(value,allowedTextValues){if(typeof value==="number"&&Number.isInteger(value)&&value>=0&&value<=100){return value}const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized){return void 0}const candidate=normalized==="med"?"medium":normalized;if(allowedTextValues.some(entry=>entry===candidate)){return candidate}const parsed=Number(candidate);return Number.isInteger(parsed)&&parsed>=0&&parsed<=100?parsed:void 0}function toImportNormalizedEnum(value,allowed){const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized){return void 0}const candidate=normalized==="med"?"medium":normalized;return allowed.includes(candidate)?candidate:void 0}function toImportLinkScope(value){return toNonEmptyImportString(value)?.toLowerCase()==="global"?"global":"project"}function toImportLogEntries(value,options){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const entries=values.map(entry=>toImportLogEntry(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedFiles(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedDocs(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedTests(value,options={}){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const entries=values.map(entry=>toImportLinkedTest(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function selectImportAuthor(explicitAuthor,settingsAuthor){return resolveAuthor(explicitAuthor,settingsAuthor)}function isImportRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function normalizeImportCollection(value,allowScalar){if(Array.isArray(value)){return value}return allowScalar?[value]:void 0}function firstNonEmptyImportString(record,keys){for(const key of keys){const value=toNonEmptyImportString(record[key]);if(value){return value}}return void 0}function toImportValueMap(value,coerce){if(!isImportRecord(value)){return void 0}const entries=Object.entries(value).map(([key,entryValue])=>[key.trim(),coerce(entryValue)]).filter(entry=>entry[0].length>0&&entry[1]!==void 0);return entries.length>0?Object.fromEntries(entries):void 0}function toImportLogEntry(entry,options){if(typeof entry==="string"){return toImportLogEntryFromText(entry,options)}if(!isImportRecord(entry)){return void 0}const text=firstNonEmptyImportString(entry,options.textKeys??["text"]);if(!text){return void 0}const createdAtKey=options.createdAtKey??"created_at";const authorKey=options.authorKey??"author";const createdAt=(options.toIsoString?options.toIsoString(entry[createdAtKey]):toNonEmptyImportString(entry[createdAtKey]))??options.fallbackCreatedAt;return{created_at:createdAt,author:toNonEmptyImportString(entry[authorKey])??options.fallbackAuthor,text}}function toImportLogEntryFromText(entry,options){const text=toNonEmptyImportString(entry);return text?{created_at:options.fallbackCreatedAt,author:options.fallbackAuthor,text}:void 0}function toImportLinkedArtifacts(value,options,build){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const pathKeys=options.pathKeys??["path"];const entries=values.map(entry=>toImportLinkedArtifact(entry,pathKeys,build)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedArtifact(entry,pathKeys,build){if(typeof entry==="string"){const pathValue2=toNonEmptyImportString(entry);return pathValue2?build(pathValue2):void 0}if(!isImportRecord(entry)){return void 0}const pathValue=firstNonEmptyImportString(entry,pathKeys);return pathValue?build(pathValue,entry):void 0}function toImportLinkedTest(entry,options){if(typeof entry==="string"){const command2=toNonEmptyImportString(entry);return command2?{command:command2,scope:"project"}:void 0}if(!isImportRecord(entry)){return void 0}const command=firstNonEmptyImportString(entry,options.commandKeys??["command"]);const testPath=firstNonEmptyImportString(entry,options.pathKeys??["path"]);if(!command&&(options.requireCommand===true||!testPath)){return void 0}return{...command?{command}:{},...testPath?{path:testPath}:{},scope:toImportLinkScope(entry.scope),timeout_seconds:toImportLinkedTestTimeout(entry.timeout_seconds,options),note:toNonEmptyImportString(entry.note),...options.includeExtendedAssertions===true?toImportLinkedTestAssertions(entry):{}}}function toImportLinkedTestTimeout(value,options){const parsed=options.integerTimeout===true?toImportInteger(value):toImportFiniteNumber(value);if(parsed===void 0){return void 0}const minimum=options.timeoutMinimum??0;return options.timeoutExclusiveMinimum===true?parsed>minimum?parsed:void 0:parsed>=minimum?parsed:void 0}function toImportFiniteNumber(value){if(typeof value==="number"&&Number.isFinite(value)){return value}if(typeof value!=="string"||value.trim().length===0){return void 0}const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0}function toImportLinkedTestAssertions(entry){return{pm_context_mode:toImportNormalizedEnum(entry.pm_context_mode,["schema","tracker","auto"]),env_set:toImportStringMap(entry.env_set),env_clear:toImportStringList(entry.env_clear),shared_host_safe:toImportBoolean(entry.shared_host_safe),assert_stdout_contains:toImportStringList(entry.assert_stdout_contains),assert_stdout_regex:toImportStringList(entry.assert_stdout_regex),assert_stderr_contains:toImportStringList(entry.assert_stderr_contains),assert_stderr_regex:toImportStringList(entry.assert_stderr_regex),assert_stdout_min_lines:toImportInteger(entry.assert_stdout_min_lines),assert_json_field_equals:toImportStringMap(entry.assert_json_field_equals),assert_json_field_gte:toImportNumberMap(entry.assert_json_field_gte)}}async function ensureTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function emptyImportedDocument(){return{metadata:{},body:""}}async function commitImportedItem(params){const{pmRoot,id,itemPath,document,author,message,settings,conflictWarningPrefix}=params;const historyPath=getHistoryPath(pmRoot,id);const beforeDocument=emptyImportedDocument();try{const releaseLock=await acquireLock(pmRoot,id,settings.locks.ttl_seconds,author,false,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms);try{await writeFileAtomic(itemPath,serializeItemDocument(document,{format:"toon"}));try{const entry=createHistoryEntry({nowIso:nowIso(),author,op:"import",before:beforeDocument,after:document,message});await appendHistoryEntry(historyPath,entry);const writeWarnings=[...await runActiveOnWriteHooks({path:itemPath,scope:"project",op:"import",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]}),...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"import:history",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]})];return{committed:true,writeWarnings}}catch(error){await removeFileIfExists(itemPath);throw error}}finally{await releaseLock()}}catch(error){if(error instanceof PmCliError&&error.exitCode===EXIT_CODE.CONFLICT){return{committed:false,conflictWarning:`${conflictWarningPrefix}:${id}`}}throw error}}export{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkScope,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString};
|
|
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]="aba4af26-98d3-53aa-8b23-1be7c90a38d1")}catch(e2){}})();import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{acquireLock}from"../core/lock/lock.js";import{enforceWorkflowMutation}from"../core/policy/workflow-policy-store.js";import{parseTags}from"../core/item/parse.js";import{normalizeStatusInput}from"../core/item/status.js";import{serializeItemDocument}from"../core/item/item-format.js";import{getHistoryPath}from"../core/store/paths.js";import{removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{runActiveOnWriteHooks}from"../core/extensions/index.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{assertInitializedTracker}from"./environment/tracker-preflight.js";function toNonEmptyImportString(value){if(typeof value!=="string"){return void 0}const trimmed=value.trim();return trimmed.length>0?trimmed:void 0}function toEstimatedMinutesValue(value){if(typeof value==="number"&&Number.isFinite(value)&&value>=0){return value}if(typeof value==="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isFinite(parsed)&&parsed>=0){return parsed}}return void 0}function toImportPriority(value){if(typeof value==="number"&&Number.isInteger(value)&&value>=0&&value<=4){return value}if(typeof value==="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isInteger(parsed)&&parsed>=0&&parsed<=4){return parsed}}return 2}function toImportTags(value){if(Array.isArray(value)){const tags=value.filter(entry=>typeof entry==="string").map(entry=>entry.trim().toLowerCase()).filter(entry=>entry.length>0);return Array.from(new Set(tags)).sort((left,right)=>left.localeCompare(right))}if(typeof value==="string"){return parseTags(value)}return[]}function toImportStatus(value){const normalized=toNonEmptyImportString(value);if(normalized){const canonical=normalizeStatusInput(normalized);if(canonical){return canonical}}return"open"}function toImportInteger(value){if(typeof value==="number"&&Number.isInteger(value)){return value}if(typeof value!=="string"||value.trim().length===0){return void 0}const parsed=Number(value);return Number.isInteger(parsed)?parsed:void 0}function toImportBoolean(value){if(typeof value==="boolean"){return value}if(typeof value==="number"){return value===1?true:value===0?false:void 0}if(typeof value!=="string"){return void 0}const normalized=value.trim().toLowerCase();if(normalized==="true"||normalized==="1"){return true}return normalized==="false"||normalized==="0"?false:void 0}function toImportStringList(value){if(!Array.isArray(value)){return void 0}const entries=value.map(entry=>toNonEmptyImportString(entry)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportStringMap(value){return toImportValueMap(value,toNonEmptyImportString)}function toImportNumberMap(value){return toImportValueMap(value,toImportFiniteNumber)}function toImportConfidence(value,allowedTextValues){if(typeof value==="number"&&Number.isInteger(value)&&value>=0&&value<=100){return value}const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized){return void 0}const candidate=normalized==="med"?"medium":normalized;if(allowedTextValues.some(entry=>entry===candidate)){return candidate}const parsed=Number(candidate);return Number.isInteger(parsed)&&parsed>=0&&parsed<=100?parsed:void 0}function toImportNormalizedEnum(value,allowed){const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized){return void 0}const candidate=normalized==="med"?"medium":normalized;return allowed.includes(candidate)?candidate:void 0}function toImportLinkScope(value){return toNonEmptyImportString(value)?.toLowerCase()==="global"?"global":"project"}function toImportLogEntries(value,options){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const entries=values.map(entry=>toImportLogEntry(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedFiles(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedDocs(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedTests(value,options={}){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const entries=values.map(entry=>toImportLinkedTest(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function selectImportAuthor(explicitAuthor,settingsAuthor){return resolveAuthor(explicitAuthor,settingsAuthor)}function isImportRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function normalizeImportCollection(value,allowScalar){if(Array.isArray(value)){return value}return allowScalar?[value]:void 0}function firstNonEmptyImportString(record,keys){for(const key of keys){const value=toNonEmptyImportString(record[key]);if(value){return value}}return void 0}function toImportValueMap(value,coerce){if(!isImportRecord(value)){return void 0}const entries=Object.entries(value).map(([key,entryValue])=>[key.trim(),coerce(entryValue)]).filter(entry=>entry[0].length>0&&entry[1]!==void 0);return entries.length>0?Object.fromEntries(entries):void 0}function toImportLogEntry(entry,options){if(typeof entry==="string"){return toImportLogEntryFromText(entry,options)}if(!isImportRecord(entry)){return void 0}const text=firstNonEmptyImportString(entry,options.textKeys??["text"]);if(!text){return void 0}const createdAtKey=options.createdAtKey??"created_at";const authorKey=options.authorKey??"author";const createdAt=(options.toIsoString?options.toIsoString(entry[createdAtKey]):toNonEmptyImportString(entry[createdAtKey]))??options.fallbackCreatedAt;return{created_at:createdAt,author:toNonEmptyImportString(entry[authorKey])??options.fallbackAuthor,text}}function toImportLogEntryFromText(entry,options){const text=toNonEmptyImportString(entry);return text?{created_at:options.fallbackCreatedAt,author:options.fallbackAuthor,text}:void 0}function toImportLinkedArtifacts(value,options,build){const values=normalizeImportCollection(value,options.allowScalar===true);if(!values){return void 0}const pathKeys=options.pathKeys??["path"];const entries=values.map(entry=>toImportLinkedArtifact(entry,pathKeys,build)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedArtifact(entry,pathKeys,build){if(typeof entry==="string"){const pathValue2=toNonEmptyImportString(entry);return pathValue2?build(pathValue2):void 0}if(!isImportRecord(entry)){return void 0}const pathValue=firstNonEmptyImportString(entry,pathKeys);return pathValue?build(pathValue,entry):void 0}function toImportLinkedTest(entry,options){if(typeof entry==="string"){const command2=toNonEmptyImportString(entry);return command2?{command:command2,scope:"project"}:void 0}if(!isImportRecord(entry)){return void 0}const command=firstNonEmptyImportString(entry,options.commandKeys??["command"]);const testPath=firstNonEmptyImportString(entry,options.pathKeys??["path"]);if(!command&&(options.requireCommand===true||!testPath)){return void 0}return{...command?{command}:{},...testPath?{path:testPath}:{},scope:toImportLinkScope(entry.scope),timeout_seconds:toImportLinkedTestTimeout(entry.timeout_seconds,options),note:toNonEmptyImportString(entry.note),...options.includeExtendedAssertions===true?toImportLinkedTestAssertions(entry):{}}}function toImportLinkedTestTimeout(value,options){const parsed=options.integerTimeout===true?toImportInteger(value):toImportFiniteNumber(value);if(parsed===void 0){return void 0}const minimum=options.timeoutMinimum??0;return options.timeoutExclusiveMinimum===true?parsed>minimum?parsed:void 0:parsed>=minimum?parsed:void 0}function toImportFiniteNumber(value){if(typeof value==="number"&&Number.isFinite(value)){return value}if(typeof value!=="string"||value.trim().length===0){return void 0}const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0}function toImportLinkedTestAssertions(entry){return{pm_context_mode:toImportNormalizedEnum(entry.pm_context_mode,["schema","tracker","auto"]),env_set:toImportStringMap(entry.env_set),env_clear:toImportStringList(entry.env_clear),shared_host_safe:toImportBoolean(entry.shared_host_safe),assert_stdout_contains:toImportStringList(entry.assert_stdout_contains),assert_stdout_regex:toImportStringList(entry.assert_stdout_regex),assert_stderr_contains:toImportStringList(entry.assert_stderr_contains),assert_stderr_regex:toImportStringList(entry.assert_stderr_regex),assert_stdout_min_lines:toImportInteger(entry.assert_stdout_min_lines),assert_json_field_equals:toImportStringMap(entry.assert_json_field_equals),assert_json_field_gte:toImportNumberMap(entry.assert_json_field_gte)}}async function ensureTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function emptyImportedDocument(){return{metadata:{},body:""}}async function commitImportedItem(params){const{pmRoot,id,itemPath,document,author,message,settings,conflictWarningPrefix}=params;const historyPath=getHistoryPath(pmRoot,id);const beforeDocument=emptyImportedDocument();try{const releaseLock=await acquireLock(pmRoot,id,settings.locks.ttl_seconds,author,false,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms);try{const workflowPolicy=await enforceWorkflowMutation({pmRoot,settings,operation:"import",author,before:null,after:document});await writeFileAtomic(itemPath,serializeItemDocument(document,{format:"toon"}));try{const entry=createHistoryEntry({nowIso:nowIso(),author,op:"import",before:beforeDocument,after:document,message,context:workflowPolicy.decisions.length===0?void 0:{workflow_policies:workflowPolicy.decisions}});await appendHistoryEntry(historyPath,entry);const writeWarnings=[...workflowPolicy.warnings,...await runActiveOnWriteHooks({path:itemPath,scope:"project",op:"import",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]}),...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"import:history",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]})];return{committed:true,writeWarnings}}catch(error){await removeFileIfExists(itemPath);throw error}}finally{await releaseLock()}}catch(error){if(error instanceof PmCliError&&error.exitCode===EXIT_CODE.CONFLICT&&!error.code?.startsWith("workflow_policy_")){return{committed:false,conflictWarning:`${conflictWarningPrefix}:${id}`}}throw error}}export{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkScope,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString};
|
|
2
2
|
//# sourceMappingURL=package-import-adapters.js.map
|