@unbrained/pm-cli 2026.5.28 → 2026.5.30
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/CHANGELOG.md +127 -93
- package/dist/cli/bootstrap-args.d.ts +1 -1
- package/dist/cli/bootstrap-args.js +59 -9
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/commander-usage.js +8 -8
- package/dist/cli/commander-usage.js.map +1 -1
- package/dist/cli/commands/activity.js +4 -4
- package/dist/cli/commands/activity.js.map +1 -1
- package/dist/cli/commands/aggregate.js +4 -3
- package/dist/cli/commands/aggregate.js.map +1 -1
- package/dist/cli/commands/calendar.d.ts +8 -0
- package/dist/cli/commands/calendar.js +15 -4
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/close.js +4 -4
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/completion.js +36 -4
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/config.d.ts +11 -1
- package/dist/cli/commands/config.js +68 -6
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/create.d.ts +1 -0
- package/dist/cli/commands/create.js +55 -6
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/deps.js +4 -4
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/extension/bundled-catalog.js +4 -3
- package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
- package/dist/cli/commands/extension/install-sources.d.ts +1 -0
- package/dist/cli/commands/extension/install-sources.js +20 -2
- package/dist/cli/commands/extension/install-sources.js.map +1 -1
- package/dist/cli/commands/extension.js +26 -5
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/get.js +6 -3
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.js +3 -11
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/linked-test-parsers.js +5 -4
- package/dist/cli/commands/linked-test-parsers.js.map +1 -1
- package/dist/cli/commands/list.js +25 -6
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/plan.js +5 -4
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/search.js +45 -2
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/stats.js +4 -4
- package/dist/cli/commands/stats.js.map +1 -1
- package/dist/cli/commands/test-all.js +4 -4
- package/dist/cli/commands/test-all.js.map +1 -1
- package/dist/cli/commands/update-many.js +35 -6
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/update.js +38 -6
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/help-json-payload.d.ts +1 -11
- package/dist/cli/help-json-payload.js +12 -12
- package/dist/cli/help-json-payload.js.map +1 -1
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +39 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +3 -3
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +20 -8
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-setup.js +4 -2
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.d.ts +2 -6
- package/dist/cli/registration-helpers.js +9 -6
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js +164 -0
- package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-RJONRNXN.js +682 -0
- package/dist/cli-bundle/chunks/chunk-RJONRNXN.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js +13864 -0
- package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js.map +7 -0
- package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js +24225 -0
- package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js.map +7 -0
- package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js +223 -0
- package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js.map +7 -0
- package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js +702 -0
- package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js.map +7 -0
- package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js +355 -0
- package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js.map +7 -0
- package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js +237 -0
- package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js.map +7 -0
- package/dist/cli-bundle/main.js +6896 -0
- package/dist/cli-bundle/main.js.map +7 -0
- package/dist/cli.js +1 -1
- package/dist/core/config/nested-settings.d.ts +88 -0
- package/dist/core/config/nested-settings.js +273 -0
- package/dist/core/config/nested-settings.js.map +1 -0
- package/dist/core/item/parse.d.ts +19 -0
- package/dist/core/item/parse.js +76 -2
- package/dist/core/item/parse.js.map +1 -1
- package/dist/core/item/priority.d.ts +2 -1
- package/dist/core/item/priority.js +12 -2
- package/dist/core/item/priority.js.map +1 -1
- package/dist/core/item/type-synonyms.d.ts +20 -0
- package/dist/core/item/type-synonyms.js +42 -0
- package/dist/core/item/type-synonyms.js.map +1 -0
- package/dist/core/search/cache.js +46 -4
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/search/providers.js +25 -5
- package/dist/core/search/providers.js.map +1 -1
- package/dist/core/search/semantic-defaults.js +73 -32
- package/dist/core/search/semantic-defaults.js.map +1 -1
- package/dist/core/search/staleness.d.ts +23 -0
- package/dist/core/search/staleness.js +34 -0
- package/dist/core/search/staleness.js.map +1 -0
- package/dist/core/search/vector-stores.js +12 -3
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/core/sentry/helpers.d.ts +1 -1
- package/dist/core/sentry/helpers.js +4 -4
- package/dist/core/sentry/helpers.js.map +1 -1
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/html-entity-decode.d.ts +22 -0
- package/dist/core/shared/html-entity-decode.js +127 -0
- package/dist/core/shared/html-entity-decode.js.map +1 -0
- package/dist/core/shared/split-comma-list.d.ts +20 -0
- package/dist/core/shared/split-comma-list.js +29 -0
- package/dist/core/shared/split-comma-list.js.map +1 -0
- package/dist/core/shared/time.js +52 -2
- package/dist/core/shared/time.js.map +1 -1
- package/dist/core/store/front-matter-cache.d.ts +24 -0
- package/dist/core/store/front-matter-cache.js +119 -8
- package/dist/core/store/front-matter-cache.js.map +1 -1
- package/dist/core/store/item-store.d.ts +7 -0
- package/dist/core/store/item-store.js +13 -3
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +3 -2
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +19 -3
- package/dist/core/store/settings.js.map +1 -1
- package/dist/mcp/server.js +11 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +47 -11
- package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +5 -2
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +12 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts.js +28 -7
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/runtime.d.ts +1 -1
- package/dist/sdk/runtime.js +3 -3
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/docs/AGENT_GUIDE.md +7 -0
- package/docs/COMMANDS.md +17 -0
- package/docs/CONFIGURATION.md +66 -0
- package/docs/QUICKSTART.md +3 -0
- package/package.json +7 -4
- package/packages/pm-calendar/extensions/calendar/index.js +27 -2
- package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
- package/packages/pm-calendar/extensions/calendar/runtime.js +5 -0
- package/packages/pm-calendar/extensions/calendar/runtime.ts +6 -0
- package/scripts/bundle-cli.mjs +39 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["core/sentry/helpers.ts"],"sourceRoot":"/","sourcesContent":["import { getSentry } from \"./instrument.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { EXIT_CODE, type TelemetryErrorCategory } from \"../shared/constants.js\";\nimport {\n deriveTelemetryCommandResolution,\n deriveTelemetryCommandTaxonomy,\n type TelemetryCommandResolution,\n type TelemetryResolutionStage,\n} from \"../telemetry/observability.js\";\nimport type { Span } from \"@sentry/node\";\n\nlet activeCommandSpan: Span | undefined;\n\nfunction setSpanAttribute(\n span: Span,\n key: string,\n value: string | number | boolean | undefined,\n): void {\n if (value === undefined) {\n return;\n }\n const attributeTarget = span as unknown as { setAttribute?: (attrKey: string, attrValue: string | number | boolean) => void };\n if (typeof attributeTarget.setAttribute === \"function\") {\n attributeTarget.setAttribute(key, value);\n }\n}\n\nexport function sentrySetCommandContext(\n command: string,\n args: string[],\n options: Record<string, unknown>,\n metadata?: {\n source_context?: string;\n source_context_source?: string;\n },\n): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n const taxonomy = deriveTelemetryCommandTaxonomy(command);\n\n Sentry.setTag(\"pm.command\", command);\n Sentry.setTag(\"pm.command_root\", taxonomy.command_root);\n Sentry.setTag(\"pm.command_family\", taxonomy.command_family);\n if (typeof metadata?.source_context === \"string\" && metadata.source_context.trim().length > 0) {\n Sentry.setTag(\"pm.source_context\", metadata.source_context);\n }\n\n const safeArgs = args.map((arg) =>\n arg.startsWith(\"--\") ? arg.split(\"=\")[0] : arg,\n );\n\n Sentry.setContext(\"pm.command\", {\n name: command,\n root: taxonomy.command_root,\n leaf: taxonomy.command_leaf,\n family: taxonomy.command_family,\n args: safeArgs,\n option_keys: Object.keys(options).sort(),\n source_context: metadata?.source_context,\n source_context_source: metadata?.source_context_source,\n });\n\n Sentry.addBreadcrumb({\n category: \"pm.command\",\n message: `pm ${command}`,\n level: \"info\",\n data: {\n args: safeArgs,\n command_root: taxonomy.command_root,\n command_family: taxonomy.command_family,\n source_context: metadata?.source_context,\n },\n });\n}\n\nexport function sentryStartCommandSpan(command: string): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n\n activeCommandSpan = Sentry.startInactiveSpan({\n op: \"pm.command\",\n name: `pm ${command}`,\n forceTransaction: true,\n });\n}\n\nexport function sentryFinishCommandSpan(\n ok: boolean,\n error?: string,\n metadata?: {\n error_code?: string;\n error_category?: TelemetryErrorCategory;\n exit_code?: number;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n },\n): void {\n if (!activeCommandSpan) return;\n const normalizedOk = ok ? \"true\" : \"false\";\n const normalizedExitCode = typeof metadata?.exit_code === \"number\" ? String(metadata.exit_code) : undefined;\n const Sentry = getSentry();\n if (Sentry) {\n Sentry.setTag(\"pm.ok\", normalizedOk);\n Sentry.setTag(\"pm.command_ok\", normalizedOk);\n if (typeof metadata?.exit_code === \"number\") {\n Sentry.setTag(\"pm.exit_code\", String(metadata.exit_code));\n Sentry.setTag(\"pm.command_exit_code\", String(metadata.exit_code));\n }\n if (typeof metadata?.error_code === \"string\" && metadata.error_code.trim().length > 0) {\n Sentry.setTag(\"pm.error_code\", metadata.error_code);\n }\n if (typeof metadata?.error_category === \"string\" && metadata.error_category.trim().length > 0) {\n Sentry.setTag(\"pm.error_category\", metadata.error_category);\n }\n if (typeof metadata?.command_resolution === \"string\" && metadata.command_resolution.trim().length > 0) {\n Sentry.setTag(\"pm.command_resolution\", metadata.command_resolution);\n }\n if (typeof metadata?.resolution_stage === \"string\" && metadata.resolution_stage.trim().length > 0) {\n Sentry.setTag(\"pm.resolution_stage\", metadata.resolution_stage);\n }\n }\n setSpanAttribute(activeCommandSpan, \"pm.ok\", normalizedOk);\n setSpanAttribute(activeCommandSpan, \"pm.command_ok\", normalizedOk);\n setSpanAttribute(activeCommandSpan, \"pm.exit_code\", normalizedExitCode);\n setSpanAttribute(activeCommandSpan, \"pm.command_exit_code\", normalizedExitCode);\n setSpanAttribute(activeCommandSpan, \"pm.error_code\", metadata?.error_code);\n setSpanAttribute(activeCommandSpan, \"pm.error_category\", metadata?.error_category);\n setSpanAttribute(activeCommandSpan, \"pm.command_resolution\", metadata?.command_resolution);\n setSpanAttribute(activeCommandSpan, \"pm.resolution_stage\", metadata?.resolution_stage);\n activeCommandSpan.setStatus(ok ? { code: 1 } : { code: 2, message: error ?? \"command_failed\" });\n activeCommandSpan.end();\n activeCommandSpan = undefined;\n}\n\nexport function sentryCaptureCliError(error: unknown): void {\n if (!shouldCaptureCliError(error)) return;\n\n const Sentry = getSentry();\n if (!Sentry) return;\n\n if (error instanceof Error) {\n const extras: Record<string, unknown> = {};\n if (\"exitCode\" in error && typeof (error as { exitCode: unknown }).exitCode === \"number\") {\n extras.exit_code = (error as { exitCode: number }).exitCode;\n }\n if (\"context\" in error && typeof (error as { context: unknown }).context === \"object\") {\n extras.error_context = (error as { context: unknown }).context;\n }\n Sentry.captureException(error, { extra: extras });\n } else {\n Sentry.captureException(new Error(String(error)));\n }\n}\n\nexport function sentryLogCliUsageError(params: {\n command: string;\n error_code: string;\n error_category: TelemetryErrorCategory;\n exit_code: number;\n error_message: string;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n source_context?: string;\n}): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n const resolvedCommandResolution =\n params.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: false,\n errorCode: params.error_code,\n errorCategory: params.error_category,\n });\n const resolvedResolutionStage = params.resolution_stage ?? \"unknown\";\n\n const payload = {\n \"pm.command\": params.command,\n \"pm.error_code\": params.error_code,\n \"pm.error_category\": params.error_category,\n \"pm.exit_code\": params.exit_code,\n \"pm.error_message\": params.error_message,\n \"pm.command_resolution\": resolvedCommandResolution,\n \"pm.resolution_stage\": resolvedResolutionStage,\n \"pm.source_context\": params.source_context ?? \"\",\n };\n const loggerCandidate = (Sentry as unknown as { logger?: { warn?: (message: string, attributes?: Record<string, unknown>) => void } })\n .logger;\n if (loggerCandidate && typeof loggerCandidate.warn === \"function\") {\n loggerCandidate.warn(\"pm_cli_usage_error\", payload);\n return;\n }\n\n Sentry.captureMessage(`pm_cli_usage_error:${params.error_code}`, {\n level: \"warning\",\n tags: {\n \"pm.command\": params.command,\n \"pm.error_code\": params.error_code,\n \"pm.error_category\": params.error_category,\n \"pm.exit_code\": String(params.exit_code),\n \"pm.command_resolution\": resolvedCommandResolution,\n \"pm.resolution_stage\": resolvedResolutionStage,\n \"pm.source_context\": params.source_context ?? \"unknown\",\n },\n extra: payload,\n });\n}\n\nexport function shouldCaptureCliError(error: unknown): boolean {\n if (error instanceof PmCliError) {\n return false;\n }\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"exitCode\" in error &&\n typeof (error as { exitCode?: unknown }).exitCode === \"number\"\n ) {\n const exitCode = Math.trunc((error as { exitCode: number }).exitCode);\n const expectedExitCodes: ReadonlySet<number> = new Set([\n EXIT_CODE.SUCCESS,\n EXIT_CODE.USAGE,\n EXIT_CODE.NOT_FOUND,\n EXIT_CODE.CONFLICT,\n ]);\n return !expectedExitCodes.has(exitCode);\n }\n return true;\n}\n\nexport async function sentryFlush(): Promise<void> {\n const Sentry = getSentry();\n if (!Sentry) return;\n\n try {\n await Sentry.flush(3000);\n } catch {\n // Sentry flush must never block CLI exit.\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAA+B,MAAM,wBAAwB,CAAC;AAChF,OAAO,EACL,gCAAgC,EAChC,8BAA8B,GAG/B,MAAM,+BAA+B,CAAC;AAGvC,IAAI,iBAAmC,CAAC;AAExC,SAAS,gBAAgB,CACvB,IAAU,E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M,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;AACH,CAAC","debugId":"901908ed-f774-5833-91fc-7d143bc10f0a"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["core/sentry/helpers.ts"],"sourceRoot":"/","sourcesContent":["import { getSentry } from \"./instrument.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { EXIT_CODE, type TelemetryErrorCategory } from \"../shared/constants.js\";\nimport {\n deriveTelemetryCommandResolution,\n deriveTelemetryCommandTaxonomy,\n type TelemetryCommandResolution,\n type TelemetryResolutionStage,\n} from \"../telemetry/observability.js\";\nimport type { Span } from \"@sentry/node\";\n\nlet activeCommandSpan: Span | undefined;\n\nfunction setSpanAttribute(\n span: Span,\n key: string,\n value: string | number | boolean | undefined,\n): void {\n if (value === undefined) {\n return;\n }\n const attributeTarget = span as unknown as { setAttribute?: (attrKey: string, attrValue: string | number | boolean) => void };\n if (typeof attributeTarget.setAttribute === \"function\") {\n attributeTarget.setAttribute(key, value);\n }\n}\n\nexport function sentrySetCommandContext(\n command: string,\n args: string[],\n options: Record<string, unknown>,\n metadata?: {\n source_context?: string;\n source_context_source?: string;\n },\n): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n const taxonomy = deriveTelemetryCommandTaxonomy(command);\n\n Sentry.setTag(\"pm.command\", command);\n Sentry.setTag(\"pm.command_root\", taxonomy.command_root);\n Sentry.setTag(\"pm.command_family\", taxonomy.command_family);\n if (typeof metadata?.source_context === \"string\" && metadata.source_context.trim().length > 0) {\n Sentry.setTag(\"pm.source_context\", metadata.source_context);\n }\n\n const safeArgs = args.map((arg) =>\n arg.startsWith(\"--\") ? arg.split(\"=\")[0] : arg,\n );\n\n Sentry.setContext(\"pm.command\", {\n name: command,\n root: taxonomy.command_root,\n leaf: taxonomy.command_leaf,\n family: taxonomy.command_family,\n args: safeArgs,\n option_keys: Object.keys(options).sort(),\n source_context: metadata?.source_context,\n source_context_source: metadata?.source_context_source,\n });\n\n Sentry.addBreadcrumb({\n category: \"pm.command\",\n message: `pm ${command}`,\n level: \"info\",\n data: {\n args: safeArgs,\n command_root: taxonomy.command_root,\n command_family: taxonomy.command_family,\n source_context: metadata?.source_context,\n },\n });\n}\n\nexport function sentryStartCommandSpan(command: string): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n\n activeCommandSpan = Sentry.startInactiveSpan({\n op: \"pm.command\",\n name: `pm ${command}`,\n forceTransaction: true,\n });\n}\n\nexport function sentryFinishCommandSpan(\n ok: boolean,\n error?: string,\n metadata?: {\n error_code?: string;\n error_category?: TelemetryErrorCategory;\n exit_code?: number;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n },\n): void {\n if (!activeCommandSpan) return;\n const normalizedOk = ok ? \"true\" : \"false\";\n const normalizedExitCode = typeof metadata?.exit_code === \"number\" ? String(metadata.exit_code) : undefined;\n const Sentry = getSentry();\n if (Sentry) {\n Sentry.setTag(\"pm.ok\", normalizedOk);\n Sentry.setTag(\"pm.command_ok\", normalizedOk);\n if (typeof metadata?.exit_code === \"number\") {\n Sentry.setTag(\"pm.exit_code\", String(metadata.exit_code));\n Sentry.setTag(\"pm.command_exit_code\", String(metadata.exit_code));\n }\n if (typeof metadata?.error_code === \"string\" && metadata.error_code.trim().length > 0) {\n Sentry.setTag(\"pm.error_code\", metadata.error_code);\n }\n if (typeof metadata?.error_category === \"string\" && metadata.error_category.trim().length > 0) {\n Sentry.setTag(\"pm.error_category\", metadata.error_category);\n }\n if (typeof metadata?.command_resolution === \"string\" && metadata.command_resolution.trim().length > 0) {\n Sentry.setTag(\"pm.command_resolution\", metadata.command_resolution);\n }\n if (typeof metadata?.resolution_stage === \"string\" && metadata.resolution_stage.trim().length > 0) {\n Sentry.setTag(\"pm.resolution_stage\", metadata.resolution_stage);\n }\n }\n setSpanAttribute(activeCommandSpan, \"pm.ok\", normalizedOk);\n setSpanAttribute(activeCommandSpan, \"pm.command_ok\", normalizedOk);\n setSpanAttribute(activeCommandSpan, \"pm.exit_code\", normalizedExitCode);\n setSpanAttribute(activeCommandSpan, \"pm.command_exit_code\", normalizedExitCode);\n setSpanAttribute(activeCommandSpan, \"pm.error_code\", metadata?.error_code);\n setSpanAttribute(activeCommandSpan, \"pm.error_category\", metadata?.error_category);\n setSpanAttribute(activeCommandSpan, \"pm.command_resolution\", metadata?.command_resolution);\n setSpanAttribute(activeCommandSpan, \"pm.resolution_stage\", metadata?.resolution_stage);\n activeCommandSpan.setStatus(ok ? { code: 1 } : { code: 2, message: error ?? \"command_failed\" });\n activeCommandSpan.end();\n activeCommandSpan = undefined;\n}\n\nexport function sentryCaptureCliError(error: unknown): void {\n if (!shouldCaptureCliError(error)) return;\n\n const Sentry = getSentry();\n if (!Sentry) return;\n\n if (error instanceof Error) {\n const extras: Record<string, unknown> = {};\n if (\"exitCode\" in error && typeof (error as { exitCode: unknown }).exitCode === \"number\") {\n extras.exit_code = (error as { exitCode: number }).exitCode;\n }\n if (\"context\" in error && typeof (error as { context: unknown }).context === \"object\") {\n extras.error_context = (error as { context: unknown }).context;\n }\n Sentry.captureException(error, { extra: extras });\n } else {\n Sentry.captureException(new Error(String(error)));\n }\n}\n\nexport function sentryLogCliUsageError(params: {\n command: string;\n error_code: string;\n error_category: TelemetryErrorCategory;\n exit_code: number;\n error_message: string;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n source_context?: string;\n}): void {\n const Sentry = getSentry();\n if (!Sentry) return;\n const resolvedCommandResolution =\n params.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: false,\n errorCode: params.error_code,\n errorCategory: params.error_category,\n });\n const resolvedResolutionStage = params.resolution_stage ?? \"unknown\";\n\n const payload = {\n \"pm.command\": params.command,\n \"pm.error_code\": params.error_code,\n \"pm.error_category\": params.error_category,\n \"pm.exit_code\": params.exit_code,\n \"pm.error_message\": params.error_message,\n \"pm.command_resolution\": resolvedCommandResolution,\n \"pm.resolution_stage\": resolvedResolutionStage,\n \"pm.source_context\": params.source_context ?? \"\",\n };\n const loggerCandidate = (Sentry as unknown as { logger?: { warn?: (message: string, attributes?: Record<string, unknown>) => void } })\n .logger;\n if (loggerCandidate && typeof loggerCandidate.warn === \"function\") {\n loggerCandidate.warn(\"pm_cli_usage_error\", payload);\n return;\n }\n\n Sentry.captureMessage(`pm_cli_usage_error:${params.error_code}`, {\n level: \"warning\",\n tags: {\n \"pm.command\": params.command,\n \"pm.error_code\": params.error_code,\n \"pm.error_category\": params.error_category,\n \"pm.exit_code\": String(params.exit_code),\n \"pm.command_resolution\": resolvedCommandResolution,\n \"pm.resolution_stage\": resolvedResolutionStage,\n \"pm.source_context\": params.source_context ?? \"unknown\",\n },\n extra: payload,\n });\n}\n\nexport function shouldCaptureCliError(error: unknown): boolean {\n if (error instanceof PmCliError) {\n return false;\n }\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"exitCode\" in error &&\n typeof (error as { exitCode?: unknown }).exitCode === \"number\"\n ) {\n const exitCode = Math.trunc((error as { exitCode: number }).exitCode);\n const expectedExitCodes: ReadonlySet<number> = new Set([\n EXIT_CODE.SUCCESS,\n EXIT_CODE.USAGE,\n EXIT_CODE.NOT_FOUND,\n EXIT_CODE.CONFLICT,\n ]);\n return !expectedExitCodes.has(exitCode);\n }\n return true;\n}\n\nexport async function sentryFlush(timeoutMs = 3000): Promise<void> {\n const Sentry = getSentry();\n if (!Sentry) return;\n\n try {\n await Sentry.flush(timeoutMs);\n } catch {\n // Sentry flush must never block CLI exit.\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB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AK;YACf,SAAS,CAAC,SAAS;YACnB,SAAS,CAAC,QAAQ;SACnB,CAAC,CAAC;QACH,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAS,GAAG,IAAI;IAChD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;AACH,CAAC","debugId":"92efd73f-f305-5695-8211-81b579afe53d"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0658378d-3fa8-59fa-ab4a-8f1bba265e01")}catch(e){}}();
|
|
3
3
|
import { createDefaultExtensionGovernancePolicy } from "../extensions/extension-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Canonical default lifecycle status model and workflow role mapping.
|
|
@@ -279,6 +279,7 @@ export const SETTINGS_DEFAULTS = {
|
|
|
279
279
|
embedding_timeout_ms: 30_000,
|
|
280
280
|
scanner_max_batch_retries: 3,
|
|
281
281
|
provider: "",
|
|
282
|
+
mutation_refresh_policy: "semantic_configured",
|
|
282
283
|
},
|
|
283
284
|
providers: {
|
|
284
285
|
openai: {
|
|
@@ -374,4 +375,4 @@ export function resolveTelemetryErrorCategory(errorCode) {
|
|
|
374
375
|
return "unknown";
|
|
375
376
|
}
|
|
376
377
|
//# sourceMappingURL=constants.js.map
|
|
377
|
-
//# debugId=
|
|
378
|
+
//# debugId=0658378d-3fa8-59fa-ab4a-8f1bba265e01
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["core/shared/constants.ts"],"sourceRoot":"/","sourcesContent":["import type {\n BuiltinItemType,\n GovernancePreset,\n GovernanceSettings,\n ItemFrontMatter,\n PmSettings,\n RuntimeStatusDefinition,\n RuntimeWorkflowDefinition,\n} from \"../../types/index.js\";\nimport { createDefaultExtensionGovernancePolicy } from \"../extensions/extension-types.js\";\n\n/**\n * Canonical default lifecycle status model and workflow role mapping.\n *\n * Single source of truth: `SETTINGS_DEFAULTS.schema` references these, and\n * `src/core/schema/runtime-schema.ts` re-exports them as\n * `DEFAULT_RUNTIME_STATUS_DEFINITIONS` / `DEFAULT_RUNTIME_WORKFLOW`.\n */\nexport const DEFAULT_STATUS_DEFINITIONS: ReadonlyArray<RuntimeStatusDefinition> = Object.freeze([\n {\n id: \"draft\",\n roles: [\"draft\"],\n },\n {\n id: \"open\",\n roles: [\"active\", \"default_open\"],\n },\n {\n id: \"in_progress\",\n aliases: [\"in-progress\"],\n roles: [\"active\"],\n },\n {\n id: \"blocked\",\n roles: [\"blocked\"],\n },\n {\n id: \"closed\",\n roles: [\"terminal\", \"terminal_done\", \"default_close\"],\n },\n {\n id: \"canceled\",\n aliases: [\"cancelled\"],\n roles: [\"terminal\", \"terminal_canceled\", \"default_cancel\"],\n },\n]);\n\nexport const DEFAULT_WORKFLOW_DEFINITION: RuntimeWorkflowDefinition = Object.freeze({\n draft_status: \"draft\",\n open_status: \"open\",\n in_progress_status: \"in_progress\",\n blocked_status: \"blocked\",\n close_status: \"closed\",\n canceled_status: \"canceled\",\n});\n\nexport const PM_DIRNAME = \".agents/pm\";\nexport const SETTINGS_FILENAME = \"settings.json\";\n\nexport const PM_CORE_REQUIRED_SUBDIRS = [\n \"\",\n \"epics\",\n \"features\",\n \"tasks\",\n \"chores\",\n \"issues\",\n \"schema\",\n \"history\",\n \"index\",\n \"search\",\n \"extensions\",\n \"locks\",\n] as const;\n\nexport const PM_OPTIONAL_TYPE_SUBDIRS = [\n \"decisions\",\n \"events\",\n \"reminders\",\n \"milestones\",\n \"meetings\",\n \"plans\",\n] as const;\n\nexport const PM_REQUIRED_SUBDIRS = [...PM_CORE_REQUIRED_SUBDIRS, ...PM_OPTIONAL_TYPE_SUBDIRS] as const;\n\nexport const TYPE_TO_FOLDER: Record<BuiltinItemType, string> = {\n Epic: \"epics\",\n Feature: \"features\",\n Task: \"tasks\",\n Chore: \"chores\",\n Issue: \"issues\",\n Decision: \"decisions\",\n Event: \"events\",\n Reminder: \"reminders\",\n Milestone: \"milestones\",\n Meeting: \"meetings\",\n Plan: \"plans\",\n};\n\nexport const FRONT_MATTER_KEY_ORDER: ReadonlyArray<string> = [\n \"id\",\n \"title\",\n \"description\",\n \"type\",\n \"source_type\",\n \"type_options\",\n \"status\",\n \"priority\",\n \"tags\",\n \"created_at\",\n \"updated_at\",\n \"deadline\",\n \"reminders\",\n \"events\",\n \"closed_at\",\n \"assignee\",\n \"source_owner\",\n \"author\",\n \"estimated_minutes\",\n \"acceptance_criteria\",\n \"design\",\n \"external_ref\",\n \"definition_of_ready\",\n \"order\",\n \"goal\",\n \"objective\",\n \"value\",\n \"impact\",\n \"outcome\",\n \"why_now\",\n \"parent\",\n \"reviewer\",\n \"risk\",\n \"confidence\",\n \"sprint\",\n \"release\",\n \"blocked_by\",\n \"blocked_reason\",\n \"unblock_note\",\n \"reporter\",\n \"severity\",\n \"environment\",\n \"repro_steps\",\n \"resolution\",\n \"expected_result\",\n \"actual_result\",\n \"affected_version\",\n \"fixed_version\",\n \"component\",\n \"regression\",\n \"customer_impact\",\n \"dependencies\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"files\",\n \"tests\",\n \"test_runs\",\n \"docs\",\n \"close_reason\",\n \"plan_mode\",\n \"plan_scope\",\n \"plan_harness\",\n \"plan_resume_context\",\n \"plan_validation\",\n \"plan_decisions\",\n \"plan_discoveries\",\n \"plan_steps\",\n];\n\ntype BuiltinGovernancePreset = Exclude<GovernancePreset, \"custom\">;\n\nexport const GOVERNANCE_PRESET_DEFAULTS: Record<BuiltinGovernancePreset, Omit<GovernanceSettings, \"preset\">> = {\n minimal: {\n ownership_enforcement: \"none\",\n create_mode_default: \"progressive\",\n close_validation_default: \"off\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n force_required_for_stale_lock: false,\n },\n default: {\n ownership_enforcement: \"warn\",\n create_mode_default: \"progressive\",\n close_validation_default: \"warn\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n force_required_for_stale_lock: true,\n },\n strict: {\n ownership_enforcement: \"strict\",\n create_mode_default: \"strict\",\n close_validation_default: \"strict\",\n parent_reference: \"strict_error\",\n metadata_profile: \"strict\",\n force_required_for_stale_lock: true,\n },\n};\n\nexport const DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS = [\n \"no active blocker\",\n \"ready for planned execution sequencing\",\n \"work completed\",\n \"work is closed\",\n] as const;\n\nexport const DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS = {\n blocked_reason: [\"no active blocker because work is closed\", \"work is closed\"],\n resolution: [\"closed with implementation evidence\", \"closed with verification evidence\", \"work completed and recorded\", \"work is closed\"],\n actual_result: [\"closed and recorded\", \"work completed\", \"work completed and recorded\"],\n} as const;\n\nfunction cloneOptionalArray<T>(values: readonly T[] | undefined): T[] | undefined {\n return values ? [...values] : undefined;\n}\n\nexport const SETTINGS_DEFAULTS: PmSettings = {\n version: 1,\n id_prefix: \"pm-\",\n author_default: \"\",\n item_format: \"toon\",\n locks: {\n ttl_seconds: 1800,\n },\n output: {\n default_format: \"toon\",\n },\n history: {\n missing_stream: \"auto_create\",\n },\n validation: {\n sprint_release_format: \"warn\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n metadata_required_fields: [],\n lifecycle_stale_blocker_reason_patterns: [...DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS],\n lifecycle_closure_like_blocked_reason_patterns: [\n ...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.blocked_reason,\n ],\n lifecycle_closure_like_resolution_patterns: [...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.resolution],\n lifecycle_closure_like_actual_result_patterns: [\n ...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.actual_result,\n ],\n },\n governance: {\n preset: \"minimal\",\n ...GOVERNANCE_PRESET_DEFAULTS.minimal,\n },\n workflow: {\n definition_of_done: [],\n },\n testing: {\n record_results_to_items: false,\n },\n telemetry: {\n enabled: true,\n first_run_prompt_completed: false,\n capture_level: \"redacted\",\n endpoint: \"https://pm-cli.unbrained.dev/v1/events\",\n installation_id: \"\",\n retention_days: 365,\n },\n agent_guidance: {\n prompt_completed: false,\n declined: false,\n declined_at: \"\",\n template_version: 1,\n last_checked_files: [],\n },\n item_types: {\n definitions: [],\n },\n schema: {\n version: 1,\n files: {\n types: \"schema/types.json\",\n statuses: \"schema/statuses.json\",\n fields: \"schema/fields.json\",\n workflows: \"schema/workflows.json\",\n },\n statuses: DEFAULT_STATUS_DEFINITIONS.map((definition) => ({\n ...definition,\n aliases: cloneOptionalArray(definition.aliases),\n roles: cloneOptionalArray(definition.roles),\n })),\n fields: [],\n workflow: { ...DEFAULT_WORKFLOW_DEFINITION },\n unknown_field_policy: \"allow\",\n },\n extensions: {\n enabled: [],\n disabled: [],\n policy: createDefaultExtensionGovernancePolicy(),\n },\n search: {\n score_threshold: 0,\n hybrid_semantic_weight: 0.7,\n max_results: 50,\n embedding_model: \"\",\n embedding_batch_size: 32,\n embedding_timeout_ms: 30_000,\n scanner_max_batch_retries: 3,\n provider: \"\",\n },\n providers: {\n openai: {\n base_url: \"\",\n api_key: \"\",\n model: \"\",\n },\n ollama: {\n base_url: \"\",\n model: \"\",\n },\n },\n context: {\n default_depth: \"brief\",\n activity_limit: 10,\n stale_threshold_days: 7,\n sections: {\n hierarchy: true,\n activity: true,\n progress: true,\n blockers: true,\n files: true,\n workload: true,\n staleness: true,\n tests: true,\n },\n },\n vector_store: {\n adapter: \"\",\n qdrant: {\n url: \"\",\n api_key: \"\",\n },\n lancedb: {\n path: \"\",\n },\n },\n};\n\nexport const EMPTY_CANONICAL_DOCUMENT = {\n metadata: {},\n body: \"\",\n};\n\nexport const EXIT_CODE = {\n SUCCESS: 0,\n GENERIC_FAILURE: 1,\n USAGE: 2,\n NOT_FOUND: 3,\n CONFLICT: 4,\n DEPENDENCY_FAILED: 5,\n} as const;\n\nexport type TelemetryErrorCategory = \"usage\" | \"validation\" | \"conflict\" | \"runtime\" | \"unknown\";\n\nexport const TELEMETRY_ERROR_CATEGORY_BY_CODE: Readonly<Record<string, TelemetryErrorCategory>> = Object.freeze({\n unknown_command: \"usage\",\n unknown_option: \"usage\",\n missing_required_option: \"usage\",\n missing_required_argument: \"usage\",\n invalid_command_usage: \"usage\",\n invalid_argument_value: \"validation\",\n health_findings: \"validation\",\n validation_findings: \"validation\",\n close_through_update: \"validation\",\n no_update_fields: \"validation\",\n unsupported_update_option: \"validation\",\n tracker_not_initialized: \"validation\",\n item_not_found: \"validation\",\n ownership_conflict: \"conflict\",\n lock_conflict: \"conflict\",\n terminal_state_conflict: \"conflict\",\n dependency_failed: \"runtime\",\n command_failed: \"runtime\",\n unknown_error: \"runtime\",\n});\n\nexport function resolveTelemetryErrorCategory(errorCode: string | undefined): TelemetryErrorCategory {\n const normalized = (errorCode ?? \"\").trim().toLowerCase();\n if (normalized.length === 0) {\n return \"unknown\";\n }\n const explicit = TELEMETRY_ERROR_CATEGORY_BY_CODE[normalized];\n if (typeof explicit === \"string\") {\n return explicit;\n }\n if (normalized.includes(\"conflict\") || normalized.includes(\"locked\")) {\n return \"conflict\";\n }\n if (normalized.startsWith(\"unknown_\") || normalized.startsWith(\"missing_required_\")) {\n return \"usage\";\n }\n if (normalized.startsWith(\"invalid_\") || normalized.endsWith(\"_not_found\") || normalized.includes(\"validation\")) {\n return \"validation\";\n }\n if (normalized.endsWith(\"_error\") || normalized.endsWith(\"_failed\")) {\n return \"runtime\";\n }\n return \"unknown\";\n}\n"],"names":[],"mappings":";;AASA,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAE1F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA2C,MAAM,CAAC,MAAM,CAAC;IAC9F;QACE,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,CAAC,OAAO,CAAC;KACjB;IACD;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC;KAClC;IACD;QACE,EAAE,EAAE,aAAa;QACjB,OAAO,EAAE,CAAC,aAAa,CAAC;QACxB,KAAK,EAAE,CAAC,QAAQ,CAAC;KAClB;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,CAAC,SAAS,CAAC;KACnB;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,CAAC,UAAU,EAAE,eAAe,EAAE,eAAe,CAAC;KACtD;IACD;QACE,EAAE,EAAE,UAAU;QACd,OAAO,EAAE,CAAC,WAAW,CAAC;QACtB,KAAK,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,CAAC;KAC3D;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAA8B,MAAM,CAAC,MAAM,CAAC;IAClF,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,MAAM;IACnB,kBAAkB,EAAE,aAAa;IACjC,cAAc,EAAE,SAAS;IACzB,YAAY,EAAE,QAAQ;IACtB,eAAe,EAAE,UAAU;CAC5B,CAAC,CAAC;AAEH,MAAM,C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sourceRoot":"/","sourcesContent":["import type {\n BuiltinItemType,\n GovernancePreset,\n GovernanceSettings,\n ItemFrontMatter,\n PmSettings,\n RuntimeStatusDefinition,\n RuntimeWorkflowDefinition,\n} from \"../../types/index.js\";\nimport { createDefaultExtensionGovernancePolicy } from \"../extensions/extension-types.js\";\n\n/**\n * Canonical default lifecycle status model and workflow role mapping.\n *\n * Single source of truth: `SETTINGS_DEFAULTS.schema` references these, and\n * `src/core/schema/runtime-schema.ts` re-exports them as\n * `DEFAULT_RUNTIME_STATUS_DEFINITIONS` / `DEFAULT_RUNTIME_WORKFLOW`.\n */\nexport const DEFAULT_STATUS_DEFINITIONS: ReadonlyArray<RuntimeStatusDefinition> = Object.freeze([\n {\n id: \"draft\",\n roles: [\"draft\"],\n },\n {\n id: \"open\",\n roles: [\"active\", \"default_open\"],\n },\n {\n id: \"in_progress\",\n aliases: [\"in-progress\"],\n roles: [\"active\"],\n },\n {\n id: \"blocked\",\n roles: [\"blocked\"],\n },\n {\n id: \"closed\",\n roles: [\"terminal\", \"terminal_done\", \"default_close\"],\n },\n {\n id: \"canceled\",\n aliases: [\"cancelled\"],\n roles: [\"terminal\", \"terminal_canceled\", \"default_cancel\"],\n },\n]);\n\nexport const DEFAULT_WORKFLOW_DEFINITION: RuntimeWorkflowDefinition = Object.freeze({\n draft_status: \"draft\",\n open_status: \"open\",\n in_progress_status: \"in_progress\",\n blocked_status: \"blocked\",\n close_status: \"closed\",\n canceled_status: \"canceled\",\n});\n\nexport const PM_DIRNAME = \".agents/pm\";\nexport const SETTINGS_FILENAME = \"settings.json\";\n\nexport const PM_CORE_REQUIRED_SUBDIRS = [\n \"\",\n \"epics\",\n \"features\",\n \"tasks\",\n \"chores\",\n \"issues\",\n \"schema\",\n \"history\",\n \"index\",\n \"search\",\n \"extensions\",\n \"locks\",\n] as const;\n\nexport const PM_OPTIONAL_TYPE_SUBDIRS = [\n \"decisions\",\n \"events\",\n \"reminders\",\n \"milestones\",\n \"meetings\",\n \"plans\",\n] as const;\n\nexport const PM_REQUIRED_SUBDIRS = [...PM_CORE_REQUIRED_SUBDIRS, ...PM_OPTIONAL_TYPE_SUBDIRS] as const;\n\nexport const TYPE_TO_FOLDER: Record<BuiltinItemType, string> = {\n Epic: \"epics\",\n Feature: \"features\",\n Task: \"tasks\",\n Chore: \"chores\",\n Issue: \"issues\",\n Decision: \"decisions\",\n Event: \"events\",\n Reminder: \"reminders\",\n Milestone: \"milestones\",\n Meeting: \"meetings\",\n Plan: \"plans\",\n};\n\nexport const FRONT_MATTER_KEY_ORDER: ReadonlyArray<string> = [\n \"id\",\n \"title\",\n \"description\",\n \"type\",\n \"source_type\",\n \"type_options\",\n \"status\",\n \"priority\",\n \"tags\",\n \"created_at\",\n \"updated_at\",\n \"deadline\",\n \"reminders\",\n \"events\",\n \"closed_at\",\n \"assignee\",\n \"source_owner\",\n \"author\",\n \"estimated_minutes\",\n \"acceptance_criteria\",\n \"design\",\n \"external_ref\",\n \"definition_of_ready\",\n \"order\",\n \"goal\",\n \"objective\",\n \"value\",\n \"impact\",\n \"outcome\",\n \"why_now\",\n \"parent\",\n \"reviewer\",\n \"risk\",\n \"confidence\",\n \"sprint\",\n \"release\",\n \"blocked_by\",\n \"blocked_reason\",\n \"unblock_note\",\n \"reporter\",\n \"severity\",\n \"environment\",\n \"repro_steps\",\n \"resolution\",\n \"expected_result\",\n \"actual_result\",\n \"affected_version\",\n \"fixed_version\",\n \"component\",\n \"regression\",\n \"customer_impact\",\n \"dependencies\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"files\",\n \"tests\",\n \"test_runs\",\n \"docs\",\n \"close_reason\",\n \"plan_mode\",\n \"plan_scope\",\n \"plan_harness\",\n \"plan_resume_context\",\n \"plan_validation\",\n \"plan_decisions\",\n \"plan_discoveries\",\n \"plan_steps\",\n];\n\ntype BuiltinGovernancePreset = Exclude<GovernancePreset, \"custom\">;\n\nexport const GOVERNANCE_PRESET_DEFAULTS: Record<BuiltinGovernancePreset, Omit<GovernanceSettings, \"preset\">> = {\n minimal: {\n ownership_enforcement: \"none\",\n create_mode_default: \"progressive\",\n close_validation_default: \"off\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n force_required_for_stale_lock: false,\n },\n default: {\n ownership_enforcement: \"warn\",\n create_mode_default: \"progressive\",\n close_validation_default: \"warn\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n force_required_for_stale_lock: true,\n },\n strict: {\n ownership_enforcement: \"strict\",\n create_mode_default: \"strict\",\n close_validation_default: \"strict\",\n parent_reference: \"strict_error\",\n metadata_profile: \"strict\",\n force_required_for_stale_lock: true,\n },\n};\n\nexport const DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS = [\n \"no active blocker\",\n \"ready for planned execution sequencing\",\n \"work completed\",\n \"work is closed\",\n] as const;\n\nexport const DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS = {\n blocked_reason: [\"no active blocker because work is closed\", \"work is closed\"],\n resolution: [\"closed with implementation evidence\", \"closed with verification evidence\", \"work completed and recorded\", \"work is closed\"],\n actual_result: [\"closed and recorded\", \"work completed\", \"work completed and recorded\"],\n} as const;\n\nfunction cloneOptionalArray<T>(values: readonly T[] | undefined): T[] | undefined {\n return values ? [...values] : undefined;\n}\n\nexport const SETTINGS_DEFAULTS: PmSettings = {\n version: 1,\n id_prefix: \"pm-\",\n author_default: \"\",\n item_format: \"toon\",\n locks: {\n ttl_seconds: 1800,\n },\n output: {\n default_format: \"toon\",\n },\n history: {\n missing_stream: \"auto_create\",\n },\n validation: {\n sprint_release_format: \"warn\",\n parent_reference: \"warn\",\n metadata_profile: \"core\",\n metadata_required_fields: [],\n lifecycle_stale_blocker_reason_patterns: [...DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS],\n lifecycle_closure_like_blocked_reason_patterns: [\n ...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.blocked_reason,\n ],\n lifecycle_closure_like_resolution_patterns: [...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.resolution],\n lifecycle_closure_like_actual_result_patterns: [\n ...DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.actual_result,\n ],\n },\n governance: {\n preset: \"minimal\",\n ...GOVERNANCE_PRESET_DEFAULTS.minimal,\n },\n workflow: {\n definition_of_done: [],\n },\n testing: {\n record_results_to_items: false,\n },\n telemetry: {\n enabled: true,\n first_run_prompt_completed: false,\n capture_level: \"redacted\",\n endpoint: \"https://pm-cli.unbrained.dev/v1/events\",\n installation_id: \"\",\n retention_days: 365,\n },\n agent_guidance: {\n prompt_completed: false,\n declined: false,\n declined_at: \"\",\n template_version: 1,\n last_checked_files: [],\n },\n item_types: {\n definitions: [],\n },\n schema: {\n version: 1,\n files: {\n types: \"schema/types.json\",\n statuses: \"schema/statuses.json\",\n fields: \"schema/fields.json\",\n workflows: \"schema/workflows.json\",\n },\n statuses: DEFAULT_STATUS_DEFINITIONS.map((definition) => ({\n ...definition,\n aliases: cloneOptionalArray(definition.aliases),\n roles: cloneOptionalArray(definition.roles),\n })),\n fields: [],\n workflow: { ...DEFAULT_WORKFLOW_DEFINITION },\n unknown_field_policy: \"allow\",\n },\n extensions: {\n enabled: [],\n disabled: [],\n policy: createDefaultExtensionGovernancePolicy(),\n },\n search: {\n score_threshold: 0,\n hybrid_semantic_weight: 0.7,\n max_results: 50,\n embedding_model: \"\",\n embedding_batch_size: 32,\n embedding_timeout_ms: 30_000,\n scanner_max_batch_retries: 3,\n provider: \"\",\n mutation_refresh_policy: \"semantic_configured\",\n },\n providers: {\n openai: {\n base_url: \"\",\n api_key: \"\",\n model: \"\",\n },\n ollama: {\n base_url: \"\",\n model: \"\",\n },\n },\n context: {\n default_depth: \"brief\",\n activity_limit: 10,\n stale_threshold_days: 7,\n sections: {\n hierarchy: true,\n activity: true,\n progress: true,\n blockers: true,\n files: true,\n workload: true,\n staleness: true,\n tests: true,\n },\n },\n vector_store: {\n adapter: \"\",\n qdrant: {\n url: \"\",\n api_key: \"\",\n },\n lancedb: {\n path: \"\",\n },\n },\n};\n\nexport const EMPTY_CANONICAL_DOCUMENT = {\n metadata: {},\n body: \"\",\n};\n\nexport const EXIT_CODE = {\n SUCCESS: 0,\n GENERIC_FAILURE: 1,\n USAGE: 2,\n NOT_FOUND: 3,\n CONFLICT: 4,\n DEPENDENCY_FAILED: 5,\n} as const;\n\nexport type TelemetryErrorCategory = \"usage\" | \"validation\" | \"conflict\" | \"runtime\" | \"unknown\";\n\nexport const TELEMETRY_ERROR_CATEGORY_BY_CODE: Readonly<Record<string, TelemetryErrorCategory>> = Object.freeze({\n unknown_command: \"usage\",\n unknown_option: \"usage\",\n missing_required_option: \"usage\",\n missing_required_argument: \"usage\",\n invalid_command_usage: \"usage\",\n invalid_argument_value: \"validation\",\n health_findings: \"validation\",\n validation_findings: \"validation\",\n close_through_update: \"validation\",\n no_update_fields: \"validation\",\n unsupported_update_option: \"validation\",\n tracker_not_initialized: \"validation\",\n item_not_found: \"validation\",\n ownership_conflict: \"conflict\",\n lock_conflict: \"conflict\",\n terminal_state_conflict: \"conflict\",\n dependency_failed: \"runtime\",\n command_failed: \"runtime\",\n unknown_error: \"runtime\",\n});\n\nexport function resolveTelemetryErrorCategory(errorCode: string | undefined): TelemetryErrorCategory {\n const normalized = (errorCode ?? \"\").trim().toLowerCase();\n if (normalized.length === 0) {\n return \"unknown\";\n }\n const explicit = TELEMETRY_ERROR_CATEGORY_BY_CODE[normalized];\n if (typeof explicit === \"string\") {\n return explicit;\n }\n if (normalized.includes(\"conflict\") || normalized.includes(\"locked\")) {\n return \"conflict\";\n }\n if (normalized.startsWith(\"unknown_\") || normalized.startsWith(\"missing_required_\")) {\n return \"usage\";\n }\n if (normalized.startsWith(\"invalid_\") || normalized.endsWith(\"_not_found\") || normalized.includes(\"validation\")) {\n return \"validation\";\n }\n if (normalized.endsWith(\"_error\") || normalized.endsWith(\"_failed\")) {\n return \"runtime\";\n }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AAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAG,gCAAgC,CAAC,UAAU,CAAC,CAAC;IAC9D,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrE,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACpF,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAChH,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","debugId":"0658378d-3fa8-59fa-ab4a-8f1bba265e01"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode the five core HTML entities (`<`, `>`, `"`, `'`,
|
|
3
|
+
* `&`) in a single pass — but only when the input contains `<` or
|
|
4
|
+
* `>`. Returns the input unchanged otherwise so the function is a no-op for
|
|
5
|
+
* normal text and idempotent on already-decoded strings.
|
|
6
|
+
*
|
|
7
|
+
* Single-pass semantics guarantee `&lt;` decodes to `<` (literal) rather
|
|
8
|
+
* than collapsing to `<`, preserving any intentional double-encoding.
|
|
9
|
+
*/
|
|
10
|
+
export declare function decodeHtmlEntitiesIfEscaped(input: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Walk an arbitrary value (string / array / plain object) and apply
|
|
13
|
+
* {@link decodeHtmlEntitiesIfEscaped} to every string leaf. Non-string scalars
|
|
14
|
+
* (numbers, booleans, null, undefined) and non-plain values pass through
|
|
15
|
+
* untouched.
|
|
16
|
+
*
|
|
17
|
+
* The walker mutates a fresh shallow copy at each level so the caller's input
|
|
18
|
+
* is not modified. Cycles are not expected (MCP arguments arrive as JSON), but
|
|
19
|
+
* a WeakMap is used as defensive protection against accidental cycles and
|
|
20
|
+
* repeated references.
|
|
21
|
+
*/
|
|
22
|
+
export declare function decodeHtmlEntitiesInOptions<T>(options: T): T;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Defensive HTML-entity decode for free-text fields arriving over the MCP boundary.
|
|
2
|
+
// Background (pm-ydkl 2026-05-28): when Claude / the Anthropic MCP SDK forwards
|
|
3
|
+
// tool arguments containing `<` or `>`, the upstream platform HTML-encodes those
|
|
4
|
+
// characters before they reach pm-cli. The result is stored pm text containing
|
|
5
|
+
// literal `<type>` instead of `<type>`. Direct CLI calls do NOT have this
|
|
6
|
+
// issue — only the MCP path — so the decode is applied exclusively at the MCP
|
|
7
|
+
// server boundary on incoming tool-call arguments.
|
|
8
|
+
//
|
|
9
|
+
// We decode only the five core HTML entities and ONLY when `<` or `>` is
|
|
10
|
+
// present in the string (the signal that something upstream HTML-encoded it).
|
|
11
|
+
// That makes the function a true no-op for normal text. All replacements run in
|
|
12
|
+
// a single non-greedy pass via a lookup map so we never double-decode — most
|
|
13
|
+
// importantly `&lt;` stays as the literal `<` (because `&` is the
|
|
14
|
+
// last entity resolved in the pass), preserving any text that was already
|
|
15
|
+
// double-encoded upstream.
|
|
16
|
+
|
|
17
|
+
!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]="34d22aab-8ac6-5f82-b625-f7fd5673e13f")}catch(e){}}();
|
|
18
|
+
const ENTITY_MAP = Object.freeze({
|
|
19
|
+
"<": "<",
|
|
20
|
+
">": ">",
|
|
21
|
+
""": '"',
|
|
22
|
+
"'": "'",
|
|
23
|
+
"&": "&",
|
|
24
|
+
});
|
|
25
|
+
// Pattern order is important for documentation only: the alternation matches
|
|
26
|
+
// the leftmost occurrence at each position, and the map lookup resolves each
|
|
27
|
+
// match independently. Crucially, `&` is matched as a whole token, so a
|
|
28
|
+
// substring like `&lt;` matches `&` once → `<` (literal) and the
|
|
29
|
+
// regex engine then advances past the inserted text without re-scanning it.
|
|
30
|
+
const ENTITY_PATTERN = /&(?:lt|gt|quot|#39|amp);/g;
|
|
31
|
+
/**
|
|
32
|
+
* Decode the five core HTML entities (`<`, `>`, `"`, `'`,
|
|
33
|
+
* `&`) in a single pass — but only when the input contains `<` or
|
|
34
|
+
* `>`. Returns the input unchanged otherwise so the function is a no-op for
|
|
35
|
+
* normal text and idempotent on already-decoded strings.
|
|
36
|
+
*
|
|
37
|
+
* Single-pass semantics guarantee `&lt;` decodes to `<` (literal) rather
|
|
38
|
+
* than collapsing to `<`, preserving any intentional double-encoding.
|
|
39
|
+
*/
|
|
40
|
+
export function decodeHtmlEntitiesIfEscaped(input) {
|
|
41
|
+
if (typeof input !== "string") {
|
|
42
|
+
return input;
|
|
43
|
+
}
|
|
44
|
+
// Activation signal is INTENTIONALLY narrow: only `<` / `>` trigger
|
|
45
|
+
// decoding. Rationale: the observed MCP-platform behavior only encodes
|
|
46
|
+
// angle brackets (the characters that risk display-time HTML
|
|
47
|
+
// misinterpretation upstream). Widening to `&` / `"` / `'`
|
|
48
|
+
// would risk altering legitimate text that contains those literal token
|
|
49
|
+
// sequences for unrelated reasons (a URL containing `&`, a snippet
|
|
50
|
+
// of HTML being intentionally stored as escaped, etc.). If upstream
|
|
51
|
+
// changes its encoding policy to cover `&` / `"` / `'` standalone, the
|
|
52
|
+
// signal-guard here will need to be widened in lockstep — covered by
|
|
53
|
+
// tests `&-only is no-op` and `"-only is no-op`.
|
|
54
|
+
if (!input.includes("<") && !input.includes(">")) {
|
|
55
|
+
return input;
|
|
56
|
+
}
|
|
57
|
+
// The regex only matches keys present in ENTITY_MAP, so the lookup is total.
|
|
58
|
+
return input.replace(ENTITY_PATTERN, (match) => ENTITY_MAP[match]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Walk an arbitrary value (string / array / plain object) and apply
|
|
62
|
+
* {@link decodeHtmlEntitiesIfEscaped} to every string leaf. Non-string scalars
|
|
63
|
+
* (numbers, booleans, null, undefined) and non-plain values pass through
|
|
64
|
+
* untouched.
|
|
65
|
+
*
|
|
66
|
+
* The walker mutates a fresh shallow copy at each level so the caller's input
|
|
67
|
+
* is not modified. Cycles are not expected (MCP arguments arrive as JSON), but
|
|
68
|
+
* a WeakMap is used as defensive protection against accidental cycles and
|
|
69
|
+
* repeated references.
|
|
70
|
+
*/
|
|
71
|
+
export function decodeHtmlEntitiesInOptions(options) {
|
|
72
|
+
return decodeValue(options, new WeakMap());
|
|
73
|
+
}
|
|
74
|
+
function decodeValue(value, seen) {
|
|
75
|
+
if (typeof value === "string") {
|
|
76
|
+
return decodeHtmlEntitiesIfEscaped(value);
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(value)) {
|
|
79
|
+
if (seen.has(value)) {
|
|
80
|
+
return seen.get(value);
|
|
81
|
+
}
|
|
82
|
+
const result = [];
|
|
83
|
+
seen.set(value, result);
|
|
84
|
+
for (const entry of value) {
|
|
85
|
+
result.push(decodeValue(entry, seen));
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
if (value !== null && typeof value === "object") {
|
|
90
|
+
// Only traverse plain objects (`{}` and `Object.create(null)` literals).
|
|
91
|
+
// Class instances (Date, RegExp, Map, Set, Buffer, etc.) and `null`-proto
|
|
92
|
+
// objects with no proto would lose their prototype and methods if we
|
|
93
|
+
// rebuilt them as a `Record<string, unknown>` here, so we pass them through.
|
|
94
|
+
if (!isPlainObject(value)) {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
if (seen.has(value)) {
|
|
98
|
+
return seen.get(value);
|
|
99
|
+
}
|
|
100
|
+
const source = value;
|
|
101
|
+
// Preserve the original prototype so downstream callers can still rely on
|
|
102
|
+
// standard methods like `.hasOwnProperty` on plain objects.
|
|
103
|
+
const result = Object.create(Object.getPrototypeOf(value));
|
|
104
|
+
seen.set(value, result);
|
|
105
|
+
// Use Object.defineProperty (not bracket assignment) for ALL keys so a
|
|
106
|
+
// smuggled `__proto__` / `constructor` / `prototype` key from an MCP
|
|
107
|
+
// caller becomes a regular own property — never triggers JS's special
|
|
108
|
+
// prototype-chain assignment semantics that would otherwise pollute
|
|
109
|
+
// Object.prototype. This preserves legitimate data while staying safe.
|
|
110
|
+
for (const [key, entry] of Object.entries(source)) {
|
|
111
|
+
Object.defineProperty(result, key, {
|
|
112
|
+
value: decodeValue(entry, seen),
|
|
113
|
+
enumerable: true,
|
|
114
|
+
writable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
function isPlainObject(value) {
|
|
123
|
+
const proto = Object.getPrototypeOf(value);
|
|
124
|
+
return proto === Object.prototype || proto === null;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=html-entity-decode.js.map
|
|
127
|
+
//# debugId=34d22aab-8ac6-5f82-b625-f7fd5673e13f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-entity-decode.js","sources":["core/shared/html-entity-decode.ts"],"sourceRoot":"/","sourcesContent":["// Defensive HTML-entity decode for free-text fields arriving over the MCP boundary.\n// Background (pm-ydkl 2026-05-28): when Claude / the Anthropic MCP SDK forwards\n// tool arguments containing `<` or `>`, the upstream platform HTML-encodes those\n// characters before they reach pm-cli. The result is stored pm text containing\n// literal `<type>` instead of `<type>`. Direct CLI calls do NOT have this\n// issue — only the MCP path — so the decode is applied exclusively at the MCP\n// server boundary on incoming tool-call arguments.\n//\n// We decode only the five core HTML entities and ONLY when `<` or `>` is\n// present in the string (the signal that something upstream HTML-encoded it).\n// That makes the function a true no-op for normal text. All replacements run in\n// a single non-greedy pass via a lookup map so we never double-decode — most\n// importantly `&lt;` stays as the literal `<` (because `&` is the\n// last entity resolved in the pass), preserving any text that was already\n// double-encoded upstream.\n\nconst ENTITY_MAP: Readonly<Record<string, string>> = Object.freeze({\n \"<\": \"<\",\n \">\": \">\",\n \""\": '\"',\n \"'\": \"'\",\n \"&\": \"&\",\n});\n\n// Pattern order is important for documentation only: the alternation matches\n// the leftmost occurrence at each position, and the map lookup resolves each\n// match independently. Crucially, `&` is matched as a whole token, so a\n// substring like `&lt;` matches `&` once → `<` (literal) and the\n// regex engine then advances past the inserted text without re-scanning it.\nconst ENTITY_PATTERN = /&(?:lt|gt|quot|#39|amp);/g;\n\n/**\n * Decode the five core HTML entities (`<`, `>`, `"`, `'`,\n * `&`) in a single pass — but only when the input contains `<` or\n * `>`. Returns the input unchanged otherwise so the function is a no-op for\n * normal text and idempotent on already-decoded strings.\n *\n * Single-pass semantics guarantee `&lt;` decodes to `<` (literal) rather\n * than collapsing to `<`, preserving any intentional double-encoding.\n */\nexport function decodeHtmlEntitiesIfEscaped(input: string): string {\n if (typeof input !== \"string\") {\n return input;\n }\n // Activation signal is INTENTIONALLY narrow: only `<` / `>` trigger\n // decoding. Rationale: the observed MCP-platform behavior only encodes\n // angle brackets (the characters that risk display-time HTML\n // misinterpretation upstream). Widening to `&` / `"` / `'`\n // would risk altering legitimate text that contains those literal token\n // sequences for unrelated reasons (a URL containing `&`, a snippet\n // of HTML being intentionally stored as escaped, etc.). If upstream\n // changes its encoding policy to cover `&` / `\"` / `'` standalone, the\n // signal-guard here will need to be widened in lockstep — covered by\n // tests `&-only is no-op` and `"-only is no-op`.\n if (!input.includes(\"<\") && !input.includes(\">\")) {\n return input;\n }\n // The regex only matches keys present in ENTITY_MAP, so the lookup is total.\n return input.replace(ENTITY_PATTERN, (match) => ENTITY_MAP[match] as string);\n}\n\n/**\n * Walk an arbitrary value (string / array / plain object) and apply\n * {@link decodeHtmlEntitiesIfEscaped} to every string leaf. Non-string scalars\n * (numbers, booleans, null, undefined) and non-plain values pass through\n * untouched.\n *\n * The walker mutates a fresh shallow copy at each level so the caller's input\n * is not modified. Cycles are not expected (MCP arguments arrive as JSON), but\n * a WeakMap is used as defensive protection against accidental cycles and\n * repeated references.\n */\nexport function decodeHtmlEntitiesInOptions<T>(options: T): T {\n return decodeValue(options, new WeakMap<object, unknown>()) as T;\n}\n\nfunction decodeValue(value: unknown, seen: WeakMap<object, unknown>): unknown {\n if (typeof value === \"string\") {\n return decodeHtmlEntitiesIfEscaped(value);\n }\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return seen.get(value);\n }\n const result: unknown[] = [];\n seen.set(value, result);\n for (const entry of value) {\n result.push(decodeValue(entry, seen));\n }\n return result;\n }\n if (value !== null && typeof value === \"object\") {\n // Only traverse plain objects (`{}` and `Object.create(null)` literals).\n // Class instances (Date, RegExp, Map, Set, Buffer, etc.) and `null`-proto\n // objects with no proto would lose their prototype and methods if we\n // rebuilt them as a `Record<string, unknown>` here, so we pass them through.\n if (!isPlainObject(value)) {\n return value;\n }\n if (seen.has(value as object)) {\n return seen.get(value as object);\n }\n const source = value as Record<string, unknown>;\n // Preserve the original prototype so downstream callers can still rely on\n // standard methods like `.hasOwnProperty` on plain objects.\n const result: Record<string, unknown> = Object.create(Object.getPrototypeOf(value as object));\n seen.set(value as object, result);\n // Use Object.defineProperty (not bracket assignment) for ALL keys so a\n // smuggled `__proto__` / `constructor` / `prototype` key from an MCP\n // caller becomes a regular own property — never triggers JS's special\n // prototype-chain assignment semantics that would otherwise pollute\n // Object.prototype. This preserves legitimate data while staying safe.\n for (const [key, entry] of Object.entries(source)) {\n Object.defineProperty(result, key, {\n value: decodeValue(entry, seen),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return result;\n }\n return value;\n}\n\nfunction isPlainObject(value: object): boolean {\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,2BAA2B;;;AAE3B,MAAM,UAAU,GAAqC,MAAM,CAAC,MAAM,CAAC;IACjE,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,GAAG;IACb,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,GAAG;CACb,CAAC,CAAC;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAa;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,0EAA0E;IAC1E,uEAAuE;IACvE,6DAA6D;IAC7D,wEAAwE;IACxE,wEAAwE;IACxE,uEAAuE;IACvE,oEAAoE;IACpE,uEAAuE;IACvE,qEAAqE;IACrE,0DAA0D;IAC1D,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC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AG,CAAC,KAAe,CAAC,CAAC;QACnC,CAAC;QACD,MAAM,MAAM,GAAG,KAAgC,CAAC;QAChD,0EAA0E;QAC1E,4DAA4D;QAC5D,MAAM,MAAM,GAA4B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAe,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,GAAG,CAAC,KAAe,EAAE,MAAM,CAAC,CAAC;QAClC,uEAAuE;QACvE,qEAAqE;QACrE,sEAAsE;QACtE,oEAAoE;QACpE,uEAAuE;QACvE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;gBACjC,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC;gBAC/B,UAAU,EAAE,IAAI;gBAChB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC","debugId":"34d22aab-8ac6-5f82-b625-f7fd5673e13f"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SplitCommaListOptions {
|
|
2
|
+
/** Separator pattern. Defaults to `/,/`. */
|
|
3
|
+
separators?: RegExp | string;
|
|
4
|
+
/** De-duplicate entries while preserving first-seen order. Defaults to `true`. */
|
|
5
|
+
unique?: boolean;
|
|
6
|
+
/** Sort entries lexicographically (default JS string sort). Defaults to `false`. */
|
|
7
|
+
sort?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Split a comma-separated (or custom-separator) string into trimmed, non-empty entries.
|
|
11
|
+
*
|
|
12
|
+
* Default behaviour:
|
|
13
|
+
* - Splits on `,`.
|
|
14
|
+
* - Trims each entry and discards empty results (collapsing leading/trailing/duplicate separators).
|
|
15
|
+
* - De-duplicates while preserving first-seen order.
|
|
16
|
+
* - Does not sort.
|
|
17
|
+
*
|
|
18
|
+
* Returns `[]` for `undefined`/`null` input. Pure, dependency-free.
|
|
19
|
+
*/
|
|
20
|
+
export declare function splitCommaList(raw: string | undefined | null, options?: SplitCommaListOptions): string[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a comma-separated (or custom-separator) string into trimmed, non-empty entries.
|
|
3
|
+
*
|
|
4
|
+
* Default behaviour:
|
|
5
|
+
* - Splits on `,`.
|
|
6
|
+
* - Trims each entry and discards empty results (collapsing leading/trailing/duplicate separators).
|
|
7
|
+
* - De-duplicates while preserving first-seen order.
|
|
8
|
+
* - Does not sort.
|
|
9
|
+
*
|
|
10
|
+
* Returns `[]` for `undefined`/`null` input. Pure, dependency-free.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
!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]="e5a31927-2a55-5d1d-97e4-b6190988caa1")}catch(e){}}();
|
|
14
|
+
export function splitCommaList(raw, options) {
|
|
15
|
+
if (raw === undefined || raw === null) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const separators = options?.separators ?? /,/;
|
|
19
|
+
const parts = raw.split(separators);
|
|
20
|
+
const trimmed = parts.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
21
|
+
const unique = options?.unique !== false;
|
|
22
|
+
const deduped = unique ? Array.from(new Set(trimmed)) : trimmed;
|
|
23
|
+
if (options?.sort === true) {
|
|
24
|
+
return [...deduped].sort();
|
|
25
|
+
}
|
|
26
|
+
return deduped;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=split-comma-list.js.map
|
|
29
|
+
//# debugId=e5a31927-2a55-5d1d-97e4-b6190988caa1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-comma-list.js","sources":["core/shared/split-comma-list.ts"],"sourceRoot":"/","sourcesContent":["export interface SplitCommaListOptions {\n /** Separator pattern. Defaults to `/,/`. */\n separators?: RegExp | string;\n /** De-duplicate entries while preserving first-seen order. Defaults to `true`. */\n unique?: boolean;\n /** Sort entries lexicographically (default JS string sort). Defaults to `false`. */\n sort?: boolean;\n}\n\n/**\n * Split a comma-separated (or custom-separator) string into trimmed, non-empty entries.\n *\n * Default behaviour:\n * - Splits on `,`.\n * - Trims each entry and discards empty results (collapsing leading/trailing/duplicate separators).\n * - De-duplicates while preserving first-seen order.\n * - Does not sort.\n *\n * Returns `[]` for `undefined`/`null` input. Pure, dependency-free.\n */\nexport function splitCommaList(raw: string | undefined | null, options?: SplitCommaListOptions): string[] {\n if (raw === undefined || raw === null) {\n return [];\n }\n const separators = options?.separators ?? /,/;\n const parts = raw.split(separators as never);\n const trimmed = parts.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n const unique = options?.unique !== false;\n const deduped = unique ? Array.from(new Set(trimmed)) : trimmed;\n if (options?.sort === true) {\n return [...deduped].sort();\n }\n return deduped;\n}\n"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;;;AACH,MAAM,UAAU,cAAc,CAAC,GAA8B,EAAE,OAA+B;IAC5F,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,GAAG,CAAC;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,UAAmB,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,IAAI,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","debugId":"e5a31927-2a55-5d1d-97e4-b6190988caa1"}
|
package/dist/core/shared/time.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b41467c9-6c80-5391-b9eb-3d13f170a105")}catch(e){}}();
|
|
3
3
|
import { PmCliError } from "./errors.js";
|
|
4
4
|
import { EXIT_CODE } from "./constants.js";
|
|
5
5
|
const RELATIVE_DEADLINE = /^([+-]?)(\d+)([hdwm])$/i;
|
|
@@ -89,6 +89,55 @@ function parseTimestampWithFallbacks(input) {
|
|
|
89
89
|
function daysInUtcMonth(year, monthIndex) {
|
|
90
90
|
return new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();
|
|
91
91
|
}
|
|
92
|
+
const MONTH_NAMES = [
|
|
93
|
+
"January",
|
|
94
|
+
"February",
|
|
95
|
+
"March",
|
|
96
|
+
"April",
|
|
97
|
+
"May",
|
|
98
|
+
"June",
|
|
99
|
+
"July",
|
|
100
|
+
"August",
|
|
101
|
+
"September",
|
|
102
|
+
"October",
|
|
103
|
+
"November",
|
|
104
|
+
"December",
|
|
105
|
+
];
|
|
106
|
+
// Leading literal calendar date in either hyphenated (`2026-02-30`) or compact
|
|
107
|
+
// (`20260230`) form, optionally followed by any time/zone component. We validate
|
|
108
|
+
// the digits the caller actually typed — not the parsed instant — so timezone
|
|
109
|
+
// offsets never produce a false "impossible date" rejection. The hyphenated form
|
|
110
|
+
// is unambiguous, so anything may follow (`T`/space time, `Z`, `+/-` offset). The
|
|
111
|
+
// compact form must be followed by end-of-string or a time digit (with an optional
|
|
112
|
+
// `T`/space separator) so a no-separator compact datetime like `20260230135900Z`
|
|
113
|
+
// is still guarded and a 7-digit non-date is not misread as a date.
|
|
114
|
+
const LEADING_HYPHEN_DATE = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
115
|
+
const LEADING_COMPACT_DATE = /^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/;
|
|
116
|
+
/**
|
|
117
|
+
* Reject literal calendar dates whose day cannot exist (e.g. `2026-02-30`, which JS
|
|
118
|
+
* `Date` silently rolls forward to March 2). Without this, agents that pass an
|
|
119
|
+
* impossible deadline get a silently-wrong stored date instead of an actionable
|
|
120
|
+
* error. Only triggers on a leading literal date; relative tokens, "now", and pure
|
|
121
|
+
* times are untouched. Month 00 / >12 is also rejected with a clear message rather
|
|
122
|
+
* than falling through to the generic "invalid value" path.
|
|
123
|
+
*/
|
|
124
|
+
function assertRealCalendarDate(originalInput, trimmed, fieldLabel) {
|
|
125
|
+
const match = LEADING_HYPHEN_DATE.exec(trimmed) ?? LEADING_COMPACT_DATE.exec(trimmed);
|
|
126
|
+
if (!match) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const year = Number.parseInt(match[1], 10);
|
|
130
|
+
const month = Number.parseInt(match[2], 10);
|
|
131
|
+
const day = Number.parseInt(match[3], 10);
|
|
132
|
+
const label = fieldLabel?.trim() || "deadline";
|
|
133
|
+
if (month < 1 || month > 12) {
|
|
134
|
+
throw new PmCliError(`Invalid ${label} value "${originalInput}". Month "${match[2]}" is out of range — use a month between 01 and 12.`, EXIT_CODE.USAGE);
|
|
135
|
+
}
|
|
136
|
+
const maxDay = daysInUtcMonth(year, month - 1);
|
|
137
|
+
if (day < 1 || day > maxDay) {
|
|
138
|
+
throw new PmCliError(`Invalid ${label} value "${originalInput}". ${MONTH_NAMES[month - 1]} ${year} has ${maxDay} days, so day "${match[3]}" does not exist. Use a real YYYY-MM-DD calendar date.`, EXIT_CODE.USAGE);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
92
141
|
function addUtcMonths(now, amount) {
|
|
93
142
|
const result = new Date(now.getTime());
|
|
94
143
|
const startDay = result.getUTCDate();
|
|
@@ -115,6 +164,7 @@ export function resolveIsoOrRelative(input, now = new Date(), fieldLabel = "dead
|
|
|
115
164
|
const msPerUnit = unit === "h" ? 60 * 60 * 1000 : unit === "d" ? 24 * 60 * 60 * 1000 : 7 * 24 * 60 * 60 * 1000;
|
|
116
165
|
return new Date(now.getTime() + amount * msPerUnit).toISOString();
|
|
117
166
|
}
|
|
167
|
+
assertRealCalendarDate(input, trimmed, fieldLabel);
|
|
118
168
|
const timestamp = parseTimestampWithFallbacks(trimmed);
|
|
119
169
|
if (!Number.isFinite(timestamp)) {
|
|
120
170
|
const normalizedLabel = fieldLabel.trim().length > 0 ? fieldLabel.trim() : "deadline";
|
|
@@ -126,4 +176,4 @@ export function resolveIsoOrRelative(input, now = new Date(), fieldLabel = "dead
|
|
|
126
176
|
return new Date(timestamp).toISOString();
|
|
127
177
|
}
|
|
128
178
|
//# sourceMappingURL=time.js.map
|
|
129
|
-
//# debugId=
|
|
179
|
+
//# debugId=b41467c9-6c80-5391-b9eb-3d13f170a105
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sources":["core/shared/time.ts"],"sourceRoot":"/","sourcesContent":["import { PmCliError } from \"./errors.js\";\nimport { EXIT_CODE } from \"./constants.js\";\n\nconst RELATIVE_DEADLINE = /^([+-]?)(\\d+)([hdwm])$/i;\nconst COMPOUND_RELATIVE_DEADLINE = /^[+-]?\\d+[hdwm](?:[+-]\\d+[hdwm])+$/i;\nconst COMPACT_DATE = /^(\\d{4})(\\d{2})(\\d{2})$/;\nconst COMPACT_DATETIME = /^(\\d{4})(\\d{2})(\\d{2})(?:[T\\s]?)(\\d{2})(\\d{2})(\\d{2})?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\nconst HYPHEN_TIME = /^(\\d{4}-\\d{2}-\\d{2})[T\\s](\\d{2})-(\\d{2})(?:-(\\d{2}))?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\nconst COMPACT_TIME = /^(\\d{4}-\\d{2}-\\d{2})[T\\s](\\d{2})(\\d{2})(\\d{2})?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\nexport function isTimestampLiteral(input: string): boolean {\n return Number.isFinite(Date.parse(input));\n}\n\nexport function compareTimestampStrings(left: string, right: string): number {\n const leftMs = Date.parse(left);\n const rightMs = Date.parse(right);\n if (Number.isFinite(leftMs) && Number.isFinite(rightMs) && leftMs !== rightMs) {\n return leftMs - rightMs;\n }\n return left.localeCompare(right);\n}\n\nfunction normalizeFraction(raw: string | undefined): string {\n if (!raw) return \"\";\n const digits = raw.slice(1);\n return `.${digits.padEnd(3, \"0\").slice(0, 3)}`;\n}\n\nfunction normalizeOffset(raw: string | undefined): string {\n if (!raw) return \"\";\n if (raw.toUpperCase() === \"Z\") return \"Z\";\n const compact = /^([+-]\\d{2})(\\d{2})$/.exec(raw);\n if (compact) return `${compact[1]}:${compact[2]}`;\n return raw;\n}\n\nfunction normalizeTimestampCandidates(input: string): string[] {\n const candidates: string[] = [];\n const push = (value: string | undefined): void => {\n if (!value || value === input || candidates.includes(value)) return;\n candidates.push(value);\n };\n\n const compactDate = COMPACT_DATE.exec(input);\n if (compactDate) {\n const [, year, month, day] = compactDate;\n push(`${year}-${month}-${day}`);\n }\n\n const compactDateTime = COMPACT_DATETIME.exec(input);\n if (compactDateTime) {\n const [, year, month, day, hour, minute, secondRaw, fractionRaw, offsetRaw] = compactDateTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(\n `${year}-${month}-${day}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`,\n );\n }\n\n const hyphenTime = HYPHEN_TIME.exec(input);\n if (hyphenTime) {\n const [, datePart, hour, minute, secondRaw, fractionRaw, offsetRaw] = hyphenTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(`${datePart}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`);\n }\n\n const compactTime = COMPACT_TIME.exec(input);\n if (compactTime) {\n const [, datePart, hour, minute, secondRaw, fractionRaw, offsetRaw] = compactTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(`${datePart}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`);\n }\n\n const spaceDateTime = /^(\\d{4}-\\d{2}-\\d{2})\\s+(.+)$/.exec(input);\n if (spaceDateTime) {\n const [, datePart, timePart] = spaceDateTime;\n push(`${datePart}T${timePart}`);\n }\n\n return candidates;\n}\n\nfunction parseTimestampWithFallbacks(input: string): number {\n const direct = Date.parse(input);\n if (Number.isFinite(direct)) return direct;\n for (const candidate of normalizeTimestampCandidates(input)) {\n const parsed = Date.parse(candidate);\n if (Number.isFinite(parsed)) return parsed;\n }\n return Number.NaN;\n}\n\nfunction daysInUtcMonth(year: number, monthIndex: number): number {\n return new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();\n}\n\nfunction addUtcMonths(now: Date, amount: number): Date {\n const result = new Date(now.getTime());\n const startDay = result.getUTCDate();\n const targetMonthIndex = result.getUTCMonth() + amount;\n const targetYear = result.getUTCFullYear() + Math.floor(targetMonthIndex / 12);\n const targetMonth = ((targetMonthIndex % 12) + 12) % 12;\n const day = Math.min(startDay, daysInUtcMonth(targetYear, targetMonth));\n result.setUTCFullYear(targetYear, targetMonth, day);\n return result;\n}\n\nexport function resolveIsoOrRelative(\n input: string,\n now: Date = new Date(),\n fieldLabel = \"deadline\",\n): string {\n const trimmed = input.trim();\n if (trimmed.toLowerCase() === \"now\") {\n return now.toISOString();\n }\n const relative = RELATIVE_DEADLINE.exec(trimmed);\n if (relative) {\n const sign = relative[1] === \"-\" ? -1 : 1;\n const amount = Number.parseInt(relative[2], 10) * sign;\n const unit = relative[3].toLowerCase();\n if (unit === \"m\") {\n return addUtcMonths(now, amount).toISOString();\n }\n const msPerUnit = unit === \"h\" ? 60 * 60 * 1000 : unit === \"d\" ? 24 * 60 * 60 * 1000 : 7 * 24 * 60 * 60 * 1000;\n return new Date(now.getTime() + amount * msPerUnit).toISOString();\n }\n\n const timestamp = parseTimestampWithFallbacks(trimmed);\n if (!Number.isFinite(timestamp)) {\n const normalizedLabel = fieldLabel.trim().length > 0 ? fieldLabel.trim() : \"deadline\";\n const guidance = COMPOUND_RELATIVE_DEADLINE.test(trimmed)\n ? \"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.\"\n : 'Use ISO/date string input, \"now\", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';\n throw new PmCliError(\n `Invalid ${normalizedLabel} value \"${input}\". ${guidance}`,\n EXIT_CODE.USAGE,\n );\n }\n return new Date(timestamp).toISOString();\n}\n"],"names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EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC/G,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,CAAC;IAED,MAAM,SAAS,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QACtF,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;YACvD,CAAC,CAAC,mIAAmI;YACrI,CAAC,CAAC,gFAAgF,CAAC;QACrF,MAAM,IAAI,UAAU,CAClB,WAAW,eAAe,WAAW,KAAK,MAAM,QAAQ,EAAE,EAC1D,SAAS,CAAC,KAAK,CAChB,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC","debugId":"a29d4357-1ae1-52f9-97ee-85b5fda86e40"}
|
|
1
|
+
{"version":3,"file":"time.js","sources":["core/shared/time.ts"],"sourceRoot":"/","sourcesContent":["import { PmCliError } from \"./errors.js\";\nimport { EXIT_CODE } from \"./constants.js\";\n\nconst RELATIVE_DEADLINE = /^([+-]?)(\\d+)([hdwm])$/i;\nconst COMPOUND_RELATIVE_DEADLINE = /^[+-]?\\d+[hdwm](?:[+-]\\d+[hdwm])+$/i;\nconst COMPACT_DATE = /^(\\d{4})(\\d{2})(\\d{2})$/;\nconst COMPACT_DATETIME = /^(\\d{4})(\\d{2})(\\d{2})(?:[T\\s]?)(\\d{2})(\\d{2})(\\d{2})?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\nconst HYPHEN_TIME = /^(\\d{4}-\\d{2}-\\d{2})[T\\s](\\d{2})-(\\d{2})(?:-(\\d{2}))?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\nconst COMPACT_TIME = /^(\\d{4}-\\d{2}-\\d{2})[T\\s](\\d{2})(\\d{2})(\\d{2})?([.,]\\d{1,3})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\n\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n\nexport function isTimestampLiteral(input: string): boolean {\n return Number.isFinite(Date.parse(input));\n}\n\nexport function compareTimestampStrings(left: string, right: string): number {\n const leftMs = Date.parse(left);\n const rightMs = Date.parse(right);\n if (Number.isFinite(leftMs) && Number.isFinite(rightMs) && leftMs !== rightMs) {\n return leftMs - rightMs;\n }\n return left.localeCompare(right);\n}\n\nfunction normalizeFraction(raw: string | undefined): string {\n if (!raw) return \"\";\n const digits = raw.slice(1);\n return `.${digits.padEnd(3, \"0\").slice(0, 3)}`;\n}\n\nfunction normalizeOffset(raw: string | undefined): string {\n if (!raw) return \"\";\n if (raw.toUpperCase() === \"Z\") return \"Z\";\n const compact = /^([+-]\\d{2})(\\d{2})$/.exec(raw);\n if (compact) return `${compact[1]}:${compact[2]}`;\n return raw;\n}\n\nfunction normalizeTimestampCandidates(input: string): string[] {\n const candidates: string[] = [];\n const push = (value: string | undefined): void => {\n if (!value || value === input || candidates.includes(value)) return;\n candidates.push(value);\n };\n\n const compactDate = COMPACT_DATE.exec(input);\n if (compactDate) {\n const [, year, month, day] = compactDate;\n push(`${year}-${month}-${day}`);\n }\n\n const compactDateTime = COMPACT_DATETIME.exec(input);\n if (compactDateTime) {\n const [, year, month, day, hour, minute, secondRaw, fractionRaw, offsetRaw] = compactDateTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(\n `${year}-${month}-${day}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`,\n );\n }\n\n const hyphenTime = HYPHEN_TIME.exec(input);\n if (hyphenTime) {\n const [, datePart, hour, minute, secondRaw, fractionRaw, offsetRaw] = hyphenTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(`${datePart}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`);\n }\n\n const compactTime = COMPACT_TIME.exec(input);\n if (compactTime) {\n const [, datePart, hour, minute, secondRaw, fractionRaw, offsetRaw] = compactTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n push(`${datePart}T${hour}:${minute}${second}${normalizeFraction(fractionRaw)}${normalizeOffset(offsetRaw)}`);\n }\n\n const spaceDateTime = /^(\\d{4}-\\d{2}-\\d{2})\\s+(.+)$/.exec(input);\n if (spaceDateTime) {\n const [, datePart, timePart] = spaceDateTime;\n push(`${datePart}T${timePart}`);\n }\n\n return candidates;\n}\n\nfunction parseTimestampWithFallbacks(input: string): number {\n const direct = Date.parse(input);\n if (Number.isFinite(direct)) return direct;\n for (const candidate of normalizeTimestampCandidates(input)) {\n const parsed = Date.parse(candidate);\n if (Number.isFinite(parsed)) return parsed;\n }\n return Number.NaN;\n}\n\nfunction daysInUtcMonth(year: number, monthIndex: number): number {\n return new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();\n}\n\nconst MONTH_NAMES = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\",\n] as const;\n\n// Leading literal calendar date in either hyphenated (`2026-02-30`) or compact\n// (`20260230`) form, optionally followed by any time/zone component. We validate\n// the digits the caller actually typed — not the parsed instant — so timezone\n// offsets never produce a false \"impossible date\" rejection. The hyphenated form\n// is unambiguous, so anything may follow (`T`/space time, `Z`, `+/-` offset). The\n// compact form must be followed by end-of-string or a time digit (with an optional\n// `T`/space separator) so a no-separator compact datetime like `20260230135900Z`\n// is still guarded and a 7-digit non-date is not misread as a date.\nconst LEADING_HYPHEN_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})/;\nconst LEADING_COMPACT_DATE = /^(\\d{4})(\\d{2})(\\d{2})(?:[T ]?\\d{2}|$)/;\n\n/**\n * Reject literal calendar dates whose day cannot exist (e.g. `2026-02-30`, which JS\n * `Date` silently rolls forward to March 2). Without this, agents that pass an\n * impossible deadline get a silently-wrong stored date instead of an actionable\n * error. Only triggers on a leading literal date; relative tokens, \"now\", and pure\n * times are untouched. Month 00 / >12 is also rejected with a clear message rather\n * than falling through to the generic \"invalid value\" path.\n */\nfunction assertRealCalendarDate(originalInput: string, trimmed: string, fieldLabel: string): void {\n const match = LEADING_HYPHEN_DATE.exec(trimmed) ?? LEADING_COMPACT_DATE.exec(trimmed);\n if (!match) {\n return;\n }\n const year = Number.parseInt(match[1], 10);\n const month = Number.parseInt(match[2], 10);\n const day = Number.parseInt(match[3], 10);\n const label = fieldLabel?.trim() || \"deadline\";\n if (month < 1 || month > 12) {\n throw new PmCliError(\n `Invalid ${label} value \"${originalInput}\". Month \"${match[2]}\" is out of range — use a month between 01 and 12.`,\n EXIT_CODE.USAGE,\n );\n }\n const maxDay = daysInUtcMonth(year, month - 1);\n if (day < 1 || day > maxDay) {\n throw new PmCliError(\n `Invalid ${label} value \"${originalInput}\". ${MONTH_NAMES[month - 1]} ${year} has ${maxDay} days, so day \"${match[3]}\" does not exist. Use a real YYYY-MM-DD calendar date.`,\n EXIT_CODE.USAGE,\n );\n }\n}\n\nfunction addUtcMonths(now: Date, amount: number): Date {\n const result = new Date(now.getTime());\n const startDay = result.getUTCDate();\n const targetMonthIndex = result.getUTCMonth() + amount;\n const targetYear = result.getUTCFullYear() + Math.floor(targetMonthIndex / 12);\n const targetMonth = ((targetMonthIndex % 12) + 12) % 12;\n const day = Math.min(startDay, daysInUtcMonth(targetYear, targetMonth));\n result.setUTCFullYear(targetYear, targetMonth, day);\n return result;\n}\n\nexport function resolveIsoOrRelative(\n input: string,\n now: Date = new Date(),\n fieldLabel = \"deadline\",\n): string {\n const trimmed = input.trim();\n if (trimmed.toLowerCase() === \"now\") {\n return now.toISOString();\n }\n const relative = RELATIVE_DEADLINE.exec(trimmed);\n if (relative) {\n const sign = relative[1] === \"-\" ? -1 : 1;\n const amount = Number.parseInt(relative[2], 10) * sign;\n const unit = relative[3].toLowerCase();\n if (unit === \"m\") {\n return addUtcMonths(now, amount).toISOString();\n }\n const msPerUnit = unit === \"h\" ? 60 * 60 * 1000 : unit === \"d\" ? 24 * 60 * 60 * 1000 : 7 * 24 * 60 * 60 * 1000;\n return new Date(now.getTime() + amount * msPerUnit).toISOString();\n }\n\n assertRealCalendarDate(input, trimmed, fieldLabel);\n\n const timestamp = parseTimestampWithFallbacks(trimmed);\n if (!Number.isFinite(timestamp)) {\n const normalizedLabel = fieldLabel.trim().length > 0 ? fieldLabel.trim() : \"deadline\";\n const guidance = COMPOUND_RELATIVE_DEADLINE.test(trimmed)\n ? \"Compound relative expressions like +3d+1h are not supported; use a single relative token (for example +3d) or an ISO/date string.\"\n : 'Use ISO/date string input, \"now\", or relative +6h/-6h/+1d/-1d/+2w/-2w/+6m/-6m.';\n throw new PmCliError(\n `Invalid ${normalizedLabel} value \"${input}\". ${guidance}`,\n EXIT_CODE.USAGE,\n );\n }\n return new Date(timestamp).toISOString();\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AACzE,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAC/C,MAAM,gBAAgB,GAAG,6FAA6F,CAAC;AACvH,MAAM,WAAW,GAAG,4FAA4F,CAAC;AACjH,MAAM,YAAY,GAAG,sFAAsF,CAAC;AAE5G,MAAM,UAAU,MAA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,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC/G,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,CAAC;IAED,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAEnD,MAAM,SAAS,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QACtF,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;YACvD,CAAC,CAAC,mIAAmI;YACrI,CAAC,CAAC,gFAAgF,CAAC;QACrF,MAAM,IAAI,UAAU,CAClB,WAAW,eAAe,WAAW,KAAK,MAAM,QAAQ,EAAE,EAC1D,SAAS,CAAC,KAAK,CAChB,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC","debugId":"b41467c9-6c80-5391-b9eb-3d13f170a105"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ItemDocument, ItemFormat, ItemMetadata, RuntimeSchemaSettings } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Heavy "collection" front-matter fields. These arrays dominate the on-disk cache
|
|
4
|
+
* (e.g. a single item's comment thread can be hundreds of KB) yet the hot list path
|
|
5
|
+
* (`pm list`, stats, deps, activity, calendar, close) never reads them. They are
|
|
6
|
+
* stored in a separate collections cache that is parsed only when a caller opts in
|
|
7
|
+
* (`includeCollections`), keeping the always-loaded light cache an order of magnitude
|
|
8
|
+
* smaller and its JSON.parse correspondingly cheaper.
|
|
9
|
+
*/
|
|
10
|
+
export declare const HEAVY_METADATA_KEYS: readonly ["comments", "notes", "learnings", "files", "tests", "test_runs", "docs"];
|
|
2
11
|
export interface CachedDocumentCandidate {
|
|
3
12
|
metadata: ItemMetadata;
|
|
4
13
|
body?: string;
|
|
@@ -12,6 +21,14 @@ export interface ListCacheOptions {
|
|
|
12
21
|
* the large body cache entirely; only body consumers (search/reindex) pay for it.
|
|
13
22
|
*/
|
|
14
23
|
includeBody?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* When false, heavy collection fields (comments/notes/learnings/files/tests/
|
|
26
|
+
* test_runs/docs) are neither loaded from nor written to the separate collections
|
|
27
|
+
* cache, and are absent from the returned metadata. Light-only callers (`pm list`
|
|
28
|
+
* compact, stats, deps, activity, calendar, close) skip the large collections cache
|
|
29
|
+
* entirely. Defaults to true so any caller that does read those fields stays correct.
|
|
30
|
+
*/
|
|
31
|
+
includeCollections?: boolean;
|
|
15
32
|
}
|
|
16
33
|
/**
|
|
17
34
|
* List all item documents using a persistent on-disk metadata cache.
|
|
@@ -25,3 +42,10 @@ export interface ListCacheOptions {
|
|
|
25
42
|
*/
|
|
26
43
|
export declare function listAllDocumentCandidatesCached(pmRoot: string, preferredFormat: ItemFormat | undefined, typeToFolder: Record<string, string>, warnings: string[] | undefined, schema: RuntimeSchemaSettings | undefined, options?: ListCacheOptions): Promise<CachedDocumentCandidate[]>;
|
|
27
44
|
export declare function listAllDocumentsCached(pmRoot: string, preferredFormat: ItemFormat | undefined, typeToFolder: Record<string, string>, warnings: string[] | undefined, schema: RuntimeSchemaSettings | undefined): Promise<ItemDocument[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Light variant of {@link listAllDocumentsCached}: returns metadata WITHOUT the heavy
|
|
47
|
+
* collection fields (comments/notes/learnings/files/tests/test_runs/docs), skipping the
|
|
48
|
+
* large collections cache entirely. Only safe for callers that read just the light
|
|
49
|
+
* scalar/small fields (id/title/status/type/priority/parent/tags/dates/dependencies/…).
|
|
50
|
+
*/
|
|
51
|
+
export declare function listAllDocumentsCachedLight(pmRoot: string, preferredFormat: ItemFormat | undefined, typeToFolder: Record<string, string>, warnings: string[] | undefined, schema: RuntimeSchemaSettings | undefined): Promise<ItemDocument[]>;
|