Update to DXIR
Snapshot Nov 27, 2026 · 06:13 UTC · version 0.5.12+strategy.20261126
Package or technical metadata updated
Package or technical metadata updated
Observed in package metadata. These changes alone do not establish a new customer-facing feature.
Up to 3 plugins free · no card required.
All fields and original values.
These are saved file metadata. Open a changed file to read its text edits.
Package file
Nov 26, 2026 · 06:14 UTC
82f0af02ee8fe32665c4262a353d878bded1ed1ec3fd530d776f2eec81000de3
Nov 27, 2026 · 06:13 UTC
52b28a12c8def589b314520f54948c5e9c0bf3494691a2674abae9b339811778
Package file
Nov 26, 2026 · 06:14 UTC
ad0dc2aa30958e398b3c195dd4cbc9d032b44a4fd7285271e7b134adadd43e5f
Nov 27, 2026 · 06:13 UTC
17b31fdbaf6831888e819d26b3dcb20faa92218fed716f0c74f52c81b2964e8e
Package file
Nov 26, 2026 · 06:14 UTC
14198
Nov 27, 2026 · 06:13 UTC
16372
Package file
Nov 26, 2026 · 06:14 UTC
dfdc3ef5333460143b3e0789ae9f5e332595dd7ce7bf7dfee6313439d50130e2
Nov 27, 2026 · 06:13 UTC
d7cd7d469e2a9b052b3eeefdc14fcec428180289ecde204c4a28537fc8979e09
Compare saved observations
Download comparison JSONChanged files
Choose a file to see its text changes. Binary or large files show metadata only.
skills/research-strategy/SKILL.md →
scripts/project.mjs
− removed · + added
--- before +++ after @@ -1,15 +1,17 @@ -import o from"node:fs/promises";import s from"node:path";import P from"node:os";import{createHash as q,randomUUID as E}from"node:crypto";import{pathToFileURL as U}from"node:url";import{isDeepStrictEqual as S}from"node:util";import{artifact as D,locked as L,uploadArtifact as B}from"./journal.mjs";const p=t=>{if(!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(t||""))throw new Error("invalid_id");return t},u=t=>q("sha256").update(t).digest("hex"),O=(t,i)=>{const e=s.relative(t,i);if(e===".."||e.startsWith(`..${s.sep}`)||s.isAbsolute(e))throw new Error("path_outside_project")};async function A(t,i=P.homedir()){if(typeof t!="string"||!t.trim()||t!==t.trim()||t.length>100||/^[.]/.test(t)||/[<>:"/\\|?*\x00-\x1f\x7f]/.test(t)||/[. ]$/.test(t)||/^(con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(t))throw new Error("invalid_folder_name");if(!s.isAbsolute(i))throw new Error("absolute_parent_required");const e=await o.realpath(i);if(!(await o.stat(e)).isDirectory())throw new Error("invalid_parent_directory");const n=s.join(e,t);O(e,n);try{throw await o.lstat(n),new Error("folder_already_exists")}catch(r){if(r.code!=="ENOENT")throw r}return{status:"awaiting_folder_approval",folder_path:n,host_project_status:"not_verified"}}async function X(t,i,e){if(!e)throw new Error("folder_approval_required");const n=await A(t,i);if(e!==n.folder_path)throw new Error("folder_approval_path_mismatch");try{await o.mkdir(n.folder_path,{mode:448})}catch(a){throw a.code==="EEXIST"?new Error("folder_already_exists"):a}const r=await o.lstat(n.folder_path);if(r.isSymbolicLink()||!r.isDirectory())throw new Error("unsafe_project_directory");if(await o.realpath(n.folder_path)!==n.folder_path)throw new Error("project_location_changed");return{...n,status:"folder_created"}}async function d(t,i){let e=t;for(const n of i){e=s.join(e,n);try{await o.mkdir(e)}catch(a){if(a.code!=="EEXIST")throw a}const r=await o.lstat(e);if(r.isSymbolicLink()||!r.isDirectory())throw new Error("unsafe_project_directory");if(O(t,await o.realpath(e)),e===s.join(t,".dxir"))try{await o.writeFile(s.join(e,".gitignore"),`* -`,{flag:"wx"})}catch(a){if(a.code!=="EEXIST")throw a}}return e}async function y(t,i){try{await o.writeFile(t,i,{flag:"wx",mode:384})}catch(e){if(e.code!=="EEXIST")throw e;if((await o.lstat(t)).isSymbolicLink()||!(await o.readFile(t)).equals(Buffer.from(i)))throw new Error("existing_file_differs")}}async function C(t,i,e,n){t=await o.realpath(t),p(i),p(e);const r=await d(t,[".dxir"]);await y(s.join(r,"location.json"),JSON.stringify({location_key:u(process.platform==="win32"?t.toLowerCase():t)})+` -`);const a=s.join(r,"project.json");try{if((await o.lstat(a)).isSymbolicLink())throw new Error("unsafe_project_mapping");const l=JSON.parse(await o.readFile(a,"utf8"));if(l.project_id!==i||l.account_id!==e)throw new Error("folder_already_connected");if(n&&l.folder_key!==n)throw new Error("folder_key_mismatch");return p(l.folder_key),l}catch(l){if(l.code!=="ENOENT")throw l}const c={version:1,project_id:i,account_id:e,folder_key:n?p(n):E()};return await y(a,JSON.stringify(c,null,2)+` -`),c}async function k(t,i){t=await o.realpath(t),p(i);const e=await d(t,[".dxir"]);await y(s.join(e,"location.json"),JSON.stringify({location_key:u(process.platform==="win32"?t.toLowerCase():t)})+` -`);for(const r of["project.json","app-context.json"])try{const a=s.join(e,r);if((await o.lstat(a)).isSymbolicLink())throw new Error("unsafe_project_mapping");const c=JSON.parse(await o.readFile(a,"utf8"));if(c.account_id!==i)throw new Error("folder_already_connected");return p(c.folder_key),c}catch(a){if(a.code!=="ENOENT")throw a}const n={version:1,account_id:i,folder_key:E()};return await y(s.join(e,"app-context.json"),JSON.stringify(n,null,2)+` -`),n}async function H(t,i){const e=await k(t,p(i.account_id));if(e.folder_key!==i.folder_key||i.status!=="active")throw new Error("context_mismatch");const n=await C(t,p(i.project_id),i.account_id,e.folder_key),r=await z(t,p(i.connection_id));return{...n,...r}}async function b(t){try{const i=await o.lstat(t);if(!i.isFile()||i.nlink!==1)throw new Error("unsafe_project_mapping");return await o.readFile(t,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}}async function N(t,i){const e=s.join(s.dirname(t),E()+".tmp");try{await o.writeFile(e,i,{mode:384,flag:"wx"}),await o.rename(e,t)}finally{await o.rm(e,{force:!0})}}async function R(t,i){t=await o.realpath(t);const e=await k(t,p(i.account_id));if(i.project_id!==e.project_id)throw new Error("context_mismatch");const n=p(i.mutation_id),r=i.input;if(!r||typeof r!="object"||Array.isArray(r))throw new Error("invalid_input");const a={mutation_id:n,...i.selection_id?{selection_id:p(i.selection_id)}:{},service_key:i.service_key,input:r,input_evidence:i.input_evidence||{},source_ids:i.source_ids||[],ai_model:i.ai_model,ai_budget_usd:i.ai_budget_usd},c=await d(await o.realpath(t),[".dxir","analyses",n]);if(i.selection_id){const f=s.join(c,"selection.json");if((await o.lstat(f)).isSymbolicLink())throw new Error("unsafe_project_mapping");const _=JSON.parse(await o.readFile(f,"utf8"));if(_.selection_id!==i.selection_id||_.mutation_id!==n)throw new Error("selection_checkpoint_mismatch")}const l=s.join(c,"input.json"),w=JSON.stringify(a,null,2)+` -`,h=i.retry_after_needs_input;return await L(c,async()=>{const f=await b(l);if(!h){if(f===w)return;if(f!==null)throw new Error("existing_file_differs");return N(l,w)}const _=h.response;if(!a.selection_id||_?.status!=="needs_input"||_.service_key!==a.service_key||Object.hasOwn(_,"selection_id")&&_.selection_id!==a.selection_id||Object.hasOwn(_,"mutation_id")&&_.mutation_id!==n||_.analysis_id||_.input_sha256||!Array.isArray(_.input_errors)||!_.input_errors.length||!_.input_errors.every(m=>typeof m?.field=="string"&&m.field.length))throw new Error("analysis_correction_invalid");if(f===w)return;if(f===null)throw new Error("analysis_correction_stale");const x=u(f);if(x!==h.checkpoint_sha256)throw new Error("analysis_correction_stale");if(await b(s.join(c,"receipt.json"))!==null)throw new Error("analysis_already_prepared");const v=new Set(_.input_errors.map(m=>m.field)),g=JSON.parse(f),j=JSON.parse(w),F={...g,input_evidence:j.input_evidence,...v.has("source_ids")?{source_ids:j.source_ids}:{},input:{...g.input}};for(const m of v)Object.hasOwn(j.input,m)?F.input[m]=j.input[m]:delete F.input[m];const $=!S(g.input,j.input)||v.has("source_ids")&&!S(g.source_ids,j.source_ids)||(v.has("source_ids")||v.has("input_evidence"))&&!S(g.input_evidence,j.input_evidence);if(!S(F,j)||!$)throw new Error("analysis_correction_invalid");const T=s.join(c,"input-"+x+".json"),J=await b(T);if(J!==null&&J!==f)throw new Error("existing_file_differs");J===null&&await N(T,f),await N(l,w)}),{file:s.relative(t,l),mutation_id:n,checkpoint_sha256:u(w)}}async function W(t,i){t=await o.realpath(t);const e=await k(t,p(i.account_id));if(i.project_id!==e.project_id)throw new Error("context_mismatch");const n=p(i.mutation_id),r=s.join(t,".dxir","connection.json");if((await o.lstat(r)).isSymbolicLink())throw new Error("unsafe_project_mapping");const a=JSON.parse(await o.readFile(r,"utf8"));if(p(i.connection_id)!==a.connection_id)throw new Error("context_mismatch");const c={mutation_id:n,connection_id:i.connection_id},l=await d(t,[".dxir","analyses",n]);if(await y(s.join(l,"selection-request.json"),JSON.stringify(c,null,2)+` -`),i.selection_id){const w={...c,selection_id:p(i.selection_id)};return await y(s.join(l,"selection.json"),JSON.stringify(w,null,2)+` -`),w}return c}async function G(t,i){t=await o.realpath(t);const e=await k(t,p(i.account_id));if(i.project_id!==e.project_id)throw new Error("context_mismatch");const n=p(i.mutation_id),r=await d(t,[".dxir","analyses",n]);if(!/^[a-f0-9]{64}$/.test(i.input_sha256))throw new Error("invalid_hash");const a={mutation_id:n,analysis_id:p(i.analysis_id),input_sha256:i.input_sha256};return await L(r,async()=>{const c=await b(s.join(r,"input.json")),l=c&&JSON.parse(c);if(!l||l.mutation_id!==n||l.service_key!==i.service_key||(l.selection_id||null)!==(i.selection_id||null)||i.checkpoint_sha256&&i.checkpoint_sha256!==u(c))throw new Error("analysis_checkpoint_mismatch");const w=s.join(r,"receipt.json"),h=await b(w),f=JSON.stringify(a,null,2)+` -`;if(h!==null&&h!==f)throw new Error("existing_file_differs");h===null&&await N(w,f)}),a}async function z(t,i){t=await o.realpath(t),p(i);const e=await d(t,[".dxir"]),n=s.join(e,"connection.json");return await y(n,JSON.stringify({connection_id:i},null,2)+` -`),{connection_id:i}}async function M(t,i,e=t){if(t=await o.realpath(t),e=await o.realpath(e),!i||s.isAbsolute(i))throw new Error("select_relative_file");const n=s.resolve(t,i);O(t,n);const r=s.relative(t,n).split(s.sep);if(r.some(x=>[".git",".dxir","node_modules",".ssh"].includes(x))||/(^\.env(?:\.|$)|\.(?:pem|key|p12|pfx)$)/i.test(s.basename(n)))throw new Error("sensitive_or_generated_path");let a=t;for(const x of r)if(a=s.join(a,x),(await o.lstat(a)).isSymbolicLink())throw new Error("symlink_not_allowed");O(t,await o.realpath(n));const c=await o.stat(n);if(!c.isFile()||c.size<1||c.size>15*1024*1024)throw new Error("invalid_file_size");const l=await o.readFile(n),w=u(l),h=s.extname(n).toLowerCase(),f={".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".pdf":"application/pdf",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}[h];if(!f)throw new Error("unsupported_file_type");const _=await d(e,[".dxir","sources",w]);return await y(s.join(_,"source"),l),{source_id:E(),file_name:s.basename(n),content_type:f,size_bytes:l.length,sha256:w,snapshot:s.relative(e,s.join(_,"source"))}}async function Q(t,i){if(t=await o.realpath(t),!/^[a-f0-9]{64}$/.test(i.sha256))throw new Error("invalid_hash");const e=await d(t,[".dxir","sources",i.sha256]),n=s.join(e,"source");if((await o.lstat(n)).isSymbolicLink())throw new Error("symlink_not_allowed");const r=await o.readFile(n);if(u(r)!==i.sha256)throw new Error("snapshot_hash_mismatch");const a=new URL(i.upload_url);if(a.protocol!=="https:"||a.hostname!=="weufexgfzkdzqkfjxdpj.supabase.co"||a.port||a.username||a.password||!a.pathname.startsWith("/storage/v1/object/upload/sign/dxir-project-sources/"))throw new Error("invalid_upload_destination");if(!(await fetch(a,{method:"PUT",headers:{"Content-Type":i.content_type},body:r,redirect:"error"})).ok)throw new Error("upload_failed");return{uploaded:!0,sha256:i.sha256,size_bytes:r.length}}async function V(t,i){if(t=await o.realpath(t),p(i.analysis_id),typeof i.html!="string"||!/^[a-f0-9]{64}$/.test(i.sha256)||u(Buffer.from(i.html))!==i.sha256)throw new Error("report_hash_mismatch");const e=await d(t,[".dxir","reports",i.analysis_id,i.sha256]),n=s.join(e,"report.html");return await L(e,async()=>{const r=await o.lstat(n).catch(c=>{if(c.code!=="ENOENT")throw c;return null});if(r){if(!r.isFile()||r.nlink!==1)throw new Error("unsafe_report_cache");if(u(await o.readFile(n))===i.sha256)return}const a=s.join(e,E()+".tmp");try{const c=await o.open(a,"wx",384);try{await c.writeFile(i.html),await c.sync()}finally{await c.close()}r&&await o.rename(n,s.join(e,"report-conflict-"+E()+".bin")),await o.rename(a,n)}finally{await o.rm(a,{force:!0})}}),{file:s.relative(t,n),sha256:i.sha256,verified:!0}}async function Y(t,i){t=await o.realpath(t);const e=await d(t,[".dxir"]),n=JSON.parse(await o.readFile(s.join(e,"project.json"),"utf8")),r=JSON.parse(await o.readFile(s.join(e,"connection.json"),"utf8"));if(JSON.parse(await o.readFile(s.join(e,"location.json"),"utf8")).location_key!==u(process.platform==="win32"?t.toLowerCase():t))throw new Error("project_location_changed");if(i.account_id!==n.account_id||i.project_id!==n.project_id||i.connection_id!==r.connection_id)throw new Error("room_project_mismatch");if(i.binding_status!=="active"||i.decision!=="start")throw new Error("room_not_bound");const c={version:1,handoff_id:p(i.id),room_id:p(i.room_id),binding_id:p(i.binding_id),executor_key:p(i.executor_key),execution_context_id:p(i.execution_context_id),project_id:n.project_id,connection_id:r.connection_id,account_id:n.account_id},l=await d(t,[".dxir","rooms",c.room_id]);return await y(s.join(l,`${c.binding_id}.json`),JSON.stringify(c,null,2)+` -`),c}async function Z(){const[t,...i]=process.argv.slice(2),e=Object.fromEntries(i.reduce((c,l,w)=>w%2===0?[...c,[l.replace(/^--/,""),i[w+1]]]:c,[])),n=e.root||process.cwd();if(t==="folder-plan"||t==="folder-create"){const c=t==="folder-plan"?await A(e.name,e.parent):await X(e.name,e.parent,e["approved-path"]);process.stdout.write(JSON.stringify(c)+` -`);return}let r;if(["upload","upload-artifact","save-report","room-bind","context-bind","checkpoint-input","save-selection","save-analysis"].includes(t)){const c=[];let l=0;for await(const w of process.stdin){if(l+=w.length,l>20*1024*1024)throw new Error("input_too_large");c.push(w)}r=JSON.parse(Buffer.concat(c).toString("utf8"))}const a=t==="artifact"?D(e.file,n):t==="upload-artifact"?await B({file:r.relative_path,cwd:n,sha256:r.sha256,contentType:r.content_type,uploadUrl:r.upload_url}):t==="context-init"?await k(n,e["account-id"]):t==="context-bind"?await H(n,r):t==="checkpoint-input"?await R(n,r):t==="save-selection"?await W(n,r):t==="save-analysis"?await G(n,r):t==="init"?await C(n,e["project-id"],e["account-id"]):t==="bind"?await z(n,e["connection-id"]):t==="snapshot"?await M(n,e.file,e["snapshot-root"]):t==="upload"?await Q(n,r):t==="room-bind"?await Y(n,r):t==="save-report"?await V(n,r):(()=>{throw new Error("unknown_command")})();process.stdout.write(JSON.stringify(a)+` -`)}process.argv[1]&&import.meta.url===U(s.resolve(process.argv[1])).href&&Z().catch(t=>{process.stderr.write(String(t.message).replace(/https?:\/\/\S+/g,"[url]")+` -`),process.exitCode=1});export{H as bindAppContext,z as bindProject,X as createProjectFolder,d as directory,k as initializeAppContext,C as initializeProject,A as planProjectFolder,y as preserve,R as saveAnalysisCheckpoint,G as saveAnalysisReceipt,V as saveProjectReport,Y as saveRoomBinding,W as saveSelectionCheckpoint,M as snapshotProjectFile,Q as uploadProjectSnapshot}; +import o from"node:fs/promises";import s from"node:path";import P from"node:os";import{createHash as D,randomUUID as b}from"node:crypto";import{pathToFileURL as U}from"node:url";import{isDeepStrictEqual as J}from"node:util";import{artifact as B,locked as F,uploadArtifact as R}from"./journal.mjs";const _=t=>{if(!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(t||""))throw new Error("invalid_id");return t},h=t=>D("sha256").update(t).digest("hex"),A=(t,e)=>{const i=s.relative(t,e);if(i===".."||i.startsWith(`..${s.sep}`)||s.isAbsolute(i))throw new Error("path_outside_project")};async function z(t,e=P.homedir()){if(typeof t!="string"||!t.trim()||t!==t.trim()||t.length>100||/^[.]/.test(t)||/[<>:"/\\|?*\x00-\x1f\x7f]/.test(t)||/[. ]$/.test(t)||/^(con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(t))throw new Error("invalid_folder_name");if(!s.isAbsolute(e))throw new Error("absolute_parent_required");const i=await o.realpath(e);if(!(await o.stat(i)).isDirectory())throw new Error("invalid_parent_directory");const r=s.join(i,t);A(i,r);try{throw await o.lstat(r),new Error("folder_already_exists")}catch(n){if(n.code!=="ENOENT")throw n}return{status:"awaiting_folder_approval",folder_path:r,host_project_status:"not_verified"}}async function X(t,e,i){if(!i)throw new Error("folder_approval_required");const r=await z(t,e);if(i!==r.folder_path)throw new Error("folder_approval_path_mismatch");try{await o.mkdir(r.folder_path,{mode:448})}catch(c){throw c.code==="EEXIST"?new Error("folder_already_exists"):c}const n=await o.lstat(r.folder_path);if(n.isSymbolicLink()||!n.isDirectory())throw new Error("unsafe_project_directory");if(await o.realpath(r.folder_path)!==r.folder_path)throw new Error("project_location_changed");return{...r,status:"folder_created"}}async function y(t,e){let i=t;for(const r of e){i=s.join(i,r);try{await o.mkdir(i)}catch(c){if(c.code!=="EEXIST")throw c}const n=await o.lstat(i);if(n.isSymbolicLink()||!n.isDirectory())throw new Error("unsafe_project_directory");if(A(t,await o.realpath(i)),i===s.join(t,".dxir"))try{await o.writeFile(s.join(i,".gitignore"),`* +`,{flag:"wx"})}catch(c){if(c.code!=="EEXIST")throw c}}return i}async function E(t,e){try{await o.writeFile(t,e,{flag:"wx",mode:384})}catch(i){if(i.code!=="EEXIST")throw i;if((await o.lstat(t)).isSymbolicLink()||!(await o.readFile(t)).equals(Buffer.from(e)))throw new Error("existing_file_differs")}}async function $(t,e,i,r){t=await o.realpath(t),_(e),_(i);const n=await y(t,[".dxir"]);await E(s.join(n,"location.json"),JSON.stringify({location_key:h(process.platform==="win32"?t.toLowerCase():t)})+` +`);const c=s.join(n,"project.json");try{if((await o.lstat(c)).isSymbolicLink())throw new Error("unsafe_project_mapping");const l=JSON.parse(await o.readFile(c,"utf8"));if(l.project_id!==e||l.account_id!==i)throw new Error("folder_already_connected");if(r&&l.folder_key!==r)throw new Error("folder_key_mismatch");return _(l.folder_key),l}catch(l){if(l.code!=="ENOENT")throw l}const a={version:1,project_id:e,account_id:i,folder_key:r?_(r):b()};return await E(c,JSON.stringify(a,null,2)+` +`),a}async function O(t,e){t=await o.realpath(t),_(e);const i=await y(t,[".dxir"]);await E(s.join(i,"location.json"),JSON.stringify({location_key:h(process.platform==="win32"?t.toLowerCase():t)})+` +`);for(const n of["project.json","app-context.json"])try{const c=s.join(i,n);if((await o.lstat(c)).isSymbolicLink())throw new Error("unsafe_project_mapping");const a=JSON.parse(await o.readFile(c,"utf8"));if(a.account_id!==e)throw new Error("folder_already_connected");return _(a.folder_key),a}catch(c){if(c.code!=="ENOENT")throw c}const r={version:1,account_id:e,folder_key:b()};return await E(s.join(i,"app-context.json"),JSON.stringify(r,null,2)+` +`),r}async function H(t,e){const i=await O(t,_(e.account_id));if(i.folder_key!==e.folder_key||e.status!=="active")throw new Error("context_mismatch");const r=await $(t,_(e.project_id),e.account_id,i.folder_key),n=await q(t,_(e.connection_id));return{...r,...n}}async function x(t){try{const e=await o.lstat(t);if(!e.isFile()||e.nlink!==1)throw new Error("unsafe_project_mapping");return await o.readFile(t,"utf8")}catch(e){if(e.code==="ENOENT")return null;throw e}}async function N(t,e){const i=s.join(s.dirname(t),b()+".tmp");try{await o.writeFile(i,e,{mode:384,flag:"wx"}),await o.rename(i,t)}finally{await o.rm(i,{force:!0})}}async function W(t,e){t=await o.realpath(t);const i=await O(t,_(e.account_id));if(e.project_id!==i.project_id)throw new Error("context_mismatch");const r=_(e.mutation_id),n=e.input;if(!n||typeof n!="object"||Array.isArray(n))throw new Error("invalid_input");const c={mutation_id:r,...e.selection_id?{selection_id:_(e.selection_id)}:{},service_key:e.service_key,input:n,input_evidence:e.input_evidence||{},source_ids:e.source_ids||[],ai_model:e.ai_model,ai_budget_usd:e.ai_budget_usd},a=await y(await o.realpath(t),[".dxir","analyses",r]);if(e.selection_id){const d=s.join(a,"selection.json");if((await o.lstat(d)).isSymbolicLink())throw new Error("unsafe_project_mapping");const w=JSON.parse(await o.readFile(d,"utf8"));if(w.selection_id!==e.selection_id||w.mutation_id!==r)throw new Error("selection_checkpoint_mismatch")}const l=s.join(a,"input.json"),p=JSON.stringify(c,null,2)+` +`,m=e.retry_after_needs_input;return await F(a,async()=>{const d=await x(l);if(!m){if(d===p)return;if(d!==null)throw new Error("existing_file_differs");return N(l,p)}const w=m.response;if(!c.selection_id||w?.status!=="needs_input"||w.service_key!==c.service_key||Object.hasOwn(w,"selection_id")&&w.selection_id!==c.selection_id||Object.hasOwn(w,"mutation_id")&&w.mutation_id!==r||w.analysis_id||w.input_sha256||!Array.isArray(w.input_errors)||!w.input_errors.length||!w.input_errors.every(g=>typeof g?.field=="string"&&g.field.length))throw new Error("analysis_correction_invalid");if(d===p)return;if(d===null)throw new Error("analysis_correction_stale");const j=h(d);if(j!==m.checkpoint_sha256)throw new Error("analysis_correction_stale");if(await x(s.join(a,"receipt.json"))!==null)throw new Error("analysis_already_prepared");const u=new Set(w.input_errors.map(g=>g.field)),k=JSON.parse(d),v=JSON.parse(p),f={...k,input_evidence:v.input_evidence,...u.has("source_ids")?{source_ids:v.source_ids}:{},input:{...k.input}};for(const g of u)Object.hasOwn(v.input,g)?f.input[g]=v.input[g]:delete f.input[g];const S=!J(k.input,v.input)||u.has("source_ids")&&!J(k.source_ids,v.source_ids)||(u.has("source_ids")||u.has("input_evidence"))&&!J(k.input_evidence,v.input_evidence);if(!J(f,v)||!S)throw new Error("analysis_correction_invalid");const C=s.join(a,"input-"+j+".json"),T=await x(C);if(T!==null&&T!==d)throw new Error("existing_file_differs");T===null&&await N(C,d),await N(l,p)}),{file:s.relative(t,l),mutation_id:r,checkpoint_sha256:h(p)}}async function Z(t,e){t=await o.realpath(t);const i=await O(t,_(e.account_id));if(e.project_id!==i.project_id)throw new Error("context_mismatch");const r=_(e.mutation_id),n=s.join(t,".dxir","connection.json");if((await o.lstat(n)).isSymbolicLink())throw new Error("unsafe_project_mapping");const c=JSON.parse(await o.readFile(n,"utf8"));if(_(e.connection_id)!==c.connection_id)throw new Error("context_mismatch");const a={mutation_id:r,connection_id:e.connection_id},l=await y(t,[".dxir","analyses",r]);if(await E(s.join(l,"selection-request.json"),JSON.stringify(a,null,2)+` +`),e.selection_id){const p={...a,selection_id:_(e.selection_id)};return await E(s.join(l,"selection.json"),JSON.stringify(p,null,2)+` +`),p}return a}async function G(t,e){t=await o.realpath(t);const i=await O(t,_(e.account_id));if(e.project_id!==i.project_id)throw new Error("context_mismatch");const r=_(e.mutation_id),n=await y(t,[".dxir","analyses",r]);if(!/^[a-f0-9]{64}$/.test(e.input_sha256))throw new Error("invalid_hash");const c={mutation_id:r,analysis_id:_(e.analysis_id),input_sha256:e.input_sha256};return await F(n,async()=>{const a=await x(s.join(n,"input.json")),l=a&&JSON.parse(a);if(!l||l.mutation_id!==r||l.service_key!==e.service_key||(l.selection_id||null)!==(e.selection_id||null)||e.checkpoint_sha256&&e.checkpoint_sha256!==h(a))throw new Error("analysis_checkpoint_mismatch");const p=s.join(n,"receipt.json"),m=await x(p),d=JSON.stringify(c,null,2)+` +`;if(m!==null&&m!==d)throw new Error("existing_file_differs");m===null&&await N(p,d)}),c}async function q(t,e){t=await o.realpath(t),_(e);const i=await y(t,[".dxir"]),r=s.join(i,"connection.json");return await E(r,JSON.stringify({connection_id:e},null,2)+` +`),{connection_id:e}}function L(t){return typeof t=="string"&&t.length<=200&&/^(?:[A-Za-z0-9_.:-]+[_:.])?dxir_strategy_automation(?:_read)?$/.test(t)}async function M(t,e={}){t=await o.realpath(t);const i=s.join(t,".dxir");try{if(!(await o.lstat(i)).isDirectory())throw new Error("unsafe_project_mapping")}catch(f){if(f.code==="ENOENT"&&!e.read_tool)return{status:"unbound"};throw f}const r=JSON.parse(await x(s.join(i,"project.json"))),n=JSON.parse(await x(s.join(i,"connection.json")));if((!r||!n)&&!e.read_tool)return{status:"unbound"};const c=JSON.parse(await x(s.join(i,"location.json")));if(!r||!n||c?.location_key!==h(process.platform==="win32"?t.toLowerCase():t))throw new Error("context_mismatch");const a={account_id:_(r.account_id),project_id:_(r.project_id),connection_id:_(n.connection_id),folder_key:_(r.folder_key)},l=s.join(i,"strategy-route.json");if(e.read_tool!==void 0){if(!L(e.read_tool)||e.account_id!==a.account_id||e.view?.project_id!==a.project_id||e.view?.connection_id!==a.connection_id||!["inactive","running","waiting","stopped"].includes(e.view?.status)||!Number.isSafeInteger(e.view.revision)||e.view.revision<0)throw new Error("verified_strategy_read_required");await F(i,async()=>{const f=JSON.stringify({...a,read_tool:e.read_tool})+` +`;await x(l)!==f&&await N(l,f)})}const p=JSON.parse(await x(l)),d=p&&Object.entries(a).every(([f,S])=>p[f]===S)&&L(p.read_tool)?p.read_tool:null,w={status:"bound",...a,preferred_read_tool:d};if(e.available_read_tools===void 0)return w;if(!Array.isArray(e.available_read_tools)||!e.available_read_tools.every(L))throw new Error("invalid_read_routes");const j=new Set(e.available_read_tools),u=e.attempts??[];if(!Array.isArray(u)||u.some(f=>!L(f?.tool)||typeof f.code!="string"))throw new Error("invalid_read_routes");const k=u.find(({code:f,confirmed_revocation:S})=>f==="dxir_project_approval_required"||f==="dxir_connection_revoked"&&S===!0);for(const{tool:f}of u)j.delete(f);const v=k||u.length>=2?null:j.has(d)?d:j.values().next().value??null;return{...w,next_read_tool:v,access_error:k?.code??null}}async function Q(t,e,i=t){if(t=await o.realpath(t),i=await o.realpath(i),!e||s.isAbsolute(e))throw new Error("select_relative_file");const r=s.resolve(t,e);A(t,r);const n=s.relative(t,r).split(s.sep);if(n.some(j=>[".git",".dxir","node_modules",".ssh"].includes(j))||/(^\.env(?:\.|$)|\.(?:pem|key|p12|pfx)$)/i.test(s.basename(r)))throw new Error("sensitive_or_generated_path");let c=t;for(const j of n)if(c=s.join(c,j),(await o.lstat(c)).isSymbolicLink())throw new Error("symlink_not_allowed");A(t,await o.realpath(r));const a=await o.stat(r);if(!a.isFile()||a.size<1||a.size>15*1024*1024)throw new Error("invalid_file_size");const l=await o.readFile(r),p=h(l),m=s.extname(r).toLowerCase(),d={".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".json":"application/json",".pdf":"application/pdf",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}[m];if(!d)throw new Error("unsupported_file_type");const w=await y(i,[".dxir","sources",p]);return await E(s.join(w,"source"),l),{source_id:b(),file_name:s.basename(r),content_type:d,size_bytes:l.length,sha256:p,snapshot:s.relative(i,s.join(w,"source"))}}async function V(t,e){if(t=await o.realpath(t),!/^[a-f0-9]{64}$/.test(e.sha256))throw new Error("invalid_hash");const i=await y(t,[".dxir","sources",e.sha256]),r=s.join(i,"source");if((await o.lstat(r)).isSymbolicLink())throw new Error("symlink_not_allowed");const n=await o.readFile(r);if(h(n)!==e.sha256)throw new Error("snapshot_hash_mismatch");const c=new URL(e.upload_url);if(c.protocol!=="https:"||c.hostname!=="weufexgfzkdzqkfjxdpj.supabase.co"||c.port||c.username||c.password||!c.pathname.startsWith("/storage/v1/object/upload/sign/dxir-project-sources/"))throw new Error("invalid_upload_destination");if(!(await fetch(c,{method:"PUT",headers:{"Content-Type":e.content_type},body:n,redirect:"error"})).ok)throw new Error("upload_failed");return{uploaded:!0,sha256:e.sha256,size_bytes:n.length}}async function Y(t,e){if(t=await o.realpath(t),_(e.analysis_id),typeof e.html!="string"||!/^[a-f0-9]{64}$/.test(e.sha256)||h(Buffer.from(e.html))!==e.sha256)throw new Error("report_hash_mismatch");const i=await y(t,[".dxir","reports",e.analysis_id,e.sha256]),r=s.join(i,"report.html");return await F(i,async()=>{const n=await o.lstat(r).catch(a=>{if(a.code!=="ENOENT")throw a;return null});if(n){if(!n.isFile()||n.nlink!==1)throw new Error("unsafe_report_cache");if(h(await o.readFile(r))===e.sha256)return}const c=s.join(i,b()+".tmp");try{const a=await o.open(c,"wx",384);try{await a.writeFile(e.html),await a.sync()}finally{await a.close()}n&&await o.rename(r,s.join(i,"report-conflict-"+b()+".bin")),await o.rename(c,r)}finally{await o.rm(c,{force:!0})}}),{file:s.relative(t,r),sha256:e.sha256,verified:!0}}async function I(t,e){t=await o.realpath(t);const i=await y(t,[".dxir"]),r=JSON.parse(await o.readFile(s.join(i,"project.json"),"utf8")),n=JSON.parse(await o.readFile(s.join(i,"connection.json"),"utf8"));if(JSON.parse(await o.readFile(s.join(i,"location.json"),"utf8")).location_key!==h(process.platform==="win32"?t.toLowerCase():t))throw new Error("project_location_changed");if(e.account_id!==r.account_id||e.project_id!==r.project_id||e.connection_id!==n.connection_id)throw new Error("room_project_mismatch");if(e.binding_status!=="active"||e.decision!=="start")throw new Error("room_not_bound");const a={version:1,handoff_id:_(e.id),room_id:_(e.room_id),binding_id:_(e.binding_id),executor_key:_(e.executor_key),execution_context_id:_(e.execution_context_id),project_id:r.project_id,connection_id:n.connection_id,account_id:r.account_id},l=await y(t,[".dxir","rooms",a.room_id]);return await E(s.join(l,`${a.binding_id}.json`),JSON.stringify(a,null,2)+` +`),a}async function K(){const[t,...e]=process.argv.slice(2),i=Object.fromEntries(e.reduce((a,l,p)=>p%2===0?[...a,[l.replace(/^--/,""),e[p+1]]]:a,[])),r=i.root||process.cwd();if(t==="folder-plan"||t==="folder-create"){const a=t==="folder-plan"?await z(i.name,i.parent):await X(i.name,i.parent,i["approved-path"]);process.stdout.write(JSON.stringify(a)+` +`);return}let n;if(["upload","upload-artifact","save-report","room-bind","context-bind","strategy-route","checkpoint-input","save-selection","save-analysis"].includes(t)){const a=[];let l=0;for await(const p of process.stdin){if(l+=p.length,l>20*1024*1024)throw new Error("input_too_large");a.push(p)}n=JSON.parse(Buffer.concat(a).toString("utf8"))}if(t==="strategy-route"){process.stdout.write(JSON.stringify(await M(r,n))+` +`);return}const c=t==="artifact"?B(i.file,r):t==="upload-artifact"?await R({file:n.relative_path,cwd:r,sha256:n.sha256,contentType:n.content_type,uploadUrl:n.upload_url}):t==="context-init"?await O(r,i["account-id"]):t==="context-bind"?await H(r,n):t==="checkpoint-input"?await W(r,n):t==="save-selection"?await Z(r,n):t==="save-analysis"?await G(r,n):t==="init"?await $(r,i["project-id"],i["account-id"]):t==="bind"?await q(r,i["connection-id"]):t==="snapshot"?await Q(r,i.file,i["snapshot-root"]):t==="upload"?await V(r,n):t==="room-bind"?await I(r,n):t==="save-report"?await Y(r,n):(()=>{throw new Error("unknown_command")})();process.stdout.write(JSON.stringify(c)+` +`)}process.argv[1]&&import.meta.url===U(s.resolve(process.argv[1])).href&&K().catch(t=>{process.stderr.write(String(t.message).replace(/https?:\/\/\S+/g,"[url]")+` +`),process.exitCode=1});export{H as bindAppContext,q as bindProject,X as createProjectFolder,y as directory,O as initializeAppContext,$ as initializeProject,z as planProjectFolder,E as preserve,W as saveAnalysisCheckpoint,G as saveAnalysisReceipt,Y as saveProjectReport,I as saveRoomBinding,Z as saveSelectionCheckpoint,Q as snapshotProjectFile,M as strategyRoute,V as uploadProjectSnapshot};
Full technical diff · 11 changed fields
changed /files/.codex-plugin~1plugin.json/sha256
"82f0af02ee8fe32665c4262a353d878bded1ed1ec3fd530d776f2eec81000de3"
"52b28a12c8def589b314520f54948c5e9c0bf3494691a2674abae9b339811778"
changed /files/scripts~1project.mjs/sha256
"ad0dc2aa30958e398b3c195dd4cbc9d032b44a4fd7285271e7b134adadd43e5f"
"17b31fdbaf6831888e819d26b3dcb20faa92218fed716f0c74f52c81b2964e8e"
changed /files/scripts~1project.mjs/size
14198
16372
changed /files/scripts~1strategy-cycle.mjs/sha256
"dfdc3ef5333460143b3e0789ae9f5e332595dd7ce7bf7dfee6313439d50130e2"
"d7cd7d469e2a9b052b3eeefdc14fcec428180289ecde204c4a28537fc8979e09"
changed /files/scripts~1strategy-cycle.mjs/size
51669
54600
changed /files/skills~1research-strategy~1SKILL.md/sha256
"c8fd60e7adfd3c68aab43ef2be3d6986d53b13ec259b31ef16579db0ec739f19"
"8043d67e780fa9491ce33f671620c90740787fe36985a6c7c53f8314cec8ce21"
changed /files/skills~1research-strategy~1SKILL.md/size
35725
36036
changed /files/skills~1strategy-automation~1SKILL.md/sha256
"bdc831a25f6dce6bf35a5c4cdcb5589db3dd5ffc263cbbf41eb2418ffc49f539"
"930de71966d2f3f3dbcba57a3d2bfbba035a9b0daf7d2069569b7bd4f5596f14"
changed /files/skills~1strategy-automation~1SKILL.md/size
16749
18070
changed /files/skills~1strategy-automation~1references~1operation.md/sha256
"5a1d6d3225a9fcdc572b36c0d31d2bae49d6002b1956de1b357654923de9fce8"
"c7277221da49266afe6b7e4e3a26d410fc19efd3f45774b62b49fc8ec4ae6dbf"
changed /files/skills~1strategy-automation~1references~1operation.md/size
41078
45965
Full snapshot data
{
"files": {
".app.json": {
"sha256": "ee77482dd2fccf713db10baccd5b8b67b8014c5048c7219ecfdb11e916f18732",
"size": 108
},
".codex-plugin/plugin.json": {
"sha256": "52b28a12c8def589b314520f54948c5e9c0bf3494691a2674abae9b339811778",
"size": 6511
},
".mcp.json": {
"sha256": "5f3cc361a431db8416f351619f072bcc50e4bfd3eba8e3c1887d75291c9ff6d8",
"size": 309
},
"assets/icon.png": {
"sha256": "f1244c192a01adf442c172edc53e081d6a31744515ee6624c2cf864a15af8947",
"size": 2263
},
"assets/logo-dark.png": {
"sha256": "745cd0183d55f0b7e87886f6221149c7b808b298297f455b38e20afed25537da",
"size": 21316
},
"assets/logo.png": {
"sha256": "745cd0183d55f0b7e87886f6221149c7b808b298297f455b38e20afed25537da",
"size": 21316
},
"scripts/action-room.mjs": {
"sha256": "5249856f599c5266c042887b80ebf1fe9c54c6011f8809d1b0d0b707a953ba70",
"size": 4066
},
"scripts/brand.mjs": {
"sha256": "2f81904e87b03564c52394738e4fbb7ee1ad004618e7d20a106f2be5ee50db01",
"size": 9962
},
"scripts/decision-materials.mjs": {
"sha256": "03da93bcae539c249b1912fccd5c128916bfd2057ea5c3a32907600202a38db0",
"size": 7636
},
"scripts/document-template.mjs": {
"sha256": "1e573b837c07114538ea0d49f005000af42246f53a4c1b959cbacaceb55ad291",
"size": 10975
},
"scripts/document.mjs": {
"sha256": "f8cd9cd690a793cf33af96bb4f93b186a1729d77b5a8616ccaac2c0128ca649b",
"size": 8537
},
"scripts/journal.mjs": {
"sha256": "07c83b0a551854456348560b5d0429657107ad3ecaef3d78c9faef115b8d9f23",
"size": 29177
},
"scripts/office-material.mjs": {
"sha256": "7cca812263ea8c60408557efcbc5a356249cf597eea2c69b3288de84794c4974",
"size": 115761
},
"scripts/project.mjs": {
"sha256": "17b31fdbaf6831888e819d26b3dcb20faa92218fed716f0c74f52c81b2964e8e",
"size": 16372
},
"scripts/strategy-cycle.mjs": {
"sha256": "d7cd7d469e2a9b052b3eeefdc14fcec428180289ecde204c4a28537fc8979e09",
"size": 54600
},
"skills/action-room/SKILL.md": {
"sha256": "a3d6c17327c4b0a8cf6fdd88031df62a4f18f7ac3927b24a258ed9e76dbb81d5",
"size": 34658
},
"skills/action-room/references/brand.md": {
"sha256": "6f809a07ef8d770b4ae78caac7393cfb0e4371c2076186549c58cc82776eb8ea",
"size": 5211
},
"skills/action-room/references/documents.md": {
"sha256": "76c4d2901d754b656a032eff33f16fdc1aa150f22784d3442228a949947c2182",
"size": 8378
},
"skills/action-room/references/execution.md": {
"sha256": "b913df0b6627d3d31d07cc4e0871c5b40b635abbd79d9fd0642f0326a92bfaf4",
"size": 8584
},
"skills/action-room/references/local-protocol.md": {
"sha256": "12838df8ac55290d1683ca2fc5f4d15b83c81481053d092a4beac388938412e2",
"size": 11098
},
"skills/action-room/references/research.md": {
"sha256": "6758797e5f8b136155475ee0665d2b97bbe3ff4037612a5f114b4d27791244a8",
"size": 17926
},
"skills/research-strategy/SKILL.md": {
"sha256": "8043d67e780fa9491ce33f671620c90740787fe36985a6c7c53f8314cec8ce21",
"size": 36036
},
"skills/setup/SKILL.md": {
"sha256": "bf4143e28ebeedaedac43589cfc2abf3d69ec8098bf4d92ebff77cb520a8b3f7",
"size": 2575
},
"skills/strategy-automation/SKILL.md": {
"sha256": "930de71966d2f3f3dbcba57a3d2bfbba035a9b0daf7d2069569b7bd4f5596f14",
"size": 18070
},
"skills/strategy-automation/references/operation.md": {
"sha256": "c7277221da49266afe6b7e4e3a26d410fc19efd3f45774b62b49fc8ec4ae6dbf",
"size": 45965
},
"third-party-notices.txt": {
"sha256": "f03912dda5e50ad3847cb6120a2985d2b0e847e716b38d313ca8dc1bd6a75256",
"size": 19269
}
}
}SHA-256 of public snapshot: b7fd465c69f89c7e3cc6badc671be4bf0ec73ead20f6837585851c26c9768155