@popmelt.com/core 0.22.0 → 0.22.1

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.
@@ -1 +1 @@
1
- import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-BLXPOSA6.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};
1
+ import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-EEFXBJOO.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};
package/dist/cli.mjs CHANGED
@@ -4,7 +4,7 @@ import{spawn as By}from"child_process";import{readFile as Jy,unlink as qy}from"f
4
4
  `);let o=new Map;for(let r of e){let i=r.pathname||"(unknown)",s=o.get(i)??[];s.push(r.instruction),o.set(i,s)}return[...o.entries()].map(([r,i])=>`\`${r}\`
5
5
  ${i.map(s=>`- ${s}`).join(`
6
6
  `)}`).join(`
7
- `)}var na={name:"@popmelt.com/core",version:"0.22.0",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var st=na.version;var Hl=new Set(["minimal","low","medium","high","xhigh","max","ultra"]),Vl=new Set(["default","flex","fast","priority"]);function hn(t){let e=typeof t.reasoningEffort=="string"&&Hl.has(t.reasoningEffort)?t.reasoningEffort:void 0,n=typeof t.serviceTier=="string"&&Vl.has(t.serviceTier)?t.serviceTier:void 0;return e||n?{reasoningEffort:e,serviceTier:n}:void 0}function Wo(t){let e=[];return t?.reasoningEffort&&e.push(`model_reasoning_effort=${JSON.stringify(t.reasoningEffort)}`),t?.serviceTier&&e.push(`service_tier=${JSON.stringify(t.serviceTier)}`),e}import{createHash as su,randomUUID as au}from"crypto";import{isAbsolute as du,relative as cu}from"path";import{randomUUID as Pt}from"crypto";function Go(t){return[...t.matchAll(/<resolution>\s*([\s\S]*?)(?:<\/resolution>|$)/g)].at(-1)?.[1]?.trim()}function Ho(t){return t.replace(/<resolution>[\s\S]*?(?:<\/resolution>|$)/g,"")}var oa={project:0,route:1,component:2,selector:2,file:3},ra={intention:0,principle:1,pattern:2};function gn(t,e){let n=oa[t.scope.kind]-oa[e.scope.kind];return n!==0?n:ra[t.kind]-ra[e.kind]}function ia(t){return t==="expresses"||t==="excepts"}function Kl(t,e){if(e.type==="expresses"||e.type==="excepts")return structuredClone(e);if(e.type==="operationalizes")return{...structuredClone(e),type:"expresses"};if(e.type==="instantiates")return{...structuredClone(e),type:"expresses",fromId:e.toId,toId:e.fromId};if(e.type==="refines"){let n=t.explanations.find(i=>i.id===e.fromId),o=t.explanations.find(i=>i.id===e.toId);if(!n||!o)return;let r=gn(n,o);return r===0?void 0:r>0?{...structuredClone(e),type:"expresses"}:{...structuredClone(e),type:"expresses",fromId:e.toId,toId:e.fromId}}}function Qt(t){let e=structuredClone(t),n=new Set;return e.relations=t.relations.flatMap(o=>{let r=Kl(t,o);if(!r)return[];let i=`${r.type}:${r.fromId}:${r.toStoreId??""}:${r.toId}`;return n.has(i)?[]:(n.add(i),[r])}),e}import{createHash as Ql}from"crypto";import{mkdir as Xl,open as Yl,readFile as sa,readdir as Zl,rename as ep,unlink as tp}from"fs/promises";import{dirname as np,join as yn}from"path";function nt(t){return structuredClone(t)}function aa(t){return Ql("sha256").update(JSON.stringify(t)).digest("hex")}async function Xt(t,e){await Xl(np(t),{recursive:!0});let n=`${t}.${process.pid}.${Date.now()}.tmp`,o=await Yl(n,"w");try{await o.writeFile(`${JSON.stringify(e,null,2)}
7
+ `)}var na={name:"@popmelt.com/core",version:"0.22.1",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var st=na.version;var Hl=new Set(["minimal","low","medium","high","xhigh","max","ultra"]),Vl=new Set(["default","flex","fast","priority"]);function hn(t){let e=typeof t.reasoningEffort=="string"&&Hl.has(t.reasoningEffort)?t.reasoningEffort:void 0,n=typeof t.serviceTier=="string"&&Vl.has(t.serviceTier)?t.serviceTier:void 0;return e||n?{reasoningEffort:e,serviceTier:n}:void 0}function Wo(t){let e=[];return t?.reasoningEffort&&e.push(`model_reasoning_effort=${JSON.stringify(t.reasoningEffort)}`),t?.serviceTier&&e.push(`service_tier=${JSON.stringify(t.serviceTier)}`),e}import{createHash as su,randomUUID as au}from"crypto";import{isAbsolute as du,relative as cu}from"path";import{randomUUID as Pt}from"crypto";function Go(t){return[...t.matchAll(/<resolution>\s*([\s\S]*?)(?:<\/resolution>|$)/g)].at(-1)?.[1]?.trim()}function Ho(t){return t.replace(/<resolution>[\s\S]*?(?:<\/resolution>|$)/g,"")}var oa={project:0,route:1,component:2,selector:2,file:3},ra={intention:0,principle:1,pattern:2};function gn(t,e){let n=oa[t.scope.kind]-oa[e.scope.kind];return n!==0?n:ra[t.kind]-ra[e.kind]}function ia(t){return t==="expresses"||t==="excepts"}function Kl(t,e){if(e.type==="expresses"||e.type==="excepts")return structuredClone(e);if(e.type==="operationalizes")return{...structuredClone(e),type:"expresses"};if(e.type==="instantiates")return{...structuredClone(e),type:"expresses",fromId:e.toId,toId:e.fromId};if(e.type==="refines"){let n=t.explanations.find(i=>i.id===e.fromId),o=t.explanations.find(i=>i.id===e.toId);if(!n||!o)return;let r=gn(n,o);return r===0?void 0:r>0?{...structuredClone(e),type:"expresses"}:{...structuredClone(e),type:"expresses",fromId:e.toId,toId:e.fromId}}}function Qt(t){let e=structuredClone(t),n=new Set;return e.relations=t.relations.flatMap(o=>{let r=Kl(t,o);if(!r)return[];let i=`${r.type}:${r.fromId}:${r.toStoreId??""}:${r.toId}`;return n.has(i)?[]:(n.add(i),[r])}),e}import{createHash as Ql}from"crypto";import{mkdir as Xl,open as Yl,readFile as sa,readdir as Zl,rename as ep,unlink as tp}from"fs/promises";import{dirname as np,join as yn}from"path";function nt(t){return structuredClone(t)}function aa(t){return Ql("sha256").update(JSON.stringify(t)).digest("hex")}async function Xt(t,e){await Xl(np(t),{recursive:!0});let n=`${t}.${process.pid}.${Date.now()}.tmp`,o=await Yl(n,"w");try{await o.writeFile(`${JSON.stringify(e,null,2)}
8
8
  `,"utf8"),await o.sync()}finally{await o.close()}try{await ep(n,t)}catch(r){throw await tp(n).catch(()=>{}),r}}function op(t,e){return{version:1,projectId:t,createdAt:e,updatedAt:e,head:{sequence:0,hash:null},explanations:[],concrete:[],relations:[]}}function rp(t,e){let n=t.explanations.findIndex(o=>o.id===e.id);n>=0?t.explanations[n]=nt(e):t.explanations.push(nt(e))}function oi(t,e){let n=nt(t);for(let o of e)if(o.op==="add_explanation"){if(n.explanations.some(r=>r.id===o.explanation.id))throw new Error(`Imprint explanation already exists: ${o.explanation.id}`);n.explanations.push(nt(o.explanation))}else if(o.op==="replace_explanation")rp(n,o.explanation);else if(o.op==="remove_explanation")n.explanations=n.explanations.filter(r=>r.id!==o.explanationId),n.relations=n.relations.filter(r=>r.fromId!==o.explanationId&&(r.toStoreId!==void 0||r.toId!==o.explanationId));else if(o.op==="add_concrete")n.concrete.some(r=>r.id===o.concrete.id)||n.concrete.push(nt(o.concrete));else if(o.op==="remove_concrete")n.concrete=n.concrete.filter(r=>r.id!==o.concreteId),n.relations=n.relations.filter(r=>r.fromId!==o.concreteId&&(r.toStoreId!==void 0||r.toId!==o.concreteId));else if(o.op==="add_evidence"){let r=n.explanations.find(i=>i.id===o.explanationId);if(!r)throw new Error(`Unknown imprint explanation: ${o.explanationId}`);r.evidence.some(i=>i.id===o.evidence.id)||(r.evidence.push(nt(o.evidence)),r.updatedAt=o.evidence.createdAt)}else if(o.op==="revise_explanation"){let r=n.explanations.find(i=>i.id===o.explanationId);if(!r)throw new Error(`Unknown imprint explanation: ${o.explanationId}`);Object.assign(r,nt(o.patch),{updatedAt:o.updatedAt})}else if(o.op==="add_relation"){let r=o.relation,i=n.explanations.find(u=>u.id===r.fromId),s=!!r.toStoreId,a=s?void 0:n.explanations.find(u=>u.id===r.toId),d=n.concrete.some(u=>u.id===r.fromId),c=!s&&n.concrete.some(u=>u.id===r.toId);if(ia(r.type)){if(!(r.type==="expresses"?s?!!i:!!((i||d)&&a):!!(i&&(a||s))))throw new Error(`Imprint ${r.type} relation has invalid endpoints: ${r.id}`);if(n.relations.some(f=>f.type===r.type&&f.fromId===r.fromId&&f.toStoreId===r.toStoreId&&f.toId===r.toId))throw new Error(`Duplicate imprint relation: ${r.type}:${r.fromId}:${r.toStoreId??""}:${r.toId}`);if(r.type==="expresses"&&i&&a){if(gn(i,a)<0)throw new Error(`Imprint expresses relation must point from specific to abstract: ${r.id}`);let f=new Map;for(let I of n.relations)I.type!=="expresses"||I.toStoreId||f.set(I.fromId,[...f.get(I.fromId)??[],I.toId]);let h=[r.toId],S=new Set;for(;h.length;){let I=h.pop();if(I===r.fromId)throw new Error(`Imprint expresses relation would create a cycle: ${r.id}`);S.has(I)||(S.add(I),h.push(...f.get(I)??[]))}}}else if(!i||!a&&!c)throw new Error(`Imprint relation references an unknown explanation: ${r.id}`);n.relations.some(u=>u.id===r.id)||n.relations.push(nt(r))}else o.op==="remove_relation"&&(n.relations=n.relations.filter(r=>r.id!==o.relationId));return n}function ip(t,e){let n=[],o=nt(t);for(let r of e){if(r.op==="add_explanation")n.unshift({op:"remove_explanation",explanationId:r.explanation.id});else if(r.op==="remove_explanation"){let i=o.explanations.find(s=>s.id===r.explanationId);i&&n.unshift({op:"add_explanation",explanation:nt(i)})}else if(r.op==="add_concrete")n.unshift({op:"remove_concrete",concreteId:r.concrete.id});else if(r.op==="remove_concrete"){let i=o.concrete.find(s=>s.id===r.concreteId);i&&n.unshift({op:"add_concrete",concrete:nt(i)})}else if(r.op==="replace_explanation"||r.op==="revise_explanation"||r.op==="add_evidence"){let i=r.op==="replace_explanation"?r.explanation.id:r.explanationId,s=o.explanations.find(a=>a.id===i);s&&n.unshift({op:"replace_explanation",explanation:nt(s)})}else if(r.op==="add_relation")n.unshift({op:"remove_relation",relationId:r.relation.id});else if(r.op==="remove_relation"){let i=o.relations.find(s=>s.id===r.relationId);i&&n.unshift({op:"add_relation",relation:nt(i)})}o=oi(o,[r])}return n}function da(t){return t.op==="add_explanation"||t.op==="replace_explanation"?[t.explanation.id]:t.op==="remove_explanation"||t.op==="add_evidence"||t.op==="revise_explanation"?[t.explanationId]:t.op==="add_relation"?[t.relation.fromId,...t.relation.toStoreId?[]:[t.relation.toId]]:[]}var Vo=class{constructor(e,n){this.projectRoot=e;this.projectId=n;this.writeChain=Promise.resolve();this.imprintDir=yn(e,".popmelt","imprint"),this.manifestPath=yn(this.imprintDir,"manifest.json"),this.graphPath=yn(this.imprintDir,"graph.json"),this.journalDir=yn(this.imprintDir,"journal")}async readHead(){return(await this.readManifest()).head}async readManifest(){try{let e=JSON.parse(await sa(this.manifestPath,"utf8"));if(e.version!==1||e.projectId!==this.projectId)throw new Error("Imprint manifest does not match this project.");return e}catch(e){if(e.code!=="ENOENT")throw e;let n=new Date().toISOString();return{version:1,projectId:this.projectId,createdAt:n,updatedAt:n,head:{sequence:0,hash:null}}}}async loadRaw(){let e=await this.readManifest(),o=(await Zl(this.journalDir).catch(a=>{if(a.code==="ENOENT")return[];throw a})).filter(a=>/^\d{12}-.+\.json$/.test(a)).sort(),r=op(this.projectId,e.createdAt),i=[],s=null;for(let a=0;a<o.length;a++){let d=JSON.parse(await sa(yn(this.journalDir,o[a]),"utf8")),{hash:c,...u}=d;if(d.sequence!==a+1||d.previousHash!==s||c!==aa(u))throw new Error(`Imprint journal hash mismatch at sequence ${d.sequence}.`);r=oi(r,d.mutations),r.updatedAt=d.committedAt,r.head={sequence:d.sequence,hash:d.hash},i.push(d),s=d.hash}return{graph:r,transactions:i,recoveredTransactions:Math.max(0,i.length-e.head.sequence)}}async load(){let e=await this.loadRaw();return{...e,graph:Qt(e.graph)}}async migrateTopology(){let e=await this.readManifest();if(e.topologyVersion===2)return{migrated:!1,relationMutations:0};let n=await this.loadRaw(),o=Qt(n.graph),r=new Map(o.relations.map(s=>[s.id,s])),i=[];for(let s of n.graph.relations){let a=r.get(s.id);a&&a.type===s.type&&a.fromId===s.fromId&&a.toStoreId===s.toStoreId&&a.toId===s.toId||(i.push({op:"remove_relation",relationId:s.id}),a&&i.push({op:"add_relation",relation:a}))}if(i.length){let s=new Date().toISOString();return await this.commit({transactionId:`topology-v2-${n.graph.head.sequence+1}`,committedAt:s,source:{kind:"migration",threadId:"imprint-topology",jobId:"imprint-topology-v2"},summary:"Simplify Imprint topology to expresses and excepts",mutations:i}),{migrated:!0,relationMutations:i.length}}return await Xt(this.graphPath,o),await Xt(this.manifestPath,{...e,topologyVersion:2}),{migrated:!0,relationMutations:0}}async commit(e){let n;return this.writeChain=this.writeChain.then(async()=>{let o=await this.load();if(o.transactions.some(f=>f.transactionId===e.transactionId))throw new Error(`Imprint transaction already exists: ${e.transactionId}`);let r=o.graph.head.sequence+1,i=ip(o.graph,e.mutations),s={version:1,sequence:r,transactionId:e.transactionId,projectId:this.projectId,committedAt:e.committedAt,previousHash:o.graph.head.hash,source:e.source,summary:e.summary,mutations:nt(e.mutations),inverseMutations:i,...e.undoesTransactionId?{undoesTransactionId:e.undoesTransactionId}:{}},a={...s,hash:aa(s)},d=oi(o.graph,a.mutations);d.updatedAt=e.committedAt,d.head={sequence:r,hash:a.hash};let c=`${String(r).padStart(12,"0")}-${e.transactionId}.json`;await Xt(yn(this.journalDir,c),a);let u={version:1,topologyVersion:2,projectId:this.projectId,createdAt:d.createdAt,updatedAt:e.committedAt,head:d.head};await Xt(this.graphPath,d),await Xt(this.manifestPath,u),n={graph:d,transaction:a}}),await this.writeChain,n}async undo(e,n,o,r){let i=await this.load(),s=i.transactions.find(c=>c.transactionId===e);if(!s)throw new Error("The imprint update is no longer available to undo.");if(i.transactions.some(c=>c.undoesTransactionId===e))throw new Error("This imprint update has already been undone.");let a=new Set(s.mutations.flatMap(da));if(i.transactions.filter(c=>c.sequence>s.sequence).some(c=>c.mutations.some(u=>da(u).some(f=>a.has(f)))))throw new Error("This imprint update has newer dependent changes and cannot be undone cleanly. Edit or challenge the current explanation instead.");return this.commit({transactionId:r,committedAt:o,source:n,summary:`Undo: ${s.summary}`,mutations:s.inverseMutations,undoesTransactionId:e})}async recover(){let e=await this.load();return await Xt(this.graphPath,e.graph),await Xt(this.manifestPath,{version:1,topologyVersion:2,projectId:this.projectId,createdAt:e.graph.createdAt,updatedAt:e.graph.updatedAt,head:e.graph.head}),{...e,recoveredTransactions:0}}};var sp=new Set(["application_only","transient_state","concrete_without_model_path","duplicate","insufficient_evidence","task_specific_detail","no_shared_understanding_change"]),ap=new Set(["about","after","again","before","being","change","from","have","into","make","should","that","the","their","this","with","would","here","only","consistent","match","matched","matching","mirror","mirrored","mirroring","align","aligned","aligning"]),dp=[/\bconsistent\s+with\b/i,/\bmatch(?:es|ed|ing)?\b/i,/\bmirror(?:s|ed|ing)?\b/i,/\bthe\s+same\s+as\b/i,/\bborrow(?:s|ed|ing)?\s+from\b/i,/\balign(?:s|ed|ing)?\s+with\b/i,/\b(?:more|look|looks|feel|feels|behave|behaves)\s+like\b/i],cp=/\b(all|any|every|everywhere|across|throughout|globally|project[- ]wide)\b/i;function ii(t){return!!(t&&cp.test(t))}function lp(t){return t.scope.kind==="project"||ii(`${t.statement} ${t.rationale}`)}function pp(t){let e=t?.scope.values.filter(n=>n!=="*").join(", ");return e?`Does applying this understanding here match your intent for ${e}?`:"Does applying this understanding here match your intent?"}function up(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().replace(/[^a-z0-9]+/g," ").trim().replace(/\s+/g," ")}function mp(t){return t.length>4&&t.endsWith("ies")?[t,`${t.slice(0,-3)}y`]:t.length>3&&t.endsWith("s")&&!t.endsWith("ss")?[t,t.slice(0,-1)]:[t]}function kt(t){return new Set(up(t).split(" ").filter(e=>e.length>2&&!ap.has(e)).flatMap(mp))}function ca(t){return t.replace(/^\s*(?:please\s+)?(?:let(?:'|’)s\s+)?(?:make|apply|use|keep|change|update)\s+/i,"").replace(/[\s,.:;!?]+$/g,"").trim().slice(0,240)}function fp(t){if(t)for(let e of dp){let n=e.exec(t);if(!n||n.index<=0)continue;let o=ca(t.slice(0,n.index)),r=ca(t.slice(n.index+n[0].length));if(o&&r)return{target:o,reference:r}}}function Dt(t,e){if(!t.size||!e.size)return 0;let n=0;for(let o of t)e.has(o)&&(n+=1);return n/Math.min(t.size,e.size)}function ri(t){return!t||!Array.isArray(t.values)||t.values.length===0?{kind:"project",values:["*"]}:{kind:t.kind,values:[...new Set(t.values.map(e=>e.trim()).filter(Boolean))]}}function Nt(t,e,n){return{id:Pt(),kind:e==="excepts"?"exception":e==="challenges"?"correction":"observation",stance:e,summary:n,threadId:t.threadId,jobId:t.jobId,createdAt:t.occurredAt??new Date().toISOString()}}function Te(t,e=800){return typeof t=="string"?t.trim().slice(0,e):""}function la(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(!["project","route","component","selector","file"].includes(String(e.kind))||!Array.isArray(e.values))return;let n=e.values.filter(o=>typeof o=="string"&&!!o.trim());return n.length?{kind:e.kind,values:n}:void 0}function pa(t,e,n){if(t&&typeof t=="object"&&!Array.isArray(t)){let i=t,s=Te(i.explanationId,100),a=Te(i.clientId,100),d=Te(i.storeId,100);if(s&&a)throw new Error("relation endpoint must use either explanationId or clientId, not both");let c=s||a;return c?{explanationId:c,...d?{storeId:d}:{}}:void 0}let o=Te(e,100),r=Te(n,100);return o?{explanationId:o,...r?{storeId:r}:{}}:void 0}function ua(t,e){if(!t||!e.trim())return{found:!1};let n=t;for(let o of e.split(".").filter(Boolean))if(Array.isArray(n)){let r=Number(o);if(!Number.isInteger(r)||r<0||r>=n.length)return{found:!1};n=n[r]}else if(n&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,o))n=n[o];else return{found:!1};return{found:!0,value:n}}function Xn(t,e={}){let n=[...t.matchAll(/<imprint>([\s\S]*?)<\/imprint>/g)],o=Ho(t).replace(/<imprint>[\s\S]*?<\/imprint>/g,"").replace(/<imprint>[\s\S]*$/g,"").trim(),r=n.at(-1)?.[1],i,s=[];if(r)i=r;else{let a=Go(t);if(a===void 0)return{visibleText:o,error:"imprint assessment is missing"};try{let d=JSON.parse(a);if(!d||typeof d!="object"||Array.isArray(d)||!Object.prototype.hasOwnProperty.call(d,"imprint"))return{visibleText:o,error:"imprint assessment is missing"};let c=d;i=c.imprint,s=Array.isArray(c.annotations)?c.annotations:[]}catch{return{visibleText:o,error:"resolution envelope is invalid"}}}try{let a=typeof i=="string"?JSON.parse(i):i;if(!a||typeof a!="object"||Array.isArray(a))throw new Error("imprint assessment is invalid");if(a.decision==="none"){let y=String(a.reason);if(!sp.has(y))throw new Error("imprint no-op reason is invalid");if(y==="task_specific_detail"&&s.some(A=>{if(!A||typeof A!="object"||Array.isArray(A))return!1;let D=A;return(D.finalScope??D.inferredScope)?.breadth==="pattern"}))throw new Error("pattern-scoped resolution cannot be classified as task_specific_detail");let p=Array.isArray(a.usedExplanationIds)?a.usedExplanationIds.filter(A=>typeof A=="string"&&!!A.trim()):[],b=Array.isArray(a.appliedExplanationIds)?a.appliedExplanationIds.filter(A=>typeof A=="string"&&!!A.trim()):[],v=new Set(e.context?.explanations.map(A=>A.id)??[]);if([...new Set([...p,...b])].some(A=>!v.has(A)))throw new Error("imprint use must cite only surfaced explanations");let x=[...new Set([...p,...e.applicationOccurred?[]:b])],g=e.applicationOccurred?b:[],w;if(g.length){w=g;let A=new Set(e.context?.pendingGroundingExplanationIds??[]),D=g.filter(B=>{let X=e.context?.explanations.find(re=>re.id===B);return v.has(B)&&X&&(X.state==="emerging"||X.state==="testing")&&!A.has(B)});if(D.length){let B=a.grounding,X=typeof B?.explanationId=="string"&&D.includes(B.explanationId)?B.explanationId:D[0],re=Te(B?.question,300);return{draft:{decision:"apply",summary:{title:Te(a.summary?.title,120)||"Applied shared understanding",detail:Te(a.summary?.detail,500)||Te(e.requestText||o,500)||"Applied an ungrounded explanation in a new context."},appliedExplanationIds:g,grounding:{explanationId:X,question:re||"Does applying this understanding here match your intent?"}},visibleText:o}}}if(y==="duplicate"){let A=Te(a.duplicateOfExplanationId,100),D=a.scopeComparison;if(!A)throw new Error("duplicate assessment requires duplicateOfExplanationId");if(D!=="equivalent"&&D!=="existing_broader")throw new Error("duplicate assessment requires an equivalent or existing_broader scopeComparison");let B=e.context?.explanations.find(X=>X.id===A);if(!B)throw new Error("duplicate assessment must cite a surfaced explanation");if(ii(e.requestText)&&!lp(B))throw new Error("duplicate explanation does not cover the requested broader scope");return{draft:{decision:"none",reason:y,duplicateOfExplanationId:A,scopeComparison:D,...x.length?{usedExplanationIds:x}:{},...w?{appliedExplanationIds:w}:{}},visibleText:o}}return{draft:{decision:"none",reason:y,...x.length?{usedExplanationIds:x}:{},...w?{appliedExplanationIds:w}:{}},visibleText:o}}if(a.decision==="recognize"){let y=Te(a.explanationId,100);if(!y)throw new Error("recognition requires explanationId");let p=e.context?.explanations.find(m=>m.id===y);if(!p)throw new Error("recognition must cite a surfaced explanation");if(p.state!=="grounded")throw new Error("recognition must cite a grounded explanation");let b=a.summary,v={title:Te(b?.title,120),detail:Te(b?.detail,500)};if(!v.title||!v.detail)throw new Error("recognition summary title and detail are required");return{draft:{decision:"recognize",explanationId:y,summary:v},visibleText:o}}if(a.decision==="apply"){let y=a.summary,p={title:Te(y?.title,120),detail:Te(y?.detail,500)};if(!p.title||!p.detail)throw new Error("application summary title and detail are required");let b=Array.isArray(a.appliedExplanationIds)?a.appliedExplanationIds.filter(A=>typeof A=="string"&&!!A.trim()):[];if(!b.length)throw new Error("application requires appliedExplanationIds");let v=new Map(e.context?.explanations.map(A=>[A.id,A])??[]);if(b.some(A=>!v.has(A)))throw new Error("application must cite only surfaced explanations");if(!e.applicationOccurred)return{draft:{decision:"none",reason:"application_only",usedExplanationIds:[...new Set(b)]},visibleText:o};let m=new Set(e.context?.pendingGroundingExplanationIds??[]),x=b.filter(A=>{let D=v.get(A);return D&&(D.state==="emerging"||D.state==="testing")&&!m.has(A)});if(!x.length){if(b.every(D=>v.get(D)?.state==="grounded"||m.has(D)))return{draft:{decision:"none",reason:"application_only",appliedExplanationIds:b},visibleText:o};throw new Error("application must cite a surfaced ungrounded explanation")}let g=a.grounding,w=typeof g?.explanationId=="string"&&x.includes(g.explanationId)?g.explanationId:x[0];return{draft:{decision:"apply",summary:p,appliedExplanationIds:b,grounding:{explanationId:w,question:Te(g?.question,300)||"Does applying this understanding here match your intent?"}},visibleText:o}}if(a.decision!==void 0&&a.decision!=="mutate")throw new Error("imprint decision is invalid");let d=a.summary,c=d?.kind;if(!["added","strengthened","refined","challenged","exception","consolidated"].includes(String(c)))throw new Error("summary.kind is invalid");let u={kind:c,title:Te(d?.title,120),detail:Te(d?.detail,500)};if(!u.title||!u.detail)throw new Error("summary title and detail are required");let f=Array.isArray(a.appliedExplanationIds)?a.appliedExplanationIds.filter(y=>typeof y=="string"&&!!y.trim()):[],h=[];for(let y of Array.isArray(a.mutations)?a.mutations:[]){if(!y||typeof y!="object")continue;let p=y;if(p.op==="add"&&["intention","principle","pattern"].includes(String(p.kind))){let b=Te(p.statement),v=Te(p.rationale);if(!b||!v)continue;h.push({op:"add",clientId:Te(p.clientId,100)||void 0,kind:p.kind,statement:b,rationale:v,scope:la(p.scope),rootReason:Te(p.rootReason,300)||void 0})}else if(p.op==="revise"&&typeof p.explanationId=="string"){let b={op:"revise",explanationId:p.explanationId,statement:Te(p.statement)||void 0,rationale:Te(p.rationale)||void 0,scope:la(p.scope),reopenGrounding:p.reopenGrounding===!0};(b.statement||b.rationale||b.scope||b.reopenGrounding)&&h.push(b)}else if(p.op==="evidence"&&typeof p.explanationId=="string"&&["supports","challenges","excepts"].includes(String(p.stance))){let b=Te(p.summary);b&&h.push({op:"evidence",explanationId:p.explanationId,stance:p.stance,summary:b})}else if(p.op==="relation"){if(!["expresses","excepts"].includes(String(p.type)))throw new Error("relation type is invalid");let b=Te(p.rationale),v=pa(p.from,p.fromId,p.fromStoreId),m=pa(p.to,p.toId,p.toStoreId);if(!b)throw new Error("relation rationale is required");if(!v||!m)throw new Error("relation endpoints require an explanationId or clientId");h.push({op:"relation",type:p.type,from:v,to:m,rationale:b})}else if(p.op==="supersede"&&typeof p.explanationId=="string"&&typeof p.replacementId=="string"){let b=Te(p.reason);b&&h.push({op:"supersede",explanationId:p.explanationId,replacementId:p.replacementId,reason:b})}else if(p.op==="bind_concrete"&&typeof p.explanationId=="string"){let b=Te(p.modelPath,300);b&&h.push({op:"bind_concrete",explanationId:p.explanationId,modelPath:b,rationale:Te(p.rationale)})}else p.op==="retire"&&typeof p.explanationId=="string"&&h.push({op:"retire",explanationId:p.explanationId,reason:Te(p.reason)})}let S=a.grounding,I=S&&typeof S.explanationId=="string"&&Te(S.question)?{explanationId:S.explanationId,question:Te(S.question,300)}:void 0;return{draft:{decision:"mutate",summary:u,appliedExplanationIds:f,mutations:h,grounding:I},visibleText:o}}catch(a){return{visibleText:o,error:a instanceof Error?a.message:String(a)}}}function Yn(t,e={}){let n=t?.explanations??[],o=new Set(t?.pendingGroundingExplanationIds??[]),r=new Set(t?.correctionExplanationIds??[]),i=ii(e.requestText),s=t?.retrievalIntent,a=t?.historicalCaveats??[],d=n.find(h=>h.storeId&&!h.readOnly)?.storeId,c=(h,S)=>{let I=h[S];return I?`[${I.storeId}] ${I.explanationId}`:S==="from"?h.fromId:h.toId},u=!!t?.relations?.some(h=>h.from&&h.to&&h.from.storeId!==h.to.storeId),f=n.some(h=>h.readOnly);return["","## Continuous imprinting","","An imprint is provisional shared understanding learned through human-AI collaboration. It is advisory, not authoritative product truth. Accepted product decisions above always win when they conflict.",...n.length?["","Relevant explanations from the project imprint:",...n.map((h,S)=>[`${S+1}. [${h.state}; ${h.kind}] ${h.statement}`,` - Why: ${h.rationale}`,` - Scope: ${h.scope.kind} ${h.scope.values.join(", ")}`,` - Explanation: ${h.id}`,...h.storeId?[` - Store: ${h.storeId}${h.readOnly?" (read-only)":" (writable primary)"}`]:[],...o.has(h.id)?[" - Grounding: already pending; do not ask again"]:[],...r.has(h.id)?[" - Correction: the developer selected No for this explanation and the current reply supplies the missing correction context"]:[],...h.concrete.map(I=>` - Concrete terminal: ${I.modelPath} = ${JSON.stringify(I.value)}`)].join(`
9
9
  `)),...t?.truncated?["Additional imprint context exists outside this bounded packet."]:[]]:[],...t?.relations?.length?["","Known explanation topology:",...t.relations.map(h=>`- ${h.storeId?`[owned by ${h.storeId}${h.readOnly?"; read-only":""}] `:""}${c(h,"from")} --${h.type}--> ${c(h,"to")}: ${h.rationale}`)]:[],...f||u?["","Store-qualified topology remains locally owned: the relation must originate at an explanation in the writable primary store, while its target may be in a mounted read-only store. Never proxy a relation whose source belongs to a mounted store.",`For a cross-store relation, use qualified endpoints: {"op":"relation","type":"expresses|excepts","from":{"storeId":"${d??"<writable-primary-store>"}","clientId":"<new-specific-client-id>"},"to":{"storeId":"<mounted-target-store>","explanationId":"<existing-abstract-target-id>"},"rationale":"<why>"}. Use clientId for a new explanation created in this transaction and explanationId for an existing durable explanation.`]:[],...s?["","Explicit pattern transfer detected:",`- Target: ${s.target}`,`- Reference: ${s.reference}`,"Before editing, state which dimensions you intend to transfer from the reference and which target-specific behavior you will preserve. Compare the relevant surface, spacing, typography, radius, and interaction behavior; transfer only the dimensions supported by the request and evidence. If the intended transfer remains materially ambiguous after inspecting both anchors, ask one focused question."]:[],...a.length?["","Directly relevant challenged history (historical caveats, not current Imprint truth):",...a.map((h,S)=>[`${S+1}. [challenged; ${h.kind}] ${h.statement}`,` - Why it was previously proposed: ${h.rationale}`,` - Scope: ${h.scope.kind} ${h.scope.values.join(", ")}`,` - Historical explanation: ${h.id}`,...h.storeId?[` - Store: ${h.storeId}${h.readOnly?" (read-only)":" (writable primary)"}`]:[]].join(`
10
10
  `)),"Use these caveats only to avoid repeating a rejected or over-broad transfer. Do not cite them as usedExplanationIds or treat them as active guidance."]:[],...n.some(h=>h.readOnly)?["","Mounted-store explanations are read-only context. They may inform the work and be cited as used understanding, but do not mutate, ground, revise, or add evidence to them without an explicit writable orientation for that store."]:[],...t?.unavailableStoreIds?.length?["",`Some mounted Imprint knowledge was unavailable during this bounded read: ${t.unavailableStoreIds.join(", ")}. Do not infer its contents.`]:[],...t?.unavailableTopologyStoreIds?.length?["",`Some mounted Imprint topology was unavailable during this bounded read: ${t.unavailableTopologyStoreIds.join(", ")}. Available explanations remain usable, but do not infer missing relationships.`]:[],"","Work normally and preserve developer agency. A testing explanation may guide action as a hypothesis without asking permission first. An emerging explanation is observation-only: use it to recognize recurrence, not to choose behavior. If the developer independently repeats an emerging observation in a meaningfully different occurrence, that new application may promote it into testing and request grounding. Silence is not confirmation.","Assess learning proactively as part of completing every thread. Do not wait for the developer to ask whether there was a learning. Before choosing none, look one abstraction level above the exact edit and ask: would the reasoning behind this outcome change how a future agent handles a meaningfully different occurrence?","The developer's original annotation, ordinary instruction, scope language, and later corrections are already human-supplied evidence. They can support learning when they establish a reusable dependency, boundary, or rationale; a separate post-completion learning prompt is not required. Mere acceptance of completed work is still insufficient.","The default outcome is no imprint mutation. Completing work or making a successful design choice does not by itself constitute learning.","Application evidence is distinct from changing shared understanding. When an emerging or testing explanation materially influenced a completed action, report decision apply even when no explanation wording changed.","Applying grounded understanding does not mutate the graph. Usually report none. Use decision recognize only when visibly acknowledging the grounded explanation closes a correction loop or otherwise makes consequential reuse legible to the developer. Recognition must cite one exact surfaced grounded explanation ID; never infer or invent an ID.","Application and recognition are whole-statement operations. Cite an existing explanation only when the completed behavior is compatible with every material clause, its scope, and its exceptions. Sharing one useful clause is not a match. If the durable behavior is narrower, add one atomic explanation linked to the broader explanation when the admission tests pass; otherwise report none.","Mutate the imprint only when this collaboration changed reusable shared understanding: a future agent facing a meaningfully different task would behave differently because of what was learned here.","Relationship-first admission: before calling any completed change task-specific, compare its requested behavior and effective scope with every surfaced explanation that could plausibly govern the same subject or treatment. The developer does not need to name an Imprint concept or relation. Infer the relationship from the ordinary instruction, the annotated context, the implementation, and the surfaced explanations.","A narrower completed behavior that departs from an applicable broader explanation establishes an applicability boundary even when the developer did not say exception. Add one narrow testing explanation and link it to the broader rule with excepts. If the behaviors concern distinct concepts rather than the same rule, assess the reusable behavior as a sibling explanation instead. Do not manufacture an exception merely because implementations differ.","Scope and Imprint assessment must agree. If any resolved annotation has an effective inferred or final breadth of pattern, do not classify the Imprint decision as task_specific_detail. Either capture the reusable conceptual change, report application of existing understanding, cite a valid duplicate, or use another accurate no-op reason. The bridge rejects pattern-scoped task_specific_detail assessments.","","Before proposing a mutation, apply every admission test:","1. Reusable: it guides a future decision beyond reproducing this exact edit.","2. Novel: it is not already expressed by an explanation or its evidence.","3. Durable: it is an intention, rationale, relationship, or recurring pattern, not temporary implementation state.","4. Atomic: it expresses one claim at one abstraction level.","5. Scoped: its applicability can be named without silently generalizing.","6. Supported: the human supplied evidence, correction, or confirmation anywhere in the thread, including the original instruction, not merely acceptance of completed work or the model's own implementation choice.","If any test fails, return a decision of none.","","Usually not learning: exact copy substitutions, one-pixel adjustments, element reordering, implementation mechanics, keeping something hidden temporarily, applying an already-known pattern, or a stylistic choice made without human feedback. Distinguish mechanics from the reusable reasoning they may reveal: a CSS property alone is not learning, but a human-directed causal rule such as keeping optical adjustment out of layout geometry may be. This heuristic never overrides relationship-first admission: a small local change that narrows or contradicts an applicable surfaced explanation may establish an exception or correction. A task-specific edit otherwise becomes learning only if the human establishes a reusable dependency, applicability boundary, or rationale beyond that edit.","When a candidate overlaps an existing explanation, consolidate before adding. Same meaning plus a new observation means evidence only. A concrete application means bind_concrete, not a broader explanation. A scope correction means revise scope. A direct disagreement means add the replacement and supersede the contradicted explanation. A different abstraction level means a separate related explanation.","Duplicate means the same reusable claim is already represented at an equivalent or broader conceptual scope. Shared code, a centralized component, or implementation reuse does not establish conceptual duplication. A narrower component-, route-, selector-, or file-scoped explanation is not a duplicate of newly broadened applicability.","Words such as all, every, across, throughout, globally, and project-wide are explicit applicability signals. When the human broadens a grounded explanation, preserve the grounded narrower explanation and add a broader testing explanation. Link the narrower explanation to the broader one with expresses. Do not substitute another no-op reason for that scope change.",...i?["CURRENT SCOPE SIGNAL: The developer used explicit broadening language in this instruction. Do not classify it as duplicate unless the cited existing explanation already expresses universal or project-wide applicability."]:[],"Keep correction identity explicit. If feedback refines an emerging or testing explanation without rejecting its underlying claim, revise it and set reopenGrounding true; do not also add challenging evidence to that same explanation. If feedback rejects the claim as written, preserve that rejected wording, add a distinct replacement, and supersede the old explanation. Never revise an explanation and mark that same identity challenged in one update.","When an explanation is marked Correction in the supplied context, the developer selected No but the graph has not yet been changed. Interpret the current reply before mutating anything. Decide whether it corrects only the implementation result, the explanation scope, or the reasoning. Do not challenge the whole explanation for a narrow correction, and do not recognize a different explanation merely because one clause overlaps.","Topology assessment is mandatory for every add mutation. Imprint topology has exactly two relation types: expresses and excepts. expresses always points from the more specific, concrete, or lower-level explanation to the more abstract explanation it expresses. excepts points from the narrower exception to the rule whose applicability it limits. Support and challenge belong in evidence; correction belongs in supersede; neither is a topology relation. If an addition is genuinely a new root with no meaningful relative, include rootReason explaining why. Unmapped additions without rootReason are rejected.","Never append implementation facts to an intention merely because they occurred in the same component. Grounded explanations are append-only: add evidence for a compatible observation, but never revise or demote the grounded explanation. A material change in meaning, causal rationale, abstraction level, or applicability must be a new testing explanation linked with expresses or excepts. Multiple specific explanations may express the same parent, and one explanation may express multiple parents; never create an expresses cycle.","Grounded explanations may support new higher-level theory. Emerging explanations must not be the sole basis for another durable explanation. Concrete project facts should remain concrete; do not turn a one-off value into a universal principle.","Request grounding when an ungrounded explanation materially influenced the action, this application produced genuinely new evidence, and that explanation does not already have grounding pending. Ask at most one grounding question per thread. The bridge supplies a fallback question when the application is otherwise valid.","","At the end, emit exactly one machine-readable <resolution> envelope after the normal response. Its `annotations` array reports annotation outcomes, and its required `imprint` field completes the learning assessment. The envelope is hidden from the developer. Do not emit a separate <imprint> block.",'As soon as one or more surfaced explanations become actively useful during the work, emit `<imprint-use>{"explanationIds":["<every actively useful surfaced explanation id>"]}</imprint-use>` immediately. This live receipt is hidden from conversational prose. Emit it at the point of use rather than waiting for the final response. Emit a later marker only when additional explanations become actively useful. Never emit it for explanations that were merely retrieved, read, searched, or considered.',"Treat Imprint as actively useful when a surfaced explanation materially informs an answer, recommendation, implementation choice, or other decision. Whenever it is actively useful, always cite every materially used surfaced explanation in `usedExplanationIds`. This produces a usage receipt only; it does not strengthen or mutate shared understanding. Do not cite explanations that were merely retrieved, read, or considered but did not influence the result.","`appliedExplanationIds` is narrower: include an explanation there only when it governed a completed implementation or other observable action that genuinely tests the explanation. Never use `appliedExplanationIds` for an answer-only, informational, research, or read-only request. An explanation may be used without being applied; every applied explanation is also understood to be used.","For no learning, include:",'"imprint":{"decision":"none","reason":"application_only|transient_state|concrete_without_model_path|duplicate|insufficient_evidence|task_specific_detail|no_shared_understanding_change","usedExplanationIds":["<every surfaced explanation that was actively useful, or omit when none>"]}',"A no-op reason cannot suppress genuine application evidence. When a completed action was governed by an ungrounded explanation, report decision apply directly so the summary and grounding question are intentional. Answering a question with that explanation is usage, not application.","When and only when reason is duplicate, also include `duplicateOfExplanationId` naming one surfaced explanation and `scopeComparison` set to `equivalent` or `existing_broader`. The bridge rejects uncited duplicates and duplicates whose cited explanation cannot cover explicit broadening language.","For application evidence without a conceptual change, include:",'"imprint":{"decision":"apply","summary":{"title":"<short expandable-summary title>","detail":"<how the explanation influenced this completed action>"},"appliedExplanationIds":["<surfaced emerging or testing explanation id>"],"grounding":{"explanationId":"<one applied id>","question":"<brief post-application confirmation question>"}}',"For a consequential, non-mutating reuse of grounded understanding that should be visible, include:",'"imprint":{"decision":"recognize","explanationId":"<one exact surfaced grounded explanation id>","summary":{"title":"<short name for the recognized understanding>","detail":"<how it guided this outcome>"}}',"Or, only after every admission test passes for a conceptual change:",'"imprint":{"decision":"mutate","summary":{"kind":"added|strengthened|refined|challenged|exception|consolidated","title":"<short expandable-summary title>","detail":"<what changed in shared understanding>"},"appliedExplanationIds":["<only an ungrounded explanation materially tested here>"],"mutations":[{"op":"add","clientId":"new-1","kind":"intention|principle|pattern","statement":"<one durable atomic explanation>","rationale":"<why the evidence supports it>","scope":{"kind":"project|route|component|selector|file","values":["<scope>"]},"rootReason":"<only when this is genuinely unrelated to every surfaced or new explanation>"},{"op":"revise","explanationId":"<only an emerging or testing id>","statement":"<optional>","rationale":"<optional>","scope":{"kind":"component","values":["CardTile"]},"reopenGrounding":false},{"op":"evidence","explanationId":"<id>","stance":"supports|challenges|excepts","summary":"<thread evidence>"},{"op":"relation","type":"expresses|excepts","from":{"clientId":"<new-specific-client-id>"},"to":{"explanationId":"<existing-abstract-id>"},"rationale":"<why; use clientId for new transaction-local explanations and explanationId for existing durable explanations>"},{"op":"supersede","explanationId":"<contradicted old id>","replacementId":"<new clientId or existing id>","reason":"<direct conflict>"},{"op":"bind_concrete","explanationId":"<id or clientId>","modelPath":"<exact existing model path>","rationale":"<how this fact expresses the explanation>"},{"op":"retire","explanationId":"<id>","reason":"<why>"}],"grounding":{"explanationId":"<one applied ungrounded id or clientId>","question":"<brief post-application confirmation question>"}}','The final shape is `<resolution>{"annotations":[...],"imprint":{...}}</resolution>`. The `imprint` field is required even when the decision is none; omission leaves the completed run explicitly unassessed.',"Include only mutation objects actually needed. A new explanation established through completed implementation must include its clientId in appliedExplanationIds; the bridge also derives this application from a completed change as a safeguard. Applying a grounded explanation never requires a mutation, but actively using it still requires its id in appliedExplanationIds. Never claim that a new explanation is grounded."].join(`
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{b as t}from"./chunk-4XEZ4YQA.mjs";import"./chunk-N2ZEZCHO.mjs";import{b as e}from"./chunk-J3UIBBU2.mjs";export{t as PopmeltProvider,e as usePopmelt};
2
+ import{b as t}from"./chunk-QO2FFOQ4.mjs";import"./chunk-N2ZEZCHO.mjs";import{b as e}from"./chunk-J3UIBBU2.mjs";export{t as PopmeltProvider,e as usePopmelt};
@@ -1,4 +1,4 @@
1
- import{a as o}from"./chunk-DBKGRJ7N.mjs";import"./chunk-K5IIMTQE.mjs";import"./chunk-NOHXTT24.mjs";import{fileURLToPath as a}from"url";function c(t={}){return{name:"popmelt",hooks:{"astro:config:setup"({command:r,config:i,updateConfig:n,injectScript:p}){if(r!=="dev")return;let{client:e=!0,...s}=t;n({vite:{plugins:[o({...s,projectRoot:t.projectRoot??a(i.root)})],optimizeDeps:{include:e?["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"]:[]}}}),p("page",e?d:`
1
+ import{a as o}from"./chunk-7Z5QN5LB.mjs";import"./chunk-RILGQYOR.mjs";import"./chunk-NOHXTT24.mjs";import{fileURLToPath as a}from"url";function c(t={}){return{name:"popmelt",hooks:{"astro:config:setup"({command:r,config:i,updateConfig:n,injectScript:p}){if(r!=="dev")return;let{client:e=!0,...s}=t;n({vite:{plugins:[o({...s,projectRoot:t.projectRoot??a(i.root)})],optimizeDeps:{include:e?["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"]:[]}}}),p("page",e?d:`
2
2
  import { bridgeUrl, projectId } from 'virtual:popmelt/bridge';
3
3
  if (bridgeUrl) window.__POPMELT_BRIDGE_URL__ = bridgeUrl;
4
4
  if (projectId) window.__POPMELT_PROJECT_ID__ = projectId;
@@ -1,4 +1,4 @@
1
- import{a as s,b as d}from"./chunk-K5IIMTQE.mjs";import{b as i}from"./chunk-NOHXTT24.mjs";import{addPluginTemplate as l,defineNuxtModule as m}from"nuxt/kit";var a=m({meta:{name:"@popmelt.com/core/nuxt",configKey:"popmelt"},async setup(n,e){if(!e.options.dev)return;let p={config:{server:e.options.devServer},middlewares:{use(){}}},t=await s({...n,projectRoot:n.projectRoot??e.options.rootDir},p,3e3);if(t.port===null)return;e.hook("vite:extend",({config:r})=>{r.optimizeDeps??={},r.optimizeDeps.include=[...new Set([...r.optimizeDeps.include??[],"react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"])]});let o=await d(t,p),u=o?i(o):void 0;e.hook("close",async()=>{u?.(),await o?.release()}),l({filename:"popmelt.client.mjs",mode:"client",getContents:()=>`import { defineNuxtPlugin } from '#app';
1
+ import{a as s,b as d}from"./chunk-RILGQYOR.mjs";import{b as i}from"./chunk-NOHXTT24.mjs";import{addPluginTemplate as l,defineNuxtModule as m}from"nuxt/kit";var a=m({meta:{name:"@popmelt.com/core/nuxt",configKey:"popmelt"},async setup(n,e){if(!e.options.dev)return;let p={config:{server:e.options.devServer},middlewares:{use(){}}},t=await s({...n,projectRoot:n.projectRoot??e.options.rootDir},p,3e3);if(t.port===null)return;e.hook("vite:extend",({config:r})=>{r.optimizeDeps??={},r.optimizeDeps.include=[...new Set([...r.optimizeDeps.include??[],"react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","lucide-react"])]});let o=await d(t,p),u=o?i(o):void 0;e.hook("close",async()=>{u?.(),await o?.release()}),l({filename:"popmelt.client.mjs",mode:"client",getContents:()=>`import { defineNuxtPlugin } from '#app';
2
2
  export default defineNuxtPlugin((nuxtApp) => {
3
3
  let disposed = false;
4
4
  let mounting;
@@ -1 +1 @@
1
- import{a}from"./chunk-DBKGRJ7N.mjs";import"./chunk-K5IIMTQE.mjs";import"./chunk-NOHXTT24.mjs";export{a as popmelt};
1
+ import{a}from"./chunk-7Z5QN5LB.mjs";import"./chunk-RILGQYOR.mjs";import"./chunk-NOHXTT24.mjs";export{a as popmelt};
@@ -1,4 +1,4 @@
1
- import{a as Bi,b as Li}from"./chunk-NOHXTT24.mjs";import{spawn as Wm}from"child_process";import{closeSync as Gm,openSync as Vm}from"fs";import{appendFile as Km,mkdir as Hm,readFile as Qm,realpath as Xm}from"fs/promises";import{dirname as Ym,join as Oi}from"path";import{fileURLToPath as Zm}from"url";function Yt(t){return Nd(t).slice(0,12)}var Dd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Nd(t){let e=typeof TextEncoder<"u"?Array.from(new TextEncoder().encode(t)):qd(t),n=e.length*8;for(e.push(128);e.length%64!==56;)e.push(0);for(let h=7;h>=0;h--)e.push(n/Math.pow(2,h*8)&255);let r=1779033703,o=3144134277,i=1013904242,s=2773480762,a=1359893119,d=2600822924,c=528734635,I=1541459225,y=new Array(64);for(let h=0;h<e.length;h+=64){for(let m=0;m<16;m++){let g=h+m*4;y[m]=(e[g]<<24|e[g+1]<<16|e[g+2]<<8|e[g+3])>>>0}for(let m=16;m<64;m++){let g=mt(y[m-15],7)^mt(y[m-15],18)^y[m-15]>>>3,A=mt(y[m-2],17)^mt(y[m-2],19)^y[m-2]>>>10;y[m]=y[m-16]+g+y[m-7]+A>>>0}let k=r,v=o,f=i,p=s,b=a,w=d,u=c,S=I;for(let m=0;m<64;m++){let g=mt(b,6)^mt(b,11)^mt(b,25),A=b&w^~b&u,D=S+g+A+Dd[m]+y[m]>>>0,q=mt(k,2)^mt(k,13)^mt(k,22),X=k&v^k&f^v&f,oe=q+X>>>0;S=u,u=w,w=b,b=p+D>>>0,p=f,f=v,v=k,k=D+oe>>>0}r=r+k>>>0,o=o+v>>>0,i=i+f>>>0,s=s+p>>>0,a=a+b>>>0,d=d+w>>>0,c=c+u>>>0,I=I+S>>>0}return[r,o,i,s,a,d,c,I].map(h=>h.toString(16).padStart(8,"0")).join("")}function mt(t,e){return t>>>e|t<<32-e}function qd(t){let e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):e.push(224|r>>12,128|r>>6&63,128|r&63)}return e}var Fi={name:"@popmelt.com/core",version:"0.22.0",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var vt=Fi.version;import{execFileSync as Im,spawn as ld}from"child_process";import{randomUUID as Pt}from"crypto";function bt(t){return t.startsWith("claude:")?"claude":"codex"}function Ui(t){return`${bt(t)}-session:${t}`}function Jt(t){return/^(codex|claude)-session:/.test(t)}import{mkdir as wm,readFile as vm,readdir as bm,realpath as xm,stat as hd,unlink as Sm,writeFile as fo}from"fs/promises";import{createServer as Tm}from"http";import{tmpdir as km}from"os";import{basename as ho,isAbsolute as $i,join as lt,relative as Pm,resolve as Rm}from"path";function wo(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((o,i)=>wo(o,`${e}[${i}]`,n));else for(let[o,i]of Object.entries(t))wo(i,`${e}.${o}`,n);n.delete(t)}function mr(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");wo(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}function zi(t){let e=t.instruction?.trim();return e?t.attachments?.some(r=>r.name?.trim()===e)?null:e:null}function vo(t,e){let n=t?.tagName?.toLowerCase(),r=t?.id?`#${t.id}`:"",o=t?.className?`.${t.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${r}${o}`:e;return t?.reactComponent?`<${t.reactComponent}> ${i}`:i}function Bd(t){let e=t.elements?.[0]?.reactComponent||t.elements?.[0]?.tagName||t.linkedSelector,n=t.type&&t.type!=="annotation"?`${t.type} annotation`:"Annotation";return e?`${n} on ${e}`:n}function Wi(t){let e=t.annotations.map(o=>{let i=o.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:o.id,pathname:o.pathname,text:zi(o)??Bd(o),...i>0?{interactionEpisodeStepCount:i}:{}}}),n=new Map,r=o=>{let i=`${o.pathname??""}:${o.durableSelector??o.selector}`,s=n.get(i);if(s){s.changes.push(o.text),o.annotationNumber!==void 0&&(s.annotationNumber===void 0||o.annotationNumber<s.annotationNumber)&&(s.annotationNumber=o.annotationNumber);return}let a={kind:"changes",elementKey:i,elementLabel:vo(o.element,o.selector),...o.annotationNumber!==void 0?{annotationNumber:o.annotationNumber}:{},pathname:o.pathname,changes:[o.text]};n.set(i,a),e.push(a)};for(let o of t.styleModifications??[])for(let i of o.changes)r({...o,text:`${i.property}: ${i.original||"unset"} \u2192 ${i.modified||"unset"}${i.token?` (${i.token})`:""}`});for(let o of t.textModifications??[])r({...o,text:`Text: ${o.original||"empty"} \u2192 ${o.modified||"empty"}`});for(let o of t.domModifications??[])r({...o,text:o.operation==="copy"?"Copied element":"Moved element"});return t.spacingTokenChanges?.length&&e.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:t.spacingTokenChanges.map(o=>`${o.tokenName}: ${o.originalPx}px \u2192 ${o.newPx}px`)}),e}function Gi(t){let e=t.annotations.flatMap(o=>{let i=zi(o);return i?[{instruction:i,pathname:o.pathname}]:[]});if(e.length===0)return;if(new Set(e.map(o=>o.pathname).filter(Boolean)).size<=1)return e.map(o=>o.instruction).join(`
1
+ import{a as Bi,b as Li}from"./chunk-NOHXTT24.mjs";import{spawn as Wm}from"child_process";import{closeSync as Gm,openSync as Vm}from"fs";import{appendFile as Km,mkdir as Hm,readFile as Qm,realpath as Xm}from"fs/promises";import{dirname as Ym,join as Oi}from"path";import{fileURLToPath as Zm}from"url";function Yt(t){return Nd(t).slice(0,12)}var Dd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Nd(t){let e=typeof TextEncoder<"u"?Array.from(new TextEncoder().encode(t)):qd(t),n=e.length*8;for(e.push(128);e.length%64!==56;)e.push(0);for(let h=7;h>=0;h--)e.push(n/Math.pow(2,h*8)&255);let r=1779033703,o=3144134277,i=1013904242,s=2773480762,a=1359893119,d=2600822924,c=528734635,I=1541459225,y=new Array(64);for(let h=0;h<e.length;h+=64){for(let m=0;m<16;m++){let g=h+m*4;y[m]=(e[g]<<24|e[g+1]<<16|e[g+2]<<8|e[g+3])>>>0}for(let m=16;m<64;m++){let g=mt(y[m-15],7)^mt(y[m-15],18)^y[m-15]>>>3,A=mt(y[m-2],17)^mt(y[m-2],19)^y[m-2]>>>10;y[m]=y[m-16]+g+y[m-7]+A>>>0}let k=r,v=o,f=i,p=s,b=a,w=d,u=c,S=I;for(let m=0;m<64;m++){let g=mt(b,6)^mt(b,11)^mt(b,25),A=b&w^~b&u,D=S+g+A+Dd[m]+y[m]>>>0,q=mt(k,2)^mt(k,13)^mt(k,22),X=k&v^k&f^v&f,oe=q+X>>>0;S=u,u=w,w=b,b=p+D>>>0,p=f,f=v,v=k,k=D+oe>>>0}r=r+k>>>0,o=o+v>>>0,i=i+f>>>0,s=s+p>>>0,a=a+b>>>0,d=d+w>>>0,c=c+u>>>0,I=I+S>>>0}return[r,o,i,s,a,d,c,I].map(h=>h.toString(16).padStart(8,"0")).join("")}function mt(t,e){return t>>>e|t<<32-e}function qd(t){let e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):e.push(224|r>>12,128|r>>6&63,128|r&63)}return e}var Fi={name:"@popmelt.com/core",version:"0.22.1",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var vt=Fi.version;import{execFileSync as Im,spawn as ld}from"child_process";import{randomUUID as Pt}from"crypto";function bt(t){return t.startsWith("claude:")?"claude":"codex"}function Ui(t){return`${bt(t)}-session:${t}`}function Jt(t){return/^(codex|claude)-session:/.test(t)}import{mkdir as wm,readFile as vm,readdir as bm,realpath as xm,stat as hd,unlink as Sm,writeFile as fo}from"fs/promises";import{createServer as Tm}from"http";import{tmpdir as km}from"os";import{basename as ho,isAbsolute as $i,join as lt,relative as Pm,resolve as Rm}from"path";function wo(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((o,i)=>wo(o,`${e}[${i}]`,n));else for(let[o,i]of Object.entries(t))wo(i,`${e}.${o}`,n);n.delete(t)}function mr(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");wo(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}function zi(t){let e=t.instruction?.trim();return e?t.attachments?.some(r=>r.name?.trim()===e)?null:e:null}function vo(t,e){let n=t?.tagName?.toLowerCase(),r=t?.id?`#${t.id}`:"",o=t?.className?`.${t.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${r}${o}`:e;return t?.reactComponent?`<${t.reactComponent}> ${i}`:i}function Bd(t){let e=t.elements?.[0]?.reactComponent||t.elements?.[0]?.tagName||t.linkedSelector,n=t.type&&t.type!=="annotation"?`${t.type} annotation`:"Annotation";return e?`${n} on ${e}`:n}function Wi(t){let e=t.annotations.map(o=>{let i=o.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:o.id,pathname:o.pathname,text:zi(o)??Bd(o),...i>0?{interactionEpisodeStepCount:i}:{}}}),n=new Map,r=o=>{let i=`${o.pathname??""}:${o.durableSelector??o.selector}`,s=n.get(i);if(s){s.changes.push(o.text),o.annotationNumber!==void 0&&(s.annotationNumber===void 0||o.annotationNumber<s.annotationNumber)&&(s.annotationNumber=o.annotationNumber);return}let a={kind:"changes",elementKey:i,elementLabel:vo(o.element,o.selector),...o.annotationNumber!==void 0?{annotationNumber:o.annotationNumber}:{},pathname:o.pathname,changes:[o.text]};n.set(i,a),e.push(a)};for(let o of t.styleModifications??[])for(let i of o.changes)r({...o,text:`${i.property}: ${i.original||"unset"} \u2192 ${i.modified||"unset"}${i.token?` (${i.token})`:""}`});for(let o of t.textModifications??[])r({...o,text:`Text: ${o.original||"empty"} \u2192 ${o.modified||"empty"}`});for(let o of t.domModifications??[])r({...o,text:o.operation==="copy"?"Copied element":"Moved element"});return t.spacingTokenChanges?.length&&e.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:t.spacingTokenChanges.map(o=>`${o.tokenName}: ${o.originalPx}px \u2192 ${o.newPx}px`)}),e}function Gi(t){let e=t.annotations.flatMap(o=>{let i=zi(o);return i?[{instruction:i,pathname:o.pathname}]:[]});if(e.length===0)return;if(new Set(e.map(o=>o.pathname).filter(Boolean)).size<=1)return e.map(o=>o.instruction).join(`
2
2
 
3
3
  `);let r=new Map;for(let o of e){let i=o.pathname||"(unknown)",s=r.get(i)??[];s.push(o.instruction),r.set(i,s)}return[...r.entries()].map(([o,i])=>`\`${o}\`
4
4
  ${i.map(s=>`- ${s}`).join(`
package/dist/server.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{spawn as Hm}from"child_process";import{closeSync as Qm,openSync as Xm}from"fs";import{appendFile as Ym,mkdir as Zm,readFile as ef,realpath as tf}from"fs/promises";import{dirname as nf,join as Di}from"path";import{fileURLToPath as rf}from"url";function Yt(t){return qd(t).slice(0,12)}var Nd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function qd(t){let e=typeof TextEncoder<"u"?Array.from(new TextEncoder().encode(t)):Jd(t),n=e.length*8;for(e.push(128);e.length%64!==56;)e.push(0);for(let h=7;h>=0;h--)e.push(n/Math.pow(2,h*8)&255);let r=1779033703,o=3144134277,i=1013904242,s=2773480762,a=1359893119,d=2600822924,c=528734635,y=1541459225,I=new Array(64);for(let h=0;h<e.length;h+=64){for(let m=0;m<16;m++){let g=h+m*4;I[m]=(e[g]<<24|e[g+1]<<16|e[g+2]<<8|e[g+3])>>>0}for(let m=16;m<64;m++){let g=mt(I[m-15],7)^mt(I[m-15],18)^I[m-15]>>>3,A=mt(I[m-2],17)^mt(I[m-2],19)^I[m-2]>>>10;I[m]=I[m-16]+g+I[m-7]+A>>>0}let k=r,v=o,f=i,p=s,b=a,w=d,u=c,S=y;for(let m=0;m<64;m++){let g=mt(b,6)^mt(b,11)^mt(b,25),A=b&w^~b&u,D=S+g+A+Nd[m]+I[m]>>>0,q=mt(k,2)^mt(k,13)^mt(k,22),X=k&v^k&f^v&f,oe=q+X>>>0;S=u,u=w,w=b,b=p+D>>>0,p=f,f=v,v=k,k=D+oe>>>0}r=r+k>>>0,o=o+v>>>0,i=i+f>>>0,s=s+p>>>0,a=a+b>>>0,d=d+w>>>0,c=c+u>>>0,y=y+S>>>0}return[r,o,i,s,a,d,c,y].map(h=>h.toString(16).padStart(8,"0")).join("")}function mt(t,e){return t>>>e|t<<32-e}function Jd(t){let e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):e.push(224|r>>12,128|r>>6&63,128|r&63)}return e}var Li={name:"@popmelt.com/core",version:"0.22.0",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var vt=Li.version;import{execFileSync as wm,spawn as cd}from"child_process";import{randomUUID as Pt}from"crypto";function bt(t){return t.startsWith("claude:")?"claude":"codex"}function Fi(t){return`${bt(t)}-session:${t}`}function Jt(t){return/^(codex|claude)-session:/.test(t)}import{mkdir as vm,readFile as bm,readdir as xm,realpath as Sm,stat as fd,unlink as Tm,writeFile as fo}from"fs/promises";import{createServer as km}from"http";import{tmpdir as Pm}from"os";import{basename as ho,isAbsolute as $i,join as lt,relative as Rm,resolve as Am}from"path";function wo(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((o,i)=>wo(o,`${e}[${i}]`,n));else for(let[o,i]of Object.entries(t))wo(i,`${e}.${o}`,n);n.delete(t)}function mr(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");wo(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}function Ui(t){let e=t.instruction?.trim();return e?t.attachments?.some(r=>r.name?.trim()===e)?null:e:null}function vo(t,e){let n=t?.tagName?.toLowerCase(),r=t?.id?`#${t.id}`:"",o=t?.className?`.${t.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${r}${o}`:e;return t?.reactComponent?`<${t.reactComponent}> ${i}`:i}function Ld(t){let e=t.elements?.[0]?.reactComponent||t.elements?.[0]?.tagName||t.linkedSelector,n=t.type&&t.type!=="annotation"?`${t.type} annotation`:"Annotation";return e?`${n} on ${e}`:n}function zi(t){let e=t.annotations.map(o=>{let i=o.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:o.id,pathname:o.pathname,text:Ui(o)??Ld(o),...i>0?{interactionEpisodeStepCount:i}:{}}}),n=new Map,r=o=>{let i=`${o.pathname??""}:${o.durableSelector??o.selector}`,s=n.get(i);if(s){s.changes.push(o.text),o.annotationNumber!==void 0&&(s.annotationNumber===void 0||o.annotationNumber<s.annotationNumber)&&(s.annotationNumber=o.annotationNumber);return}let a={kind:"changes",elementKey:i,elementLabel:vo(o.element,o.selector),...o.annotationNumber!==void 0?{annotationNumber:o.annotationNumber}:{},pathname:o.pathname,changes:[o.text]};n.set(i,a),e.push(a)};for(let o of t.styleModifications??[])for(let i of o.changes)r({...o,text:`${i.property}: ${i.original||"unset"} \u2192 ${i.modified||"unset"}${i.token?` (${i.token})`:""}`});for(let o of t.textModifications??[])r({...o,text:`Text: ${o.original||"empty"} \u2192 ${o.modified||"empty"}`});for(let o of t.domModifications??[])r({...o,text:o.operation==="copy"?"Copied element":"Moved element"});return t.spacingTokenChanges?.length&&e.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:t.spacingTokenChanges.map(o=>`${o.tokenName}: ${o.originalPx}px \u2192 ${o.newPx}px`)}),e}function Wi(t){let e=t.annotations.flatMap(o=>{let i=Ui(o);return i?[{instruction:i,pathname:o.pathname}]:[]});if(e.length===0)return;if(new Set(e.map(o=>o.pathname).filter(Boolean)).size<=1)return e.map(o=>o.instruction).join(`
1
+ import{spawn as Hm}from"child_process";import{closeSync as Qm,openSync as Xm}from"fs";import{appendFile as Ym,mkdir as Zm,readFile as ef,realpath as tf}from"fs/promises";import{dirname as nf,join as Di}from"path";import{fileURLToPath as rf}from"url";function Yt(t){return qd(t).slice(0,12)}var Nd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function qd(t){let e=typeof TextEncoder<"u"?Array.from(new TextEncoder().encode(t)):Jd(t),n=e.length*8;for(e.push(128);e.length%64!==56;)e.push(0);for(let h=7;h>=0;h--)e.push(n/Math.pow(2,h*8)&255);let r=1779033703,o=3144134277,i=1013904242,s=2773480762,a=1359893119,d=2600822924,c=528734635,y=1541459225,I=new Array(64);for(let h=0;h<e.length;h+=64){for(let m=0;m<16;m++){let g=h+m*4;I[m]=(e[g]<<24|e[g+1]<<16|e[g+2]<<8|e[g+3])>>>0}for(let m=16;m<64;m++){let g=mt(I[m-15],7)^mt(I[m-15],18)^I[m-15]>>>3,A=mt(I[m-2],17)^mt(I[m-2],19)^I[m-2]>>>10;I[m]=I[m-16]+g+I[m-7]+A>>>0}let k=r,v=o,f=i,p=s,b=a,w=d,u=c,S=y;for(let m=0;m<64;m++){let g=mt(b,6)^mt(b,11)^mt(b,25),A=b&w^~b&u,D=S+g+A+Nd[m]+I[m]>>>0,q=mt(k,2)^mt(k,13)^mt(k,22),X=k&v^k&f^v&f,oe=q+X>>>0;S=u,u=w,w=b,b=p+D>>>0,p=f,f=v,v=k,k=D+oe>>>0}r=r+k>>>0,o=o+v>>>0,i=i+f>>>0,s=s+p>>>0,a=a+b>>>0,d=d+w>>>0,c=c+u>>>0,y=y+S>>>0}return[r,o,i,s,a,d,c,y].map(h=>h.toString(16).padStart(8,"0")).join("")}function mt(t,e){return t>>>e|t<<32-e}function Jd(t){let e=[];for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);r<128?e.push(r):r<2048?e.push(192|r>>6,128|r&63):e.push(224|r>>12,128|r>>6&63,128|r&63)}return e}var Li={name:"@popmelt.com/core",version:"0.22.1",description:"A tiny, powerful design layer for humans and AI",license:"PolyForm-Shield-1.0.0",author:"Popmelt <reb@popmelt.com> (https://popmelt.com)",homepage:"https://github.com/popmelt/core",bugs:{url:"https://github.com/popmelt/core/issues"},repository:{type:"git",url:"git+https://github.com/popmelt/core.git"},keywords:["ai","annotations","collaboration","devtools","react","visual-feedback"],bin:{popmelt:"dist/cli.mjs"},sideEffects:!1,packageManager:"pnpm@9.12.0",engines:{node:">=18.0.0"},scripts:{build:"tsup",clean:"git clean -xdf .turbo node_modules dist",format:'prettier --check "**/*.{ts,tsx}"',lint:"eslint . && node scripts/check-eslint-suppressions.mjs","pack:smoke":"node scripts/pack-smoke.mjs","peer:smoke":"node scripts/peer-compat-smoke.mjs","vue:smoke":"pnpm run build && node scripts/vue-install-smoke.mjs","nuxt:smoke":"pnpm run build && node scripts/nuxt-install-smoke.mjs","astro:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs astro","svelte:smoke":"pnpm run build && node scripts/framework-install-smoke.mjs svelte && node scripts/framework-install-smoke.mjs sveltekit",prepublishOnly:"pnpm run verify",test:"vitest run","test:coverage":"vitest run --coverage.enabled","test:browser":"pnpm run build && tsc --noEmit -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts","test:browser:mutation":"node e2e/check-lifecycle-mutation.mjs","test:watch":"vitest",typecheck:"tsc --noEmit --incremental false",verify:"pnpm run typecheck && pnpm run format && pnpm run lint && pnpm run test:coverage && pnpm run build && pnpm run pack:smoke"},exports:{".":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./provider":{types:"./dist/index.d.mts",import:"./dist/index.mjs"},"./browser":{types:"./dist/browser.d.mts",import:"./dist/browser.mjs"},"./server":{types:"./dist/server.d.mts",import:"./dist/server.mjs"},"./memory":{types:"./dist/memory.d.mts",import:"./dist/memory.mjs"},"./memory/legacy":{types:"./dist/memory-legacy.d.mts",import:"./dist/memory-legacy.mjs"},"./memory/store":{types:"./dist/memory-store.d.mts",import:"./dist/memory-store.mjs"},"./next":{types:"./dist/plugin-next.d.mts",import:"./dist/plugin-next.mjs",default:"./dist/plugin-next.mjs"},"./vite":{types:"./dist/plugin-vite.d.mts",import:"./dist/plugin-vite.mjs",default:"./dist/plugin-vite.mjs"},"./vite/client":{types:"./dist/vite-client.d.ts"},"./astro":{types:"./dist/plugin-astro.d.mts",import:"./dist/plugin-astro.mjs",default:"./dist/plugin-astro.mjs"},"./nuxt":{types:"./dist/plugin-nuxt.d.mts",import:"./dist/plugin-nuxt.mjs",default:"./dist/plugin-nuxt.mjs"},"./media":{types:"./dist/media.d.mts",import:"./dist/media.mjs"},"./three":{types:"./dist/adapter-three.d.mts",import:"./dist/adapter-three.mjs"},"./react-three-fiber":{types:"./dist/adapter-react-three-fiber.d.mts",import:"./dist/adapter-react-three-fiber.mjs"}},files:["dist","codex-plugin","claude-plugin","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],dependencies:{"modern-screenshot":"4.7.0",ws:"8.21.3"},peerDependencies:{nuxt:">=4.5.2 <5","lucide-react":">=1.23.0",next:">=14.0.0",react:">=18.0.0","react-dom":">=18.0.0","@react-three/fiber":">=8.0.0",three:">=0.150.0"},peerDependenciesMeta:{nuxt:{optional:!0},next:{optional:!0},"@react-three/fiber":{optional:!0},three:{optional:!0}},devDependencies:{nuxt:"4.5.2","@kit/eslint-config":"workspace:^","@react-three/fiber":"9.7.0","@tanstack/react-router":"1.120.5","@types/react":"19.1.0","@types/react-dom":"19.1.2","@types/three":"^0.185.4","@types/ws":"8.18.1","@vitejs/plugin-react":"^5.1.1","@vitejs/plugin-vue":"6.0.8","@vitest/coverage-v8":"3.2.4",eslint:"^9.24.0",geist:"1.7.2",jsdom:"26.1.0","lucide-react":"^1.23.0",next:"15.5.24",prettier:"3.5.3",react:"19.1.0","react-dom":"19.1.0",three:"^0.185.1",tsup:"^8.5.1",typescript:"^5.8.3",vite:"7.3.6",vitest:"3.2.4",vue:"3.5.42","vue-router":"5.3.1"}};var vt=Li.version;import{execFileSync as wm,spawn as cd}from"child_process";import{randomUUID as Pt}from"crypto";function bt(t){return t.startsWith("claude:")?"claude":"codex"}function Fi(t){return`${bt(t)}-session:${t}`}function Jt(t){return/^(codex|claude)-session:/.test(t)}import{mkdir as vm,readFile as bm,readdir as xm,realpath as Sm,stat as fd,unlink as Tm,writeFile as fo}from"fs/promises";import{createServer as km}from"http";import{tmpdir as Pm}from"os";import{basename as ho,isAbsolute as $i,join as lt,relative as Rm,resolve as Am}from"path";function wo(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((o,i)=>wo(o,`${e}[${i}]`,n));else for(let[o,i]of Object.entries(t))wo(i,`${e}.${o}`,n);n.delete(t)}function mr(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");wo(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}function Ui(t){let e=t.instruction?.trim();return e?t.attachments?.some(r=>r.name?.trim()===e)?null:e:null}function vo(t,e){let n=t?.tagName?.toLowerCase(),r=t?.id?`#${t.id}`:"",o=t?.className?`.${t.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${r}${o}`:e;return t?.reactComponent?`<${t.reactComponent}> ${i}`:i}function Ld(t){let e=t.elements?.[0]?.reactComponent||t.elements?.[0]?.tagName||t.linkedSelector,n=t.type&&t.type!=="annotation"?`${t.type} annotation`:"Annotation";return e?`${n} on ${e}`:n}function zi(t){let e=t.annotations.map(o=>{let i=o.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:o.id,pathname:o.pathname,text:Ui(o)??Ld(o),...i>0?{interactionEpisodeStepCount:i}:{}}}),n=new Map,r=o=>{let i=`${o.pathname??""}:${o.durableSelector??o.selector}`,s=n.get(i);if(s){s.changes.push(o.text),o.annotationNumber!==void 0&&(s.annotationNumber===void 0||o.annotationNumber<s.annotationNumber)&&(s.annotationNumber=o.annotationNumber);return}let a={kind:"changes",elementKey:i,elementLabel:vo(o.element,o.selector),...o.annotationNumber!==void 0?{annotationNumber:o.annotationNumber}:{},pathname:o.pathname,changes:[o.text]};n.set(i,a),e.push(a)};for(let o of t.styleModifications??[])for(let i of o.changes)r({...o,text:`${i.property}: ${i.original||"unset"} \u2192 ${i.modified||"unset"}${i.token?` (${i.token})`:""}`});for(let o of t.textModifications??[])r({...o,text:`Text: ${o.original||"empty"} \u2192 ${o.modified||"empty"}`});for(let o of t.domModifications??[])r({...o,text:o.operation==="copy"?"Copied element":"Moved element"});return t.spacingTokenChanges?.length&&e.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:t.spacingTokenChanges.map(o=>`${o.tokenName}: ${o.originalPx}px \u2192 ${o.newPx}px`)}),e}function Wi(t){let e=t.annotations.flatMap(o=>{let i=Ui(o);return i?[{instruction:i,pathname:o.pathname}]:[]});if(e.length===0)return;if(new Set(e.map(o=>o.pathname).filter(Boolean)).size<=1)return e.map(o=>o.instruction).join(`
2
2
 
3
3
  `);let r=new Map;for(let o of e){let i=o.pathname||"(unknown)",s=r.get(i)??[];s.push(o.instruction),r.set(i,s)}return[...r.entries()].map(([o,i])=>`\`${o}\`
4
4
  ${i.map(s=>`- ${s}`).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popmelt.com/core",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "A tiny, powerful design layer for humans and AI",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "author": "Popmelt <reb@popmelt.com> (https://popmelt.com)",