@unbrained/pm-cli 2026.5.28 → 2026.5.29

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +100 -83
  2. package/dist/cli/commander-usage.js +8 -8
  3. package/dist/cli/commander-usage.js.map +1 -1
  4. package/dist/cli/commands/aggregate.js +4 -3
  5. package/dist/cli/commands/aggregate.js.map +1 -1
  6. package/dist/cli/commands/calendar.d.ts +8 -0
  7. package/dist/cli/commands/calendar.js +13 -2
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/completion.js +34 -2
  10. package/dist/cli/commands/completion.js.map +1 -1
  11. package/dist/cli/commands/config.d.ts +11 -1
  12. package/dist/cli/commands/config.js +68 -6
  13. package/dist/cli/commands/config.js.map +1 -1
  14. package/dist/cli/commands/create.d.ts +1 -0
  15. package/dist/cli/commands/create.js +40 -4
  16. package/dist/cli/commands/create.js.map +1 -1
  17. package/dist/cli/commands/extension/bundled-catalog.js +4 -3
  18. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  19. package/dist/cli/commands/health.js +3 -11
  20. package/dist/cli/commands/health.js.map +1 -1
  21. package/dist/cli/commands/linked-test-parsers.js +5 -4
  22. package/dist/cli/commands/linked-test-parsers.js.map +1 -1
  23. package/dist/cli/commands/plan.js +5 -4
  24. package/dist/cli/commands/plan.js.map +1 -1
  25. package/dist/cli/commands/search.js +45 -2
  26. package/dist/cli/commands/search.js.map +1 -1
  27. package/dist/cli/commands/update-many.js +35 -6
  28. package/dist/cli/commands/update-many.js.map +1 -1
  29. package/dist/cli/commands/update.d.ts +2 -0
  30. package/dist/cli/commands/update.js +38 -6
  31. package/dist/cli/commands/update.js.map +1 -1
  32. package/dist/cli/help-json-payload.d.ts +1 -11
  33. package/dist/cli/help-json-payload.js +12 -12
  34. package/dist/cli/help-json-payload.js.map +1 -1
  35. package/dist/cli/register-mutation.js +20 -8
  36. package/dist/cli/register-mutation.js.map +1 -1
  37. package/dist/cli/register-setup.js +4 -2
  38. package/dist/cli/register-setup.js.map +1 -1
  39. package/dist/cli/registration-helpers.d.ts +2 -6
  40. package/dist/cli/registration-helpers.js +9 -6
  41. package/dist/cli/registration-helpers.js.map +1 -1
  42. package/dist/core/config/nested-settings.d.ts +86 -0
  43. package/dist/core/config/nested-settings.js +258 -0
  44. package/dist/core/config/nested-settings.js.map +1 -0
  45. package/dist/core/item/parse.d.ts +19 -0
  46. package/dist/core/item/parse.js +76 -2
  47. package/dist/core/item/parse.js.map +1 -1
  48. package/dist/core/item/priority.d.ts +2 -1
  49. package/dist/core/item/priority.js +12 -2
  50. package/dist/core/item/priority.js.map +1 -1
  51. package/dist/core/search/providers.js +25 -5
  52. package/dist/core/search/providers.js.map +1 -1
  53. package/dist/core/search/staleness.d.ts +23 -0
  54. package/dist/core/search/staleness.js +34 -0
  55. package/dist/core/search/staleness.js.map +1 -0
  56. package/dist/core/search/vector-stores.js +12 -3
  57. package/dist/core/search/vector-stores.js.map +1 -1
  58. package/dist/core/shared/html-entity-decode.d.ts +21 -0
  59. package/dist/core/shared/html-entity-decode.js +122 -0
  60. package/dist/core/shared/html-entity-decode.js.map +1 -0
  61. package/dist/core/shared/split-comma-list.d.ts +20 -0
  62. package/dist/core/shared/split-comma-list.js +29 -0
  63. package/dist/core/shared/split-comma-list.js.map +1 -0
  64. package/dist/mcp/server.js +10 -3
  65. package/dist/mcp/server.js.map +1 -1
  66. package/dist/sdk/cli-contracts/commander-mutation-options.js +47 -11
  67. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  68. package/dist/sdk/cli-contracts/tool-option-contracts.js +5 -2
  69. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  70. package/dist/sdk/cli-contracts/tool-parameter-tables.js +12 -2
  71. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  72. package/dist/sdk/cli-contracts.js +25 -4
  73. package/dist/sdk/cli-contracts.js.map +1 -1
  74. package/dist/sdk/runtime.d.ts +1 -1
  75. package/dist/sdk/runtime.js +3 -3
  76. package/dist/sdk/runtime.js.map +1 -1
  77. package/docs/AGENT_GUIDE.md +7 -0
  78. package/docs/COMMANDS.md +17 -0
  79. package/docs/CONFIGURATION.md +55 -0
  80. package/docs/QUICKSTART.md +3 -0
  81. package/package.json +1 -1
  82. package/packages/pm-calendar/extensions/calendar/runtime.js +5 -0
  83. package/packages/pm-calendar/extensions/calendar/runtime.ts +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"vector-stores.js","sources":["core/search/vector-stores.ts"],"sourceRoot":"/","sourcesContent":["import type { PmSettings } from \"../../types/index.js\";\nimport { mkdir, readFile, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport {\n executeSearchJsonRequest,\n normalizeSearchHttpTimeoutMs,\n resolveSearchHttpFetcher,\n} from \"./http-client.js\";\nimport type { SearchHttpFetcher, SearchHttpResponse } from \"./http-client.js\";\nimport {\n isFiniteNumberArray,\n toErrorMessage,\n toNonEmptyString,\n trimTrailingSlashes,\n} from \"../shared/primitives.js\";\n\nexport type VectorStoreName = \"qdrant\" | \"lancedb\";\n\nexport interface QdrantVectorStoreConfig {\n name: \"qdrant\";\n url: string;\n api_key?: string;\n}\n\nexport interface LanceDbVectorStoreConfig {\n name: \"lancedb\";\n path: string;\n}\n\nexport type VectorStoreConfig = QdrantVectorStoreConfig | LanceDbVectorStoreConfig;\n\nexport interface VectorStoreResolution {\n active: VectorStoreConfig | null;\n available: VectorStoreConfig[];\n}\n\nexport interface VectorStoreRequestTarget {\n store: VectorStoreName;\n query_target: string;\n upsert_target: string;\n}\n\nexport interface VectorQueryPlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorRecord {\n id: string;\n vector: number[];\n payload?: Record<string, unknown>;\n}\n\nexport interface VectorUpsertPlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorDeletePlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorQueryHit {\n id: string;\n score: number;\n payload?: Record<string, unknown>;\n}\n\nexport interface VectorUpsertResult {\n status: string;\n}\n\nexport type VectorHttpResponse = SearchHttpResponse;\n\nexport type VectorRequestFetcher = SearchHttpFetcher<VectorHttpResponse>;\n\nexport interface ExecuteVectorRequestOptions {\n timeout_ms?: number;\n fetcher?: VectorRequestFetcher;\n warnings?: string[];\n}\n\ntype VectorSettingsInput = {\n vector_store?: {\n qdrant?: {\n url?: string;\n api_key?: string;\n };\n lancedb?: {\n path?: string;\n };\n };\n};\n\nconst DEFAULT_COLLECTION = \"pm_items\";\nconst LANCE_DB_LOCAL_SNAPSHOT_DIR = \".pm-cli-local-vectors\";\nconst LANCE_DB_LOCAL_SNAPSHOT_VERSION = 1;\ninterface LanceDbLocalTableCacheEntry {\n records: Map<string, VectorRecord>;\n mtimeMs: number | null;\n size: number | null;\n}\n\nconst lanceDbLocalTables = new Map<string, LanceDbLocalTableCacheEntry>();\n\nfunction normalizeVector(value: unknown): number[] {\n if (!isFiniteNumberArray(value) || value.length === 0) {\n throw new Error(\"Vector values must be a non-empty numeric array\");\n }\n return [...value];\n}\n\nfunction normalizeLimit(value: number): number {\n if (!Number.isFinite(value) || value <= 0) {\n throw new Error(\"Vector query limit must be a positive number\");\n }\n return Math.floor(value);\n}\n\nfunction normalizeQdrantQueryResponse(payload: unknown): VectorQueryHit[] {\n const result = (payload as { result?: unknown }).result;\n if (!Array.isArray(result)) {\n throw new TypeError(\"Qdrant query response must include a result array\");\n }\n const hits = result.map((entry, index) => {\n const idValue = (entry as { id?: unknown }).id;\n const idCandidate = typeof idValue === \"number\" ? String(idValue) : idValue;\n const id = toNonEmptyString(idCandidate);\n if (!id) {\n throw new Error(`Qdrant query response entry at index ${index} is missing a non-empty id`);\n }\n\n const score = (entry as { score?: unknown }).score;\n if (typeof score !== \"number\" || !Number.isFinite(score)) {\n throw new TypeError(`Qdrant query response entry at index ${index} is missing a finite numeric score`);\n }\n\n const payloadValue = (entry as { payload?: unknown }).payload;\n if (\n payloadValue !== undefined &&\n (typeof payloadValue !== \"object\" || payloadValue === null || Array.isArray(payloadValue))\n ) {\n throw new Error(`Qdrant query response entry at index ${index} must provide payload as an object when set`);\n }\n\n return {\n id,\n score,\n ...(payloadValue ? { payload: payloadValue as Record<string, unknown> } : {}),\n };\n });\n hits.sort((left, right) => {\n if (left.score !== right.score) {\n return right.score - left.score;\n }\n return left.id.localeCompare(right.id);\n });\n return hits;\n}\n\nfunction normalizeQdrantUpsertResponse(payload: unknown): VectorUpsertResult {\n const nestedStatus = toNonEmptyString((payload as { result?: { status?: unknown } }).result?.status);\n if (nestedStatus) {\n return { status: nestedStatus };\n }\n const topLevelStatus = toNonEmptyString((payload as { status?: unknown }).status);\n if (topLevelStatus) {\n return { status: topLevelStatus };\n }\n throw new Error(\"Qdrant upsert response must include status metadata\");\n}\n\nasync function executeRemoteVectorPlan(\n endpoint: string,\n plan: {\n method: \"POST\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n },\n timeoutMs: number,\n fetcher: VectorRequestFetcher,\n requestKind: \"query\" | \"upsert\" | \"delete\",\n): Promise<unknown> {\n return await executeSearchJsonRequest({\n endpoint,\n method: plan.method,\n headers: plan.headers,\n body: plan.body,\n timeoutMs,\n fetcher,\n requestLabel: `Vector ${requestKind} request`,\n responseLabel: `Vector ${requestKind} response`,\n });\n}\n\nfunction resolveQdrantStore(settings: VectorSettingsInput): QdrantVectorStoreConfig | null {\n const url = toNonEmptyString(settings.vector_store?.qdrant?.url);\n if (!url) {\n return null;\n }\n const apiKey = toNonEmptyString(settings.vector_store?.qdrant?.api_key);\n return {\n name: \"qdrant\",\n url,\n ...(apiKey ? { api_key: apiKey } : {}),\n };\n}\n\nfunction resolveLanceDbStore(settings: VectorSettingsInput): LanceDbVectorStoreConfig | null {\n const lancedbPath = toNonEmptyString(settings.vector_store?.lancedb?.path);\n if (!lancedbPath) {\n return null;\n }\n return {\n name: \"lancedb\",\n path: lancedbPath,\n };\n}\n\nfunction normalizeVectorRecords(records: VectorRecord[]): VectorRecord[] {\n if (!Array.isArray(records) || records.length === 0) {\n throw new Error(\"Vector upsert records must include at least one entry\");\n }\n return records.map((record, index) => {\n const id = toNonEmptyString(record.id);\n if (!id) {\n throw new Error(`Vector upsert record at index ${index} is missing a non-empty id`);\n }\n const vector = normalizeVector(record.vector);\n const payload = record.payload;\n if (payload !== undefined && (typeof payload !== \"object\" || payload === null || Array.isArray(payload))) {\n throw new Error(`Vector upsert record at index ${index} must provide payload as an object when set`);\n }\n return {\n id,\n vector,\n ...(payload ? { payload } : {}),\n };\n });\n}\n\nfunction normalizeVectorDeleteIds(ids: string[]): string[] {\n if (!Array.isArray(ids) || ids.length === 0) {\n throw new Error(\"Vector delete ids must include at least one entry\");\n }\n const normalizedIds = ids\n .map((id, index) => {\n const normalized = toNonEmptyString(id);\n if (!normalized) {\n throw new Error(`Vector delete id at index ${index} is missing a non-empty value`);\n }\n return normalized;\n })\n .sort((left, right) => left.localeCompare(right));\n const uniqueIds: string[] = [];\n for (const id of normalizedIds) {\n if (uniqueIds.at(-1) !== id) {\n uniqueIds.push(id);\n }\n }\n return uniqueIds;\n}\n\nfunction resolveQdrantDeleteTarget(upsertTarget: string): string {\n return upsertTarget.replace(/\\/points\\?wait=true$/, \"/points/delete?wait=true\");\n}\n\nfunction getLanceDbLocalTableKey(storePath: string, table: string): string {\n return getLanceDbSnapshotPath(storePath, table);\n}\n\nfunction getLanceDbSnapshotPath(storePath: string, table: string): string {\n return join(resolve(storePath), LANCE_DB_LOCAL_SNAPSHOT_DIR, `${table}.json`);\n}\n\nfunction isNodeErrorWithCode(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && (error as { code?: unknown }).code === code;\n}\n\nfunction normalizeSnapshotRecord(entry: unknown, index: number, snapshotPath: string): VectorRecord {\n const id = toNonEmptyString((entry as { id?: unknown }).id);\n if (!id) {\n throw new Error(`LanceDB local snapshot '${snapshotPath}' record at index ${index} is missing a non-empty id`);\n }\n const vector = normalizeVector((entry as { vector?: unknown }).vector);\n const payload = (entry as { payload?: unknown }).payload;\n if (payload !== undefined && (typeof payload !== \"object\" || payload === null || Array.isArray(payload))) {\n throw new Error(\n `LanceDB local snapshot '${snapshotPath}' record '${id}' must provide payload as an object when set`,\n );\n }\n return {\n id,\n vector,\n ...(payload ? { payload: payload as Record<string, unknown> } : {}),\n };\n}\n\nfunction parseLanceDbSnapshot(snapshotPath: string, expectedTable: string, raw: string): Map<string, VectorRecord> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch (error) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' is not valid JSON: ${toErrorMessage(error)}`);\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' must be a JSON object`);\n }\n\n const version = (parsed as { version?: unknown }).version;\n if (version !== LANCE_DB_LOCAL_SNAPSHOT_VERSION) {\n throw new Error(\n `LanceDB local snapshot at '${snapshotPath}' must include version=${LANCE_DB_LOCAL_SNAPSHOT_VERSION}`,\n );\n }\n\n const table = toNonEmptyString((parsed as { table?: unknown }).table);\n if (!table) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include a non-empty table value`);\n }\n if (table !== expectedTable) {\n throw new Error(\n `LanceDB local snapshot at '${snapshotPath}' table mismatch: expected '${expectedTable}', received '${table}'`,\n );\n }\n\n const recordsValue = (parsed as { records?: unknown }).records;\n if (!Array.isArray(recordsValue)) {\n throw new TypeError(`LanceDB local snapshot at '${snapshotPath}' must include a records array`);\n }\n\n const tableRecords = new Map<string, VectorRecord>();\n for (let index = 0; index < recordsValue.length; index += 1) {\n const record = normalizeSnapshotRecord(recordsValue[index], index, snapshotPath);\n tableRecords.set(record.id, record);\n }\n return tableRecords;\n}\n\nasync function loadLanceDbLocalTable(storePath: string, table: string): Promise<Map<string, VectorRecord>> {\n const key = getLanceDbLocalTableKey(storePath, table);\n const snapshotPath = getLanceDbSnapshotPath(storePath, table);\n let snapshotStats: { mtimeMs: number; size: number } | null = null;\n try {\n const stats = await stat(snapshotPath);\n snapshotStats = { mtimeMs: stats.mtimeMs, size: stats.size };\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw error;\n }\n }\n\n const cached = lanceDbLocalTables.get(key);\n if (cached && !snapshotStats) {\n if (cached.mtimeMs === null && cached.size === null && cached.records.size === 0) {\n return cached.records;\n }\n const loaded = new Map<string, VectorRecord>();\n lanceDbLocalTables.set(key, { records: loaded, mtimeMs: null, size: null });\n return loaded;\n }\n if (\n cached &&\n snapshotStats &&\n cached.mtimeMs === snapshotStats.mtimeMs &&\n cached.size === snapshotStats.size\n ) {\n return cached.records;\n }\n\n let loaded = new Map<string, VectorRecord>();\n try {\n const raw = await readFile(snapshotPath, \"utf8\");\n loaded = parseLanceDbSnapshot(snapshotPath, table, raw);\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw error;\n }\n }\n lanceDbLocalTables.set(key, {\n records: loaded,\n mtimeMs: snapshotStats?.mtimeMs ?? null,\n size: snapshotStats?.size ?? null,\n });\n return loaded;\n}\n\nfunction buildSnapshotRecords(table: Map<string, VectorRecord>): VectorRecord[] {\n const records = [...table.values()];\n records.sort((left, right) => left.id.localeCompare(right.id));\n return records.map((record) => ({\n id: record.id,\n vector: [...record.vector],\n ...(record.payload ? { payload: record.payload } : {}),\n }));\n}\n\nasync function removeSnapshotFile(snapshotPath: string): Promise<void> {\n try {\n await unlink(snapshotPath);\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`);\n }\n }\n}\n\nasync function persistLanceDbLocalTable(storePath: string, tableName: string, table: Map<string, VectorRecord>): Promise<void> {\n const snapshotPath = getLanceDbSnapshotPath(storePath, tableName);\n if (table.size === 0) {\n await removeSnapshotFile(snapshotPath);\n return;\n }\n\n const snapshotDir = dirname(snapshotPath);\n try {\n await mkdir(snapshotDir, { recursive: true });\n } catch (error) {\n throw new Error(\n `LanceDB local snapshot directory create failed at '${snapshotDir}': ${toErrorMessage(error)}`,\n );\n }\n\n const tempPath = join(\n snapshotDir,\n `${basename(snapshotPath)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`,\n );\n const serialized = `${JSON.stringify(\n {\n version: LANCE_DB_LOCAL_SNAPSHOT_VERSION,\n table: tableName,\n records: buildSnapshotRecords(table),\n },\n null,\n 2,\n )}\\n`;\n try {\n await writeFile(tempPath, serialized, \"utf8\");\n await rename(tempPath, snapshotPath);\n } catch (error) {\n await unlink(tempPath).catch(() => {});\n throw new Error(`LanceDB local snapshot write failed at '${snapshotPath}': ${toErrorMessage(error)}`);\n }\n}\n\nfunction l2Norm(vector: number[]): number {\n let sumSq = 0;\n for (let index = 0; index < vector.length; index += 1) {\n sumSq += vector[index] * vector[index];\n }\n return Math.sqrt(sumSq);\n}\n\nfunction cosineSimilarity(left: number[], right: number[]): number {\n let dotProd = 0;\n for (let index = 0; index < left.length; index += 1) {\n dotProd += left[index] * right[index];\n }\n const leftNorm = l2Norm(left);\n const rightNorm = l2Norm(right);\n if (leftNorm === 0 || rightNorm === 0) {\n return 0;\n }\n return dotProd / (leftNorm * rightNorm);\n}\n\nexport function resolveVectorStores(settings: PmSettings | VectorSettingsInput): VectorStoreResolution {\n const qdrant = resolveQdrantStore(settings);\n const lancedb = resolveLanceDbStore(settings);\n const available = [qdrant, lancedb].filter((entry): entry is VectorStoreConfig => entry !== null);\n return {\n active: available[0] ?? null,\n available,\n };\n}\n\nexport function resolveVectorStoreRequestTarget(store: VectorStoreConfig): VectorStoreRequestTarget {\n if (store.name === \"qdrant\") {\n const baseUrl = trimTrailingSlashes(store.url);\n return {\n store: \"qdrant\",\n query_target: `${baseUrl}/collections/${DEFAULT_COLLECTION}/points/search`,\n upsert_target: `${baseUrl}/collections/${DEFAULT_COLLECTION}/points?wait=true`,\n };\n }\n const encodedPath = encodeURIComponent(store.path);\n return {\n store: \"lancedb\",\n query_target: `lancedb://${encodedPath}#${DEFAULT_COLLECTION}`,\n upsert_target: `lancedb://${encodedPath}#${DEFAULT_COLLECTION}`,\n };\n}\n\nexport function buildVectorQueryPlan(store: VectorStoreConfig, vector: number[], limit: number): VectorQueryPlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedVector = normalizeVector(vector);\n const normalizedLimit = normalizeLimit(limit);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n vector: normalizedVector,\n limit: normalizedLimit,\n with_payload: true,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n vector: normalizedVector,\n limit: normalizedLimit,\n },\n };\n}\n\nexport function buildVectorUpsertPlan(store: VectorStoreConfig, records: VectorRecord[]): VectorUpsertPlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedRecords = normalizeVectorRecords(records);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n points: normalizedRecords,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n records: normalizedRecords,\n },\n };\n}\n\nexport function buildVectorDeletePlan(store: VectorStoreConfig, ids: string[]): VectorDeletePlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedIds = normalizeVectorDeleteIds(ids);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n points: normalizedIds,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n ids: normalizedIds,\n },\n };\n}\n\nexport async function executeVectorQuery(\n store: VectorStoreConfig,\n vector: number[],\n limit: number,\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorQueryHit[]> {\n const plan = buildVectorQueryPlan(store, vector, limit);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const queryBody = plan.body as {\n table: string;\n vector: number[];\n limit: number;\n };\n const table = await loadLanceDbLocalTable(lanceDbStore.path, queryBody.table);\n if (table.size === 0) {\n return [];\n }\n const queryVector = normalizeVector(queryBody.vector);\n const queryLimit = normalizeLimit(queryBody.limit);\n const hits: VectorQueryHit[] = [];\n let dimensionMismatchCount = 0;\n for (const record of table.values()) {\n if (record.vector.length !== queryVector.length) {\n dimensionMismatchCount++;\n continue;\n }\n hits.push({\n id: record.id,\n score: cosineSimilarity(queryVector, record.vector),\n ...(record.payload ? { payload: record.payload } : {}),\n });\n }\n if (dimensionMismatchCount > 0 && options.warnings) {\n options.warnings.push(\n `vector_dimension_mismatch:${dimensionMismatchCount} records skipped (expected ${queryVector.length} dimensions)`,\n );\n }\n hits.sort((left, right) => {\n if (left.score !== right.score) {\n return right.score - left.score;\n }\n return left.id.localeCompare(right.id);\n });\n return hits.slice(0, queryLimit);\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n plan.target.query_target,\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"query\",\n );\n return normalizeQdrantQueryResponse(payload);\n}\n\nexport async function executeVectorUpsert(\n store: VectorStoreConfig,\n records: VectorRecord[],\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorUpsertResult> {\n const plan = buildVectorUpsertPlan(store, records);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const upsertBody = plan.body as {\n table: string;\n records: VectorRecord[];\n };\n const key = getLanceDbLocalTableKey(lanceDbStore.path, upsertBody.table);\n const table = await loadLanceDbLocalTable(lanceDbStore.path, upsertBody.table);\n for (const record of upsertBody.records) {\n table.set(record.id, record);\n }\n await persistLanceDbLocalTable(lanceDbStore.path, upsertBody.table, table);\n const snapshotPath = getLanceDbSnapshotPath(lanceDbStore.path, upsertBody.table);\n const snapshotStats = await stat(snapshotPath);\n lanceDbLocalTables.set(key, {\n records: table,\n mtimeMs: snapshotStats.mtimeMs,\n size: snapshotStats.size,\n });\n return { status: \"ok\" };\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n plan.target.upsert_target,\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"upsert\",\n );\n return normalizeQdrantUpsertResponse(payload);\n}\n\nexport async function executeVectorDelete(\n store: VectorStoreConfig,\n ids: string[],\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorUpsertResult> {\n const plan = buildVectorDeletePlan(store, ids);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const deleteBody = plan.body as {\n table: string;\n ids: string[];\n };\n const key = getLanceDbLocalTableKey(lanceDbStore.path, deleteBody.table);\n const table = await loadLanceDbLocalTable(lanceDbStore.path, deleteBody.table);\n if (table.size === 0) {\n return { status: \"ok\" };\n }\n for (const id of deleteBody.ids) {\n table.delete(id);\n }\n await persistLanceDbLocalTable(lanceDbStore.path, deleteBody.table, table);\n if (table.size === 0) {\n lanceDbLocalTables.delete(key);\n } else {\n const snapshotPath = getLanceDbSnapshotPath(lanceDbStore.path, deleteBody.table);\n const snapshotStats = await stat(snapshotPath);\n lanceDbLocalTables.set(key, {\n records: table,\n mtimeMs: snapshotStats.mtimeMs,\n size: snapshotStats.size,\n });\n }\n return { status: \"ok\" };\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n resolveQdrantDeleteTarget(plan.target.upsert_target),\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"delete\",\n );\n return normalizeQdrantUpsertResponse(payload);\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAuFjC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AACtC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AAC5D,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAO1C,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuC,CAAC;AAE1E,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CA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AAC;QAC3E,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACrB,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YACjF,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;YAC/C,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC1B,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,aAAa,CAAC,OAAO;gBAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,SAAS,GAAG,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACrF,MAAM,OAAO,GAAG,wBAAwB,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAC3C,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EACpD;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,EACD,SAAS,EACT,OAAO,EACP,QAAQ,CACT,CAAC;IACF,OAAO,6BAA6B,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC","debugId":"7e81fcbb-b493-5774-862f-30107a96e0ce"}
1
+ {"version":3,"file":"vector-stores.js","sources":["core/search/vector-stores.ts"],"sourceRoot":"/","sourcesContent":["import type { PmSettings } from \"../../types/index.js\";\nimport { mkdir, readFile, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport {\n executeSearchJsonRequest,\n normalizeSearchHttpTimeoutMs,\n resolveSearchHttpFetcher,\n} from \"./http-client.js\";\nimport type { SearchHttpFetcher, SearchHttpResponse } from \"./http-client.js\";\nimport {\n isFiniteNumberArray,\n toErrorMessage,\n toNonEmptyString,\n trimTrailingSlashes,\n} from \"../shared/primitives.js\";\n\nexport type VectorStoreName = \"qdrant\" | \"lancedb\";\n\nexport interface QdrantVectorStoreConfig {\n name: \"qdrant\";\n url: string;\n api_key?: string;\n}\n\nexport interface LanceDbVectorStoreConfig {\n name: \"lancedb\";\n path: string;\n}\n\nexport type VectorStoreConfig = QdrantVectorStoreConfig | LanceDbVectorStoreConfig;\n\nexport interface VectorStoreResolution {\n active: VectorStoreConfig | null;\n available: VectorStoreConfig[];\n}\n\nexport interface VectorStoreRequestTarget {\n store: VectorStoreName;\n query_target: string;\n upsert_target: string;\n}\n\nexport interface VectorQueryPlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorRecord {\n id: string;\n vector: number[];\n payload?: Record<string, unknown>;\n}\n\nexport interface VectorUpsertPlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorDeletePlan {\n target: VectorStoreRequestTarget;\n method: \"POST\" | \"LOCAL\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n}\n\nexport interface VectorQueryHit {\n id: string;\n score: number;\n payload?: Record<string, unknown>;\n}\n\nexport interface VectorUpsertResult {\n status: string;\n}\n\nexport type VectorHttpResponse = SearchHttpResponse;\n\nexport type VectorRequestFetcher = SearchHttpFetcher<VectorHttpResponse>;\n\nexport interface ExecuteVectorRequestOptions {\n timeout_ms?: number;\n fetcher?: VectorRequestFetcher;\n warnings?: string[];\n}\n\ntype VectorSettingsInput = {\n vector_store?: {\n qdrant?: {\n url?: string;\n api_key?: string;\n };\n lancedb?: {\n path?: string;\n };\n };\n};\n\nconst DEFAULT_COLLECTION = \"pm_items\";\nconst LANCE_DB_LOCAL_SNAPSHOT_DIR = \".pm-cli-local-vectors\";\nconst LANCE_DB_LOCAL_SNAPSHOT_VERSION = 1;\ninterface LanceDbLocalTableCacheEntry {\n records: Map<string, VectorRecord>;\n mtimeMs: number | null;\n size: number | null;\n}\n\nconst lanceDbLocalTables = new Map<string, LanceDbLocalTableCacheEntry>();\n\nfunction normalizeVector(value: unknown): number[] {\n if (!isFiniteNumberArray(value) || value.length === 0) {\n throw new Error(\"Vector values must be a non-empty numeric array\");\n }\n return [...value];\n}\n\nfunction normalizeLimit(value: number): number {\n if (!Number.isFinite(value) || value <= 0) {\n throw new Error(\"Vector query limit must be a positive number\");\n }\n return Math.floor(value);\n}\n\nfunction normalizeQdrantQueryResponse(payload: unknown): VectorQueryHit[] {\n const result = (payload as { result?: unknown }).result;\n if (!Array.isArray(result)) {\n throw new TypeError(\"Qdrant query response must include a result array\");\n }\n const hits = result.map((entry, index) => {\n const idValue = (entry as { id?: unknown }).id;\n const idCandidate = typeof idValue === \"number\" ? String(idValue) : idValue;\n const id = toNonEmptyString(idCandidate);\n if (!id) {\n throw new Error(`Qdrant query response entry at index ${index} is missing a non-empty id`);\n }\n\n const score = (entry as { score?: unknown }).score;\n if (typeof score !== \"number\" || !Number.isFinite(score)) {\n throw new TypeError(`Qdrant query response entry at index ${index} is missing a finite numeric score`);\n }\n\n const payloadValue = (entry as { payload?: unknown }).payload;\n if (\n payloadValue !== undefined &&\n (typeof payloadValue !== \"object\" || payloadValue === null || Array.isArray(payloadValue))\n ) {\n throw new Error(`Qdrant query response entry at index ${index} must provide payload as an object when set`);\n }\n\n return {\n id,\n score,\n ...(payloadValue ? { payload: payloadValue as Record<string, unknown> } : {}),\n };\n });\n hits.sort((left, right) => {\n if (left.score !== right.score) {\n return right.score - left.score;\n }\n return left.id.localeCompare(right.id);\n });\n return hits;\n}\n\nfunction normalizeQdrantUpsertResponse(payload: unknown): VectorUpsertResult {\n const nestedStatus = toNonEmptyString((payload as { result?: { status?: unknown } }).result?.status);\n if (nestedStatus) {\n return { status: nestedStatus };\n }\n const topLevelStatus = toNonEmptyString((payload as { status?: unknown }).status);\n if (topLevelStatus) {\n return { status: topLevelStatus };\n }\n throw new Error(\"Qdrant upsert response must include status metadata\");\n}\n\nasync function executeRemoteVectorPlan(\n endpoint: string,\n plan: {\n method: \"POST\";\n headers: Record<string, string>;\n body: Record<string, unknown>;\n },\n timeoutMs: number,\n fetcher: VectorRequestFetcher,\n requestKind: \"query\" | \"upsert\" | \"delete\",\n): Promise<unknown> {\n return await executeSearchJsonRequest({\n endpoint,\n method: plan.method,\n headers: plan.headers,\n body: plan.body,\n timeoutMs,\n fetcher,\n requestLabel: `Vector ${requestKind} request`,\n responseLabel: `Vector ${requestKind} response`,\n });\n}\n\nfunction resolveQdrantStore(settings: VectorSettingsInput): QdrantVectorStoreConfig | null {\n const url = toNonEmptyString(settings.vector_store?.qdrant?.url);\n if (!url) {\n return null;\n }\n const apiKey = toNonEmptyString(settings.vector_store?.qdrant?.api_key);\n return {\n name: \"qdrant\",\n url,\n ...(apiKey ? { api_key: apiKey } : {}),\n };\n}\n\nfunction resolveLanceDbStore(settings: VectorSettingsInput): LanceDbVectorStoreConfig | null {\n const lancedbPath = toNonEmptyString(settings.vector_store?.lancedb?.path);\n if (!lancedbPath) {\n return null;\n }\n return {\n name: \"lancedb\",\n path: lancedbPath,\n };\n}\n\nfunction normalizeVectorRecords(records: VectorRecord[]): VectorRecord[] {\n if (!Array.isArray(records) || records.length === 0) {\n throw new Error(\"Vector upsert records must include at least one entry\");\n }\n return records.map((record, index) => {\n const id = toNonEmptyString(record.id);\n if (!id) {\n throw new Error(`Vector upsert record at index ${index} is missing a non-empty id`);\n }\n const vector = normalizeVector(record.vector);\n const payload = record.payload;\n if (payload !== undefined && (typeof payload !== \"object\" || payload === null || Array.isArray(payload))) {\n throw new Error(`Vector upsert record at index ${index} must provide payload as an object when set`);\n }\n return {\n id,\n vector,\n ...(payload ? { payload } : {}),\n };\n });\n}\n\nfunction normalizeVectorDeleteIds(ids: string[]): string[] {\n if (!Array.isArray(ids) || ids.length === 0) {\n throw new Error(\"Vector delete ids must include at least one entry\");\n }\n const normalizedIds = ids\n .map((id, index) => {\n const normalized = toNonEmptyString(id);\n if (!normalized) {\n throw new Error(`Vector delete id at index ${index} is missing a non-empty value`);\n }\n return normalized;\n })\n .sort((left, right) => left.localeCompare(right));\n const uniqueIds: string[] = [];\n for (const id of normalizedIds) {\n if (uniqueIds.at(-1) !== id) {\n uniqueIds.push(id);\n }\n }\n return uniqueIds;\n}\n\nfunction resolveQdrantDeleteTarget(upsertTarget: string): string {\n return upsertTarget.replace(/\\/points\\?wait=true$/, \"/points/delete?wait=true\");\n}\n\nfunction getLanceDbLocalTableKey(storePath: string, table: string): string {\n return getLanceDbSnapshotPath(storePath, table);\n}\n\nfunction getLanceDbSnapshotPath(storePath: string, table: string): string {\n return join(resolve(storePath), LANCE_DB_LOCAL_SNAPSHOT_DIR, `${table}.json`);\n}\n\nfunction isNodeErrorWithCode(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && (error as { code?: unknown }).code === code;\n}\n\nfunction normalizeSnapshotRecord(entry: unknown, index: number, snapshotPath: string): VectorRecord {\n const id = toNonEmptyString((entry as { id?: unknown }).id);\n if (!id) {\n throw new Error(`LanceDB local snapshot '${snapshotPath}' record at index ${index} is missing a non-empty id`);\n }\n const vector = normalizeVector((entry as { vector?: unknown }).vector);\n const payload = (entry as { payload?: unknown }).payload;\n if (payload !== undefined && (typeof payload !== \"object\" || payload === null || Array.isArray(payload))) {\n throw new Error(\n `LanceDB local snapshot '${snapshotPath}' record '${id}' must provide payload as an object when set`,\n );\n }\n return {\n id,\n vector,\n ...(payload ? { payload: payload as Record<string, unknown> } : {}),\n };\n}\n\nfunction parseLanceDbSnapshot(snapshotPath: string, expectedTable: string, raw: string): Map<string, VectorRecord> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch (error) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' is not valid JSON: ${toErrorMessage(error)}`);\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' must be a JSON object`);\n }\n\n const version = (parsed as { version?: unknown }).version;\n if (version !== LANCE_DB_LOCAL_SNAPSHOT_VERSION) {\n throw new Error(\n `LanceDB local snapshot at '${snapshotPath}' must include version=${LANCE_DB_LOCAL_SNAPSHOT_VERSION}`,\n );\n }\n\n const table = toNonEmptyString((parsed as { table?: unknown }).table);\n if (!table) {\n throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include a non-empty table value`);\n }\n if (table !== expectedTable) {\n throw new Error(\n `LanceDB local snapshot at '${snapshotPath}' table mismatch: expected '${expectedTable}', received '${table}'`,\n );\n }\n\n const recordsValue = (parsed as { records?: unknown }).records;\n if (!Array.isArray(recordsValue)) {\n throw new TypeError(`LanceDB local snapshot at '${snapshotPath}' must include a records array`);\n }\n\n const tableRecords = new Map<string, VectorRecord>();\n for (let index = 0; index < recordsValue.length; index += 1) {\n const record = normalizeSnapshotRecord(recordsValue[index], index, snapshotPath);\n tableRecords.set(record.id, record);\n }\n return tableRecords;\n}\n\nasync function loadLanceDbLocalTable(storePath: string, table: string): Promise<Map<string, VectorRecord>> {\n const key = getLanceDbLocalTableKey(storePath, table);\n const snapshotPath = getLanceDbSnapshotPath(storePath, table);\n let snapshotStats: { mtimeMs: number; size: number } | null = null;\n try {\n const stats = await stat(snapshotPath);\n snapshotStats = { mtimeMs: stats.mtimeMs, size: stats.size };\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw error;\n }\n }\n\n const cached = lanceDbLocalTables.get(key);\n if (cached && !snapshotStats) {\n if (cached.mtimeMs === null && cached.size === null && cached.records.size === 0) {\n return cached.records;\n }\n const loaded = new Map<string, VectorRecord>();\n lanceDbLocalTables.set(key, { records: loaded, mtimeMs: null, size: null });\n return loaded;\n }\n if (\n cached &&\n snapshotStats &&\n cached.mtimeMs === snapshotStats.mtimeMs &&\n cached.size === snapshotStats.size\n ) {\n return cached.records;\n }\n\n let loaded = new Map<string, VectorRecord>();\n try {\n const raw = await readFile(snapshotPath, \"utf8\");\n loaded = parseLanceDbSnapshot(snapshotPath, table, raw);\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw error;\n }\n }\n lanceDbLocalTables.set(key, {\n records: loaded,\n mtimeMs: snapshotStats?.mtimeMs ?? null,\n size: snapshotStats?.size ?? null,\n });\n return loaded;\n}\n\nfunction buildSnapshotRecords(table: Map<string, VectorRecord>): VectorRecord[] {\n const records = [...table.values()];\n records.sort((left, right) => left.id.localeCompare(right.id));\n return records.map((record) => ({\n id: record.id,\n vector: [...record.vector],\n ...(record.payload ? { payload: record.payload } : {}),\n }));\n}\n\nasync function removeSnapshotFile(snapshotPath: string): Promise<void> {\n try {\n await unlink(snapshotPath);\n } catch (error) {\n if (!isNodeErrorWithCode(error, \"ENOENT\")) {\n throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`);\n }\n }\n}\n\nasync function persistLanceDbLocalTable(storePath: string, tableName: string, table: Map<string, VectorRecord>): Promise<void> {\n const snapshotPath = getLanceDbSnapshotPath(storePath, tableName);\n if (table.size === 0) {\n await removeSnapshotFile(snapshotPath);\n return;\n }\n\n const snapshotDir = dirname(snapshotPath);\n try {\n await mkdir(snapshotDir, { recursive: true });\n } catch (error) {\n throw new Error(\n `LanceDB local snapshot directory create failed at '${snapshotDir}': ${toErrorMessage(error)}`,\n );\n }\n\n const tempPath = join(\n snapshotDir,\n `${basename(snapshotPath)}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`,\n );\n const serialized = `${JSON.stringify(\n {\n version: LANCE_DB_LOCAL_SNAPSHOT_VERSION,\n table: tableName,\n records: buildSnapshotRecords(table),\n },\n null,\n 2,\n )}\\n`;\n try {\n await writeFile(tempPath, serialized, \"utf8\");\n await rename(tempPath, snapshotPath);\n } catch (error) {\n await unlink(tempPath).catch(() => {});\n throw new Error(`LanceDB local snapshot write failed at '${snapshotPath}': ${toErrorMessage(error)}`);\n }\n}\n\nfunction l2Norm(vector: number[]): number {\n let sumSq = 0;\n for (let index = 0; index < vector.length; index += 1) {\n sumSq += vector[index] * vector[index];\n }\n return Math.sqrt(sumSq);\n}\n\nfunction cosineSimilarity(left: number[], right: number[]): number {\n let dotProd = 0;\n for (let index = 0; index < left.length; index += 1) {\n dotProd += left[index] * right[index];\n }\n const leftNorm = l2Norm(left);\n const rightNorm = l2Norm(right);\n if (leftNorm === 0 || rightNorm === 0) {\n return 0;\n }\n return dotProd / (leftNorm * rightNorm);\n}\n\nexport function resolveVectorStores(settings: PmSettings | VectorSettingsInput): VectorStoreResolution {\n const qdrant = resolveQdrantStore(settings);\n const lancedb = resolveLanceDbStore(settings);\n const available = [qdrant, lancedb].filter((entry): entry is VectorStoreConfig => entry !== null);\n // Honor `settings.vector_store.adapter` when set: if both built-in stores\n // are configured, the preferred adapter wins; otherwise fall back to the\n // first available entry (preserves the previous tie-break: qdrant > lancedb).\n // Match case-insensitively so \"Qdrant\" / \"LanceDB\" / \"lancedb\" all work.\n const preferredName = toNonEmptyString(\n (settings as { vector_store?: { adapter?: unknown } }).vector_store?.adapter,\n );\n const preferredKey = preferredName ? preferredName.toLowerCase() : null;\n const preferred = preferredKey\n ? available.find((entry) => entry.name === preferredKey)\n : undefined;\n return {\n active: preferred ?? available[0] ?? null,\n available,\n };\n}\n\nexport function resolveVectorStoreRequestTarget(store: VectorStoreConfig): VectorStoreRequestTarget {\n if (store.name === \"qdrant\") {\n const baseUrl = trimTrailingSlashes(store.url);\n return {\n store: \"qdrant\",\n query_target: `${baseUrl}/collections/${DEFAULT_COLLECTION}/points/search`,\n upsert_target: `${baseUrl}/collections/${DEFAULT_COLLECTION}/points?wait=true`,\n };\n }\n const encodedPath = encodeURIComponent(store.path);\n return {\n store: \"lancedb\",\n query_target: `lancedb://${encodedPath}#${DEFAULT_COLLECTION}`,\n upsert_target: `lancedb://${encodedPath}#${DEFAULT_COLLECTION}`,\n };\n}\n\nexport function buildVectorQueryPlan(store: VectorStoreConfig, vector: number[], limit: number): VectorQueryPlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedVector = normalizeVector(vector);\n const normalizedLimit = normalizeLimit(limit);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n vector: normalizedVector,\n limit: normalizedLimit,\n with_payload: true,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n vector: normalizedVector,\n limit: normalizedLimit,\n },\n };\n}\n\nexport function buildVectorUpsertPlan(store: VectorStoreConfig, records: VectorRecord[]): VectorUpsertPlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedRecords = normalizeVectorRecords(records);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n points: normalizedRecords,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n records: normalizedRecords,\n },\n };\n}\n\nexport function buildVectorDeletePlan(store: VectorStoreConfig, ids: string[]): VectorDeletePlan {\n const target = resolveVectorStoreRequestTarget(store);\n const normalizedIds = normalizeVectorDeleteIds(ids);\n if (store.name === \"qdrant\") {\n return {\n target,\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(store.api_key ? { \"api-key\": store.api_key } : {}),\n },\n body: {\n points: normalizedIds,\n },\n };\n }\n return {\n target,\n method: \"LOCAL\",\n headers: {},\n body: {\n table: DEFAULT_COLLECTION,\n ids: normalizedIds,\n },\n };\n}\n\nexport async function executeVectorQuery(\n store: VectorStoreConfig,\n vector: number[],\n limit: number,\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorQueryHit[]> {\n const plan = buildVectorQueryPlan(store, vector, limit);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const queryBody = plan.body as {\n table: string;\n vector: number[];\n limit: number;\n };\n const table = await loadLanceDbLocalTable(lanceDbStore.path, queryBody.table);\n if (table.size === 0) {\n return [];\n }\n const queryVector = normalizeVector(queryBody.vector);\n const queryLimit = normalizeLimit(queryBody.limit);\n const hits: VectorQueryHit[] = [];\n let dimensionMismatchCount = 0;\n for (const record of table.values()) {\n if (record.vector.length !== queryVector.length) {\n dimensionMismatchCount++;\n continue;\n }\n hits.push({\n id: record.id,\n score: cosineSimilarity(queryVector, record.vector),\n ...(record.payload ? { payload: record.payload } : {}),\n });\n }\n if (dimensionMismatchCount > 0 && options.warnings) {\n options.warnings.push(\n `vector_dimension_mismatch:${dimensionMismatchCount} records skipped (expected ${queryVector.length} dimensions)`,\n );\n }\n hits.sort((left, right) => {\n if (left.score !== right.score) {\n return right.score - left.score;\n }\n return left.id.localeCompare(right.id);\n });\n return hits.slice(0, queryLimit);\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n plan.target.query_target,\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"query\",\n );\n return normalizeQdrantQueryResponse(payload);\n}\n\nexport async function executeVectorUpsert(\n store: VectorStoreConfig,\n records: VectorRecord[],\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorUpsertResult> {\n const plan = buildVectorUpsertPlan(store, records);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const upsertBody = plan.body as {\n table: string;\n records: VectorRecord[];\n };\n const key = getLanceDbLocalTableKey(lanceDbStore.path, upsertBody.table);\n const table = await loadLanceDbLocalTable(lanceDbStore.path, upsertBody.table);\n for (const record of upsertBody.records) {\n table.set(record.id, record);\n }\n await persistLanceDbLocalTable(lanceDbStore.path, upsertBody.table, table);\n const snapshotPath = getLanceDbSnapshotPath(lanceDbStore.path, upsertBody.table);\n const snapshotStats = await stat(snapshotPath);\n lanceDbLocalTables.set(key, {\n records: table,\n mtimeMs: snapshotStats.mtimeMs,\n size: snapshotStats.size,\n });\n return { status: \"ok\" };\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n plan.target.upsert_target,\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"upsert\",\n );\n return normalizeQdrantUpsertResponse(payload);\n}\n\nexport async function executeVectorDelete(\n store: VectorStoreConfig,\n ids: string[],\n options: ExecuteVectorRequestOptions = {},\n): Promise<VectorUpsertResult> {\n const plan = buildVectorDeletePlan(store, ids);\n if (plan.method === \"LOCAL\") {\n const lanceDbStore = store as LanceDbVectorStoreConfig;\n const deleteBody = plan.body as {\n table: string;\n ids: string[];\n };\n const key = getLanceDbLocalTableKey(lanceDbStore.path, deleteBody.table);\n const table = await loadLanceDbLocalTable(lanceDbStore.path, deleteBody.table);\n if (table.size === 0) {\n return { status: \"ok\" };\n }\n for (const id of deleteBody.ids) {\n table.delete(id);\n }\n await persistLanceDbLocalTable(lanceDbStore.path, deleteBody.table, table);\n if (table.size === 0) {\n lanceDbLocalTables.delete(key);\n } else {\n const snapshotPath = getLanceDbSnapshotPath(lanceDbStore.path, deleteBody.table);\n const snapshotStats = await stat(snapshotPath);\n lanceDbLocalTables.set(key, {\n records: table,\n mtimeMs: snapshotStats.mtimeMs,\n size: snapshotStats.size,\n });\n }\n return { status: \"ok\" };\n }\n const timeoutMs = normalizeSearchHttpTimeoutMs(options.timeout_ms, \"Vector request\");\n const fetcher = resolveSearchHttpFetcher(options.fetcher, \"Vector request\");\n const payload = await executeRemoteVectorPlan(\n resolveQdrantDeleteTarget(plan.target.upsert_target),\n {\n method: \"POST\",\n headers: plan.headers,\n body: plan.body,\n },\n timeoutMs,\n fetcher,\n \"delete\",\n );\n return normalizeQdrantUpsertResponse(payload);\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAuFjC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AACtC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AAC5D,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAO1C,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAuC,CAAC;AAE1E,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IACD,O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4b6a91b781ba"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Decode the five core HTML entities (`&lt;`, `&gt;`, `&quot;`, `&#39;`,
3
+ * `&amp;`) in a single pass — but only when the input contains `&lt;` or
4
+ * `&gt;`. 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 `&amp;lt;` decodes to `&lt;` (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 visited-set is used as defensive protection against accidental cycles.
20
+ */
21
+ export declare function decodeHtmlEntitiesInOptions<T>(options: T): T;
@@ -0,0 +1,122 @@
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 `&lt;type&gt;` 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 `&lt;` or `&gt;` 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 `&amp;lt;` stays as the literal `&lt;` (because `&amp;` 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]="59b9e6dc-4fde-5bd0-b4bc-972055df82fe")}catch(e){}}();
18
+ const ENTITY_MAP = Object.freeze({
19
+ "&lt;": "<",
20
+ "&gt;": ">",
21
+ "&quot;": '"',
22
+ "&#39;": "'",
23
+ "&amp;": "&",
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, `&amp;` is matched as a whole token, so a
28
+ // substring like `&amp;lt;` matches `&amp;` once → `&lt;` (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 (`&lt;`, `&gt;`, `&quot;`, `&#39;`,
33
+ * `&amp;`) in a single pass — but only when the input contains `&lt;` or
34
+ * `&gt;`. 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 `&amp;lt;` decodes to `&lt;` (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 `&lt;` / `&gt;` 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 `&amp;` / `&quot;` / `&#39;`
48
+ // would risk altering legitimate text that contains those literal token
49
+ // sequences for unrelated reasons (a URL containing `&amp;`, 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 `&amp;-only is no-op` and `&quot;-only is no-op`.
54
+ if (!input.includes("&lt;") && !input.includes("&gt;")) {
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 visited-set is used as defensive protection against accidental cycles.
69
+ */
70
+ export function decodeHtmlEntitiesInOptions(options) {
71
+ return decodeValue(options, new WeakSet());
72
+ }
73
+ function decodeValue(value, seen) {
74
+ if (typeof value === "string") {
75
+ return decodeHtmlEntitiesIfEscaped(value);
76
+ }
77
+ if (Array.isArray(value)) {
78
+ if (seen.has(value)) {
79
+ return value;
80
+ }
81
+ seen.add(value);
82
+ return value.map((entry) => decodeValue(entry, seen));
83
+ }
84
+ if (value !== null && typeof value === "object") {
85
+ // Only traverse plain objects (`{}` and `Object.create(null)` literals).
86
+ // Class instances (Date, RegExp, Map, Set, Buffer, etc.) and `null`-proto
87
+ // objects with no proto would lose their prototype and methods if we
88
+ // rebuilt them as a `Record<string, unknown>` here, so we pass them through.
89
+ if (!isPlainObject(value)) {
90
+ return value;
91
+ }
92
+ if (seen.has(value)) {
93
+ return value;
94
+ }
95
+ seen.add(value);
96
+ const source = value;
97
+ // Preserve the original prototype so downstream callers can still rely on
98
+ // standard methods like `.hasOwnProperty` on plain objects.
99
+ const result = Object.create(Object.getPrototypeOf(value));
100
+ // Use Object.defineProperty (not bracket assignment) for ALL keys so a
101
+ // smuggled `__proto__` / `constructor` / `prototype` key from an MCP
102
+ // caller becomes a regular own property — never triggers JS's special
103
+ // prototype-chain assignment semantics that would otherwise pollute
104
+ // Object.prototype. This preserves legitimate data while staying safe.
105
+ for (const [key, entry] of Object.entries(source)) {
106
+ Object.defineProperty(result, key, {
107
+ value: decodeValue(entry, seen),
108
+ enumerable: true,
109
+ writable: true,
110
+ configurable: true,
111
+ });
112
+ }
113
+ return result;
114
+ }
115
+ return value;
116
+ }
117
+ function isPlainObject(value) {
118
+ const proto = Object.getPrototypeOf(value);
119
+ return proto === Object.prototype || proto === null;
120
+ }
121
+ //# sourceMappingURL=html-entity-decode.js.map
122
+ //# debugId=59b9e6dc-4fde-5bd0-b4bc-972055df82fe
@@ -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 `&lt;type&gt;` 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 `&lt;` or `&gt;` 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 `&amp;lt;` stays as the literal `&lt;` (because `&amp;` 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 \"&lt;\": \"<\",\n \"&gt;\": \">\",\n \"&quot;\": '\"',\n \"&#39;\": \"'\",\n \"&amp;\": \"&\",\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, `&amp;` is matched as a whole token, so a\n// substring like `&amp;lt;` matches `&amp;` once → `&lt;` (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 (`&lt;`, `&gt;`, `&quot;`, `&#39;`,\n * `&amp;`) in a single pass — but only when the input contains `&lt;` or\n * `&gt;`. 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 `&amp;lt;` decodes to `&lt;` (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 `&lt;` / `&gt;` 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 `&amp;` / `&quot;` / `&#39;`\n // would risk altering legitimate text that contains those literal token\n // sequences for unrelated reasons (a URL containing `&amp;`, 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 `&amp;-only is no-op` and `&quot;-only is no-op`.\n if (!input.includes(\"&lt;\") && !input.includes(\"&gt;\")) {\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 visited-set is used as defensive protection against accidental cycles.\n */\nexport function decodeHtmlEntitiesInOptions<T>(options: T): T {\n return decodeValue(options, new WeakSet<object>()) as T;\n}\n\nfunction decodeValue(value: unknown, seen: WeakSet<object>): unknown {\n if (typeof value === \"string\") {\n return decodeHtmlEntitiesIfEscaped(value);\n }\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return value;\n }\n seen.add(value);\n return value.map((entry) => decodeValue(entry, seen));\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 value;\n }\n seen.add(value as object);\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 // 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;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AI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC","debugId":"59b9e6dc-4fde-5bd0-b4bc-972055df82fe"}
@@ -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"}
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="16ab349e-99ce-51eb-85d5-62e1c2c56c10")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0b886283-0ee3-5dcd-bd65-6199134c8901")}catch(e){}}();
4
4
  import readline from "node:readline";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { activateExtensions, loadExtensions, runActiveCommandHandler, setActiveExtensionCommands, setActiveExtensionHooks, setActiveExtensionParsers, setActiveExtensionPreflight, setActiveExtensionRegistrations, setActiveExtensionRenderers, setActiveExtensionServices, } from "../core/extensions/index.js";
7
7
  import { pathExists } from "../core/fs/fs-utils.js";
8
8
  import { projectMutationResult } from "../core/output/mutation-projection.js";
9
9
  import { PmCliError } from "../core/shared/errors.js";
10
+ import { decodeHtmlEntitiesInOptions } from "../core/shared/html-entity-decode.js";
10
11
  import { asRecordClone } from "../core/shared/primitives.js";
11
12
  import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
12
13
  import { readSettings } from "../core/store/settings.js";
@@ -619,7 +620,13 @@ export async function handleRequest(request) {
619
620
  if (!handler) {
620
621
  throw new PmCliError(`Unknown pm MCP tool: ${name}`, 64);
621
622
  }
622
- const args = asRecordClone(params.arguments);
623
+ // pm-ydkl: defensive HTML-entity decode for free-text fields. Claude / the
624
+ // Anthropic MCP SDK HTML-encodes `<` / `>` (and friends) in tool arguments
625
+ // before they reach pm-cli, which would otherwise leak `&lt;type&gt;` into
626
+ // stored pm comments / notes / item bodies. Direct CLI calls are not
627
+ // affected; decoding at the MCP boundary normalizes the agent path while
628
+ // leaving normal text untouched.
629
+ const args = decodeHtmlEntitiesInOptions(asRecordClone(params.arguments));
623
630
  const result = await withCwd(args.cwd, () => handler(args));
624
631
  return resultContent(result);
625
632
  }
@@ -669,4 +676,4 @@ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
669
676
  startMcpServer();
670
677
  }
671
678
  //# sourceMappingURL=server.js.map
672
- //# debugId=16ab349e-99ce-51eb-85d5-62e1c2c56c10
679
+ //# debugId=0b886283-0ee3-5dcd-bd65-6199134c8901