@unbrained/pm-cli 2026.10.26 → 2026.10.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +16 -1
- package/dist/cli/register-list-query.js +5 -5
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-MWCG25PO.js → chunk-2XUDAQK5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Y42DYMZX.js → chunk-32QK43XG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-T7T4WLUY.js → chunk-34OQP43K.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-ZLVFUZI4.js → chunk-5PTMQBKJ.js} +30 -30
- package/dist/cli-bundle/chunks/{chunk-NGKTROAO.js → chunk-EKV5GP6P.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-OCDRHIVQ.js → chunk-F26MRQZY.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-XAIR53QZ.js → chunk-H434DKYU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TGOG5BFM.js → chunk-HIX2OMEZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7UDQAINZ.js → chunk-NNIYQHYT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-O3LPT34G.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-Z35XAHUN.js → chunk-OQOEBWHU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UF6EXZSP.js → chunk-Q55KZDNF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VS2IIV3F.js → chunk-QQYLNHZK.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +2 -0
- package/dist/cli-bundle/chunks/chunk-UHKN6TJM.js +114 -0
- package/dist/cli-bundle/chunks/{chunk-ZT64RDMF.js → chunk-X5TMR7KC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YJBIPNDL.js → chunk-XERBUA6A.js} +2 -2
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-63WYG2PY.js +4 -0
- package/dist/cli-bundle/chunks/{mutation-admission-VTNV6JV2.js → mutation-admission-L3A6FSZ7.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-LZDWUZS4.js → register-list-query-YSQ7UTFI.js} +9 -9
- package/dist/cli-bundle/chunks/{register-mutation-M2A7PH42.js → register-mutation-6HRXYASW.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-E7P2JTXM.js → register-operations-4O3YOYXF.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-DOV7KGSH.js → register-setup-3WAXNDMY.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-SVD6CO7U.js → settlement-hook-CRW6PVQK.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-LYLEOAQB.js → stage-I46WD4EN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WDWHUJQW.js → chunk-4TXZBGOR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IF6C43IP.js → chunk-HWD63G54.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NE27VCU7.js → chunk-J67PFM3O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PK5FJIVA.js → chunk-MVY6JDIH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UP765R2V.js → chunk-R2MTHS2H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SM2KGD4J.js +79 -0
- package/dist/cli-bundle/focused-chunks/{chunk-226XKW3W.js → chunk-SYL73MEI.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-CSCZYSNZ.js → chunk-TAFMNTA5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-I7H3XF25.js → chunk-TGUOEOKP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-U4UBQBS7.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-D5YQ4KAE.js → chunk-WDKZB3V6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KERJNFXY.js → chunk-XK3XMZM4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ADSBGYLW.js → chunk-Y57A4ZDI.js} +55 -55
- package/dist/cli-bundle/focused-chunks/{chunk-BL77VCRB.js → chunk-YC6NCPLK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZA6AEYIM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YTEC2EPM.js → chunk-ZH7GTEWL.js} +3 -3
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-GAFC52LQ.js +4 -0
- package/dist/cli-bundle/focused-chunks/{mutation-admission-L42E3U5U.js → mutation-admission-ENBFMV2X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-3CADO4XZ.js → settlement-hook-PUYJJDFL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-TUQHWU7N.js → stage-MAWZTM2H.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 +33 -33
- 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 +57 -57
- 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 +3 -3
- package/dist/core/history/event-index.d.ts +6 -0
- package/dist/core/history/event-index.js +7 -6
- package/dist/core/history/read.d.ts +3 -1
- package/dist/core/history/read.js +1 -1
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/merge/indexed-receipt-blobs.d.ts +3 -1
- package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
- package/dist/sdk/merge/receipt-file-boundary.d.ts +2 -0
- package/dist/sdk/merge/receipt-file-boundary.js +1 -1
- package/dist/sdk/merge/receipts.js +2 -2
- package/dist/sdk/mutation-events.d.ts +6 -0
- package/dist/sdk/mutation-events.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime-extended-actions.js +1 -1
- package/dist/sdk/test/execution.js +2 -2
- package/dist/sdk/test/receipt-index-snapshot.d.ts +2 -0
- package/dist/sdk/test/receipt-index-snapshot.js +2 -0
- package/dist/sdk/test/workspace-snapshot.d.ts +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/docs/PERFORMANCE.md +21 -6
- package/docs/RELEASING.md +11 -0
- package/docs/SDK_CONTEXT_COORDINATION.md +35 -4
- package/docs/TESTING.md +14 -1
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- 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-N6FTEILW.js +0 -20
- package/dist/cli-bundle/chunks/chunk-OUDR2HWR.js +0 -113
- package/dist/cli-bundle/chunks/chunk-RUKSEZE7.js +0 -2
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-NWQIDTH7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-ABMNYWV6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-NFN2P4TW.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-UHWTPOM4.js +0 -78
- package/dist/cli-bundle/focused-chunks/chunk-VVRXF4JO.js +0 -2
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-YFDNGHCM.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as so,B as ao,G as lo,I as uo,a as W,b as Wi,c as Hi,e as Ae,f as zi,g as Ki,h as Vi,i as Qi,j as Yi,m as Xi,n as Ji,p as no,q as ro,t as io,u as cn,v as dn,w as H}from"./chunk-CSCZYSNZ.js";import{$ as Di,H as pi,I as hi,L as on,M as Ci,Oa as Bi,W as ut,Y as pe,Z as mt,_ as ft,ba as Oi,ca as Li,da as ht,ea as Ni,fa as gt,ga as yt,ha as _t,ia as Pi,ma as ji,na as an,wa as Ui}from"./chunk-BL77VCRB.js";import{Na as Kr,Va as Vr}from"./chunk-ABMNYWV6.js";import{C as oo,K as co,a as Ie,c as Te,f as Re,g as qi,h as Gi,i as wt,m as Zi,n as eo,q as to}from"./chunk-D5YQ4KAE.js";import{B as pt,D as Fi,E as ne,F as re,H as Mi,I as he,L as $i,b as xi,c as Ii,f as Ai,h as sn}from"./chunk-NE27VCU7.js";import{Da as Ei,E as yi,F as _i,G as wi,H as bi,I as vi,Ka as lt,La as Ti,M as xe,Ma as Ri,V as ki,_a as M,aa as ee,ca as te,db as q,ia as Si,r as L,s as x,t as J,x as gi}from"./chunk-UHWTPOM4.js";import{b as le}from"./chunk-YW5GHQN2.js";import{j as P,l as X}from"./chunk-B266DDBJ.js";import{b as mi,c as fi}from"./chunk-AK2CI2GI.js";import{$ as Ee,Aa as tn,Ad as E,Bd as ci,Ca as et,Cd as G,Dc as me,E as Zt,F as Xe,Fa as tt,Oc as Xr,Od as ot,Qb as zr,Qd as st,Sc as Jr,Sd as at,Tc as Zr,Vc as ei,Vd as di,Wd as ct,Y as en,a as Nr,aa as Ze,fa as Gr,ga as Wr,gd as ti,ic as C,ke as dt,le as nn,md as rt,me as li,nd as fe,ne as ui,oc as Ce,od as ni,pd as ri,qa as F,qd as ii,rd as oi,sc as Qr,sd as si,se as rn,tc as ue,td as it,wa as R,wc as Yr,wd as O,ya as Hr,yc as nt,z as de,zd as ai}from"./chunk-NLZUI234.js";import{B as Ur,C as Je,D as Br,H as qr,s as Pr,w as jr,y as p,z as h}from"./chunk-KTXU5WU6.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 De=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 ln(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function da(e,t,n,r){return t.map(([i,o])=>{if(r.render_calls>=r.max_render_calls)throw new De("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 mo(e,t,n,r){let i=t,o=Object.entries(n.renderers),s=n.estimateTokens??(a=>Xr(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=da(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 De("output_envelope_unstable",r)}function cf(e,t){ln(t.tokenBudget,"tokenBudget"),ln(t.maxRenderCalls??1e4,"maxRenderCalls"),ln(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=mo(i,s(o),t,r);if(a.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new De("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=mo(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var la=["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"],un=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",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 --json",sdk:"await client.listAllComplete()"}}}};function uf(e={}){return ei({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ua(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(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;I(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."),I(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=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(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."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function ma(e,t,n){I(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."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(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."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function fa(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 pa(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 ha(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&fa(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!pa(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(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=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function ga(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function ya(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:la[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ua(t,n);return ma(t,r,n),ha(t,n),ga(t.items,n),{ok:n.length===0,findings:n}}function _a(e){let t=ya(e);if(!t.ok)throw new un(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function mf(e){_a(e)}(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 gf(e,t={}){let n=await lo({pmRoot:R(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 fo=16;async function po(e,t,n){let r=F(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<fo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let c=await ne(e,s,t.id_prefix,t.item_format,r);if(!c)break;let d=await re(c,{schema:t.schema});i.push(d.document.metadata.id),s=d.document.metadata.parent}return i}async function kf(e){await wi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await po(e.pmRoot,e.settings,e.itemId)})}async function Sf(e){await bi(e)}async function Ef(e){await vi({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await po(e.pmRoot,e.settings,e.itemId)}:{}})}var Cf={lineage_depth:fo,active_items:64,evidence_rows:32};function ho(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}import{encode as ba}from"@toon-format/toon";import{createHash as wa}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 mn(e){let t=wa("sha256").update("[");for(let n of e)t.update(tt(n)).update("\0");return t.update("]").digest("hex")}function bt(e,t){if(t===void 0)return O();let n=ri(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 Fe(e,t){let n=e.map((a,c)=>({row:a,index:c})),r=fe(t.command,{query:t.query,rows_digest:mn(e)}),i=t.after===void 0?void 0:ii(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=it(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 fn=["agenda","day","week","month"],pn=["markdown","toon","json"],va=["sun","mon","tue","wed","thu","fri","sat"],ka=365,Sa=365,vo=28,Ea=1e3;function hn(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 Ca(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 ko(e,t){let n;for(let r of t){let i=Nr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function xa(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!fn.includes(t)){let n=ko(t,fn);throw new h(`Calendar view must be one of ${fn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Ia(e){if(!e)return;let t=e.trim().toLowerCase();if(!pn.includes(t)){let n=ko(t,pn);throw new h(`Calendar format must be one of ${pn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Nf(e,t){let n=Ia(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 Ta(e,t){if(e===void 0)return;let n=L(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 Ra(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 vt(e){return new Date(e).toISOString().slice(0,10)}function So(e,t){if(!t||t==="UTC")return vt(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 vt(e)}function wn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function K(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function Eo(e){let t=new Date(wn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return K(t.toISOString(),r)}function Aa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function Da(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Fa(e,t){return E(e,t)>=0?e:t}function go(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function yo(e,t){e.set(t,(e.get(t)??0)+1)}function Ma(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 Co(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 xo(e){return va[new Date(e).getUTCDay()]}function $a(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Oa(e){let t=new Set;for(let n of e??[]){let r=$a(n);r&&t.add(r)}return t}function La(e,t,n,r,i){let o=e??K(n,-(r??Sa)),s=t??K(e??n,i??ka);return{start:o,end:E(s,o)>0?s:K(o,1)}}function Na(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[xo(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??Ea,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Oa(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 kt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function St(e,t){let n=xo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Pa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(St(e,t)&&kt(e,t)==="stop");n+=1)t=K(t,e.interval);return e.occurrences}function ja(e,t,n){let r=de(n),i=K(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 Ua(e){let t=Eo(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=K(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=ja(e,r,i);if(St(e,o)&&kt(e,o)==="stop")return e.occurrences}}return e.occurrences}function Ba(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=Co(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!St(e,s))&&kt(e,s)==="stop")return e.occurrences}}return e.occurrences}function qa(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=Co(i,n,o,e.startDate);if(!(!s||!St(e,s))&&kt(e,s)==="stop")return e.occurrences}}return e.occurrences}function Ga(e,t,n,r){let i=Na(e,t,n,r);return t.freq==="daily"?Pa(i):t.freq==="weekly"?Ua(i):t.freq==="monthly"?Ba(i):qa(i)}function Io(e){return[...e].sort((t,n)=>{let r=E(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 bn(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 Wa(e){return e.deadline?{at:e.deadline,date:vt(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,...bn(e),item_deadline:e.deadline}:null}function Ha(e){return(e.reminders??[]).map(t=>({at:t.at,date:vt(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,...bn(e)}))}function za(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Ka(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Va(e,t,n,r){let i=Ma(t.recurrence),o=za(t.start_at,t.end_at);return(t.recurrence?Ga(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):So(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Ka(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,...bn(e)}))}function Qa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Wa(o):null;s&&i.push(s),n.has("reminders")&&i.push(...Ha(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Va(o,a,t,r))}return Io(i)}function Ya(e,t,n,r,i){let o=Hi(t.type,n),s=t.tag?.trim().toLowerCase(),a=Wi(t.priority),c=Ta(t.status,r),d=t.assignee?.trim(),l=Ra(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=>Xa(f,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:c,assigneeFilter:d,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Xa(e,t){return Ja(e,t)&&Za(e,t)&&ft(e,t.runtimeFieldFilters)}function Ja(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 Za(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 ec(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function gn(e,t,n){return e.trim().toLowerCase()==="today"?wn(t):G(e,new Date(t),n)}function tc(e,t,n){let r=t.date?gn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?gn(t.from,n,"--from"):void 0,a=t.to?gn(t.to,n,"--to"):void 0;if(s&&a&&E(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 nc(r,t,n,i,o,s,a);if(e==="day"){let d=wn(r);return yn(r,n,i,o,d,K(d,1))}if(e==="week"){let d=Eo(r);return yn(r,n,i,o,d,K(d,7))}let c=Aa(r);return yn(r,n,i,o,c,Da(r))}function nc(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 yn(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Fa(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function rc(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:Io(r)}))}function ic(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),yo(n,c.item_type),yo(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:go(n),by_status:go(r),recurring_events:a}}function oc(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function To(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 sc(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===So(e.event_end,e.event_timezone)?To(e.event_end,e.event_timezone):e.event_end:null}function ac(e){let t=`${To(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=sc(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 _o(e,t){if(t&&t.length>0){e.push("### warnings");for(let n of t)e.push(`- ${n}`);e.push("")}}function Pf(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${oc(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(""),_o(t,e.warnings),wo(t.join(`
|
|
1
|
+
import{A as so,B as ao,G as lo,I as uo,a as W,b as Wi,c as Hi,e as Ae,f as zi,g as Ki,h as Vi,i as Qi,j as Yi,m as Xi,n as Ji,p as no,q as ro,t as io,u as cn,v as dn,w as H}from"./chunk-TAFMNTA5.js";import{$ as Di,H as pi,I as hi,L as on,M as Ci,Oa as Bi,W as ut,Y as pe,Z as mt,_ as ft,ba as Oi,ca as Li,da as ht,ea as Ni,fa as gt,ga as yt,ha as _t,ia as Pi,ma as ji,na as an,wa as Ui}from"./chunk-YC6NCPLK.js";import{Na as Kr,Va as Vr}from"./chunk-ZA6AEYIM.js";import{C as oo,K as co,a as Ie,c as Te,f as Re,g as qi,h as Gi,i as wt,m as Zi,n as eo,q as to}from"./chunk-WDKZB3V6.js";import{B as pt,D as Fi,E as ne,F as re,H as Mi,I as he,L as $i,b as xi,c as Ii,f as Ai,h as sn}from"./chunk-J67PFM3O.js";import{Da as Ei,E as yi,F as _i,G as wi,H as bi,I as vi,Ka as lt,La as Ti,M as xe,Ma as Ri,V as ki,_a as M,aa as ee,ca as te,db as q,ia as Si,r as L,s as x,t as J,x as gi}from"./chunk-SM2KGD4J.js";import{b as le}from"./chunk-YW5GHQN2.js";import{j as P,l as X}from"./chunk-B266DDBJ.js";import{b as mi,c as fi}from"./chunk-AK2CI2GI.js";import{$ as Ee,Aa as tn,Ad as E,Bd as ci,Ca as et,Cd as G,Dc as me,E as Zt,F as Xe,Fa as tt,Oc as Xr,Od as ot,Qb as zr,Qd as st,Sc as Jr,Sd as at,Tc as Zr,Vc as ei,Vd as di,Wd as ct,Y as en,a as Nr,aa as Ze,fa as Gr,ga as Wr,gd as ti,ic as C,ke as dt,le as nn,md as rt,me as li,nd as fe,ne as ui,oc as Ce,od as ni,pd as ri,qa as F,qd as ii,rd as oi,sc as Qr,sd as si,se as rn,tc as ue,td as it,wa as R,wc as Yr,wd as O,ya as Hr,yc as nt,z as de,zd as ai}from"./chunk-NLZUI234.js";import{B as Ur,C as Je,D as Br,H as qr,s as Pr,w as jr,y as p,z as h}from"./chunk-KTXU5WU6.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 De=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 ln(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function da(e,t,n,r){return t.map(([i,o])=>{if(r.render_calls>=r.max_render_calls)throw new De("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 mo(e,t,n,r){let i=t,o=Object.entries(n.renderers),s=n.estimateTokens??(a=>Xr(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=da(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 De("output_envelope_unstable",r)}function cf(e,t){ln(t.tokenBudget,"tokenBudget"),ln(t.maxRenderCalls??1e4,"maxRenderCalls"),ln(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=mo(i,s(o),t,r);if(a.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new De("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=mo(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var la=["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"],un=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",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 --json",sdk:"await client.listAllComplete()"}}}};function uf(e={}){return ei({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ua(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(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;I(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."),I(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=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(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."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function ma(e,t,n){I(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."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(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."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function fa(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 pa(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 ha(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&fa(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!pa(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(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=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function ga(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function ya(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:la[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ua(t,n);return ma(t,r,n),ha(t,n),ga(t.items,n),{ok:n.length===0,findings:n}}function _a(e){let t=ya(e);if(!t.ok)throw new un(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function mf(e){_a(e)}(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 gf(e,t={}){let n=await lo({pmRoot:R(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 fo=16;async function po(e,t,n){let r=F(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<fo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let c=await ne(e,s,t.id_prefix,t.item_format,r);if(!c)break;let d=await re(c,{schema:t.schema});i.push(d.document.metadata.id),s=d.document.metadata.parent}return i}async function kf(e){await wi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await po(e.pmRoot,e.settings,e.itemId)})}async function Sf(e){await bi(e)}async function Ef(e){await vi({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await po(e.pmRoot,e.settings,e.itemId)}:{}})}var Cf={lineage_depth:fo,active_items:64,evidence_rows:32};function ho(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}import{encode as ba}from"@toon-format/toon";import{createHash as wa}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 mn(e){let t=wa("sha256").update("[");for(let n of e)t.update(tt(n)).update("\0");return t.update("]").digest("hex")}function bt(e,t){if(t===void 0)return O();let n=ri(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 Fe(e,t){let n=e.map((a,c)=>({row:a,index:c})),r=fe(t.command,{query:t.query,rows_digest:mn(e)}),i=t.after===void 0?void 0:ii(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=it(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 fn=["agenda","day","week","month"],pn=["markdown","toon","json"],va=["sun","mon","tue","wed","thu","fri","sat"],ka=365,Sa=365,vo=28,Ea=1e3;function hn(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 Ca(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 ko(e,t){let n;for(let r of t){let i=Nr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function xa(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!fn.includes(t)){let n=ko(t,fn);throw new h(`Calendar view must be one of ${fn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Ia(e){if(!e)return;let t=e.trim().toLowerCase();if(!pn.includes(t)){let n=ko(t,pn);throw new h(`Calendar format must be one of ${pn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,p.USAGE)}return t}function Nf(e,t){let n=Ia(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 Ta(e,t){if(e===void 0)return;let n=L(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 Ra(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 vt(e){return new Date(e).toISOString().slice(0,10)}function So(e,t){if(!t||t==="UTC")return vt(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 vt(e)}function wn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function K(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function Eo(e){let t=new Date(wn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return K(t.toISOString(),r)}function Aa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function Da(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function Fa(e,t){return E(e,t)>=0?e:t}function go(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function yo(e,t){e.set(t,(e.get(t)??0)+1)}function Ma(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 Co(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 xo(e){return va[new Date(e).getUTCDay()]}function $a(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Oa(e){let t=new Set;for(let n of e??[]){let r=$a(n);r&&t.add(r)}return t}function La(e,t,n,r,i){let o=e??K(n,-(r??Sa)),s=t??K(e??n,i??ka);return{start:o,end:E(s,o)>0?s:K(o,1)}}function Na(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[xo(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??Ea,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Oa(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 kt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function St(e,t){let n=xo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function Pa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(St(e,t)&&kt(e,t)==="stop");n+=1)t=K(t,e.interval);return e.occurrences}function ja(e,t,n){let r=de(n),i=K(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 Ua(e){let t=Eo(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=K(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=ja(e,r,i);if(St(e,o)&&kt(e,o)==="stop")return e.occurrences}}return e.occurrences}function Ba(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=Co(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!St(e,s))&&kt(e,s)==="stop")return e.occurrences}}return e.occurrences}function qa(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=Co(i,n,o,e.startDate);if(!(!s||!St(e,s))&&kt(e,s)==="stop")return e.occurrences}}return e.occurrences}function Ga(e,t,n,r){let i=Na(e,t,n,r);return t.freq==="daily"?Pa(i):t.freq==="weekly"?Ua(i):t.freq==="monthly"?Ba(i):qa(i)}function Io(e){return[...e].sort((t,n)=>{let r=E(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 bn(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 Wa(e){return e.deadline?{at:e.deadline,date:vt(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,...bn(e),item_deadline:e.deadline}:null}function Ha(e){return(e.reminders??[]).map(t=>({at:t.at,date:vt(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,...bn(e)}))}function za(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Ka(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Va(e,t,n,r){let i=Ma(t.recurrence),o=za(t.start_at,t.end_at);return(t.recurrence?Ga(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):So(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Ka(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,...bn(e)}))}function Qa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Wa(o):null;s&&i.push(s),n.has("reminders")&&i.push(...Ha(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Va(o,a,t,r))}return Io(i)}function Ya(e,t,n,r,i){let o=Hi(t.type,n),s=t.tag?.trim().toLowerCase(),a=Wi(t.priority),c=Ta(t.status,r),d=t.assignee?.trim(),l=Ra(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=>Xa(f,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:c,assigneeFilter:d,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Xa(e,t){return Ja(e,t)&&Za(e,t)&&ft(e,t.runtimeFieldFilters)}function Ja(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 Za(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 ec(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function gn(e,t,n){return e.trim().toLowerCase()==="today"?wn(t):G(e,new Date(t),n)}function tc(e,t,n){let r=t.date?gn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?gn(t.from,n,"--from"):void 0,a=t.to?gn(t.to,n,"--to"):void 0;if(s&&a&&E(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 nc(r,t,n,i,o,s,a);if(e==="day"){let d=wn(r);return yn(r,n,i,o,d,K(d,1))}if(e==="week"){let d=Eo(r);return yn(r,n,i,o,d,K(d,7))}let c=Aa(r);return yn(r,n,i,o,c,Da(r))}function nc(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 yn(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:Fa(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function rc(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:Io(r)}))}function ic(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),yo(n,c.item_type),yo(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:go(n),by_status:go(r),recurring_events:a}}function oc(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function To(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 sc(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===So(e.event_end,e.event_timezone)?To(e.event_end,e.event_timezone):e.event_end:null}function ac(e){let t=`${To(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=sc(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 _o(e,t){if(t&&t.length>0){e.push("### warnings");for(let n of t)e.push(`- ${n}`);e.push("")}}function Pf(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${oc(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(""),_o(t,e.warnings),wo(t.join(`
|
|
2
2
|
`));for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${ac(r)}`);t.push("")}return _o(t,e.warnings),wo(t.join(`
|
|
3
3
|
`))}function jf(e){return ba(e)}function wo(e){let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
4
|
`;)t-=1;return e.slice(0,t)}function cc(e){let t=bt("calendar",e.after),n=xa(e.view),r=tc(n,e,t),i=W(e.limit),o=Ca(e.include),s=hn(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=hn(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),c=hn(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?vo:s,recurrenceLookbackWindowDays:u&&a===void 0?0:a,eventsOnlyCapApplied:u}}function dc(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${vo}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function bo(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 lc(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 Ro(e,t){let n=R(process.cwd(),t.path);await q(n);let r=cc(e),i=await M(n),o=P(i.schema),s=X(i.schema),a=mt(e,s,"calendar"),c=F(i,C()),d=[];dc(d,r.eventsOnlyCapApplied);let l=await he(n,i.item_format,c.type_to_folder,d,i.schema),u=Ya(l,e,c,o,a),m=La(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),f=Qa(u,m,r.includeSources,r.occurrenceLimit).filter(k=>ec(k,r.rangeBounds.start,r.rangeBounds.end)),{rows:g,..._}=Fe(f,{command:"calendar",after:e.after,clock:r.nowValue,limit:r.limit,query:{pmRoot:n,view:r.view,range:r.rangeBounds,filters:{...bo(e,a),limit:void 0},recurringWindow:m,occurrenceLimit:r.occurrenceLimit}}),y=rc(g),b=[...new Set(d)].sort((k,w)=>k.localeCompare(w));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:lc(e,r.rangeBounds),filters:bo(e,a),..._,summary_scope:"returned_rows",summary:ic(g),events:g,days:y,...b.length>0?{warnings:b}:{}}}import mc from"node:fs/promises";import Fo 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]="2e0c4f91-ea56-5bec-b071-448eff719fec")}catch{}})();var vn={version:1,aliases:{}};function Et(e=[]){let t=new Set(xe),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let i of Object.keys(r.provenance_environment_keys??{}))n(i);for(let i of Object.keys(r.provenance_resolvers??{}))n(i);for(let i of r.provenance_unavailable_dimensions??[])n(i)}return[...t].sort()}function Ao(e){if(e===void 0)return;let t=(typeof e=="string"?[e]:e).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(n=>n.length>0);return t.length===0?void 0:new Set(t)}function kn(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function uc(e,t=xe){let n=new Set(t),r=new Map,i=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let o of i.flatMap(s=>s.split(","))){let s=o.indexOf("=");if(s<0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,p.USAGE,{code:"invalid_provenance_predicate"});let a=o.slice(0,s).trim().toLowerCase(),c=o.slice(s+1).trim();if(!n.has(a))throw new h(`Unknown provenance dimension "${a||o.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,p.USAGE,{code:"unknown_provenance_dimension"});if(c.length===0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,p.USAGE,{code:"invalid_provenance_predicate"});let d=r.get(a)??new Set;d.add(c),r.set(a,d)}return r}function Ct(e,t=vn,n={}){let r=kn(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function xt(e,t=vn,n=xe){let r=Ao(e.harness),i=Ao(e.agentInstance),o=uc(e,n);return s=>{let a=kn(s,t).agent_harness;if(r&&(!a||!r.has(a))||i&&!i.has(s.agent_instance??""))return!1;for(let[c,d]of o){let l=s.agent_provenance?.[c];if(!l||!d.has(l.value))return!1}return!0}}function It(e,t=vn,n=xe){let r=new Set(n),i=new Map,o=0;for(let s of e){for(let a of Object.keys(s.agent_provenance??{}))r.add(a);kn(s,t).agent_harness?o+=1:i.set(s.author,(i.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:o,unresolved:e.length-o,unresolved_authors:[...i].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,c=0;for(let d of e){let l=d.agent_provenance?.[s];l===null?c+=1:l!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:c,legacy_missing:e.length-a-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]="aa1ede64-e578-57da-9194-1cd646cee915")}catch{}})();var fc=20,pc=5,hc=15,gc="-24h";function tp(e){let t={...e};return t.full===!0?(t.raw=!0,t.compact=!1):t.raw===!0&&t.compact===void 0&&(t.compact=!0),delete t.full,t}var yc={digest:"activity_digest",compact:"compact_activity",provenance:"provenance_activity",full:"activity"};function Sn(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new h(`${t} must not be empty`,p.USAGE);return n}function Do(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new h("Activity time bounds must not be empty",p.USAGE);let i=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return G(i,new Date(t),n)}function _c(e,t,n){return!(e.ts.length===0&&(t||n)||t&&E(e.ts,t)<0||n&&E(e.ts,n)>=0)}function Me(e,t=""){return typeof e=="string"?e:t}function wc(e,t){return{...t,id:e,ts:Me(t.ts),author:Me(t.author,"unknown"),op:Me(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:Me(t.before_hash),after_hash:Me(t.after_hash)}}function bc(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let i=t.id.localeCompare(n.id);return i!==0?i:t.op.localeCompare(n.op)})}async function vc(e){try{return(await mc.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(Br(t))return[];throw t}}function kc(e){return e.raw!==!0&&e.compact!==!0&&e.provenance!==!0?"digest":e.provenance===!0?"provenance":e.compact===!0||e.raw===!0&&e.compact!==!1?"compact":"full"}function Sc(e,t,n){if(e.unbounded!==!0)return t!==void 0?t:n==="digest"?hc:n==="compact"?fc:pc}function Ec(e,t,n){let r=t==="digest",i=Do(e.to??(r||e.unbounded!==!0?n:void 0),n,"--to"),o=Do(e.from??(r?gc:void 0),e.from===void 0&&r?i:n,"--from");if(o&&i&&E(o,i)>=0)throw new h("Activity --from must be before --to",p.USAGE);let s=pe(e.limit);if(e.unbounded===!0&&s!==void 0)throw new h("Activity --unbounded cannot be combined with --limit",p.USAGE);return{id:Sn(e.id,"Activity --id"),op:Sn(e.op,"Activity --op"),author:Sn(e.author,"Activity --author"),from:o,to:i,limit:Sc(e,s,t),limitSource:e.unbounded===!0||s!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function Cc(e){let t=R(process.cwd(),e.path);return await q(t),{pmRoot:t,settings:await M(t)}}async function xc(e){let t=F(e.settings,C()),n=await he(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await Ii({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(i=>i.id),commandLabel:"activity"});let r=Fo.join(e.pmRoot,"history");return await Ce({path:r,scope:"project"}),{historyDir:r,itemsById:new Map(n.map(i=>[i.id,{title:i.title,type:i.type,status:i.status}]))}}function Ic(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:_c(t,n.from,n.to)}async function Tc(e,t){let n=[];for(let r of await vc(e)){let i=r.slice(0,-6);if(t.id&&i!==t.id)continue;let o=await te(Fo.join(e,r),i);for(let s of o){let a=wc(i,s);Ic(s,a,t)&&n.push(a)}}return n}function Rc(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}function Ac(e){let t=[...e.entries()].sort(([r,i],[o,s])=>s-i||r.localeCompare(o)),n=t.slice(0,4).map(([r,i])=>`${r}:${i}`);return t.length>n.length&&n.push(`+${t.length-n.length}`),n.join(",")}function Dc(e,t){let n=new Map;for(let r of e){let i=n.get(r.id);if(i===void 0){n.set(r.id,{firstTs:r.ts,lastTs:r.ts,eventCount:1,operations:new Map([[r.op,1]])});continue}i.eventCount+=1,E(r.ts,i.firstTs)<0&&(i.firstTs=r.ts),E(r.ts,i.lastTs)>0&&(i.lastTs=r.ts),i.operations.set(r.op,(i.operations.get(r.op)??0)+1)}return[...n.entries()].map(([r,i])=>{let o=t.get(r);return{id:r,type:o?.type??"unknown",status:o?.status??"unknown",title:(o?.title??"(item metadata unavailable)").slice(0,160),event_count:i.eventCount,first_ts:i.firstTs,last_ts:i.lastTs,operations:Ac(i.operations)}}).sort((r,i)=>E(i.last_ts,r.last_ts)||r.id.localeCompare(i.id))}function Fc(e){let t=new Map;for(let i of e)t.set(i.op,(t.get(i.op)??0)+1);let n=[...t.entries()].sort((i,o)=>o[1]-i[1]||i[0].localeCompare(o[0])),r=n.slice(0,8);return r.length<n.length&&r.push([`+${String(n.length-r.length)}`,n.slice(r.length).reduce((i,[,o])=>i+o,0)]),Object.fromEntries(r)}function Mc(e,t,n,r,i){if(e==="digest"){let{rows:a,...c}=Fe(Dc(t,r),n);return{rows:{activity_digest:a},compact:!1,page:c}}let{rows:o,...s}=Fe(t,n);return e==="compact"?{rows:{compact_activity:Rc(o)},compact:!0,page:s}:e==="provenance"?{rows:{provenance_activity:o.map(i)},compact:!1,page:s}:{rows:{activity:o},compact:!1,page:s}}async function Mo(e,t){let n=await Cc(t),r=kc(e),i=bt("activity",e.after),o=Ec(e,r,i),s=await xc(n),a=Et(n.settings.agent_identity.harness_signals),c=n.settings.agent_identity.identity_vocabulary,d=xt({harness:o.harness,agentInstance:o.agentInstance,provenance:o.provenance},c,a),l=bc(await Tc(s.historyDir,o)).filter(d),u=Mc(r,l,{command:"activity",after:e.after,clock:i,limit:o.limit,query:{pmRoot:n.pmRoot,projectionMode:r,filters:{...o,limit:void 0,limitSource:void 0},matching_activity_digest:r==="digest"?mn(l):void 0,vocabulary:c,provenanceDimensions:a}},s.itemsById,m=>Ct(m,c,{itemId:m.id}));return{...u.rows,compact:u.compact,projection:{mode:r,row_key:yc[r]},omission_receipt:nt("activity",r),...u.page,window:{anchor:i,from:o.from??null,to:o.to??null},limit:o.limit??null,...r==="digest"?{activity_summary:{window:{from:o.from,to:o.to},event_count:l.length,item_count:u.page.total_count,author_count:new Set(l.map(m=>m.author)).size,operation_counts:Fc(l)}}:{},...e.provenanceSummary===!0?{provenance_summary:It(l,c,a)}:{},applied_bound:{kind:o.limit===void 0?"unbounded":"limit",source:o.limitSource,value:o.limit??null}}}(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]="9cdfc765-7370-57bb-a4dc-be2df8aa1e6f")}catch{}})();var $o="1970-01-01T00:00:00.000Z";function $e(e){if(typeof e!="string")return null;let t=e.trim();if(!ai(t)&&!/^\d{4}-\d{2}-\d{2}$/u.test(t))return null;try{return G(t,new Date(Number.NaN),"context signal recency coordinate")}catch{return null}}(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]="74b476d9-5f30-5135-9539-5fe3e864c60f")}catch{}})();var En=["structural","recency","activity_density","graph_proximity","claim_focus","priority_pressure","risk_pressure","deadline_pressure","knowledge_density","author_affinity","usage_affinity","semantic_similarity"],$c=Symbol("no-context-author"),Oc=Symbol("no-item-assignee");function Oo(e,t){if(typeof e!="string")return t;let n=e.trim().toLowerCase();return n.length>0?n:t}function Lc(e){if(typeof e!="string")return;let t=/^v?(\d{4})\.(\d{1,2})\.(\d{1,2})(?:$|[-+])/u.exec(e.trim());if(!t)return;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),o=new Date(Date.UTC(n,r-1,i));return o.getUTCFullYear()===n&&o.getUTCMonth()===r-1&&o.getUTCDate()===i?o.toISOString():void 0}function Nc(e){let t=Lc(e.release);return t!==void 0?{source:"release_cohort",coordinate:t}:{source:"created_at",coordinate:$e(e.created_at)??$o}}function Pc(e){if(!["substantive_history","release_cohort","created_at"].includes(e.source)||(e.source==="substantive_history"?e.history_op!==void 0&&typeof e.history_op!="string"||e.event_class!==void 0&&e.event_class!=="substantive":e.history_op!==void 0||e.event_class!==void 0))throw new TypeError("Context signal recency provenance must match its source");let t=$e(e.coordinate);if(t===null)throw new TypeError("Context signal recency coordinate must be a valid absolute timestamp with millisecond precision");return{...e,coordinate:t}}function jc(e,t){let n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)?1-Math.min(Math.max(n,0),t)/t:0}function Uc(e,t){let n=typeof e=="string"?Date.parse(e):e instanceof Date?e.getTime():typeof e=="number"?e:Number.NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return 0;let r=(n-t)/864e5;return r<=0?1:1/(1+r/30)}function Bc(e){let t=typeof e=="string"?e.trim().toLowerCase():void 0;return t==="critical"||t==="high"?1:t==="medium"?.5:t==="low"?.1:0}function Tt(e,t,n){return e?.[t]??n}function Rt(e,t){let n=new Map(e.map(d=>{let l=t.recencyEvidence?.[d.id];return[d.id,l===void 0?Nc(d):Pc(l)]})),r=[...e].sort((d,l)=>{let u=n.get(d.id).coordinate,m=n.get(l.id).coordinate;return E(m,u)||d.id.localeCompare(l.id)}),i=new Map(r.map((d,l)=>[d.id,l])),o=Math.max(e.length-1,1),s=Oo(t.author,$c),a=L("in_progress",t.statusRegistry),c=Date.parse(t.now);return e.map(d=>{let l=Oo(d.assignee,Oc)===s,u=(d.comments?.length??0)+(d.notes?.length??0)+(d.learnings?.length??0);return{id:d.id,item:d,signal_provenance:{recency:n.get(d.id)},signals:{recency:e.length===1?1:1-i.get(d.id)/o,activity_density:t.activityDensity?.[d.id],graph_proximity:Tt(t.graphProximity,d.id,d.parent?.3:0),claim_focus:Tt(t.claimFocus,d.id,x(d.status,t.statusRegistry)===a?1:l?.75:0),priority_pressure:jc(d.priority,4),risk_pressure:Bc(d.risk),deadline_pressure:Uc(d.deadline,c),knowledge_density:Tt(t.knowledgeDensity,d.id,Math.min(u/5,1)),author_affinity:Tt(t.authorAffinity,d.id,l?1:0),usage_affinity:t.usageAffinity?.[d.id],semantic_similarity:t.semanticSimilarity?.[d.id]}}})}var qc="context_relevance",Gc={structural:.4,recency:.35,activity_density:.25,graph_proximity:.15,claim_focus:.6,priority_pressure:.35,risk_pressure:.2,deadline_pressure:.45,knowledge_density:.25,author_affinity:.2,usage_affinity:.3,semantic_similarity:.5},Wc=new TextEncoder;function Hc(e){let t=new Set;for(let n of e){if(typeof n.id!="string"||n.id.trim().length===0||t.has(n.id))throw new TypeError("Context relevance candidates require unique non-empty ids");t.add(n.id);for(let[r,i]of Object.entries(n.signals??{})){if(r==="structural"||!En.includes(r))throw new TypeError(`Unknown context relevance signal: ${r}`);if(i!==void 0&&(!Number.isFinite(i)||i<0||i>1))throw new TypeError(`Context relevance signal ${r} must be a finite number from 0 to 1`)}}}function zc(e){let t={...Gc};for(let[n,r]of Object.entries(e??{}))r!==void 0&&En.includes(n)&&(t[n]=r);for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<0)throw new TypeError(`Context relevance weight ${n} must be a finite non-negative number`);return t}function No(e,t={}){Hc(e);let n=zc(t.weights),r=Math.max(e.length-1,1),i=new Set(["structural"]);for(let a of e)for(let[c,d]of Object.entries(a.signals??{}))d!==void 0&&i.add(c);let o=En.filter(a=>i.has(a)),s=e.map((a,c)=>{let d={structural:e.length===1?1:1-c/r,...a.signals},l={},u=0,m=0;for(let f of o){let g=d[f];if(g===void 0)continue;let _=g*n[f];l[f]=_,u+=_,m+=n[f]}return{...a,baseline_rank:c+1,rank:0,score:m===0?0:u/m,contributions:l}});return s.sort((a,c)=>c.score-a.score||a.baseline_rank-c.baseline_rank),s.forEach((a,c)=>{a.rank=c+1}),{model:"default-weighted-v1",available_signals:o,ranked:s}}async function Kc(e,t={}){let n=No(e,t);if(!t.scorer)return n;let r=await t.scorer({candidates:e,default_report:n}),i=new Map;for(let s of r){if(i.has(s.id)||!Number.isFinite(s.score))throw new TypeError("Context relevance scorer must return one finite score for every candidate");i.set(s.id,s.score)}if(i.size!==e.length||e.some(s=>!i.has(s.id)))throw new TypeError("Context relevance scorer must return one finite score for every candidate");let o=n.ranked.map(s=>{let a=i.get(s.id);return{...s,score:a,contributions:{custom:a}}});return o.sort((s,a)=>a.score-s.score||s.baseline_rank-a.baseline_rank),o.forEach((s,a)=>{s.rank=a+1}),{model:"custom",available_signals:n.available_signals,ranked:o}}async function At(e,t,n={}){let r=No(t,n),i=await Qr(qc,{surface:e,candidates:t,default_report:r});if(!i.handled)return i.warnings.length>0?{...r,warnings:i.warnings}:r;if(!Array.isArray(i.result)||!i.result.every(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.score=="number"&&Number.isFinite(o.score)))return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]};try{let o=await Kc(t,{...n,scorer:()=>i.result});return i.warnings.length>0?{...o,warnings:i.warnings}:o}catch{return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]}}}var Vc=["ndcg","reciprocal_rank","required_recall","continuity_coverage","token_budget_adherence"];function Lo(e,t){return e.length===0?1:e.filter(n=>t.has(n)).length/e.length}function Qc(e){if(!Number.isFinite(e.actual_tokens)||e.actual_tokens<0||!Number.isFinite(e.token_budget)||e.token_budget<=0)throw new TypeError("Context ranking token counts require actual_tokens >= 0 and token_budget > 0");let t=e.judgments??{},n=e.ranked_ids.map(d=>Math.max(0,t[d]??0)),r=Object.values(t).map(d=>Math.max(0,d)).sort((d,l)=>l-d).slice(0,n.length||1),i=d=>d.reduce((l,u,m)=>l+(2**u-1)/Math.log2(m+2),0),o=i(r),s=n.findIndex(d=>d>0),a=new Set(e.ranked_ids),c=e.actual_tokens<=e.token_budget;return{ndcg:o===0?1:i(n)/o,reciprocal_rank:s<0?0:1/(s+1),required_recall:Lo(e.required_ids??[],a),continuity_coverage:Lo(e.continuity_ids??[],a),token_budget_adherence:c?1:e.token_budget/e.actual_tokens,within_token_budget:c}}function Yc(e){return Math.ceil(Wc.encode(JSON.stringify(e)).byteLength/4)}function Xc(e){return Math.round(e*1e4)/1e4}function Jc(e,t){let n=t==="context"?[...e.high_level??[],...e.low_level??[],...e.blocked_fallback??[]].map(o=>o.id):[...e.recommended?[e.recommended]:[],...e.ready??[]].map(o=>o.id),r=new Set(n),i=(e.ranking?.items??[]).filter(o=>r.has(o.id)).map(o=>({id:o.id,contributions:o.contributions}));return{rankedIds:n,attribution:i}}async function Zc(e,t){if(e.id.trim().length===0||e.rationale.trim().length===0)throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");let n=e.surface==="context"?await t.context({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"}):await t.next({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"});if(ti(n)||n.read_output?.result_omitted===!0||n.context_intent?.result_omitted===!0)throw new h(`Cannot evaluate ${e.surface} scenario "${e.id}": the read omitted its useful result.`,p.USAGE,{code:"context_evaluation_read_incomplete",nextSteps:["Increase the read output budget or start a new shared output session, then rerun the scenario."]});let{rankedIds:r,attribution:i}=Jc(n,e.surface),o={...n,ranking:void 0},s=Yc(o);return{id:e.id,surface:e.surface,rationale:e.rationale,ranked_ids:r,actual_tokens:s,metrics:Qc({ranked_ids:r,judgments:e.judgments,required_ids:e.required_ids,continuity_ids:e.continuity_ids,actual_tokens:s,token_budget:e.token_budget}),attribution:i}}function ed(e,t){if(e.length===0)throw new TypeError("Context evaluation requires at least one scenario report");let n=Vc;for(let o of n)if(!Number.isFinite(t[o]))throw new TypeError(`Context evaluation threshold ${o} must be a finite number`);let r=Object.fromEntries(n.map(o=>[o,Xc(e.reduce((s,a)=>s+a.metrics[o],0)/e.length)])),i=n.filter(o=>r[o]<t[o]).map(o=>`${o}:${r[o]}<${t[o]}`);return{scenario_count:e.length,aggregate:r,scenarios:[...e],passed:i.length===0,failures:i}}async function mp(e,t,n){let r=[];for(let i of e)r.push(await Zc(i,t));return ed(r,n)}(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]="d07ec2dc-762a-58ab-83ee-734ca1bf76a7")}catch{}})();var td={balanced:{redundancyPenalty:.35,uncertaintyPenalty:.2},context:{redundancyPenalty:.45,uncertaintyPenalty:.15},next:{redundancyPenalty:.25,uncertaintyPenalty:.3}},nd=["identity","summary","full"];function rd(e){if(!e.id.trim()||!Number.isInteger(e.rank)||e.rank<1)throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");if(!Number.isFinite(e.score)||e.score<0)throw new TypeError("Context packing candidate scores must be finite and non-negative");let t=nd.map(n=>e.token_costs[n]);if(t.some(n=>!Number.isInteger(n)||n<1)||t[0]>t[1]||t[1]>t[2])throw new TypeError("Context projection costs must be positive monotone integers");if(e.uncertainty!==void 0&&(!Number.isFinite(e.uncertainty)||e.uncertainty<0))throw new TypeError("Context packing uncertainty must be finite and non-negative")}function id(e){if(!Number.isInteger(e.tokenBudget)||e.tokenBudget<1)throw new TypeError("Context packing tokenBudget must be a positive integer");let t=e.profile??"balanced",n=td[t];if(!n)throw new TypeError("Unknown context packing profile");let r=e.redundancyPenalty??n.redundancyPenalty,i=e.uncertaintyPenalty??n.uncertaintyPenalty;if(!Number.isFinite(r)||r<0||r>1||!Number.isFinite(i)||i<0)throw new TypeError("Context packing penalties must be finite and within their supported ranges");if(e.latencyBudgetMs!==void 0&&(!Number.isFinite(e.latencyBudgetMs)||e.latencyBudgetMs<=0))throw new TypeError("Context packing latencyBudgetMs must be positive");return{redundancy:r,uncertainty:i,profile:t}}function od(e){let t=new Set;for(let n of e){if(rd(n),t.has(n.id))throw new TypeError("Context packing candidates require unique ids");t.add(n.id)}return[...e].sort((n,r)=>n.rank-r.rank||n.id.localeCompare(r.id))}function sd(e,t,n,r,i){let o=-1,s=0;for(let a=0;a<e.length;a+=1){if(a%128===0&&i()>=r)return{index:o,evaluated:s,timedOut:!0};let c=e[a];if(c.token_costs.identity>t)continue;s+=1;let d=o<0?void 0:e[o],l=n(c)/c.token_costs.identity,u=d===void 0?Number.NEGATIVE_INFINITY:n(d)/d.token_costs.identity;(l>u||l===u&&d!==void 0&&(c.rank<d.rank||c.rank===d.rank&&c.id.localeCompare(d.id)<0))&&(o=a)}return{index:o,evaluated:s,timedOut:!1}}function ad(e){let t=new Set,n=[],r=e.tokenBudget,i=d=>{let l=d.lineage??d.cluster,u=l&&t.has(l)?1-e.redundancyPenalty:1;return Math.max(0,(d.score-e.uncertaintyPenalty*(d.uncertainty??0))*u)},o=d=>{let l=d.token_costs.identity;n.push({...d,projection:"identity",tokens:l,marginal_value:i(d)}),r-=l;let u=d.lineage??d.cluster;u&&t.add(u)};for(let d of e.ordered.filter(l=>l.required))d.token_costs.identity<=r&&o(d);let s=e.ordered.filter(d=>!d.required),a=!0,c=0;for(;s.length>0;){let d=sd(s,r,i,e.deadline,e.readClock);if(c+=d.evaluated,d.timedOut&&(a=!1),d.index<0||d.timedOut)break;o(s.splice(d.index,1)[0])}return{included:n,remaining:r,selectionComplete:a,evaluatedCandidates:c}}function cd(e,t){let n=t;for(let r of["summary","full"]){let i=r==="summary"?"identity":"summary",o=[...e].sort((s,a)=>{let c=s.token_costs[r]-s.token_costs[i],d=a.token_costs[r]-a.token_costs[i];return a.marginal_value/Math.max(d,1)-s.marginal_value/Math.max(c,1)||s.rank-a.rank||s.id.localeCompare(a.id)});for(let s of o){if(s.projection!==i)continue;let a=s.token_costs[r]-s.tokens;a>n||(s.projection=r,s.tokens+=a,n-=a)}}return n}function Po(e,t){let n=id(t),r=od(e),i=t.readClock??performance.now.bind(performance),o=t.latencyBudgetMs===void 0?Number.POSITIVE_INFINITY:i()+t.latencyBudgetMs,s=ad({ordered:r,tokenBudget:t.tokenBudget,redundancyPenalty:n.redundancy,uncertaintyPenalty:n.uncertainty,deadline:o,readClock:i}),{included:a}=s,c=cd(a,s.remaining);a.sort((l,u)=>l.rank-u.rank||l.id.localeCompare(u.id));let d=new Set(a.map(l=>l.id));return{included:a,omitted_ids:r.filter(l=>!d.has(l.id)).map(l=>l.id),token_budget:t.tokenBudget,used_tokens:t.tokenBudget-c,remaining_tokens:c,complete:s.selectionComplete&&a.length===e.length&&a.every(l=>l.projection==="full"),selection_complete:s.selectionComplete,termination_reason:s.selectionComplete?"exhausted":"latency_budget",evaluated_candidates:s.evaluatedCandidates,latency_budget_ms:t.latencyBudgetMs??null,profile:n.profile,degradation_ladder:["full","summary","identity"]}}import Oe from"node:fs/promises";import Le from"node:path";import{createHash as jo,randomUUID as dd}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]="179e487f-baf9-59d1-a438-3ae0c12b00eb")}catch{}})();var Cn=3,xn=2,Uo=["recency","activity_density","graph_proximity","priority_pressure","risk_pressure","knowledge_density"],ld=new Set(["substantive_history","release_cohort","created_at"]),ud={context_signal_store_invalid:{code:"context_signal_store_invalid",meaning:"The persisted context-signal snapshot was unreadable or invalid and was rebuilt from authoritative items.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot can be loaded without the warning."},context_signal_store_stale:{code:"context_signal_store_stale",meaning:"The persisted context-signal snapshot did not match the authoritative cursor or item corpus and was rebuilt.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot is now fresh."},context_signal_store_write_failed:{code:"context_signal_store_write_failed",meaning:"Context signals were rebuilt in memory, but the derived snapshot could not be persisted.",recovery_command:"pm context",recovery_effect:"Retry the derived snapshot write and confirm the warning clears after storage access is restored."}};function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Bo(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function md(e){let t={};for(let n of Uo){let r=e[n];if(r!==void 0){if(!Bo(r))throw new TypeError(`Context relevance signal ${n} must be a finite number from 0 to 1`);t[n]=r}}return t}function fd(e,t){let n=e.map(i=>[i.id,t(i)]),r=Math.max(0,...n.map(([,i])=>i));return Object.fromEntries(n.map(([i,o])=>[i,r===0?0:o/r]))}function pd(e){let t=new Map(e.map(i=>[i.id,0])),n=i=>{t.set(i,(t.get(i)??0)+1)};for(let i of e){typeof i.parent=="string"&&i.parent.trim()&&(n(i.id),n(i.parent.trim()));for(let o of i.dependencies??[])typeof o.id!="string"||!o.id.trim()||(n(i.id),n(o.id.trim()))}let r=Math.max(0,...t.values());return Object.fromEntries(e.map(i=>[i.id,r===0?0:t.get(i.id)/r]))}function qo(e,t){return{...t,activityDensity:t.activityDensity??fd(e,n=>(n.comments?.length??0)+(n.notes?.length??0)+(n.learnings?.length??0)+(n.test_runs?.length??0)),graphProximity:t.graphProximity??pd(e)}}function Rn(e){let t=jo("sha256");for(let{id:n,signal_provenance:{recency:r}}of[...e].sort((i,o)=>i.id.localeCompare(o.id)))t.update(JSON.stringify([n,r.source,r.coordinate,r.history_op??null,r.event_class??null]));return`sha256:${t.digest("hex")}`}function hd(e){if(!ge(e))return null;let t=e.signal_provenance;if(![typeof e.id=="string",ge(e.signals),ge(t)].every(Boolean))return null;let n=t.recency;if(!ge(n))return null;let r=$e(n.coordinate);if(r===null)return null;let i=new Set(Uo),o=Object.entries(e.signals);return!o.every(([s,a])=>i.has(s)&&Bo(a))||![typeof n.source=="string"&&ld.has(n.source),["undefined","string"].includes(typeof n.history_op),[void 0,"substantive","maintenance"].includes(n.event_class),n.source==="substantive_history"?n.event_class===void 0||n.event_class==="substantive":n.history_op===void 0&&n.event_class===void 0].every(Boolean)?null:{id:e.id,signals:Object.fromEntries(o),signal_provenance:{recency:{source:n.source,coordinate:r,history_op:n.history_op,event_class:n.event_class}}}}function gd(e,t){let n=Array.from(e,hd);if(n.some(i=>i===null))return null;let r=n;return new Set(r.map(i=>i.id)).size!==r.length||r.some(i=>i.id.trim().length===0)||t!==Rn(r)?null:r.sort((i,o)=>i.id.localeCompare(o.id))}function yd(e){if(!ge(e)||e.format_version!==Cn||e.signal_set_version!==xn||typeof e.source_cursor!="string"||e.source_cursor.trim().length===0||typeof e.recency_evidence_fingerprint!="string"||!/^sha256:[a-f0-9]{64}$/u.test(e.recency_evidence_fingerprint)||typeof e.generated_at!="string"||!Number.isFinite(Date.parse(e.generated_at))||e.source!=="derived_index"&&e.source!=="scan_fallback"||!Array.isArray(e.items))return null;let t=gd(e.items,e.recency_evidence_fingerprint);return t===null?null:{format_version:Cn,signal_set_version:xn,source_cursor:e.source_cursor,recency_evidence_fingerprint:e.recency_evidence_fingerprint,generated_at:e.generated_at,source:e.source,items:t}}function Go(e){if(typeof e.sourceCursor!="string"||e.sourceCursor.trim().length===0)throw new TypeError("Context signal source cursor must be non-empty");if(!Number.isFinite(Date.parse(e.now)))throw new TypeError("Context signal snapshot clock must be a valid timestamp");if(e.source!=="derived_index"&&e.source!=="scan_fallback")throw new TypeError("Context signal snapshot source must be derived_index or scan_fallback")}function Wo(e,t,n=Rn(e)){let r=e.map(({id:o})=>o);if(new Set(r).size!==r.length||r.some(o=>o.trim().length===0))throw new TypeError("Context signal snapshot item IDs must be unique and non-empty");let i=e.map(({id:o,signals:s,signal_provenance:a})=>({id:o,signals:md(s),signal_provenance:a})).sort((o,s)=>o.id.localeCompare(s.id));return Object.freeze({format_version:Cn,signal_set_version:xn,source_cursor:t.sourceCursor,recency_evidence_fingerprint:n,generated_at:t.now,source:t.source,items:Object.freeze(i.map(o=>Object.freeze(o)))})}function Sp(e,t){return Go(t),Wo(Rt(e,qo(e,t)),t)}var In=class{filePath;constructor(t){if(typeof t!="string"||t.trim().length===0)throw new TypeError("Context signal store path must be non-empty");this.filePath=Le.resolve(t)}async read(){try{return JSON.parse(await Oe.readFile(this.filePath,"utf8"))}catch(t){if(ge(t)&&Je(t))return null;throw t}}async write(t){let n=Le.dirname(this.filePath);await Oe.mkdir(n,{recursive:!0});let r=Le.join(n,`.${Le.basename(this.filePath)}.${dd()}.tmp`);try{await Oe.writeFile(r,`${JSON.stringify(t)}
|
|
@@ -9,4 +9,4 @@ import{A as so,B as ao,G as lo,I as uo,a as W,b as Wi,c as Hi,e as Ae,f as zi,g
|
|
|
9
9
|
`)}catch{}}function Vs(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 Vt(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 B=Ze;function Ke(e){let t=C(),n=pi(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=B(r.name)??B(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 fr(e){let t=B(e.search?.provider),n=Ke(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function pr(e){let t=C(),n=B(e.vector_store?.adapter),r=hi(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:B(i.name)??B(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function hr(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=B(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 gr(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 Ht(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 Qt(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=ze(t),c=ze(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,_=f*r+g*l;if(_<=0)return null;let y=new Set;t.has(u)&&y.add(i);for(let b of s.get(u)??[])y.add(b);return{item:m.metadata,score:_,matched_fields:[...y].sort((b,k)=>b.localeCompare(k))}}).filter(u=>u!==null)}function yr(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function _r(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:Os(Pi(s,{fields:e.corpusFields}))})),n=Ms(t),r=$s(n,Zn(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 Ht(s,e.keywordHits)}let o=Qt(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return Ht(o,e.keywordHits)}function wr(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 br(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(`
|
|
10
10
|
`)}async function Gm(e,t){let n=e.queryExpansion.enabled?Ns(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 js(r,Ps(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 Wm(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 an(e.vectorStore,t,n,r)}if(e.vectorStore)return await an(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 Hm(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:br(i)}:null}).filter(r=>r!==null)}async function zm(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=qs(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 Km(e,t,n){let r=await zm(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await Ws(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function Vm(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 Qm(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=Hm(n,r,e.rerank.top_k),o=await Km(e,t,i);return o&&o.size>0?Vm(n,o):n}async function vr(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 Gm(e,i),s=await ht(e.provider,o,n),a=await Promise.all(s.map(async g=>await Wm(e,g,t,r))),c=wr(a),d=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:l,semanticScores:u}=gr(c,d),m=u.size;if(e.requestedMode==="semantic")return{hits:Ht(l,e.keywordHits),vectorMatchCount:m};let f=await Qm(e,i,Qt(d,u,e.keywordHits,e.hybridSemanticWeight),d);return{hits:Ht(f,e.keywordHits),vectorMatchCount:m}}function Qs(e){let t=Ke(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function Ys(e){let t=Ke(B(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}import Yt from"node:fs/promises";import kr 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 Sr(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 Xs(e){let t=kr.resolve(e);try{let n=await Yt.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function Er(e,t){let[n,r]=await Promise.all([Xs(e),Xs(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function Cr(e,t){let n=Sr(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=kr.resolve(o.resolved,i.path);if(!en(o.resolved,s))continue;let a;try{a=await Yt.realpath(s)}catch{continue}if(en(o.realpath,a))try{await Ce({path:s,scope:i.scope}),r.push(await Yt.readFile(s,"utf8"))}catch{}}return r.join(`
|
|
11
11
|
`)}async function xr(e,t,n,r){let i=le(C()),o=async(d,l,u)=>{let m=async(f,g)=>{await Ce({path:f,scope:"project"});let _=await Yt.readFile(f,"utf8");return gi(_,{format:g,schema:r,extensionFieldNames:i,onWarning:y=>s.push(y)}).body};try{return await m(l,u)}catch{let f=u==="toon"?"json_markdown":"toon",g=tn(e,d.type,d.id,f,n);try{return await m(g,f)}catch{return s.push(`item_list_item_read_failed:${kr.relative(e,g)}`),""}}},s=[],a=await Fi(e,t,n,s,r),c=[];if(a.length===0){let d=await Mi(e,t,n,s,r);for(let l of d){let u=tn(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 Js(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await Er(i,Hr(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await Cr(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 Zs=["tag","status","type","priority"];function Ir(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=Zs.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 Tr(e,t,n){let r={...e};for(let i of Zs){let o=t[i];if(o!==void 0){if(Ze(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function ea(e,t){let n=[],r=Ir(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=Tr(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:Ut(s.includeLinked),titleExact:Ut(s.titleExact),phraseExact:Ut(s.phraseExact),matchMode:Ts(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:Rs(s.minScore),countOnly:s.count===!0,tokens:qt(o),normalizedQuery:U(o),limit:pe(s.limit),projection:Bt(s,e),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}function ta(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]="d7beacb7-66a5-581f-93f0-68ceb4b8e41e")}catch{}})();function Ar(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 y=we({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,...$r(f),items:[],count:0,...g,filters:y,...l.length>0?{warnings:l}:{}}}let _=d.mode==="full"?null:[...d.fields];return{query:e.trim(),mode:t,mode_source:f,items:[],count:0,...g,filters:be({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??{}}),projection:{mode:d.mode,fields:_},now:O(),...l.length>0?{warnings:l}:{}}}function Dr(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 Fr(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]=Dr(n,i);return r})}function Mr(e,t){return Ar(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 na(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return Rr({query:e.query.trim(),mode:e.effectiveMode,...$r(e.modeSource),items:[],count:t,total:t,count_only:!0,filters:we({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 Rr({query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:[],count:t,total:t,count_only:!0,filters:be({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:e.projection.mode,fields:n},now:O()},e.warnings)}function $r(e){return e==="settings"?{mode_source:e}:{}}function Rr(e,t){return t.length===0?e:{...e,warnings:t}}function Ve(e,t){return t?{...e,workspace_memory:t}:e}function ra(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:Wt(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 ia(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return Rr({query:e.query.trim(),mode:e.effectiveMode,...$r(e.modeSource),items:t,count:t.length,...s,...o,filters:we({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:be({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:i.mode,fields:a},now:O(),...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 p_={applyFilters:or,applyExactQueryFilters:ir,applyInlineQueryFilters:Tr,buildHitHighlights:Wt,buildVerboseSearchFilters:be,buildExplicitSemanticFallbackWarning:ur,buildCompactSearchFilterSummary:we,buildHybridLexicalScore:lr,buildRerankCorpus:br,buildSemanticHits:gr,classifyImplicitSemanticFallbackReason:Kt,collectErrorCauseCodes:zt,collectExactPhraseFields:nr,collectLinkedPaths:Sr,combineHybridHits:Qt,computeBuiltInBm25Hits:_r,computeSemanticOrHybridHits:vr,resolveBuiltInBm25Mode:yr,countOccurrences:Gt,dependencyEntries:He,documentContainsExactPhrase:rr,emptySearchResult:Ar,highlightFieldSnippet:ar,loadDocuments:xr,markTokenRuns:sr,parseInlineQueryFilters:Ir,maybeEmitVectorIndexStaleWarning:mr,loadLinkedCorpus:Cr,mergeVectorHitsById:wr,normalizeExtensionProviderHits:hr,normalizeScoreMap:ze,parseProjectionConfig:Bt,parseTimestampWindow:oe,parseTokens:qt,projectSearchHits:Fr,readSearchFieldValue:Dr,requireSemanticDependencies:Vt,resolveExtensionSearchProvider:fr,resolveExtensionSearchProviderByName:Ke,resolveExtensionVectorAdapter:pr,resolveLinkedCorpusRoots:Er,scoreDocument:cr,sortHits:dr,stringArray:ve,textEntries:V,validateSearchProjectionFields:zn};async function Ym(e,t){let n=R(process.cwd(),t.path);await q(n);let r=await M(n),i=Di(r).settings,o=P(i.schema),s=X(i.schema);zn(e.projection,s,e.query);let a=mt(e.options,s,"search"),c=F(i,C()),d=Li(i),l=ji(i,n),u=fr(i),m=pr(i),f=Is(e.options.semanticWeight),g=Us(i,d.active?.name??null),_=Bs(i,d.active?.model??B(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:c,maxResults:Kn(i),scoreThreshold:e.minScoreOverride??Qn(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:f,hybridSemanticWeight:f??Yn(i),tuning:Xn(i),providerResolution:d,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m,bm25Mode:yr({configuredProvider:B(i.search?.provider),hasEmbeddingProvider:d.active!==null,hasExtensionSearchProvider:u!==null}),queryExpansion:g,queryExpansionExtension:Qs(g),rerank:_,rerankExtension:Ys(i),...Xm({requested:e.options.mode,settings:i,configuredProvider:r.search?.provider??null,providerResolution:d,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m})}}function Xm(e){let t=Oi(e.providerResolution.active?.name,e.configuredProvider)==="configured"&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null),n=e.extensionSearchProvider!==null||t,r=Vn({requested:e.requested,settings:e.settings,semanticRunnable:n});return{effectiveMode:r.mode,modeSource:r.source}}async function Jm(e,t){let n=await xr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=ut(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=Vi(t.statusRegistry),o=or(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:ir(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function Zm(e,t,n){let r=await Js(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>lr(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 ef(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=_r({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Ni(t.settings),bm25Params:Ls(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 tf(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 hr(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 nf(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 rf(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await mr(e.pmRoot,n,r),e.extensionSearchProvider||Vt(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function of(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,c=await ef(t,n,r,i,o),d=n.effectiveMode;if(c!==null||d==="keyword")return{effectiveMode:n.effectiveMode,hits:c??a};try{if(await rf(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 tf(t,n,r,l)??a,a===i){let{provider:u,vectorStore:m}=Vt(d,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),f=await vr({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=nf(d,f,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(l){return o.push(ur(n.effectiveMode,l)),{effectiveMode:"keyword",hits:i}}}function oa(e){e.searchOptions.after!==void 0&&oi(e.searchOptions.after,Jn(e))}async function h_(e,t,n){ta(t);let r=ea(e,t),i=await Ym(r,n),o=await Jm(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await Ft(o.allDocuments.map(S=>S.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:O()});s.push(...a.warnings);let c=Qo(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 oa({query:r.query,mode:i.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),Ve(Mr({...d,effectiveMode:i.effectiveMode},r.countOnly),c);let l=await Zm(r,i,o.filteredDocuments),u=await of({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 oa({query:r.query,mode:u.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),Ve(Mr({...d,effectiveMode:u.effectiveMode},r.countOnly),c);let m=u.hits.filter(S=>S.exact_id_match===!0||S.score>=i.scoreThreshold),f=dr(m,i.statusRegistry),g=f.length,_=As({pmRoot:i.pmRoot,sorted:f,query:r.query,mode:u.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),y={...d,effectiveMode:u.effectiveMode};if(r.countOnly)return Ve(na(y,g),c);let{hits:b,projection:k}=ra(r,o.filteredDocuments,_.limited),w=Fr(b,k);return Ve(ia(y,w,g,_.limited.length,k,_.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 sa=["ndcg","mrr","precision","recall"];function sf(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(!sa.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 y_(e,t){let n=sf(t),r=[];for(let i of sa){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{De as a,cf as b,la as c,un as d,uf as e,ya as f,_a as g,mf as h,gf as i,Sh as j,po as k,kf as l,Sf as m,Ef as n,Cf as o,ho as p,Nf as q,Pf as r,jf as s,Ro as t,Et as u,uc as v,Ct as w,It as x,tp as y,Mo as z,En as A,Rt as B,qc as C,No as D,Kc as E,At as F,Vc as G,Qc as H,Zc as I,ed as J,mp as K,td as L,Po as M,Cn as N,xn as O,ud as P,yd as Q,Sp as R,In as S,Tn as T,Dt as U,kd as V,xd as W,Ft as X,Md as Y,Vo as Z,$d as _,Qo as $,Od as aa,qd as ba,Ne as ca,th as da,Fn as ea,Hd as fa,zd as ga,$n as ha,ie as ia,Ln as ja,Nn as ka,Pn as la,ye as ma,Ue as na,Lt as oa,nh as pa,Kl as qa,rh as ra,Jl as sa,yh as ta,_h as ua,wh as va,bh as wa,vh as xa,Rh as ya,Ah as za,ks as Aa,Ss as Ba,Es as Ca,ig as Da,og as Ea,gg as Fa,Kn as Ga,Vn as Ha,Qn as Ia,Yn as Ja,Xn as Ka,Jn as La,As as Ma,we as Na,be as Oa,zt as Pa,Kt as Qa,Ks as Ra,Vs as Sa,p_ as Ta,h_ as Ua,sa as Va,sf as Wa,y_ as Xa};
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
12
|
+
//# sourceMappingURL=chunk-MVY6JDIH.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as q,s as V}from"./chunk-
|
|
1
|
+
import{r as q,s as V}from"./chunk-TGUOEOKP.js";import{m,s as M,u as k}from"./chunk-WDKZB3V6.js";import{Fa as O,Kd as z,R as x,W as g,nd as N,qd as D,td as j}from"./chunk-NLZUI234.js";import{D as _,H as L,y as S,z as C}from"./chunk-KTXU5WU6.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=N("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(D(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=j(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 z(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-R2MTHS2H.js.map
|