@unbrained/pm-cli 2026.11.21 → 2026.11.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/pm-developer/SKILL.md +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/register-history-maintenance.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-PJXKA4QU.js → chunk-4TB5D6HL.js} +37 -37
- package/dist/cli-bundle/chunks/{chunk-WELSVDPU.js → chunk-5ZMVLWE3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +33 -0
- package/dist/cli-bundle/chunks/{chunk-JVGRFU5H.js → chunk-AR4NP5HI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XHJ3H5PL.js → chunk-B4PPFOPY.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-5647LU3A.js → chunk-B76TFRO2.js} +47 -45
- package/dist/cli-bundle/chunks/{chunk-YJEBK7HU.js → chunk-CAR2L5NW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D6ILFXZY.js → chunk-EIGUKEV6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XWHJIRNV.js → chunk-GTPCAJMZ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CASX6SFI.js → chunk-HC2OPETM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NCFCBKIP.js → chunk-HKUV74K3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +115 -0
- package/dist/cli-bundle/chunks/{chunk-S6HB3WL2.js → chunk-J2LABXBL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKSVHOWI.js → chunk-J52BEBSS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NT5AKFE5.js → chunk-OJTMGDON.js} +31 -31
- package/dist/cli-bundle/chunks/{chunk-SRVTCYAU.js → chunk-TC6XLIYO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AHQB7W2H.js → chunk-U7EL3AYA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-CIKGG34F.js → chunk-X6MIWTTT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RMIRNYRG.js → chunk-XFHPKXAE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6QLEXRUG.js → chunk-YHVLVSEZ.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-4QBMZXKX.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-3TG636XG.js → mutation-actor-FWLYWJ37.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-LICSDNNO.js → mutation-admission-7ZDCK3G2.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-RR5KACJ3.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-WWVECKFQ.js → register-mutation-57AJQWFV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-L6HFJNWD.js → register-operations-RKWST7CU.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-K7UFG5TD.js → register-setup-CMI23PC5.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-57KH3KAC.js → stage-4KDVXC5Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YOAYY3HE.js → chunk-2ZD7275J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-532WZV65.js → chunk-324AHXJO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QGKLRXP7.js → chunk-4JZITIJB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CU2BRAOX.js → chunk-4KTFKSS3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +78 -0
- package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MKM5NKD7.js → chunk-BRZV7BFV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RPE6IX26.js → chunk-HDEKFSOK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LNHUE4VV.js → chunk-IWOXAUDU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-J63D6QST.js → chunk-ML3JHCC6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JMQJBZQ5.js → chunk-OPGOOP25.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XCJSHNXK.js → chunk-RE7ZWT7D.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WXMI4AV5.js → chunk-RQ252B6V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7A4QWNZX.js → chunk-URGHTTT3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IQK5NPMG.js → chunk-USPYKWQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +102 -0
- package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UOC6257J.js → chunk-WZWXGDYY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NP72ZDXE.js → chunk-YKSLZPLT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-2O6MLPEX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{mutation-actor-62HKR5IO.js → mutation-actor-TCYDPUGG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-X4PF2SG3.js → mutation-admission-LY73EJWM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-O7T7CXBB.js → stage-DQ7RQQ52.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +70 -58
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/fs/atomic-create.js +1 -1
- package/dist/core/fs/file-glob.js +1 -1
- package/dist/core/history/bridge.js +2 -0
- package/dist/core/history/drift-scan.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/history/history.d.ts +12 -0
- package/dist/core/history/history.js +2 -2
- package/dist/core/history/projection.js +1 -1
- package/dist/core/history/read.d.ts +9 -0
- package/dist/core/history/read.js +1 -1
- package/dist/core/history/replay.d.ts +46 -5
- package/dist/core/history/replay.js +2 -2
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
- package/dist/sdk/completion/fish.js +3 -2
- package/dist/sdk/completion/zsh.js +3 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/history/append-only-repair.d.ts +30 -0
- package/dist/sdk/history/append-only-repair.js +6 -0
- package/dist/sdk/history/maintenance.d.ts +8 -2
- package/dist/sdk/history/maintenance.js +1 -1
- package/dist/sdk/history/reanchor-refusal.js +2 -0
- package/dist/sdk/history/reseed.d.ts +15 -0
- package/dist/sdk/history/reseed.js +2 -0
- package/dist/sdk/history/salvage.d.ts +19 -8
- package/dist/sdk/history/salvage.js +5 -3
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-redact.js +1 -1
- package/dist/sdk/history-repair.d.ts +8 -2
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/item-transaction.d.ts +33 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/merge/three-way.d.ts +22 -3
- package/dist/sdk/merge/three-way.js +8 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +7 -0
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -5
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/transactions/item-finalization.js +2 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
- package/docs/COMMANDS.md +6 -2
- package/docs/HISTORY_RECOVERY.md +229 -5
- package/docs/README.md +2 -2
- package/docs/SDK.md +103 -4
- package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
- package/marketplace.json +1 -1
- package/node_modules/tar/package.json +2 -3
- package/package.json +30 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
- package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
- package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
- package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
- package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
- package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
- package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
- package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
- package/dist/sdk/agent/refusal-closure.js +0 -2
- package/dist/sdk/agent/refusal-reachability.js +0 -4
- package/dist/sdk/agent/task-transcript-contracts.js +0 -2
- package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
- package/dist/sdk/authoring.js +0 -2
- package/dist/sdk/compose.js +0 -2
- package/dist/sdk/contracts.js +0 -2
- package/dist/sdk/core-governance.js +0 -2
- package/dist/sdk/core.js +0 -2
- package/dist/sdk/corpus-shape.js +0 -2
- package/dist/sdk/define.js +0 -2
- package/dist/sdk/environment/agent-environment.js +0 -2
- package/dist/sdk/governance/artifact-ledgers.js +0 -2
- package/dist/sdk/governance/coverage-assurance.js +0 -2
- package/dist/sdk/governance/reliability.js +0 -2
- package/dist/sdk/governance.js +0 -2
- package/dist/sdk/graph/adapter.js +0 -2
- package/dist/sdk/graph/conformance.js +0 -2
- package/dist/sdk/graph/index.js +0 -2
- package/dist/sdk/graph.js +0 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/query.js +0 -2
- package/dist/sdk/relationship-migration.js +0 -2
- package/dist/sdk/testing.js +0 -8
- package/dist/sdk/workspace-recipe.js +0 -2
- package/docs/AGENT_PROVENANCE_ADR.md +0 -206
- package/docs/DEFECT_RECURRENCE.md +0 -257
- package/docs/PERFORMANCE.md +0 -204
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as q,s as V}from"./chunk-
|
|
1
|
+
import{r as q,s as V}from"./chunk-2ZD7275J.js";import{d as m,j as M,l as k}from"./chunk-HDEKFSOK.js";import{Ga as O,Nd as N,T as x,Y as g,ih as D,lh as j,oh as z}from"./chunk-UWS3FC4D.js";import{A as C,E as _,I as L,z as S}from"./chunk-3IRCYJI5.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as I,open as P}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function $(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function Q(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function U(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=$(i,t),a=n.identities.get(c);if(a!==void 0&&a!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Z(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",a=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(a))throw new TypeError(`Relationship endpoint not found: ${c} -> ${a}`);let d=new g([c,a],[i.edge],r).edges()[0];return U(d,e,r,o),Q(d)}var T=class{#t;#i;#n=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#i=t.registry??x()}get version(){return this.#n.length}events(){return Object.freeze([...this.#n])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#n.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let a of c)r=t(r,a),o+=1,s=a;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#i.require(t.kind);this.#r.identities.set($(t,this.#i),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#i.require(e.kind);this.#r.identities.delete($(e,this.#i)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Z(e,t.relationshipId,this.#e,this.#t,this.#i,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#n.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#n.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#n.slice(0,o)}let n=Y(t),r=new g(this.#t,n.values(),this.#i);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=D("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(j(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=z(this.#n.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(i){return N(i,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function f(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await I(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let o=t;for(let s of r.split(h.sep)){o=h.join(o,s);try{if((await A(o)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(_(c))break;throw c}}return n}async function y(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await P(i,p.O_RDONLY|W),r=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
|
|
2
2
|
`);for(let c=0;c<s.length;c+=1){let a=s[c].trim();if(!a)continue;let d;try{d=JSON.parse(a)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(d.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:d.eventId,relationshipId:d.relationshipId,action:d.action,...d.edge===void 0?{}:{edge:d.edge},author:d.author,timestamp:d.timestamp,...d.reason===void 0?{}:{reason:d.reason},expectedVersion:n.version})}return{log:n,raw:r}}function te(i,e,t,n){let r=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new g(t,[e.edge],n).edges()[0]),i.eventId===e.eventId.trim()&&i.relationshipId===e.relationshipId.trim()&&i.action===e.action&&i.author===e.author.trim()&&Number.isFinite(r)&&i.timestamp===new Date(r).toISOString()&&i.reason===(e.reason?.trim()||void 0)&&O(i.edge)===O(o)}var F=class i{#t;#i;#n;#o;#e;constructor(e,t,n,r){this.#t=e.pmRoot,this.#i=t,this.#n=e.registry,this.#o=n,this.#e=r}static async open(e){let t=Object.freeze([...e.nodes]),n=await f(e.pmRoot,e.relativePath),r=await w(e.pmRoot);try{await f(e.pmRoot,n);let{log:o}=await y(n,t,e.registry);return new i(e,t,n,o)}finally{await r()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await w(this.#t);try{let n=await f(this.#t,this.#o),{log:r}=await y(n,this.#i,this.#n),o=r.append(e);await I(h.dirname(n),{recursive:!0}),await f(this.#t,n);let s=await P(n,p.O_APPEND|p.O_CREAT|p.O_WRONLY|W);try{await s.appendFile(`${JSON.stringify(o)}
|
|
3
3
|
`,"utf8")}finally{await s.close()}return this.#e=r,o}finally{await t()}}async appendBatch(e,t={}){let n=await w(this.#t);try{let r=await f(this.#t,this.#o),{log:o,raw:s}=await y(r,this.#i,this.#n),c=o.version,a=new Map(o.events().map(l=>[l.eventId,l])),d=[],R=[];for(let l of e){let u=l.eventId.trim(),v=a.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&te(v,l,this.#i,this.#n)){R.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let b=o.append(l);a.set(b.eventId,b),d.push(b)}if(d.length>0){let l=s.length===0||s.endsWith(`
|
|
4
4
|
`)?s:`${s}
|
|
5
5
|
`;await I(h.dirname(r),{recursive:!0}),await f(this.#t,r),await L(r,`${l}${d.map(u=>JSON.stringify(u)).join(`
|
|
6
6
|
`)}
|
|
7
7
|
`)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(d),skipped_event_ids:Object.freeze(R)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await w(this.#t);try{let t=await f(this.#t,this.#o);return(await y(t,this.#i,this.#n)).log}finally{await e()}}};(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="73852fdf-f072-51ab-9449-d7922712eeb4")}catch{}})();function K(i){return[...i].sort().join("\0")}function ie(i,e,t){let n=i.successors.get(e);n?n.push(t):i.successors.set(e,[t]);let r=i.predecessors.get(t);r?r.push(e):i.predecessors.set(t,[e])}function G(i,e,t,n,r){let o=e.resolve(r);if(o?.ordering!==!0)return;let s=M(n),c=s===void 0?void 0:i.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let a=(o.precedence??"source_before_target")==="source_before_target";ie(i,a?t:c,a?c:t)}function ne(i,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=i.filter(r=>typeof r?.id=="string"&&r.id.trim().length>0);for(let r of n){let o=r.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let r of n){let o=r.id.trim();G(t,e,o,r.blocked_by,"blocked_by");for(let s of r.dependencies??[])typeof s!="object"||s===null||G(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let r of[t.successors,t.predecessors])for(let o of r.values())o.sort();return t}function re(i,e){let t=new Set([e]),n=[e];for(;n.length>0;){let r=n.pop();for(let o of[i.successors,i.predecessors])for(let s of o.get(r)??[])t.has(s)||(t.add(s),n.push(s))}return t}function oe(i,e){let t=new Map;for(let n of e){let r=(i.successors.get(n)??[]).filter(o=>e.has(o));r.length>0&&t.set(n,r)}return t}function H(i,e,t){let n=ne(i,e),r=n.canonicalIds.get(t.trim().toLowerCase());if(r===void 0)return{cycles:[],successors:new Map,canonical:t};let o=oe(n,re(n,r));return{cycles:q(o).filter(s=>s.includes(r)),successors:o,canonical:r}}function se(i,e,t){let n=new Set(e),r=n.has(t)?t:e[0];if(i.get(r)?.includes(r))return[r,r];for(let o of i.get(r)??[]){if(!n.has(o))continue;let s=ae(i,n,r,o);if(s)return s}return[...e,e[0]]}function ae(i,e,t,n){let r=[[n]],o=new Set([t,n]);for(;r.length>0;){let s=r.shift(),c=s.at(-1);for(let a of i.get(c)??[]){if(a===t)return[t,...s,t];!e.has(a)||o.has(a)||(o.add(a),r.push([...s,a]))}}}function ve(i,e,t){let n=m(),r=H(i,n,t),o=H(e,n,t),s=new Set(r.cycles.map(K)),c=new Set(k(i,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...k(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${V(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(K(a))).map(a=>`ordering_cycle_created:${se(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5f2ca18e-450d-5b6e-9e07-7bbf080764f9")}catch{}})();function Ee(i,e){let t=e.resolve(i);return t?.hierarchy===!0||t?.outgoing==="one"||t?.incoming==="one"}function J(i,e,t,n,r){let o=JSON.stringify([e,t,n]),s=i.get(o);s===void 0&&(s={kind:e,direction:t,node_id:n,endpoints:new Set},i.set(o,s)),s.endpoints.add(r)}function B(i,e){let t=new Map;for(let n of i)for(let r of n.dependencies??[]){let o=e.resolve(r.kind);o===void 0||o.hierarchy||(o.outgoing==="one"&&J(t,o.kind,"outgoing",n.id,r.id),o.incoming==="one"&&J(t,o.kind,"incoming",r.id,n.id))}return t}function Ie(i,e,t=m()){let n=B(i,t),r=B(e,t);for(let o of[...r.keys()].sort()){let s=r.get(o);if(s.endpoints.size<=1)continue;let c=n.get(o);if(![...s.endpoints].every(a=>c?.endpoints.has(a)))throw new C(`Relationship ${s.kind} permits only one ${s.direction} endpoint for ${s.node_id}.`,S.USAGE,{code:"dependency_cardinality_created",field:"dependencies",value:s.kind,relationship_cardinality:{kind:s.kind,direction:s.direction,node_id:s.node_id,endpoint_ids:[...s.endpoints].sort()},required:"The final dependency set must satisfy the active relationship kind's one-edge cardinality.",nextSteps:["Drop extra --dep seeds, or remove conflicting rows with update --dep-remove before adding another edge.","Choose another kind only when its declared semantics match the intended relationship."]})}}export{T as a,F as b,ve as c,Ee as d,Ie as e};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-URGHTTT3.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{E as Ho,G as Go,a as q,b as Eo,c as Co,e as Oe,f as Io,g as To,h as xo,i as Ro,j as Ao,m as Do,n as Mo,p as No,q as Lo,t as Po,u as Cn,v as In,w as H,y as jo,z as Uo}from"./chunk-CU2BRAOX.js";import{d as Wo}from"./chunk-JMQJBZQ5.js";import{Aa as oo,Ab as ho,Ba as kt,Bb as go,Ca as so,Cb as yo,Da as St,Db as _o,Ea as Et,Eb as wo,Fa as Ct,Ga as ao,Hb as vo,Jb as bo,Ka as co,La as kn,Ua as lo,ca as Ki,da as Vi,ga as vn,ha as Yi,sa as _t,sb as uo,ua as ge,ub as mo,va as wt,vb as fo,wa as vt,wb as Sn,xa as eo,xb as po,za as io}from"./chunk-XCJSHNXK.js";import{Za as gi,fb as yi,g as gn,h as yn,j as _n,k as pi,l as hi}from"./chunk-HGFNL5XI.js";import{d as Fo,e as Oo,h as $o,w as Bo}from"./chunk-RPE6IX26.js";import{a as Me,c as Fe,f as En,g as ko,h as So,i as It}from"./chunk-QGKLRXP7.js";import{E as bt,G as to,H as ye,I as _e,K as no,L as we,O as ro,b as le,f as Xi,g as Qi,j as Zi,l as bn}from"./chunk-SRDQSA6M.js";import{a as he,b as yt,c as Ji,s as A,y as B}from"./chunk-MKM5NKD7.js";import{$g as Bi,A as de,Ad as vi,Ba as hn,Bg as Li,Bh as qi,Ch as zi,Da as ue,Ec as D,F as fn,G as rt,Ga as ct,Hc as _i,Hf as C,Ic as S,Ih as wn,Jc as wi,Kc as W,Le as Ai,Mc as fe,Pc as dt,Pd as bi,Pf as Ae,Qd as ki,Rd as Si,Rf as De,Rg as Pi,Sd as Ei,Td as Ci,Ub as me,Uf as Mi,Ve as Di,Wf as Fi,Xd as Re,Xg as ut,Yf as lt,Yg as pe,Zb as fi,Zg as ji,_ as pn,_g as Ui,a as si,ah as Hi,ba as xe,bh as Gi,ca as at,ch as mt,ee as Ii,ga as li,gh as ft,ha as ui,ih as pt,kh as ht,lc as N,ld as M,md as E,mg as Oi,nc as J,nd as Z,ne,nh as Wi,oe as Ti,oh as gt,pe as xi,qe as ee,ra as R,wg as $i,xa as x,xg as Ni,za as mi,ze as Ri}from"./chunk-OSLQD5VH.js";import{A as h,C as di,D as it,E as ot,I as st,t as ai,x as ci,z as p}from"./chunk-3IRCYJI5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f698608a-2f39-5972-b24b-93287af6b373")}catch{}})();var $e=class extends RangeError{code;work;minimum_tokens;constructor(t,n,r){super(t),this.name="OutputEnvelopeFitError",this.code=t,this.work=Object.freeze({...n}),this.minimum_tokens=r}};function Tn(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function uc(e,t,n,r){return t.map(([i,o])=>{if(r.render_calls>=r.max_render_calls)throw new $e("output_envelope_work_limit",r);r.render_calls+=1;let s=o(e);if(typeof s!="string")throw new TypeError("Envelope renderers must return strings");let a=n(s);if(!Number.isSafeInteger(a)||a<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:i,text:s,bytes:Buffer.byteLength(s,"utf8"),estimated_tokens:a}})}function qo(e,t,n,r){let i=t,o=Object.entries(n.renderers),s=n.estimateTokens??(a=>Oi(Buffer.byteLength(a,"utf8")));for(let a=0;a<(n.maxStabilizationPasses??16);a+=1){let c=Object.freeze({...i}),d={...n.buildEnvelope(e,c),output_fit:c},l=uc(d,o,s,r),u=Math.max(...l.map(f=>f.bytes)),m=Math.max(...l.map(f=>f.estimated_tokens));if(u===i.output_bytes&&m===i.estimated_tokens)return{envelope:d,renderings:l};i={...i,output_bytes:u,estimated_tokens:m}}throw new $e("output_envelope_unstable",r)}function th(e,t){Tn(t.tokenBudget,"tokenBudget"),Tn(t.maxRenderCalls??1e4,"maxRenderCalls"),Tn(t.maxStabilizationPasses??16,"maxStabilizationPasses");let n=t.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(t.renderers).length===0||Object.entries(t.renderers).some(([c,d])=>!c.trim()||typeof d!="function"))throw new TypeError("Envelope fitting requires named callable renderers");let r={evaluated_candidates:0,render_calls:0,max_render_calls:t.maxRenderCalls??1e4},i=[],o=[],s=c=>({version:1,policy:n,total_candidates:e.length,included_indices:Object.freeze([...c]),omitted_count:e.length-c.length,token_budget:t.tokenBudget,estimated_tokens:0,output_bytes:0}),a=qo(i,s(o),t,r);if(a.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new $e("output_envelope_infeasible",r,a.envelope.output_fit.estimated_tokens);for(let[c,d]of e.entries()){r.evaluated_candidates+=1;let l=[...i,d],u=[...o,c],m=qo(l,s(u),t,r);if(m.envelope.output_fit.estimated_tokens<=t.tokenBudget)i=l,o=u,a=m;else if(n==="prefix")break}return{rows:i,...a,complete:i.length===e.length,work:Object.freeze({...r})}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="85653664-ce87-5265-ae01-18205a85b75a")}catch{}})();var mc=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],xn=class extends Error{receipt;constructor(t,n={}){super(`Complete-list certification failed: ${t.map(i=>i.code).join(", ")}.`),this.name="PmCompleteListValidationError";let r=n.includeBody===!0;this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:`pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded${r?" --include-body":""} --json`,sdk:r?"await client.listAllComplete({ includeBody: true })":"await client.listAllComplete()"}}}};function ih(e={}){return Li({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function T(e,t,n,r){t&&e.push({code:n,message:r})}function fc(e,t){let n=P(e.completeness)?e.completeness:{};T(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),T(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;T(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),T(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=P(e.filters)?e.filters:{},s=P(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return T(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(c=>!a.has(c)),"filtered_corpus","The list did not explicitly select every lifecycle status."),T(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),T(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function pc(e,t,n){T(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),T(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=P(e.projection)?e.projection:{};T(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=P(e.omission_receipt)?e.omission_receipt:void 0;T(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),T(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),T(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function hc(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function gc(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function yc(e,t){let n=P(e.read_output)?e.read_output:void 0;T(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),T(t,n!==void 0&&hc(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),T(t,n!==void 0&&!gc(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),T(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=P(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;T(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),T(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function _c(e,t){let n=e.map(r=>P(r)&&typeof r.id=="string"?r.id.trim():"");T(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),T(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function wc(e){if(!P(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:mc[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=fc(t,n);return pc(t,r,n),yc(t,n),_c(t.items,n),{ok:n.length===0,findings:n}}function vc(e,t){return t.includeBody!==void 0?t.includeBody:P(e)&&P(e.filters)&&e.filters.include_body===!0}function bc(e,t={}){let n=wc(e);if(!n.ok)throw new xn(n.findings,{includeBody:vc(e,t)});let r=e;return{...r,complete_list:{contract_version:1,item_count:r.items.length,unique_item_id_count:new Set(r.items.map(i=>i.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function oh(e,t={}){bc(e,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function dh(e,t={}){let n=await Ho({pmRoot:x(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var zo=16;async function Ko(e,t,n){let r=R(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<zo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let c=await ye(e,s,t.id_prefix,t.item_format,r);if(!c)break;let d=await _e(c,{schema:t.schema});i.push(d.document.metadata.id),s=d.document.metadata.parent}return i}async function hh(e){await Si({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await Ko(e.pmRoot,e.settings,e.itemId)})}async function gh(e){await Ei(e)}async function yh(e){await Ci({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await Ko(e.pmRoot,e.settings,e.itemId)}:{}})}var _h={lineage_depth:zo,active_items:64,evidence_rows:32};function Vo(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c12559a3-2703-5665-9ec2-7309589be511")}catch{}})();var Ne=["priority_floor","weighted"],kc="default-weighted-v1";function Yo(e,t,n,r){let i=new Map(e.map(a=>[a.id,a.rank]));if(n!=="priority_floor"||r!==kc)return i;let o=t.in_progress_status,s=a=>E(a.item.status,t)===o?-1:a.item.priority;return e.sort((a,c)=>s(a)-s(c)||a.rank-c.rank),e.forEach((a,c)=>{a.rank=c+1}),i}function Xo(e,t,n,r){let i=e[0];if(!i)return;if(r==="priority_floor"){let a=t.get(i.item.id);return a!==void 0&&a!==1?`priority floor (relevance rank ${a})`:void 0}let o=n.in_progress_status,s=e.slice(1).filter(a=>a.item.priority<i.item.priority&&E(a.item.status,n)!==o).map(a=>a.item.priority);return s.length>0?`relevance over p${Math.min(...s)} ready work`:void 0}import{encode as Ec}from"@toon-format/toon";import{createHash as Sc}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="66022e7d-1594-5b88-a283-c64830ff0dfd")}catch{}})();function Rn(e){let t=Sc("sha256").update("[");for(let n of e)t.update(ct(n)).update("\0");return t.update("]").digest("hex")}function Le(e,t){if(t===void 0)return D();let n=Ui(t).snapshot,r=`${e}:`,i=n?.slice(r.length);if(!n?.startsWith(r)||!i||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u.test(i)||!Number.isFinite(Date.parse(i)))throw new h("Query cursor has no supported fixed-window clock.",p.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]});return i}function Pe(e,t){let n=e.map((a,c)=>({row:a,index:c})),r=pe(t.command,{query:t.query,rows_digest:Rn(e)}),i=t.after===void 0?void 0:Bi(t.after,r);if(i&&(i.after_index===void 0||i.after_id!==String(i.after_index)||i.after_index>=e.length))throw new h("Query cursor position is outside the matching window.",p.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]});let o=mt(n,{cursor:t.after,fingerprint:r,snapshot:`${t.command}:${t.clock}`,limit:t.limit??e.length,readId:({index:a})=>String(a)}),s=i?.after_index===void 0?0:i.after_index+1;return{...o,rows:o.rows.map(({row:a})=>a),count:o.rows.length,total_count:e.length,page_start:s,omitted_count:e.length-s-o.rows.length,has_more:s+o.rows.length<e.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="351df2b3-3a1a-528c-96b9-72bb3e2f27fc")}catch{}})();var An=["agenda","day","week","month"],Dn=["markdown","toon","json"],Cc=["sun","mon","tue","wed","thu","fri","sat"],Ic=365,Tc=365,ns=28,xc=1e3;function Mn(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,p.USAGE);return n}function Rc(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",p.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",p.USAGE)}return r}function rs(e,t){let n;for(let r of t){let i=si(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function Ac(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!An.includes(t)){let n=rs(t,An);throw new h(`Calendar view must be one of ${An.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Dc(e){if(!e)return;let t=e.trim().toLowerCase();if(!Dn.includes(t)){let n=rs(t,Dn);throw new h(`Calendar format must be one of ${Dn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Mh(e,t){let n=Dc(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",p.USAGE);return t.json?"json":n??"markdown"}function Mc(e,t){if(e===void 0)return;let n=M(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,p.USAGE)}return n}function Fc(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",p.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,p.USAGE);return t}function Tt(e){return new Date(e).toISOString().slice(0,10)}function is(e,t){if(!t||t==="UTC")return Tt(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return Tt(e)}function Nn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function z(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function os(e){let t=new Date(Nn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return z(t.toISOString(),r)}function Oc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function $c(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Nc(e,t){return S(e,t)>=0?e:t}function Qo(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function Jo(e,t){e.set(t,(e.get(t)??0)+1)}function Lc(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function ss(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function as(e){return Cc[new Date(e).getUTCDay()]}function Pc(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function jc(e){let t=new Set;for(let n of e??[]){let r=Pc(n);r&&t.add(r)}return t}function Uc(e,t,n,r,i){let o=e??z(n,-(r??Tc)),s=t??z(e??n,i??Ic);return{start:o,end:S(s,o)>0?s:z(o,1)}}function Bc(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[as(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??xc,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:jc(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function xt(e,t){return S(t,e.startAt)<0?"continue":e.until&&S(t,e.until)>0||S(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,S(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function Rt(e,t){let n=as(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Hc(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(Rt(e,t)&&xt(e,t)==="stop");n+=1)t=z(t,e.interval);return e.occurrences}function Gc(e,t,n){let r=de(n),i=z(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Wc(e){let t=os(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=z(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Gc(e,r,i);if(Rt(e,o)&&xt(e,o)==="stop")return e.occurrences}}return e.occurrences}function qc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=ss(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!Rt(e,s))&&xt(e,s)==="stop")return e.occurrences}}return e.occurrences}function zc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=ss(i,n,o,e.startDate);if(!(!s||!Rt(e,s))&&xt(e,s)==="stop")return e.occurrences}}return e.occurrences}function Kc(e,t,n,r){let i=Bc(e,t,n,r);return t.freq==="daily"?Hc(i):t.freq==="weekly"?Wc(i):t.freq==="monthly"?qc(i):zc(i)}function cs(e){return[...e].sort((t,n)=>{let r=S(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function Ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Vc(e){return e.deadline?{at:e.deadline,date:Tt(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Ln(e),item_deadline:e.deadline}:null}function Yc(e){return(e.reminders??[]).map(t=>({at:t.at,date:Tt(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Ln(e)}))}function Xc(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Qc(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Jc(e,t,n,r){let i=Lc(t.recurrence),o=Xc(t.start_at,t.end_at);return(t.recurrence?Kc(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):is(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Qc(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...Ln(e)}))}function Zc(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Vc(o):null;s&&i.push(s),n.has("reminders")&&i.push(...Yc(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Jc(o,a,t,r))}return cs(i)}function ed(e,t,n,r,i){let o=Co(t.type,n),s=t.tag?.trim().toLowerCase(),a=Eo(t.priority),c=Mc(t.status,r),d=t.assignee?.trim(),l=Fc(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(d&&(d.toLowerCase()==="none"||d.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',p.USAGE);if(d!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",p.USAGE);return e.filter(f=>td(f,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:c,assigneeFilter:d,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function td(e,t){return nd(e,t)&&rd(e,t)&&vt(e,t.runtimeFieldFilters)}function nd(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function rd(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function id(e,t,n){return!(t&&S(e.at,t)<0||n&&S(e.at,n)>=0)}function Fn(e,t,n){return e.trim().toLowerCase()==="today"?Nn(t):W(e,new Date(t),n)}function od(e,t,n){let r=t.date?Fn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?Fn(t.from,n,"--from"):void 0,a=t.to?Fn(t.to,n,"--to"):void 0;if(s&&a&&S(s,a)>=0)throw new h("Calendar --from must be before --to",p.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",p.USAGE);if(e==="agenda")return sd(r,t,n,i,o,s,a);if(e==="day"){let d=Nn(r);return On(r,n,i,o,d,z(d,1))}if(e==="week"){let d=os(r);return On(r,n,i,o,d,z(d,7))}let c=Oc(r);return On(r,n,i,o,c,$c(r))}function sd(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",p.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function On(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Nc(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function ad(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:cs(r)}))}function cd(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let c of e)t.add(c.item_id),Jo(n,c.item_type),Jo(r,c.item_status),c.kind==="deadline"?i+=1:c.kind==="reminder"?o+=1:(s+=1,c.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:Qo(n),by_status:Qo(r),recurring_events:a}}function dd(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function ds(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function $n(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function ld(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===is(e.event_end,e.event_timezone)?ds(e.event_end,e.event_timezone):e.event_end:null}function ud(e){let t=`${ds(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=ld(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Zo(e,t){if(t&&t.length>0){e.push("### warnings");for(let n of t)e.push(`- ${n}`);e.push("")}}function Fh(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${dd(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- matching-events: ${e.total_count}; returned: ${e.count}; remaining: ${e.omitted_count} (summary: ${e.summary_scope})`),e.next_cursor&&t.push(`- continue: repeat the same query with --after ${e.next_cursor}`),t.push(`- by-kind: ${$n(e.summary.by_kind)}`),t.push(`- by-type: ${$n(e.summary.by_type)}`),t.push(`- by-status: ${$n(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push(e.total_count===0?"No calendar events matched the selected filters.":"No calendar events returned on this page. Repeat the same query with --limit 1 or greater to retrieve matching events."),t.push(""),Zo(t,e.warnings),es(t.join(`
|
|
1
|
+
import{E as Ho,G as Go,a as q,b as Eo,c as Co,e as Oe,f as Io,g as To,h as xo,i as Ro,j as Ao,m as Do,n as Mo,p as No,q as Lo,t as Po,u as Cn,v as In,w as H,y as jo,z as Uo}from"./chunk-4KTFKSS3.js";import{d as Wo}from"./chunk-OPGOOP25.js";import{Aa as oo,Ab as ho,Ba as kt,Bb as go,Ca as so,Cb as yo,Da as St,Db as _o,Ea as Et,Eb as wo,Fa as Ct,Ga as ao,Hb as vo,Jb as bo,Ka as co,La as kn,Ua as lo,ca as Ki,da as Vi,ga as vn,ha as Yi,sa as _t,sb as uo,ua as ge,ub as mo,va as wt,vb as fo,wa as vt,wb as Sn,xa as eo,xb as po,za as io}from"./chunk-RE7ZWT7D.js";import{Za as gi,fb as yi,g as gn,h as yn,j as _n,k as pi,l as hi}from"./chunk-ZWJTY4ID.js";import{d as Fo,e as Oo,h as $o,w as Bo}from"./chunk-HDEKFSOK.js";import{a as Me,c as Fe,f as En,g as ko,h as So,i as It}from"./chunk-4JZITIJB.js";import{E as bt,G as to,H as ye,I as _e,K as no,L as we,O as ro,b as le,f as Xi,g as Qi,j as Zi,l as bn}from"./chunk-3XSWH6QC.js";import{a as he,b as yt,c as Ji,s as A,y as B}from"./chunk-BRZV7BFV.js";import{$f as Ae,A as de,Ah as gt,Ba as hn,Bd as vi,Da as ue,F as fn,Fc as D,G as rt,Ga as ct,Ge as Ri,Ic as _i,Ig as $i,Jc as S,Jg as Ni,Kc as wi,Lc as W,Nc as fe,Ng as Li,Nh as qi,Oh as zi,Qc as dt,Qd as bi,Rd as ki,Sd as Si,Td as Ei,Tf as C,Ub as me,Ud as Ci,Uh as wn,We as Ai,Yd as Re,Zb as fi,_ as pn,a as si,ba as xe,bg as De,bh as Pi,ca as at,eg as Mi,fe as Ii,ff as Di,ga as li,gg as Fi,ha as ui,hh as ut,ig as lt,ih as pe,jh as ji,kh as Ui,lh as Bi,mc as N,md as M,mh as Hi,nd as E,nh as Gi,oc as J,od as Z,oe as ne,oh as mt,pe as Ti,qe as xi,ra as R,sh as ft,te as ee,uh as pt,wh as ht,xa as x,yg as Oi,za as mi,zh as Wi}from"./chunk-UWS3FC4D.js";import{A as h,C as di,D as it,E as ot,I as st,t as ai,x as ci,z as p}from"./chunk-3IRCYJI5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f698608a-2f39-5972-b24b-93287af6b373")}catch{}})();var $e=class extends RangeError{code;work;minimum_tokens;constructor(t,n,r){super(t),this.name="OutputEnvelopeFitError",this.code=t,this.work=Object.freeze({...n}),this.minimum_tokens=r}};function Tn(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function uc(e,t,n,r){return t.map(([i,o])=>{if(r.render_calls>=r.max_render_calls)throw new $e("output_envelope_work_limit",r);r.render_calls+=1;let s=o(e);if(typeof s!="string")throw new TypeError("Envelope renderers must return strings");let a=n(s);if(!Number.isSafeInteger(a)||a<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:i,text:s,bytes:Buffer.byteLength(s,"utf8"),estimated_tokens:a}})}function qo(e,t,n,r){let i=t,o=Object.entries(n.renderers),s=n.estimateTokens??(a=>Oi(Buffer.byteLength(a,"utf8")));for(let a=0;a<(n.maxStabilizationPasses??16);a+=1){let c=Object.freeze({...i}),d={...n.buildEnvelope(e,c),output_fit:c},l=uc(d,o,s,r),u=Math.max(...l.map(f=>f.bytes)),m=Math.max(...l.map(f=>f.estimated_tokens));if(u===i.output_bytes&&m===i.estimated_tokens)return{envelope:d,renderings:l};i={...i,output_bytes:u,estimated_tokens:m}}throw new $e("output_envelope_unstable",r)}function th(e,t){Tn(t.tokenBudget,"tokenBudget"),Tn(t.maxRenderCalls??1e4,"maxRenderCalls"),Tn(t.maxStabilizationPasses??16,"maxStabilizationPasses");let n=t.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(t.renderers).length===0||Object.entries(t.renderers).some(([c,d])=>!c.trim()||typeof d!="function"))throw new TypeError("Envelope fitting requires named callable renderers");let r={evaluated_candidates:0,render_calls:0,max_render_calls:t.maxRenderCalls??1e4},i=[],o=[],s=c=>({version:1,policy:n,total_candidates:e.length,included_indices:Object.freeze([...c]),omitted_count:e.length-c.length,token_budget:t.tokenBudget,estimated_tokens:0,output_bytes:0}),a=qo(i,s(o),t,r);if(a.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new $e("output_envelope_infeasible",r,a.envelope.output_fit.estimated_tokens);for(let[c,d]of e.entries()){r.evaluated_candidates+=1;let l=[...i,d],u=[...o,c],m=qo(l,s(u),t,r);if(m.envelope.output_fit.estimated_tokens<=t.tokenBudget)i=l,o=u,a=m;else if(n==="prefix")break}return{rows:i,...a,complete:i.length===e.length,work:Object.freeze({...r})}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="85653664-ce87-5265-ae01-18205a85b75a")}catch{}})();var mc=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],xn=class extends Error{receipt;constructor(t,n={}){super(`Complete-list certification failed: ${t.map(i=>i.code).join(", ")}.`),this.name="PmCompleteListValidationError";let r=n.includeBody===!0;this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:`pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded${r?" --include-body":""} --json`,sdk:r?"await client.listAllComplete({ includeBody: true })":"await client.listAllComplete()"}}}};function ih(e={}){return Li({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function T(e,t,n,r){t&&e.push({code:n,message:r})}function fc(e,t){let n=P(e.completeness)?e.completeness:{};T(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),T(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;T(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),T(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=P(e.filters)?e.filters:{},s=P(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return T(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(c=>!a.has(c)),"filtered_corpus","The list did not explicitly select every lifecycle status."),T(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),T(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function pc(e,t,n){T(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),T(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=P(e.projection)?e.projection:{};T(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=P(e.omission_receipt)?e.omission_receipt:void 0;T(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),T(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),T(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function hc(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function gc(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function yc(e,t){let n=P(e.read_output)?e.read_output:void 0;T(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),T(t,n!==void 0&&hc(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),T(t,n!==void 0&&!gc(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),T(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=P(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;T(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),T(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function _c(e,t){let n=e.map(r=>P(r)&&typeof r.id=="string"?r.id.trim():"");T(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),T(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function wc(e){if(!P(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:mc[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=fc(t,n);return pc(t,r,n),yc(t,n),_c(t.items,n),{ok:n.length===0,findings:n}}function vc(e,t){return t.includeBody!==void 0?t.includeBody:P(e)&&P(e.filters)&&e.filters.include_body===!0}function bc(e,t={}){let n=wc(e);if(!n.ok)throw new xn(n.findings,{includeBody:vc(e,t)});let r=e;return{...r,complete_list:{contract_version:1,item_count:r.items.length,unique_item_id_count:new Set(r.items.map(i=>i.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function oh(e,t={}){bc(e,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function dh(e,t={}){let n=await Ho({pmRoot:x(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var zo=16;async function Ko(e,t,n){let r=R(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<zo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let c=await ye(e,s,t.id_prefix,t.item_format,r);if(!c)break;let d=await _e(c,{schema:t.schema});i.push(d.document.metadata.id),s=d.document.metadata.parent}return i}async function hh(e){await Si({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await Ko(e.pmRoot,e.settings,e.itemId)})}async function gh(e){await Ei(e)}async function yh(e){await Ci({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await Ko(e.pmRoot,e.settings,e.itemId)}:{}})}var _h={lineage_depth:zo,active_items:64,evidence_rows:32};function Vo(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c12559a3-2703-5665-9ec2-7309589be511")}catch{}})();var Ne=["priority_floor","weighted"],kc="default-weighted-v1";function Yo(e,t,n,r){let i=new Map(e.map(a=>[a.id,a.rank]));if(n!=="priority_floor"||r!==kc)return i;let o=t.in_progress_status,s=a=>E(a.item.status,t)===o?-1:a.item.priority;return e.sort((a,c)=>s(a)-s(c)||a.rank-c.rank),e.forEach((a,c)=>{a.rank=c+1}),i}function Xo(e,t,n,r){let i=e[0];if(!i)return;if(r==="priority_floor"){let a=t.get(i.item.id);return a!==void 0&&a!==1?`priority floor (relevance rank ${a})`:void 0}let o=n.in_progress_status,s=e.slice(1).filter(a=>a.item.priority<i.item.priority&&E(a.item.status,n)!==o).map(a=>a.item.priority);return s.length>0?`relevance over p${Math.min(...s)} ready work`:void 0}import{encode as Ec}from"@toon-format/toon";import{createHash as Sc}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="66022e7d-1594-5b88-a283-c64830ff0dfd")}catch{}})();function Rn(e){let t=Sc("sha256").update("[");for(let n of e)t.update(ct(n)).update("\0");return t.update("]").digest("hex")}function Le(e,t){if(t===void 0)return D();let n=Ui(t).snapshot,r=`${e}:`,i=n?.slice(r.length);if(!n?.startsWith(r)||!i||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u.test(i)||!Number.isFinite(Date.parse(i)))throw new h("Query cursor has no supported fixed-window clock.",p.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]});return i}function Pe(e,t){let n=e.map((a,c)=>({row:a,index:c})),r=pe(t.command,{query:t.query,rows_digest:Rn(e)}),i=t.after===void 0?void 0:Bi(t.after,r);if(i&&(i.after_index===void 0||i.after_id!==String(i.after_index)||i.after_index>=e.length))throw new h("Query cursor position is outside the matching window.",p.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]});let o=mt(n,{cursor:t.after,fingerprint:r,snapshot:`${t.command}:${t.clock}`,limit:t.limit??e.length,readId:({index:a})=>String(a)}),s=i?.after_index===void 0?0:i.after_index+1;return{...o,rows:o.rows.map(({row:a})=>a),count:o.rows.length,total_count:e.length,page_start:s,omitted_count:e.length-s-o.rows.length,has_more:s+o.rows.length<e.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="351df2b3-3a1a-528c-96b9-72bb3e2f27fc")}catch{}})();var An=["agenda","day","week","month"],Dn=["markdown","toon","json"],Cc=["sun","mon","tue","wed","thu","fri","sat"],Ic=365,Tc=365,ns=28,xc=1e3;function Mn(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,p.USAGE);return n}function Rc(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",p.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",p.USAGE)}return r}function rs(e,t){let n;for(let r of t){let i=si(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function Ac(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!An.includes(t)){let n=rs(t,An);throw new h(`Calendar view must be one of ${An.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Dc(e){if(!e)return;let t=e.trim().toLowerCase();if(!Dn.includes(t)){let n=rs(t,Dn);throw new h(`Calendar format must be one of ${Dn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Mh(e,t){let n=Dc(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",p.USAGE);return t.json?"json":n??"markdown"}function Mc(e,t){if(e===void 0)return;let n=M(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,p.USAGE)}return n}function Fc(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",p.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,p.USAGE);return t}function Tt(e){return new Date(e).toISOString().slice(0,10)}function is(e,t){if(!t||t==="UTC")return Tt(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return Tt(e)}function Nn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function z(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function os(e){let t=new Date(Nn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return z(t.toISOString(),r)}function Oc(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function $c(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Nc(e,t){return S(e,t)>=0?e:t}function Qo(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function Jo(e,t){e.set(t,(e.get(t)??0)+1)}function Lc(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function ss(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function as(e){return Cc[new Date(e).getUTCDay()]}function Pc(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function jc(e){let t=new Set;for(let n of e??[]){let r=Pc(n);r&&t.add(r)}return t}function Uc(e,t,n,r,i){let o=e??z(n,-(r??Tc)),s=t??z(e??n,i??Ic);return{start:o,end:S(s,o)>0?s:z(o,1)}}function Bc(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[as(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??xc,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:jc(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function xt(e,t){return S(t,e.startAt)<0?"continue":e.until&&S(t,e.until)>0||S(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,S(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function Rt(e,t){let n=as(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Hc(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(Rt(e,t)&&xt(e,t)==="stop");n+=1)t=z(t,e.interval);return e.occurrences}function Gc(e,t,n){let r=de(n),i=z(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Wc(e){let t=os(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=z(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Gc(e,r,i);if(Rt(e,o)&&xt(e,o)==="stop")return e.occurrences}}return e.occurrences}function qc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=ss(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!Rt(e,s))&&xt(e,s)==="stop")return e.occurrences}}return e.occurrences}function zc(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=ss(i,n,o,e.startDate);if(!(!s||!Rt(e,s))&&xt(e,s)==="stop")return e.occurrences}}return e.occurrences}function Kc(e,t,n,r){let i=Bc(e,t,n,r);return t.freq==="daily"?Hc(i):t.freq==="weekly"?Wc(i):t.freq==="monthly"?qc(i):zc(i)}function cs(e){return[...e].sort((t,n)=>{let r=S(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function Ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Vc(e){return e.deadline?{at:e.deadline,date:Tt(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Ln(e),item_deadline:e.deadline}:null}function Yc(e){return(e.reminders??[]).map(t=>({at:t.at,date:Tt(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Ln(e)}))}function Xc(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Qc(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Jc(e,t,n,r){let i=Lc(t.recurrence),o=Xc(t.start_at,t.end_at);return(t.recurrence?Kc(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):is(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Qc(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...Ln(e)}))}function Zc(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Vc(o):null;s&&i.push(s),n.has("reminders")&&i.push(...Yc(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Jc(o,a,t,r))}return cs(i)}function ed(e,t,n,r,i){let o=Co(t.type,n),s=t.tag?.trim().toLowerCase(),a=Eo(t.priority),c=Mc(t.status,r),d=t.assignee?.trim(),l=Fc(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(d&&(d.toLowerCase()==="none"||d.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',p.USAGE);if(d!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",p.USAGE);return e.filter(f=>td(f,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:c,assigneeFilter:d,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function td(e,t){return nd(e,t)&&rd(e,t)&&vt(e,t.runtimeFieldFilters)}function nd(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function rd(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function id(e,t,n){return!(t&&S(e.at,t)<0||n&&S(e.at,n)>=0)}function Fn(e,t,n){return e.trim().toLowerCase()==="today"?Nn(t):W(e,new Date(t),n)}function od(e,t,n){let r=t.date?Fn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?Fn(t.from,n,"--from"):void 0,a=t.to?Fn(t.to,n,"--to"):void 0;if(s&&a&&S(s,a)>=0)throw new h("Calendar --from must be before --to",p.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",p.USAGE);if(e==="agenda")return sd(r,t,n,i,o,s,a);if(e==="day"){let d=Nn(r);return On(r,n,i,o,d,z(d,1))}if(e==="week"){let d=os(r);return On(r,n,i,o,d,z(d,7))}let c=Oc(r);return On(r,n,i,o,c,$c(r))}function sd(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",p.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function On(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Nc(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function ad(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:cs(r)}))}function cd(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let c of e)t.add(c.item_id),Jo(n,c.item_type),Jo(r,c.item_status),c.kind==="deadline"?i+=1:c.kind==="reminder"?o+=1:(s+=1,c.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:Qo(n),by_status:Qo(r),recurring_events:a}}function dd(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function ds(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function $n(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function ld(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===is(e.event_end,e.event_timezone)?ds(e.event_end,e.event_timezone):e.event_end:null}function ud(e){let t=`${ds(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=ld(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Zo(e,t){if(t&&t.length>0){e.push("### warnings");for(let n of t)e.push(`- ${n}`);e.push("")}}function Fh(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${dd(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- matching-events: ${e.total_count}; returned: ${e.count}; remaining: ${e.omitted_count} (summary: ${e.summary_scope})`),e.next_cursor&&t.push(`- continue: repeat the same query with --after ${e.next_cursor}`),t.push(`- by-kind: ${$n(e.summary.by_kind)}`),t.push(`- by-type: ${$n(e.summary.by_type)}`),t.push(`- by-status: ${$n(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push(e.total_count===0?"No calendar events matched the selected filters.":"No calendar events returned on this page. Repeat the same query with --limit 1 or greater to retrieve matching events."),t.push(""),Zo(t,e.warnings),es(t.join(`
|
|
2
2
|
`));for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${ud(r)}`);t.push("")}return Zo(t,e.warnings),es(t.join(`
|
|
3
3
|
`))}function Oh(e){return Ec(e)}function es(e){let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
4
|
`;)t-=1;return e.slice(0,t)}function md(e){let t=Le("calendar",e.after),n=Ac(e.view),r=od(n,e,t),i=q(e.limit),o=Rc(e.include),s=Mn(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=Mn(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),c=Mn(e.occurrenceLimit,"Calendar occurrence limit");if(c!==void 0&&c<1)throw new h("Calendar occurrence limit must be >= 1",p.USAGE);let d=o.has("events")&&!o.has("deadlines")&&!o.has("reminders"),l=e.to!==void 0||s!==void 0||a!==void 0||c!==void 0,u=d&&!l;return{nowValue:t,view:n,rangeBounds:r,limit:i,includeSources:o,occurrenceLimit:c,recurrenceLookaheadDays:u?ns:s,recurrenceLookbackWindowDays:u&&a===void 0?0:a,eventsOnlyCapApplied:u}}function fd(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${ns}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function ts(e,t){return{type:e.type??null,tag:e.tag??null,priority:e.priority??null,status:e.status??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,runtime_filters:t,limit:e.limit??null,include:e.include??null,full_period:e.fullPeriod===!0?"true":null,recurrence_lookahead_days:e.recurrenceLookaheadDays??null,recurrence_lookback_days:e.recurrenceLookbackDays??null,occurrence_limit:e.occurrenceLimit??null}}function pd(e,t){return{start:t.start??null,end:t.end??null,period_start:t.periodStart??null,period_end:t.periodEnd??null,full_period:t.fullPeriod,past:e.past===!0,from:e.from??null,to:e.to??null}}async function ls(e,t){let n=x(process.cwd(),t.path);await B(n);let r=md(e),i=await A(n),o=N(i.schema),s=J(i.schema),a=wt(e,s,"calendar"),c=R(i,C()),d=[];fd(d,r.eventsOnlyCapApplied);let l=await we(n,i.item_format,c.type_to_folder,d,i.schema),u=ed(l,e,c,o,a),m=Uc(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),f=Zc(u,m,r.includeSources,r.occurrenceLimit).filter(I=>id(I,r.rangeBounds.start,r.rangeBounds.end)),{rows:g,...y}=Pe(f,{command:"calendar",after:e.after,clock:r.nowValue,limit:r.limit,query:{pmRoot:n,view:r.view,range:r.rangeBounds,filters:{...ts(e,a),limit:void 0},recurringWindow:m,occurrenceLimit:r.occurrenceLimit}}),_=ad(g),w=[...new Set(d)].sort((I,v)=>I.localeCompare(v));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:pd(e,r.rangeBounds),filters:ts(e,a),...y,summary_scope:"returned_rows",summary:cd(g),events:g,days:_,...w.length>0?{warnings:w}:{}}}import jd from"node:fs/promises";import Es from"node:path";import{createHash as ps}from"node:crypto";import K from"node:fs/promises";import hd from"node:os";import Mt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0a7f878e-2354-5f40-9217-81b86d7b5423")}catch{}})();var gd="runtime/history-stream-summary.json",hs=1,us=64,yd=2000000000n,_d=500,wd=_d,vd=()=>Date.now(),bd=()=>kd(Sd(process,hd.userInfo));function kd(e){return e===void 0?void 0:ps("sha256").update(e).digest("hex").slice(0,16)}function Sd(e,t){try{if(e.geteuid&&e.getegid&&e.getgroups){let r=[...new Set(e.getgroups())].sort((i,o)=>i-o);return`uid:${e.geteuid()}:gid:${e.getegid()}:groups:${r.join(",")}`}let{username:n}=t();return n.length>0?`user:${n}`:void 0}catch{return}}var Ed=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;function Cd(e,t){return t===2?e%4===0&&e%100!==0||e%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function gs(e){if(typeof e!="string"||!Ed.test(e))return!1;let t=Number(e.slice(0,4)),n=Number(e.slice(5,7)),r=Number(e.slice(8,10));return n>=1&&n<=12&&r>=1&&r<=Cd(t,n)&&Number(e.slice(11,13))<24&&Number(e.slice(14,16))<60&&Number(e.slice(17,19))<60}function Id(e){let t=null,n=null,r=!1;for(let i of e){let o=typeof i=="object"&&i!==null?i.ts:void 0;if(!gs(o)){r=!0;continue}(t===null||o<t)&&(t=o),(n===null||o>n)&&(n=o)}return{count:e.length,oldest:t,newest:n,irregular:r}}function Td(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}function Dt(e){return Mt.join(e,...gd.split("/"))}function ys(e,t){if(!(!e.isFile()||e.ino===0n||t===void 0))return{size:e.size,signature:[e.dev,e.ino,e.size,e.mtimeNs,e.ctimeNs,t].join(":"),changedAtNs:e.mtimeNs>e.ctimeNs?e.mtimeNs:e.ctimeNs}}async function ms(e,t,n){let r=new Map;for(let i=0;i<t.length;i+=us){let o=t.slice(i,i+us);(await Promise.all(o.map(s=>K.stat(Mt.join(e,s),{bigint:!0}).catch(()=>{})))).forEach((s,a)=>{let c=s===void 0?void 0:ys(s,n);c!==void 0&&r.set(o[a],c)})}return r}function fs(e){return e===null||gs(e)}function xd(e){return e.oldest===null!=(e.newest===null)?!1:e.count===0?e.oldest===null&&!e.irregular:e.oldest===null?e.irregular:e.oldest<=e.newest}function Rd(e){if(!Array.isArray(e)||e.length!==5)return;let[t,n,r,i,o]=e;if(typeof t!="string"||!Number.isSafeInteger(n)||n<0||!fs(r)||!fs(i)||typeof o!="boolean")return;let s={count:n,oldest:r,newest:i,irregular:o};return xd(s)?{signature:t,bounds:s}:void 0}function _s(e){return 4096+e*1024}function Ad(e,t,n){return!e.isFile()||e.nlink!==1||e.size>_s(t)?!1:n===void 0||e.uid===n&&(e.mode&18)===0}async function Pn(e){return(await K.lstat(Mt.join(e,"runtime"))).isDirectory()}async function ws(e){try{return!(await K.lstat(Dt(e))).isFile()}catch{return!1}}async function Dd(e){try{if(!await Pn(e))return!0}catch{return!1}return ws(e)}async function Md(e,t){if(!await Pn(e))throw new Error("runtime directory is redirected");if((await K.lstat(Dt(e))).isSymbolicLink())throw new Error("history stream summary is a link");let n=await K.open(Dt(e),K.constants.O_RDONLY|K.constants.O_NOFOLLOW|K.constants.O_NONBLOCK);try{let r=await n.stat();if(!Ad(r,t,process.geteuid?.()))throw new Error("history stream summary is not a trusted file");return await Fd(n,_s(t),r.size)}finally{await n.close()}}async function Fd(e,t,n){let r=Buffer.alloc(Math.min(Math.max(n,0),t)+1),i=0;for(;;){if(i===r.length){let s=Buffer.alloc(Math.min(r.length*2,t+1));r.copy(s,0,0,i),r=s}let{bytesRead:o}=await e.read(r,i,r.length-i,i);if(o===0)break;if(i+=o,i>t)throw new Error("history stream summary grew past its size cap")}return r.subarray(0,i).toString("utf8")}async function Od(e,t){let n;try{n=await Md(e,t)}catch(r){return{state:ot(r)?"missing":"invalid",streams:new Map}}try{let r=JSON.parse(n);if(r.version!==hs||typeof r.streams!="object"||r.streams===null||Array.isArray(r.streams)||r.checksum!==vs(r.streams))return{state:"invalid",streams:new Map};let i=new Map;for(let[o,s]of Object.entries(r.streams)){let a=Rd(s);if(a===void 0)return{state:"invalid",streams:new Map};i.set(o,a)}return{state:"loaded",streams:i}}catch{return{state:"invalid",streams:new Map}}}function $d(e){let t=[...e.entries()].sort(([r],[i])=>r<i?-1:1),n={};for(let[r,{signature:i,bounds:o}]of t)n[r]=[i,o.count,o.oldest,o.newest,o.irregular];return`${JSON.stringify({version:hs,checksum:vs(n),streams:n})}
|
|
@@ -10,4 +10,4 @@ import{E as Ho,G as Go,a as q,b as Eo,c as Co,e as Oe,f as Io,g as To,h as xo,i
|
|
|
10
10
|
`)}catch{}}function Ja(e,t){return[`vector_index_stale:${e}`,`vector_index_recovery:${t.args.join(" ")}`,...t.follow_up_args?[`vector_index_recovery_follow_up:${t.follow_up_args.join(" ")}`]:[]]}function an(e,t,n,r){if(!t.active)throw new h(`Search mode '${e}' requires a configured embedding provider in settings.providers.openai or settings.providers.ollama`,p.USAGE);if(!n.active&&!r)throw new h(`Search mode '${e}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,p.USAGE);return{provider:t.active,vectorStore:n.active??null}}var U=at;function Je(e){let t=C(),n=Ki(t,e);if(!n)return null;let r=n.runtime_definition??n.definition,i=r.query,o=r.queryExpansion??r.query_expansion,s=r.rerank,a=U(r.name)??U(n.definition.name)??e;if(!a)return null;let c={providerName:a,...typeof i=="function"?{query:i}:{},...typeof o=="function"?{queryExpansion:o}:{},...typeof s=="function"?{rerank:s}:{}};return!c.query&&!c.queryExpansion&&!c.rerank?null:c}function Nr(e){let t=U(e.search?.provider),n=Je(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function Lr(e){let t=C(),n=U(e.vector_store?.adapter),r=Vi(t,n);if(!r)return null;let i=r.runtime_definition??r.definition,o=i.query;if(typeof o!="function")return null;let s=i.upsert;return{adapterName:U(i.name)??U(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function Pr(e,t,n){let r=Array.isArray(t)?t:t?.hits;if(!Array.isArray(r))throw new h(`Extension search provider "${e}" must return an array of hits or { hits: [...] }`,p.GENERIC_FAILURE);let i=new Set,o=[];for(let s of r){if(typeof s!="object"||s===null)continue;let a=U(s.id),c=s.score;if(!a||typeof c!="number"||!Number.isFinite(c)||i.has(a))continue;let d=n.get(a);if(!d)continue;let l=s.matched_fields,u=Array.isArray(l)&&l.every(m=>typeof m=="string")?[...new Set(l.map(m=>m.trim()).filter(m=>m.length>0))].sort((m,f)=>m.localeCompare(f)):[`provider:${e}`];i.add(a),o.push({item:d.metadata,score:c,matched_fields:u})}return o}function jr(e,t){let n=[],r=new Map;for(let i of e){if(r.has(i.id))continue;let o=t.get(i.id);o&&(r.set(i.id,i.score),n.push({item:o.metadata,score:i.score,matched_fields:["semantic"]}))}return{semanticHits:n,semanticScores:r}}function rn(e,t){let n=t.filter(c=>c.exact_id_match===!0);if(n.length===0)return e;let r=new Set(n.map(c=>c.item.id)),i=e.filter(c=>!r.has(c.item.id)),o=i.reduce((c,d)=>Math.max(c,d.score),0),s=n.sort((c,d)=>d.score-c.score),a=o+s.length+1;return[...s.map((c,d)=>({...c,score:a-d,matched_fields:["id"]})),...i]}function cn(e,t,n,r,i="semantic"){let o=new Map(n.map(u=>[u.item.id,u.score])),s=new Map(n.map(u=>[u.item.id,u.matched_fields])),a=Qe(t),c=Qe(o),d=new Set([...t.keys(),...o.keys()]),l=1-r;return[...d].map(u=>{let m=e.get(u),f=a.get(u)??0,g=c.get(u)??0,y=f*r+g*l;if(y<=0)return null;let _=new Set;t.has(u)&&_.add(i);for(let w of s.get(u)??[])_.add(w);return{item:m.metadata,score:y,matched_fields:[..._].sort((w,I)=>w.localeCompare(I))}}).filter(u=>u!==null)}function Ur(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function Br(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:ja(ao(s,{fields:e.corpusFields}))})),n=La(t),r=Pa(n,kr(e.query),e.bm25Params),i=new Map(e.filteredDocuments.map(s=>[s.metadata.id,s]));if(e.requestedMode==="semantic"){let s=[...r].map(([a,c])=>({item:i.get(a).metadata,score:c,matched_fields:["bm25"]}));return rn(s,e.keywordHits)}let o=cn(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return rn(o,e.keywordHits)}function Hr(e){let t=new Map;for(let r of e)for(let i of r){let o=t.get(i.id);(!o||i.score>o.score)&&t.set(i.id,i)}let n=[...t.values()];return n.sort((r,i)=>r.score!==i.score?i.score-r.score:r.id.localeCompare(i.id)),n}function Gr(e){let t=e.metadata,n=Array.isArray(t?.tags)?t.tags.join(" "):"";return[t?.title,t?.description,t?.type,t?.status,n,e.body].map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0).join(`
|
|
11
11
|
`)}async function Lp(e,t){let n=e.queryExpansion.enabled?Ba(t,e.queryExpansion.max_queries):[t],r=n.length>0?n:[t];if(!e.queryExpansion.enabled)return r;if(e.queryExpansionExtension?.expand)try{let i=await Promise.resolve(e.queryExpansionExtension.expand({query:t,mode:e.requestedMode,settings:e.settings}));return Ga(r,Ha(i),e.queryExpansion.max_queries)}catch{return e.warnings.push(`search_query_expansion_provider_failed:${e.queryExpansionExtension.providerName}:using_builtin`),r}return e.queryExpansion.provider&&e.queryExpansion.provider!=="openai"&&e.queryExpansion.provider!=="ollama"&&e.warnings.push(`search_query_expansion_provider_unavailable:${e.queryExpansion.provider}:using_builtin`),r}async function Pp(e,t,n,r){if(e.extensionVectorAdapter?.query)try{return await Promise.resolve(e.extensionVectorAdapter.query({vector:t,limit:n,settings:e.settings}))}catch(i){if(!e.vectorStore)throw new h(`Extension vector adapter query failed and no built-in fallback store is configured (${i instanceof Error?i.message:String(i)})`,p.GENERIC_FAILURE);return e.warnings.push(`search_vector_adapter_failed:${e.extensionVectorAdapter.adapterName}:using_builtin`),await kn(e.vectorStore,t,n,r)}if(e.vectorStore)return await kn(e.vectorStore,t,n,r);throw new h("Semantic search requires either a configured vector store or an extension vector adapter query handler",p.USAGE)}function jp(e,t,n){return[...e].sort((r,i)=>r.score!==i.score?i.score-r.score:r.item.id.localeCompare(i.item.id)).slice(0,n).map(r=>{let i=t.get(r.item.id);return i?{hit:r,text:Gr(i)}:null}).filter(r=>r!==null)}async function Up(e,t,n){if(!e.rerankExtension?.rerank)return null;try{let r=await Promise.resolve(e.rerankExtension.rerank({query:t,mode:"hybrid",model:e.rerank.model,top_k:e.rerank.top_k,settings:e.settings,candidates:n.map(o=>({id:o.hit.item.id,text:o.text,score:o.hit.score}))})),i=za(r);return i.length>0?new Map(i.map(o=>[o.id,o.score])):(e.warnings.push(`search_rerank_provider_invalid_response:${e.rerankExtension.providerName}:using_builtin`),null)}catch{return e.warnings.push(`search_rerank_provider_failed:${e.rerankExtension.providerName}:using_builtin`),null}}async function Bp(e,t,n){let r=await Up(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await Va(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function Hp(e,t){let n=new Set(t.keys()),r=e.map(i=>{let o=t.get(i.item.id);if(o===void 0)return i;let s=new Set(i.matched_fields);return s.add("rerank"),{...i,score:o,matched_fields:[...s].sort((a,c)=>a.localeCompare(c))}});return r.sort((i,o)=>{let s=n.has(i.item.id),a=n.has(o.item.id);return s!==a?s?-1:1:i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)}),r}async function Gp(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=jp(n,r,e.rerank.top_k),o=await Bp(e,t,i);return o&&o.size>0?Hp(n,o):n}async function Wr(e){let t=Math.max(e.limit??e.maxResults,e.maxResults),n=e.embeddingTimeoutMs!==void 0?{timeout_ms:e.embeddingTimeoutMs}:{},r=e.vectorQueryTimeoutMs!==void 0?{timeout_ms:e.vectorQueryTimeoutMs}:{},i=e.query.trim(),o=await Lp(e,i),s=await kt(e.provider,o,n),a=await Promise.all(s.map(async g=>await Pp(e,g,t,r))),c=Hr(a),d=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:l,semanticScores:u}=jr(c,d),m=u.size;if(e.requestedMode==="semantic")return{hits:rn(l,e.keywordHits),vectorMatchCount:m};let f=await Gp(e,i,cn(d,u,e.keywordHits,e.hybridSemanticWeight),d);return{hits:rn(f,e.keywordHits),vectorMatchCount:m}}function Za(e){let t=Je(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function ec(e){let t=Je(U(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}import dn from"node:fs/promises";import qr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de9a1cbd-f277-52ef-adc6-66225f2d2f4f")}catch{}})();function zr(e){let t=(e.files??[]).map(s=>({scope:s.scope,path:s.path.trim()})),n=(e.docs??[]).map(s=>({scope:s.scope,path:s.path.trim()})),r=(e.tests??[]).filter(s=>typeof s.path=="string"&&s.path.trim().length>0).map(s=>({scope:s.scope,path:s.path.trim()})),i=[...t,...n,...r].filter(s=>s.path.length>0).sort((s,a)=>s.scope.localeCompare(a.scope)||s.path.localeCompare(a.path)),o=new Map;for(let s of i)o.set(`${s.scope}:${s.path}`,s);return[...o.values()]}async function tc(e){let t=qr.resolve(e);try{let n=await dn.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function Kr(e,t){let[n,r]=await Promise.all([tc(e),tc(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function Vr(e,t){let n=zr(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=qr.resolve(o.resolved,i.path);if(!pn(o.resolved,s))continue;let a;try{a=await dn.realpath(s)}catch{continue}if(pn(o.realpath,a))try{await Ae({path:s,scope:i.scope}),r.push(await dn.readFile(s,"utf8"))}catch{}}return r.join(`
|
|
12
12
|
`)}async function Yr(e,t,n,r){let i=le(C()),o=async(d,l,u)=>{let m=async(f,g)=>{await Ae({path:f,scope:"project"});let y=await dn.readFile(f,"utf8");return vi(y,{format:g,schema:r,extensionFieldNames:i,onWarning:_=>s.push(_)}).body};try{return await m(l,u)}catch{let f=u==="toon"?"json_markdown":"toon",g=hn(e,d.type,d.id,f,n);try{return await m(g,f)}catch{return s.push(`item_list_item_read_failed:${qr.relative(e,g)}`),""}}},s=[],a=await to(e,t,n,s,r),c=[];if(a.length===0){let d=await no(e,t,n,s,r);for(let l of d){let u=hn(e,l.type,l.id,t,n),m=await o(l,u,t);c.push({metadata:l,body:m})}return{documents:c,warnings:[...new Set(s)].sort((l,u)=>l.localeCompare(u))}}for(let d of a){if(typeof d.body=="string"){c.push({metadata:d.metadata,body:d.body});continue}let l=await o(d.metadata,d.item_path,d.item_format);c.push({metadata:d.metadata,body:l})}return{documents:c,warnings:[...new Set(s)].sort((d,l)=>d.localeCompare(l))}}async function nc(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await Kr(i,mi(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await Vr(a,o)]));for(let[a,c]of s)r.set(a,c);return r}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="17122985-4157-5732-9142-444327cb273d")}catch{}})();var rc=["tag","status","type","priority"];function Xr(e){let t={},n=[];for(let r of e.split(/\s+/).filter(i=>i.length>0)){let i=r.indexOf(":"),o=i>0?r.slice(0,i).toLowerCase():"",s=i>0?r.slice(i+1):"",a=rc.includes(o)?o:void 0;if(a&&s.length>0&&t[a]===void 0){t[a]=s;continue}n.push(r)}return{residualQuery:n.join(" "),inlineFilters:t}}function Qr(e,t,n){let r={...e};for(let i of rc){let o=t[i];if(o!==void 0){if(at(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function ic(e,t){let n=[],r=Xr(e),i=Object.keys(r.inlineFilters).length>0;if(i&&r.residualQuery.trim().length===0)throw new h("Inline field:value tokens consumed the entire query, leaving no search terms.",p.USAGE,{examples:["pm search auth tag:area:search","pm list --tag area:search --status open"],nextSteps:["Add keyword terms alongside the inline filters, or use pm list for pure tag/status/type/priority filtering."]});let o=i?r.residualQuery:e,s=Qr(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:Qt(s.includeLinked),titleExact:Qt(s.titleExact),phraseExact:Qt(s.phraseExact),matchMode:Ma(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:Fa(s.minScore),countOnly:s.count===!0,tokens:Zt(o),normalizedQuery:j(o),limit:ge(s.limit),projection:Jt(s,e),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}function oc(e){if(e.after!==void 0&&e.count===!0)throw new h("Search --after cannot be combined with --count.",p.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5e71457b-904d-56d6-b205-1db9c71dfd08")}catch{}})();function Zr(e,t,n,r,i,o,s,a,c,d,l,u,m,f){let g=m?{total:0,count_only:!0}:{};if(d.mode==="compact"&&r.compact===!0){let _=oe({mode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,runtimeFieldFilters:u});return{query:e.trim(),mode:t,...ii(f),items:[],count:0,...g,filters:_,...l.length>0?{warnings:l}:{}}}let y=d.mode==="full"?null:[...d.fields];return{query:e.trim(),mode:t,mode_source:f,items:[],count:0,...g,filters:ri({effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,queryExpansion:a,rerank:c,runtimeFieldFilters:u??{}},d),projection:{mode:d.mode,fields:y},now:D(),...l.length>0?{warnings:l}:{}}}function ei(e,t){let n=t.trim();if(n.length===0)return null;if(n==="score")return e.score;if(n==="matched_fields")return e.matched_fields;if(n.startsWith("item.")){let o=n.slice(5);return o.length===0?null:e.item[o]??null}let r=e,i=e.item;return Object.prototype.hasOwnProperty.call(i,n)?i[n]??null:Object.prototype.hasOwnProperty.call(r,n)?r[n]??null:null}function ti(e,t){return t.mode==="full"?e.map(({matched_all_terms:n,exact_id_match:r,...i})=>i):e.map(n=>{let r={};for(let i of t.fields)r[i]=ei(n,i);return r})}function ni(e,t){return Zr(e.query,e.effectiveMode,e.matchMode,e.options,e.includeLinked,e.scoreThreshold,e.hybridSemanticWeight,e.queryExpansion,e.rerank,e.projection,e.warnings,e.runtimeFieldFilters,t,e.modeSource)}function sc(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return Jr({query:e.query.trim(),mode:e.effectiveMode,...ii(e.modeSource),items:[],count:t,total:t,count_only:!0,filters:oe({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let n=e.projection.mode==="full"?null:[...e.projection.fields];return Jr({query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:[],count:t,total:t,count_only:!0,filters:ri(e,e.projection),projection:{mode:e.projection.mode,fields:n},now:D()},e.warnings)}function ri(e,t){let n={matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters};return t.mode==="fields"?oe({...n,mode:e.effectiveMode}):en({...n,effectiveMode:e.effectiveMode,queryExpansion:e.queryExpansion,rerank:e.rerank})}function ii(e){return e==="settings"?{mode_source:e}:{}}function Jr(e,t){return t.length===0?e:{...e,warnings:t}}function Ze(e,t){return t?{...e,workspace_memory:t}:e}function ac(e,t,n){if(!e.highlight)return{hits:n,projection:e.projection};let r=new Map(t.map(o=>[o.metadata.id,o])),i=n.map(o=>({...o,highlights:nn(r.get(o.item.id),o.matched_fields,e.tokens)}));return e.projection.mode==="full"||e.projection.fields.includes("highlights")?{hits:i,projection:e.projection}:{hits:i,projection:{mode:e.projection.mode,fields:[...e.projection.fields,"highlights"]}}}function cc(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return Jr({query:e.query.trim(),mode:e.effectiveMode,...ii(e.modeSource),items:t,count:t.length,...s,...o,filters:oe({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let a=i.mode==="full"?null:[...i.fields];return{query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:t,count:t.length,...s,...o,filters:ri(e,i),projection:{mode:i.mode,fields:a},now:D(),...e.warnings.length>0?{warnings:e.warnings}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3bfd872f-6ed7-551c-a027-3748493de3e9")}catch{}})();var Rv={applyFilters:xr,applyExactQueryFilters:Tr,applyInlineQueryFilters:Qr,buildHitHighlights:nn,buildVerboseSearchFilters:en,buildExplicitSemanticFallbackWarning:Or,buildCompactSearchFilterSummary:oe,buildHybridLexicalScore:Fr,buildRerankCorpus:Gr,buildSemanticHits:jr,classifyImplicitSemanticFallbackReason:sn,collectErrorCauseCodes:on,collectExactPhraseFields:Cr,collectLinkedPaths:zr,combineHybridHits:cn,computeBuiltInBm25Hits:Br,computeSemanticOrHybridHits:Wr,resolveBuiltInBm25Mode:Ur,countOccurrences:tn,dependencyEntries:Xe,documentContainsExactPhrase:Ir,emptySearchResult:Zr,highlightFieldSnippet:Ar,loadDocuments:Yr,markTokenRuns:Rr,parseInlineQueryFilters:Xr,maybeEmitVectorIndexStaleWarning:$r,loadLinkedCorpus:Vr,mergeVectorHitsById:Hr,normalizeExtensionProviderHits:Pr,normalizeScoreMap:Qe,parseProjectionConfig:Jt,parseTimestampWindow:ie,parseTokens:Zt,projectSearchHits:ti,readSearchFieldValue:ei,requireSemanticDependencies:an,resolveExtensionSearchProvider:Nr,resolveExtensionSearchProviderByName:Je,resolveExtensionVectorAdapter:Lr,resolveLinkedCorpusRoots:Kr,scoreDocument:Dr,sortHits:Mr,stringArray:Ee,textEntries:V,validateSearchProjectionFields:hr};async function Wp(e,t){let n=x(process.cwd(),t.path);await B(n);let r=await A(n),i=eo(r).settings,o=N(i.schema),s=J(i.schema);hr(e.projection,s,e.query);let a=wt(e.options,s,"search"),c=R(i,C()),d=oo(i),l=co(i,n),u=Nr(i),m=Lr(i),f=Da(e.options.semanticWeight),g=Wa(i,d.active?.name??null),y=qa(i,d.active?.model??U(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:c,maxResults:gr(i),scoreThreshold:e.minScoreOverride??_r(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:f,hybridSemanticWeight:f??wr(i),tuning:vr(i),providerResolution:d,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m,bm25Mode:Ur({configuredProvider:U(i.search?.provider),hasEmbeddingProvider:d.active!==null,hasExtensionSearchProvider:u!==null}),queryExpansion:g,queryExpansionExtension:Za(g),rerank:y,rerankExtension:ec(i),...qp({requested:e.options.mode,settings:i,configuredProvider:r.search?.provider??null,providerResolution:d,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m})}}function qp(e){let t=io(e.providerResolution.active?.name,e.configuredProvider)==="configured"&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null),n=e.extensionSearchProvider!==null||t,r=yr({requested:e.requested,settings:e.settings,semanticRunnable:n});return{effectiveMode:r.mode,modeSource:r.source}}async function zp(e,t){let n=await Yr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=_t(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=xo(t.statusRegistry),o=xr(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:Tr(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function Kp(e,t,n){let r=await nc(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>Fr(o,e.tokens,e.normalizedQuery,e.includeLinked,r,t.tuning,t.settings.id_prefix,i)).filter(o=>o!==null).filter(o=>e.matchMode!=="and"||o.matched_all_terms===!0)}async function Vp(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=Br({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:so(t.settings),bm25Params:Ua(t.settings),hybridSemanticWeight:t.hybridSemanticWeight});return t.bm25Mode==="auto-fallback"&&i.push(`search_${t.effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`),o}async function Yp(e,t,n,r){if(!t.extensionSearchProvider)return null;let i=t.providerResolution.active!==null&&(t.vectorResolution.active!==null||t.extensionVectorAdapter!==null);try{let o=await Promise.resolve(t.extensionSearchProvider.query({query:e.query,mode:t.effectiveMode,tokens:e.tokens,options:e.options,settings:t.settings,documents:n}));return Pr(t.extensionSearchProvider.providerName,o,r)}catch(o){if(!i)throw new h(`Extension search provider "${t.extensionSearchProvider.providerName}" failed: ${o instanceof Error?o.message:String(o)}`,p.GENERIC_FAILURE);return null}}function Xp(e,t,n,r){return t.vectorMatchCount>0?t.hits:(r.push(`search_${e}_degraded:no_vector_matches:results_are_lexical`),e==="semantic"?n:t.hits)}async function Qp(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await $r(e.pmRoot,n,r),e.extensionSearchProvider||an(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function Jp(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,c=await Vp(t,n,r,i,o),d=n.effectiveMode;if(c!==null||d==="keyword")return{effectiveMode:n.effectiveMode,hits:c??a};try{if(await Qp(n,d,r,o,s),r.length===0||t.limit===0)return{effectiveMode:n.effectiveMode,hits:[]};let l=new Map(r.map(u=>[u.metadata.id,u]));if(a=await Yp(t,n,r,l)??a,a===i){let{provider:u,vectorStore:m}=an(d,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),f=await Wr({requestedMode:d,query:t.query,filteredDocuments:r,keywordHits:i,hybridSemanticWeight:n.hybridSemanticWeight,limit:t.limit,maxResults:n.maxResults,provider:u,vectorStore:m,extensionVectorAdapter:n.extensionVectorAdapter,queryExpansion:n.queryExpansion,queryExpansionExtension:n.queryExpansionExtension,rerank:n.rerank,rerankExtension:n.rerankExtension,warnings:o,settings:n.settings});a=Xp(d,f,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(l){return o.push(Or(n.effectiveMode,l)),{effectiveMode:"keyword",hits:i}}}function dc(e){e.searchOptions.after!==void 0&&Hi(e.searchOptions.after,br(e))}async function Av(e,t,n){oc(t);let r=ic(e,t),i=await Wp(r,n),o=await zp(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await Bt(o.allDocuments.map(k=>k.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:D()});s.push(...a.warnings);let c=Xs(a,r.query);i.effectiveMode==="hybrid"&&i.semanticWeightProvided&&i.semanticWeightOverride===void 0&&s.push("search_hybrid_semantic_weight_override_invalid:using_settings_default");let d={query:r.query,modeSource:i.modeSource,matchMode:r.matchMode,options:r.options,includeLinked:r.includeLinked,titleExact:r.titleExact,phraseExact:r.phraseExact,scoreThreshold:i.scoreThreshold,hybridSemanticWeight:i.hybridSemanticWeight,queryExpansion:i.queryExpansion,rerank:i.rerank,projection:r.projection,warnings:s,runtimeFieldFilters:i.runtimeFieldFilters};if(i.effectiveMode==="keyword"&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return dc({query:r.query,mode:i.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),Ze(ni({...d,effectiveMode:i.effectiveMode},r.countOnly),c);let l=await Kp(r,i,o.filteredDocuments),u=await Jp({prepared:r,runtime:i,filteredDocuments:o.filteredDocuments,keywordHits:l,warnings:s,modeWasExplicit:r.modeWasExplicit});if(u.effectiveMode!=="keyword"&&u.hits.length===0&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return dc({query:r.query,mode:u.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),Ze(ni({...d,effectiveMode:u.effectiveMode},r.countOnly),c);let m=u.hits.filter(k=>k.exact_id_match===!0||k.score>=i.scoreThreshold),f=Mr(m,i.statusRegistry),g=f.length,y=Oa({pmRoot:i.pmRoot,sorted:f,query:r.query,mode:u.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),_={...d,effectiveMode:u.effectiveMode};if(r.countOnly)return Ze(sc(_,g),c);let{hits:w,projection:I}=ac(r,o.filteredDocuments,y.limited),v=ti(w,I);return Ze(cc(_,v,g,y.limited.length,I,y.pageExtras),c)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f303192a-cac2-588b-b988-e3a8132f4199")}catch{}})();var lc=["ndcg","mrr","precision","recall"];function Zp(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Eval minimum must be an object of metric floors");let t={};for(let[n,r]of Object.entries(e)){if(!lc.some(i=>i===n))throw new TypeError(`Unknown eval minimum metric: ${n}`);if(typeof r!="number"||!Number.isFinite(r)||r<0||r>1)throw new TypeError(`Eval minimum.${n} must be a finite number in [0, 1]`);t[n]=r}return t}function Mv(e,t){let n=Zp(t),r=[];for(let i of lc){let o=n[i];if(o===void 0)continue;let s=e[i];!Number.isFinite(s)||s<0||s>1?r.push(`${i}:invalid`):s<o&&r.push(`${i}:${s}<${o}`)}return r}export{$e as a,th as b,mc as c,xn as d,ih as e,wc as f,bc as g,oh as h,dh as i,jy as j,Ko as k,hh as l,gh as m,yh as n,_h as o,Vo as p,da as q,Ne as r,Mh as s,Fh as t,Oh as u,ls as v,Ft as w,Pd as x,Ot as y,Nt as z,og as A,sg as B,Os as C,zn as D,Pt as E,hl as F,Ps as G,vl as H,jt as I,bl as J,kl as K,Il as L,Tl as M,yg as N,xl as O,js as P,Kn as Q,Vn as R,Pl as S,Wl as T,xg as U,Yn as V,Xn as W,Ut as X,Yl as Y,Zl as Z,Bt as _,su as $,Ys as aa,au as ba,Xs as ca,cu as da,hu as ea,Ge as fa,ay as ga,tr as ha,_u as ia,wu as ja,rr as ka,re as la,or as ma,sr as na,ar as oa,be as pa,ze as qa,zt as ra,cy as sa,Em as ta,dy as ua,Lm as va,Fy as wa,Oy as xa,$y as ya,Ny as za,Ly as Aa,qy as Ba,zy as Ca,Ca as Da,Ia as Ea,Ta as Fa,w_ as Ga,v_ as Ha,D_ as Ia,gr as Ja,yr as Ka,_r as La,wr as Ma,vr as Na,br as Oa,Oa as Pa,oe as Qa,en as Ra,on as Sa,sn as Ta,Qa as Ua,Ja as Va,Rv as Wa,Av as Xa,lc as Ya,Zp as Za,Mv as _a};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-USPYKWQG.js.map
|