olympus-ai 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/features/workflow-engine/artifacts.d.ts.map +1 -1
  3. package/dist/features/workflow-engine/artifacts.js +13 -9
  4. package/dist/features/workflow-engine/artifacts.js.map +1 -1
  5. package/dist/features/workflow-engine/construction/nfr-requirements.js +1 -1
  6. package/dist/features/workflow-engine/construction/nfr-requirements.js.map +1 -1
  7. package/dist/features/workflow-engine/engine.d.ts +1 -1
  8. package/dist/features/workflow-engine/engine.js +2 -2
  9. package/dist/features/workflow-engine/engine.js.map +1 -1
  10. package/dist/features/workflow-engine/inception/stages/units-generation.d.ts.map +1 -1
  11. package/dist/features/workflow-engine/inception/stages/units-generation.js +7 -6
  12. package/dist/features/workflow-engine/inception/stages/units-generation.js.map +1 -1
  13. package/dist/features/workflow-engine/inception/stages/user-stories.d.ts.map +1 -1
  14. package/dist/features/workflow-engine/inception/stages/user-stories.js +5 -3
  15. package/dist/features/workflow-engine/inception/stages/user-stories.js.map +1 -1
  16. package/dist/features/workflow-engine/question-manager.d.ts.map +1 -1
  17. package/dist/features/workflow-engine/question-manager.js +5 -1
  18. package/dist/features/workflow-engine/question-manager.js.map +1 -1
  19. package/dist/features/workflow-engine/state-file.d.ts.map +1 -1
  20. package/dist/features/workflow-engine/state-file.js +4 -2
  21. package/dist/features/workflow-engine/state-file.js.map +1 -1
  22. package/dist/hooks/olympus-hooks.cjs +10 -10
  23. package/dist/installer/index.d.ts +1 -1
  24. package/dist/installer/index.js +1 -1
  25. package/dist/learning/__tests__/project-resolver.test.d.ts +2 -0
  26. package/dist/learning/__tests__/project-resolver.test.d.ts.map +1 -0
  27. package/dist/learning/__tests__/project-resolver.test.js +216 -0
  28. package/dist/learning/__tests__/project-resolver.test.js.map +1 -0
  29. package/dist/learning/hooks/success-detector.d.ts.map +1 -1
  30. package/dist/learning/hooks/success-detector.js +4 -26
  31. package/dist/learning/hooks/success-detector.js.map +1 -1
  32. package/dist/learning/pattern-extractor.js +1 -1
  33. package/dist/learning/pattern-extractor.js.map +1 -1
  34. package/dist/learning/project-resolver.d.ts +6 -0
  35. package/dist/learning/project-resolver.d.ts.map +1 -0
  36. package/dist/learning/project-resolver.js +65 -0
  37. package/dist/learning/project-resolver.js.map +1 -0
  38. package/dist/learning/storage.d.ts.map +1 -1
  39. package/dist/learning/storage.js +2 -1
  40. package/dist/learning/storage.js.map +1 -1
  41. package/package.json +1 -1
  42. package/resources/agents/frontend-engineer-high.md +112 -10
  43. package/resources/agents/frontend-engineer.md +136 -73
  44. package/resources/rules/common/depth-levels.md +73 -73
  45. package/resources/rules/common/question-format-guide.md +375 -375
  46. package/resources/rules/common/session-continuity.md +47 -47
  47. package/resources/rules/inception/requirements-analysis.md +247 -215
  48. package/resources/rules/inception/workflow-planning.md +487 -487
  49. package/resources/skills/continue/SKILL.md +3 -3
  50. package/resources/skills/plan/SKILL.md +35 -25
@@ -1 +1 @@
1
- {"version":3,"file":"state-file.js","sourceRoot":"","sources":["../../../src/features/workflow-engine/state-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAG/B,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,MAAM,GAAoB,CAAC,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAEzF,MAAM,qBAAqB,GAAqB;IAC9C,qBAAqB;IACrB,qBAAqB;IACrB,uBAAuB;IACvB,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;CACnB,CAAC;AAEF,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,IAAI,C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C;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wDAAwD,UAAU,GAAG,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;IACjH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;gFAMgD,CAAC"}
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  // Olympus Hooks Bundle - Generated by esbuild
3
- "use strict";var Zg=Object.create;var _o=Object.defineProperty;var eh=Object.getOwnPropertyDescriptor;var th=Object.getOwnPropertyNames;var nh=Object.getPrototypeOf,oh=Object.prototype.hasOwnProperty;var B=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ot=(e,t)=>{for(var n in t)_o(e,n,{get:t[n],enumerable:!0})},Oa=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of th(t))!oh.call(e,r)&&r!==n&&_o(e,r,{get:()=>t[r],enumerable:!(o=eh(t,r))||o.enumerable});return e};var E=(e,t,n)=>(n=e!=null?Zg(nh(e)):{},Oa(t||!e||!e.__esModule?_o(n,"default",{value:e,enumerable:!0}):n,e)),rh=e=>Oa(_o({},"__esModule",{value:!0}),e);var li,lc=B(()=>{"use strict";li={maxAgeInDays:30,maxArchiveCount:5}});function ui(e){if(!e.token_usage)return null;let{token_usage:t}=e;return typeof t.input_tokens!="number"||typeof t.output_tokens!="number"||typeof t.total_tokens!="number"||typeof t.estimated!="boolean"?null:t}function en(e){return ui(e)?.total_tokens||0}var uc=B(()=>{"use strict"});function fe(){return process.env.OLYMPUS_TEST_LEARNING_DIR?process.env.OLYMPUS_TEST_LEARNING_DIR:(0,be.join)((0,dc.homedir)(),".claude","olympus","learning")}function Je(e){return(0,be.join)(e,".olympus","learning")}function fc(e){let t=(0,be.resolve)(e);return(0,pc.createHash)("sha256").update(t).digest("hex").substring(0,16)}function tn(e){let t=fe();if((0,q.existsSync)(t)||(0,q.mkdirSync)(t,{recursive:!0}),e){let n=Je(e);(0,q.existsSync)(n)||(0,q.mkdirSync)(n,{recursive:!0})}}function bh(e,t=li){try{let n=(0,be.dirname)(e),o=(0,be.basename)(e,".jsonl"),r=(0,q.readdirSync)(n),i=new RegExp(`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\..*\\.old\\.jsonl$`),s=r.filter(d=>i.test(d)).map(d=>{let p=d.match(/\.(\d{4}-\d{2}-\d{2})T/),m=p?new Date(p[1]):null;return{filename:d,filepath:(0,be.join)(n,d),timestamp:m}}).filter(d=>d.timestamp!==null&&!isNaN(d.timestamp.getTime())).sort((d,p)=>p.timestamp.getTime()-d.timestamp.getTime()),a=t.maxAgeInDays??30,c=t.maxArchiveCount??5,l=new Date(Date.now()-a*24*60*60*1e3),u=0;for(let d=0;d<s.length;d++){let p=s[d],m=p.timestamp<l,f=d>=c;if(m||f)try{(0,q.unlinkSync)(p.filepath),u++}catch{}}u>0&&console.log(`[Olympus Learning] Pruned ${u} old archives`)}catch(n){console.error("[Olympus Learning] Failed to prune archives:",n)}}function Co(e,t=Eh,n=li){if((0,q.existsSync)(e))try{let r=(0,q.readFileSync)(e,"utf-8").split(`
4
- `).filter(i=>i.trim()).length;if(r>=t){let i=new Date().toISOString().replace(/[:.]/g,"-"),s=e.replace(".jsonl",`.${i}.old.jsonl`);(0,q.renameSync)(e,s),console.log(`[Olympus Learning] Archived ${r} entries to ${s}`),bh(e,n)}}catch(o){console.error(`[Olympus Learning] Failed to rotate ${e}:`,o)}}function wt(e){tn();let t=(0,be.join)(fe(),"feedback-log.jsonl");Co(t),(0,q.appendFileSync)(t,JSON.stringify(e)+`
3
+ "use strict";var Zg=Object.create;var _o=Object.defineProperty;var eh=Object.getOwnPropertyDescriptor;var th=Object.getOwnPropertyNames;var nh=Object.getPrototypeOf,oh=Object.prototype.hasOwnProperty;var B=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ot=(e,t)=>{for(var n in t)_o(e,n,{get:t[n],enumerable:!0})},Oa=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of th(t))!oh.call(e,r)&&r!==n&&_o(e,r,{get:()=>t[r],enumerable:!(o=eh(t,r))||o.enumerable});return e};var E=(e,t,n)=>(n=e!=null?Zg(nh(e)):{},Oa(t||!e||!e.__esModule?_o(n,"default",{value:e,enumerable:!0}):n,e)),rh=e=>Oa(_o({},"__esModule",{value:!0}),e);var li,lc=B(()=>{"use strict";li={maxAgeInDays:30,maxArchiveCount:5}});function ui(e){if(!e.token_usage)return null;let{token_usage:t}=e;return typeof t.input_tokens!="number"||typeof t.output_tokens!="number"||typeof t.total_tokens!="number"||typeof t.estimated!="boolean"?null:t}function en(e){return ui(e)?.total_tokens||0}var uc=B(()=>{"use strict"});function fe(){return process.env.OLYMPUS_TEST_LEARNING_DIR?process.env.OLYMPUS_TEST_LEARNING_DIR:(0,be.join)((0,dc.homedir)(),".claude","olympus","learning")}function Je(e){return(0,be.join)(e,".olympus","learning")}function fc(e){let t=(0,be.resolve)(e);return(0,pc.createHash)("sha256").update(t).digest("hex").substring(0,16)}function tn(e){let t=fe();if((0,q.existsSync)(t)||(0,q.mkdirSync)(t,{recursive:!0}),e){let n=Je(e);(0,q.existsSync)(n)||(0,q.mkdirSync)(n,{recursive:!0})}}function Ch(e,t=li){try{let n=(0,be.dirname)(e),o=(0,be.basename)(e,".jsonl"),r=(0,q.readdirSync)(n),i=new RegExp(`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\..*\\.old\\.jsonl$`),s=r.filter(d=>i.test(d)).map(d=>{let p=d.match(/\.(\d{4}-\d{2}-\d{2})T/),m=p?new Date(p[1]):null;return{filename:d,filepath:(0,be.join)(n,d),timestamp:m}}).filter(d=>d.timestamp!==null&&!isNaN(d.timestamp.getTime())).sort((d,p)=>p.timestamp.getTime()-d.timestamp.getTime()),a=t.maxAgeInDays??30,c=t.maxArchiveCount??5,l=new Date(Date.now()-a*24*60*60*1e3),u=0;for(let d=0;d<s.length;d++){let p=s[d],m=p.timestamp<l,f=d>=c;if(m||f)try{(0,q.unlinkSync)(p.filepath),u++}catch{}}u>0&&console.log(`[Olympus Learning] Pruned ${u} old archives`)}catch(n){console.error("[Olympus Learning] Failed to prune archives:",n)}}function Co(e,t=Eh,n=li){if((0,q.existsSync)(e))try{let r=(0,q.readFileSync)(e,"utf-8").split(`
4
+ `).filter(i=>i.trim()).length;if(r>=t){let i=new Date().toISOString().replace(/[:.]/g,"-"),s=e.replace(".jsonl",`.${i}.old.jsonl`);(0,q.renameSync)(e,s),console.log(`[Olympus Learning] Archived ${r} entries to ${s}`),Ch(e,n)}}catch(o){console.error(`[Olympus Learning] Failed to rotate ${e}:`,o)}}function wt(e){tn();let t=(0,be.join)(fe(),"feedback-log.jsonl");Co(t),(0,q.appendFileSync)(t,JSON.stringify(e)+`
5
5
  `,"utf-8")}function Io(){let e=(0,be.join)(fe(),"feedback-log.jsonl");return(0,q.existsSync)(e)?(0,q.readFileSync)(e,"utf-8").split(`
6
- `).filter(n=>n.trim()).map(n=>JSON.parse(n)):[]}function Ch(e){let t=e.filter(r=>r.event_type==="revision"||r.event_type==="cancellation"),n=new Map;for(let r of t){let i=r.extracted_lesson||r.feedback_category||"unknown",s=n.get(i);s?(s.count++,s.examples.length<3&&s.examples.push(r.user_message.substring(0,100))):n.set(i,{count:1,examples:[r.user_message.substring(0,100)]})}let o=[];for(let[r,i]of n)i.count>=2&&o.push({pattern:r,count:i.count,examples:i.examples});return o}function Ih(e){let t=[];return e>=.85&&t.push("high success rate"),t}function Rh(e,t){let n=[];return e<.6&&n.push("low success rate"),t>2&&n.push("frequently cancelled"),n}function Ro(e,t){let n=t.filter(u=>u.agent_used===e);if(n.length===0)return null;let o=n.length,r=n.filter(u=>u.event_type==="success").length,i=n.filter(u=>u.event_type==="revision").length,s=n.filter(u=>u.event_type==="cancellation").length,a=o>0?r/o:0,c,l=n.filter(u=>ui(u)!==null);if(l.length>0){let u=l.filter(y=>y.event_type==="success"),d=l.filter(y=>y.event_type==="revision"||y.event_type==="cancellation"),p=l.reduce((y,w)=>y+en(w),0),m=u.reduce((y,w)=>y+en(w),0),f=d.reduce((y,w)=>y+en(w),0),g=u.length>0?m/u.length:0,h=d.length>0?f/d.length:0;if(c={avg_tokens_per_success:g,avg_tokens_per_failure:h,total_tokens:p,invocation_count:l.length,efficiency_score:g,trend:"insufficient_data"},l.length>=10){let y=Math.floor(l.length/2),w=l.slice(0,y),k=l.slice(y),C=w.reduce((z,S)=>z+en(S),0)/w.length,A=k.reduce((z,S)=>z+en(S),0)/k.length-C,b=C*.1;Math.abs(A)<b?c.trend="stable":A<0?c.trend="improving":c.trend="declining"}}return{agent_name:e,total_invocations:o,success_count:r,revision_count:i,cancellation_count:s,success_rate:a,failure_patterns:Ch(n),strong_areas:Ih(a),weak_areas:Rh(a,s),last_updated:new Date().toISOString(),token_efficiency:c}}function me(e,t){if(!(0,q.existsSync)(e))return t;try{return JSON.parse((0,q.readFileSync)(e,"utf-8"))}catch(n){return console.error(`[Olympus Learning] Failed to read ${e}:`,n),t}}function it(e,t){try{let n=(0,be.dirname)(e);n&&!(0,q.existsSync)(n)&&(0,q.mkdirSync)(n,{recursive:!0}),(0,q.writeFileSync)(e,JSON.stringify(t,null,2),"utf-8")}catch(n){console.error(`[Olympus Learning] Failed to write ${e}:`,n)}}function mc(e){tn();let t=(0,be.join)(fe(),"session-summaries.jsonl");Co(t),(0,q.appendFileSync)(t,JSON.stringify(e)+`
7
- `,"utf-8")}var dc,be,q,pc,Eh,ye=B(()=>{"use strict";dc=require("os"),be=require("path"),q=require("fs"),pc=require("crypto");lc();uc();Eh=1e4});var ie=U(pi=>{"use strict";pi.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((n,o)=>{t.push((r,i)=>r!=null?o(r):n(i)),e.apply(this,t)})},"name",{value:e.name})};pi.fromPromise=function(e){return Object.defineProperty(function(...t){let n=t[t.length-1];if(typeof n!="function")return e.apply(this,t);t.pop(),e.apply(this,t).then(o=>n(null,o),n)},"name",{value:e.name})}});var $c=U((sb,Pc)=>{var St=require("constants"),$h=process.cwd,Ao=null,Nh=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Ao||(Ao=$h.call(process)),Ao};try{process.cwd()}catch{}typeof process.chdir=="function"&&(fi=process.chdir,process.chdir=function(e){Ao=null,fi.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,fi));var fi;Pc.exports=Dh;function Dh(e){St.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=o(e.chmod),e.fchmod=o(e.fchmod),e.lchmod=o(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=c(e.statSync),e.fstatSync=c(e.fstatSync),e.lstatSync=c(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,d,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,d,p,m){m&&process.nextTick(m)},e.lchownSync=function(){}),Nh==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function d(p,m,f){var g=Date.now(),h=0;u(p,m,function y(w){if(w&&(w.code==="EACCES"||w.code==="EPERM"||w.code==="EBUSY")&&Date.now()-g<6e4){setTimeout(function(){e.stat(m,function(k,C){k&&k.code==="ENOENT"?u(p,m,y):f(w)})},h),h<100&&(h+=10);return}f&&f(w)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function d(p,m,f,g,h,y){var w;if(y&&typeof y=="function"){var k=0;w=function(C,I,A){if(C&&C.code==="EAGAIN"&&k<10)return k++,u.call(e,p,m,f,g,h,w);y.apply(this,arguments)}}return u.call(e,p,m,f,g,h,w)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(d,p,m,f,g){for(var h=0;;)try{return u.call(e,d,p,m,f,g)}catch(y){if(y.code==="EAGAIN"&&h<10){h++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(d,p,m){u.open(d,St.O_WRONLY|St.O_SYMLINK,p,function(f,g){if(f){m&&m(f);return}u.fchmod(g,p,function(h){u.close(g,function(y){m&&m(h||y)})})})},u.lchmodSync=function(d,p){var m=u.openSync(d,St.O_WRONLY|St.O_SYMLINK,p),f=!0,g;try{g=u.fchmodSync(m,p),f=!1}finally{if(f)try{u.closeSync(m)}catch{}else u.closeSync(m)}return g}}function n(u){St.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(d,p,m,f){u.open(d,St.O_SYMLINK,function(g,h){if(g){f&&f(g);return}u.futimes(h,p,m,function(y){u.close(h,function(w){f&&f(y||w)})})})},u.lutimesSync=function(d,p,m){var f=u.openSync(d,St.O_SYMLINK),g,h=!0;try{g=u.futimesSync(f,p,m),h=!1}finally{if(h)try{u.closeSync(f)}catch{}else u.closeSync(f)}return g}):u.futimes&&(u.lutimes=function(d,p,m,f){f&&process.nextTick(f)},u.lutimesSync=function(){})}function o(u){return u&&function(d,p,m){return u.call(e,d,p,function(f){l(f)&&(f=null),m&&m.apply(this,arguments)})}}function r(u){return u&&function(d,p){try{return u.call(e,d,p)}catch(m){if(!l(m))throw m}}}function i(u){return u&&function(d,p,m,f){return u.call(e,d,p,m,function(g){l(g)&&(g=null),f&&f.apply(this,arguments)})}}function s(u){return u&&function(d,p,m){try{return u.call(e,d,p,m)}catch(f){if(!l(f))throw f}}}function a(u){return u&&function(d,p,m){typeof p=="function"&&(m=p,p=null);function f(g,h){h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),m&&m.apply(this,arguments)}return p?u.call(e,d,p,f):u.call(e,d,f)}}function c(u){return u&&function(d,p){var m=p?u.call(e,d,p):u.call(e,d);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function l(u){if(!u||u.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Mc=U((ab,Dc)=>{var Nc=require("stream").Stream;Dc.exports=Mh;function Mh(e){return{ReadStream:t,WriteStream:n};function t(o,r){if(!(this instanceof t))return new t(o,r);Nc.call(this);var i=this;this.path=o,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var s=Object.keys(r),a=0,c=s.length;a<c;a++){var l=s[a];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(u,d){if(u){i.emit("error",u),i.readable=!1;return}i.fd=d,i.emit("open",d),i._read()})}function n(o,r){if(!(this instanceof n))return new n(o,r);Nc.call(this),this.path=o,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var i=Object.keys(r),s=0,a=i.length;s<a;s++){var c=i[s];this[c]=r[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Lc=U((cb,jc)=>{"use strict";jc.exports=Lh;var jh=Object.getPrototypeOf||function(e){return e.__proto__};function Lh(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:jh(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var on=U((lb,hi)=>{var X=require("fs"),Fh=$c(),Uh=Mc(),Wh=Lc(),xo=require("util"),ue,$o;typeof Symbol=="function"&&typeof Symbol.for=="function"?(ue=Symbol.for("graceful-fs.queue"),$o=Symbol.for("graceful-fs.previous")):(ue="___graceful-fs.queue",$o="___graceful-fs.previous");function Hh(){}function Wc(e,t){Object.defineProperty(e,ue,{get:function(){return t}})}var Lt=Hh;xo.debuglog?Lt=xo.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Lt=function(){var e=xo.format.apply(xo,arguments);e="GFS4: "+e.split(/\n/).join(`
6
+ `).filter(n=>n.trim()).map(n=>JSON.parse(n)):[]}function Ih(e){let t=e.filter(r=>r.event_type==="revision"||r.event_type==="cancellation"),n=new Map;for(let r of t){let i=r.extracted_lesson||r.feedback_category||"unknown",s=n.get(i);s?(s.count++,s.examples.length<3&&s.examples.push(r.user_message.substring(0,100))):n.set(i,{count:1,examples:[r.user_message.substring(0,100)]})}let o=[];for(let[r,i]of n)i.count>=2&&o.push({pattern:r,count:i.count,examples:i.examples});return o}function Rh(e){let t=[];return e>=.85&&t.push("high success rate"),t}function Oh(e,t){let n=[];return e<.6&&n.push("low success rate"),t>2&&n.push("frequently cancelled"),n}function Ro(e,t){let n=t.filter(u=>u.agent_used===e);if(n.length===0)return null;let o=n.length,r=n.filter(u=>u.event_type==="success").length,i=n.filter(u=>u.event_type==="revision").length,s=n.filter(u=>u.event_type==="cancellation").length,a=o>0?r/o:0,c,l=n.filter(u=>ui(u)!==null);if(l.length>0){let u=l.filter(y=>y.event_type==="success"),d=l.filter(y=>y.event_type==="revision"||y.event_type==="cancellation"),p=l.reduce((y,w)=>y+en(w),0),m=u.reduce((y,w)=>y+en(w),0),f=d.reduce((y,w)=>y+en(w),0),g=u.length>0?m/u.length:0,h=d.length>0?f/d.length:0;if(c={avg_tokens_per_success:g,avg_tokens_per_failure:h,total_tokens:p,invocation_count:l.length,efficiency_score:g,trend:"insufficient_data"},l.length>=10){let y=Math.floor(l.length/2),w=l.slice(0,y),k=l.slice(y),C=w.reduce((z,S)=>z+en(S),0)/w.length,A=k.reduce((z,S)=>z+en(S),0)/k.length-C,b=C*.1;Math.abs(A)<b?c.trend="stable":A<0?c.trend="improving":c.trend="declining"}}return{agent_name:e,total_invocations:o,success_count:r,revision_count:i,cancellation_count:s,success_rate:a,failure_patterns:Ih(n),strong_areas:Rh(a),weak_areas:Oh(a,s),last_updated:new Date().toISOString(),token_efficiency:c}}function me(e,t){if(!(0,q.existsSync)(e))return t;try{return JSON.parse((0,q.readFileSync)(e,"utf-8"))}catch(n){return console.error(`[Olympus Learning] Failed to read ${e}:`,n),t}}function it(e,t){try{let n=(0,be.dirname)(e);n&&!(0,q.existsSync)(n)&&(0,q.mkdirSync)(n,{recursive:!0}),(0,q.writeFileSync)(e,JSON.stringify(t,null,2),"utf-8")}catch(n){console.error(`[Olympus Learning] Failed to write ${e}:`,n)}}function mc(e){tn();let t=(0,be.join)(fe(),"session-summaries.jsonl");Co(t,bh),(0,q.appendFileSync)(t,JSON.stringify(e)+`
7
+ `,"utf-8")}var dc,be,q,pc,Eh,bh,ye=B(()=>{"use strict";dc=require("os"),be=require("path"),q=require("fs"),pc=require("crypto");lc();uc();Eh=1e4,bh=500});var ie=U(pi=>{"use strict";pi.fromCallback=function(e){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")e.apply(this,t);else return new Promise((n,o)=>{t.push((r,i)=>r!=null?o(r):n(i)),e.apply(this,t)})},"name",{value:e.name})};pi.fromPromise=function(e){return Object.defineProperty(function(...t){let n=t[t.length-1];if(typeof n!="function")return e.apply(this,t);t.pop(),e.apply(this,t).then(o=>n(null,o),n)},"name",{value:e.name})}});var $c=U((sb,Pc)=>{var St=require("constants"),$h=process.cwd,Ao=null,Nh=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Ao||(Ao=$h.call(process)),Ao};try{process.cwd()}catch{}typeof process.chdir=="function"&&(fi=process.chdir,process.chdir=function(e){Ao=null,fi.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,fi));var fi;Pc.exports=Dh;function Dh(e){St.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=o(e.chmod),e.fchmod=o(e.fchmod),e.lchmod=o(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=c(e.statSync),e.fstatSync=c(e.fstatSync),e.lstatSync=c(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,d,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,d,p,m){m&&process.nextTick(m)},e.lchownSync=function(){}),Nh==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function d(p,m,f){var g=Date.now(),h=0;u(p,m,function y(w){if(w&&(w.code==="EACCES"||w.code==="EPERM"||w.code==="EBUSY")&&Date.now()-g<6e4){setTimeout(function(){e.stat(m,function(k,C){k&&k.code==="ENOENT"?u(p,m,y):f(w)})},h),h<100&&(h+=10);return}f&&f(w)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function d(p,m,f,g,h,y){var w;if(y&&typeof y=="function"){var k=0;w=function(C,I,A){if(C&&C.code==="EAGAIN"&&k<10)return k++,u.call(e,p,m,f,g,h,w);y.apply(this,arguments)}}return u.call(e,p,m,f,g,h,w)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(d,p,m,f,g){for(var h=0;;)try{return u.call(e,d,p,m,f,g)}catch(y){if(y.code==="EAGAIN"&&h<10){h++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(d,p,m){u.open(d,St.O_WRONLY|St.O_SYMLINK,p,function(f,g){if(f){m&&m(f);return}u.fchmod(g,p,function(h){u.close(g,function(y){m&&m(h||y)})})})},u.lchmodSync=function(d,p){var m=u.openSync(d,St.O_WRONLY|St.O_SYMLINK,p),f=!0,g;try{g=u.fchmodSync(m,p),f=!1}finally{if(f)try{u.closeSync(m)}catch{}else u.closeSync(m)}return g}}function n(u){St.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(d,p,m,f){u.open(d,St.O_SYMLINK,function(g,h){if(g){f&&f(g);return}u.futimes(h,p,m,function(y){u.close(h,function(w){f&&f(y||w)})})})},u.lutimesSync=function(d,p,m){var f=u.openSync(d,St.O_SYMLINK),g,h=!0;try{g=u.futimesSync(f,p,m),h=!1}finally{if(h)try{u.closeSync(f)}catch{}else u.closeSync(f)}return g}):u.futimes&&(u.lutimes=function(d,p,m,f){f&&process.nextTick(f)},u.lutimesSync=function(){})}function o(u){return u&&function(d,p,m){return u.call(e,d,p,function(f){l(f)&&(f=null),m&&m.apply(this,arguments)})}}function r(u){return u&&function(d,p){try{return u.call(e,d,p)}catch(m){if(!l(m))throw m}}}function i(u){return u&&function(d,p,m,f){return u.call(e,d,p,m,function(g){l(g)&&(g=null),f&&f.apply(this,arguments)})}}function s(u){return u&&function(d,p,m){try{return u.call(e,d,p,m)}catch(f){if(!l(f))throw f}}}function a(u){return u&&function(d,p,m){typeof p=="function"&&(m=p,p=null);function f(g,h){h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),m&&m.apply(this,arguments)}return p?u.call(e,d,p,f):u.call(e,d,f)}}function c(u){return u&&function(d,p){var m=p?u.call(e,d,p):u.call(e,d);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}function l(u){if(!u||u.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Mc=U((ab,Dc)=>{var Nc=require("stream").Stream;Dc.exports=Mh;function Mh(e){return{ReadStream:t,WriteStream:n};function t(o,r){if(!(this instanceof t))return new t(o,r);Nc.call(this);var i=this;this.path=o,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var s=Object.keys(r),a=0,c=s.length;a<c;a++){var l=s[a];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(u,d){if(u){i.emit("error",u),i.readable=!1;return}i.fd=d,i.emit("open",d),i._read()})}function n(o,r){if(!(this instanceof n))return new n(o,r);Nc.call(this),this.path=o,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var i=Object.keys(r),s=0,a=i.length;s<a;s++){var c=i[s];this[c]=r[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Lc=U((cb,jc)=>{"use strict";jc.exports=Lh;var jh=Object.getPrototypeOf||function(e){return e.__proto__};function Lh(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:jh(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var on=U((lb,hi)=>{var X=require("fs"),Fh=$c(),Uh=Mc(),Wh=Lc(),xo=require("util"),ue,$o;typeof Symbol=="function"&&typeof Symbol.for=="function"?(ue=Symbol.for("graceful-fs.queue"),$o=Symbol.for("graceful-fs.previous")):(ue="___graceful-fs.queue",$o="___graceful-fs.previous");function Hh(){}function Wc(e,t){Object.defineProperty(e,ue,{get:function(){return t}})}var Lt=Hh;xo.debuglog?Lt=xo.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Lt=function(){var e=xo.format.apply(xo,arguments);e="GFS4: "+e.split(/\n/).join(`
8
8
  GFS4: `),console.error(e)});X[ue]||(Fc=global[ue]||[],Wc(X,Fc),X.close=(function(e){function t(n,o){return e.call(X,n,function(r){r||Uc(),typeof o=="function"&&o.apply(this,arguments)})}return Object.defineProperty(t,$o,{value:e}),t})(X.close),X.closeSync=(function(e){function t(n){e.apply(X,arguments),Uc()}return Object.defineProperty(t,$o,{value:e}),t})(X.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Lt(X[ue]),require("assert").equal(X[ue].length,0)}));var Fc;global[ue]||Wc(global,X[ue]);hi.exports=mi(Wh(X));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!X.__patched&&(hi.exports=mi(X),X.__patched=!0);function mi(e){Fh(e),e.gracefulify=mi,e.createReadStream=I,e.createWriteStream=A;var t=e.readFile;e.readFile=n;function n(S,O,x){return typeof O=="function"&&(x=O,O=null),D(S,O,x);function D(F,T,P,Y){return t(F,T,function(H){H&&(H.code==="EMFILE"||H.code==="ENFILE")?nn([D,[F,T,P],H,Y||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var o=e.writeFile;e.writeFile=r;function r(S,O,x,D){return typeof x=="function"&&(D=x,x=null),F(S,O,x,D);function F(T,P,Y,H,ce){return o(T,P,Y,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?nn([F,[T,P,Y,H],J,ce||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var i=e.appendFile;i&&(e.appendFile=s);function s(S,O,x,D){return typeof x=="function"&&(D=x,x=null),F(S,O,x,D);function F(T,P,Y,H,ce){return i(T,P,Y,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?nn([F,[T,P,Y,H],J,ce||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=c);function c(S,O,x,D){return typeof x=="function"&&(D=x,x=0),F(S,O,x,D);function F(T,P,Y,H,ce){return a(T,P,Y,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?nn([F,[T,P,Y,H],J,ce||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var l=e.readdir;e.readdir=d;var u=/^v[0-5]\./;function d(S,O,x){typeof O=="function"&&(x=O,O=null);var D=u.test(process.version)?function(P,Y,H,ce){return l(P,F(P,Y,H,ce))}:function(P,Y,H,ce){return l(P,Y,F(P,Y,H,ce))};return D(S,O,x);function F(T,P,Y,H){return function(ce,J){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?nn([D,[T,P,Y],ce,H||Date.now(),Date.now()]):(J&&J.sort&&J.sort(),typeof Y=="function"&&Y.call(this,ce,J))}}}if(process.version.substr(0,4)==="v0.8"){var p=Uh(e);y=p.ReadStream,k=p.WriteStream}var m=e.ReadStream;m&&(y.prototype=Object.create(m.prototype),y.prototype.open=w);var f=e.WriteStream;f&&(k.prototype=Object.create(f.prototype),k.prototype.open=C),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(S){y=S},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return k},set:function(S){k=S},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(e,"FileReadStream",{get:function(){return g},set:function(S){g=S},enumerable:!0,configurable:!0});var h=k;Object.defineProperty(e,"FileWriteStream",{get:function(){return h},set:function(S){h=S},enumerable:!0,configurable:!0});function y(S,O){return this instanceof y?(m.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function w(){var S=this;z(S.path,S.flags,S.mode,function(O,x){O?(S.autoClose&&S.destroy(),S.emit("error",O)):(S.fd=x,S.emit("open",x),S.read())})}function k(S,O){return this instanceof k?(f.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function C(){var S=this;z(S.path,S.flags,S.mode,function(O,x){O?(S.destroy(),S.emit("error",O)):(S.fd=x,S.emit("open",x))})}function I(S,O){return new e.ReadStream(S,O)}function A(S,O){return new e.WriteStream(S,O)}var b=e.open;e.open=z;function z(S,O,x,D){return typeof x=="function"&&(D=x,x=null),F(S,O,x,D);function F(T,P,Y,H,ce){return b(T,P,Y,function(J,dE){J&&(J.code==="EMFILE"||J.code==="ENFILE")?nn([F,[T,P,Y,H],J,ce||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}return e}function nn(e){Lt("ENQUEUE",e[0].name,e[1]),X[ue].push(e),gi()}var Po;function Uc(){for(var e=Date.now(),t=0;t<X[ue].length;++t)X[ue][t].length>2&&(X[ue][t][3]=e,X[ue][t][4]=e);gi()}function gi(){if(clearTimeout(Po),Po=void 0,X[ue].length!==0){var e=X[ue].shift(),t=e[0],n=e[1],o=e[2],r=e[3],i=e[4];if(r===void 0)Lt("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){Lt("TIMEOUT",t.name,n);var s=n.pop();typeof s=="function"&&s.call(null,o)}else{var a=Date.now()-i,c=Math.max(i-r,1),l=Math.min(c*1.2,100);a>=l?(Lt("RETRY",t.name,n),t.apply(null,n.concat([r]))):X[ue].push(e)}Po===void 0&&(Po=setTimeout(gi,0))}}});var we=U(st=>{"use strict";var Hc=ie().fromCallback,ke=on(),Gh=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof ke[e]=="function");Object.assign(st,ke);Gh.forEach(e=>{st[e]=Hc(ke[e])});st.exists=function(e,t){return typeof t=="function"?ke.exists(e,t):new Promise(n=>ke.exists(e,n))};st.read=function(e,t,n,o,r,i){return typeof i=="function"?ke.read(e,t,n,o,r,i):new Promise((s,a)=>{ke.read(e,t,n,o,r,(c,l,u)=>{if(c)return a(c);s({bytesRead:l,buffer:u})})})};st.write=function(e,t,...n){return typeof n[n.length-1]=="function"?ke.write(e,t,...n):new Promise((o,r)=>{ke.write(e,t,...n,(i,s,a)=>{if(i)return r(i);o({bytesWritten:s,buffer:a})})})};st.readv=function(e,t,...n){return typeof n[n.length-1]=="function"?ke.readv(e,t,...n):new Promise((o,r)=>{ke.readv(e,t,...n,(i,s,a)=>{if(i)return r(i);o({bytesRead:s,buffers:a})})})};st.writev=function(e,t,...n){return typeof n[n.length-1]=="function"?ke.writev(e,t,...n):new Promise((o,r)=>{ke.writev(e,t,...n,(i,s,a)=>{if(i)return r(i);o({bytesWritten:s,buffers:a})})})};typeof ke.realpath.native=="function"?st.realpath.native=Hc(ke.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var Bc=U((db,Gc)=>{"use strict";var Bh=require("path");Gc.exports.checkPath=function(t){if(process.platform==="win32"&&/[<>:"|?*]/.test(t.replace(Bh.parse(t).root,""))){let o=new Error(`Path contains invalid characters: ${t}`);throw o.code="EINVAL",o}}});var Kc=U((pb,yi)=>{"use strict";var qc=we(),{checkPath:Vc}=Bc(),Yc=e=>{let t={mode:511};return typeof e=="number"?e:{...t,...e}.mode};yi.exports.makeDir=async(e,t)=>(Vc(e),qc.mkdir(e,{mode:Yc(t),recursive:!0}));yi.exports.makeDirSync=(e,t)=>(Vc(e),qc.mkdirSync(e,{mode:Yc(t),recursive:!0}))});var He=U((fb,Jc)=>{"use strict";var qh=ie().fromPromise,{makeDir:Vh,makeDirSync:ki}=Kc(),wi=qh(Vh);Jc.exports={mkdirs:wi,mkdirsSync:ki,mkdirp:wi,mkdirpSync:ki,ensureDir:wi,ensureDirSync:ki}});var _t=U((mb,Qc)=>{"use strict";var Yh=ie().fromPromise,zc=we();function Kh(e){return zc.access(e).then(()=>!0).catch(()=>!1)}Qc.exports={pathExists:Yh(Kh),pathExistsSync:zc.existsSync}});var Si=U((gb,Xc)=>{"use strict";var rn=we(),Jh=ie().fromPromise;async function zh(e,t,n){let o=await rn.open(e,"r+"),r=null;try{await rn.futimes(o,t,n)}finally{try{await rn.close(o)}catch(i){r=i}}if(r)throw r}function Qh(e,t,n){let o=rn.openSync(e,"r+");return rn.futimesSync(o,t,n),rn.closeSync(o)}Xc.exports={utimesMillis:Jh(zh),utimesMillisSync:Qh}});var Ft=U((hb,nl)=>{"use strict";var sn=we(),se=require("path"),Zc=ie().fromPromise;function Xh(e,t,n){let o=n.dereference?r=>sn.stat(r,{bigint:!0}):r=>sn.lstat(r,{bigint:!0});return Promise.all([o(e),o(t).catch(r=>{if(r.code==="ENOENT")return null;throw r})]).then(([r,i])=>({srcStat:r,destStat:i}))}function Zh(e,t,n){let o,r=n.dereference?s=>sn.statSync(s,{bigint:!0}):s=>sn.lstatSync(s,{bigint:!0}),i=r(e);try{o=r(t)}catch(s){if(s.code==="ENOENT")return{srcStat:i,destStat:null};throw s}return{srcStat:i,destStat:o}}async function ey(e,t,n,o){let{srcStat:r,destStat:i}=await Xh(e,t,o);if(i){if(Bn(r,i)){let s=se.basename(e),a=se.basename(t);if(n==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:r,destStat:i,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!i.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!r.isDirectory()&&i.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(r.isDirectory()&&_i(e,t))throw new Error(No(e,t,n));return{srcStat:r,destStat:i}}function ty(e,t,n,o){let{srcStat:r,destStat:i}=Zh(e,t,o);if(i){if(Bn(r,i)){let s=se.basename(e),a=se.basename(t);if(n==="move"&&s!==a&&s.toLowerCase()===a.toLowerCase())return{srcStat:r,destStat:i,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!i.isDirectory())throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);if(!r.isDirectory()&&i.isDirectory())throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`)}if(r.isDirectory()&&_i(e,t))throw new Error(No(e,t,n));return{srcStat:r,destStat:i}}async function el(e,t,n,o){let r=se.resolve(se.dirname(e)),i=se.resolve(se.dirname(n));if(i===r||i===se.parse(i).root)return;let s;try{s=await sn.stat(i,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Bn(t,s))throw new Error(No(e,n,o));return el(e,t,i,o)}function tl(e,t,n,o){let r=se.resolve(se.dirname(e)),i=se.resolve(se.dirname(n));if(i===r||i===se.parse(i).root)return;let s;try{s=sn.statSync(i,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(Bn(t,s))throw new Error(No(e,n,o));return tl(e,t,i,o)}function Bn(e,t){return t.ino!==void 0&&t.dev!==void 0&&t.ino===e.ino&&t.dev===e.dev}function _i(e,t){let n=se.resolve(e).split(se.sep).filter(r=>r),o=se.resolve(t).split(se.sep).filter(r=>r);return n.every((r,i)=>o[i]===r)}function No(e,t,n){return`Cannot ${n} '${e}' to a subdirectory of itself, '${t}'.`}nl.exports={checkPaths:Zc(ey),checkPathsSync:ty,checkParentPaths:Zc(el),checkParentPathsSync:tl,isSrcSubdir:_i,areIdentical:Bn}});var rl=U((yb,ol)=>{"use strict";async function ny(e,t){let n=[];for await(let o of e)n.push(t(o).then(()=>null,r=>r??new Error("unknown error")));await Promise.all(n.map(o=>o.then(r=>{if(r!==null)throw r})))}ol.exports={asyncIteratorConcurrentProcess:ny}});var ll=U((kb,cl)=>{"use strict";var ge=we(),qn=require("path"),{mkdirs:oy}=He(),{pathExists:ry}=_t(),{utimesMillis:iy}=Si(),Vn=Ft(),{asyncIteratorConcurrentProcess:sy}=rl();async function ay(e,t,n={}){typeof n=="function"&&(n={filter:n}),n.clobber="clobber"in n?!!n.clobber:!0,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
9
9
 
10
10
  see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:o,destStat:r}=await Vn.checkPaths(e,t,"copy",n);if(await Vn.checkParentPaths(e,o,t,"copy"),!await sl(e,t,n))return;let s=qn.dirname(t);await ry(s)||await oy(s),await al(r,e,t,n)}async function sl(e,t,n){return n.filter?n.filter(e,t):!0}async function al(e,t,n,o){let i=await(o.dereference?ge.stat:ge.lstat)(t);if(i.isDirectory())return dy(i,e,t,n,o);if(i.isFile()||i.isCharacterDevice()||i.isBlockDevice())return cy(i,e,t,n,o);if(i.isSymbolicLink())return py(e,t,n,o);throw i.isSocket()?new Error(`Cannot copy a socket file: ${t}`):i.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${t}`):new Error(`Unknown file: ${t}`)}async function cy(e,t,n,o,r){if(!t)return il(e,n,o,r);if(r.overwrite)return await ge.unlink(o),il(e,n,o,r);if(r.errorOnExist)throw new Error(`'${o}' already exists`)}async function il(e,t,n,o){if(await ge.copyFile(t,n),o.preserveTimestamps){ly(e.mode)&&await uy(n,e.mode);let r=await ge.stat(t);await iy(n,r.atime,r.mtime)}return ge.chmod(n,e.mode)}function ly(e){return(e&128)===0}function uy(e,t){return ge.chmod(e,t|128)}async function dy(e,t,n,o,r){t||await ge.mkdir(o),await sy(await ge.opendir(n),async i=>{let s=qn.join(n,i.name),a=qn.join(o,i.name);if(await sl(s,a,r)){let{destStat:l}=await Vn.checkPaths(s,a,"copy",r);await al(l,s,a,r)}}),t||await ge.chmod(o,e.mode)}async function py(e,t,n,o){let r=await ge.readlink(t);if(o.dereference&&(r=qn.resolve(process.cwd(),r)),!e)return ge.symlink(r,n);let i=null;try{i=await ge.readlink(n)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return ge.symlink(r,n);throw s}if(o.dereference&&(i=qn.resolve(process.cwd(),i)),r!==i){if(Vn.isSrcSubdir(r,i))throw new Error(`Cannot copy '${r}' to a subdirectory of itself, '${i}'.`);if(Vn.isSrcSubdir(i,r))throw new Error(`Cannot overwrite '${i}' with '${r}'.`)}return await ge.unlink(n),ge.symlink(r,n)}cl.exports=ay});var ml=U((wb,fl)=>{"use strict";var Se=on(),Yn=require("path"),fy=He().mkdirsSync,my=Si().utimesMillisSync,Kn=Ft();function gy(e,t,n){typeof n=="function"&&(n={filter:n}),n=n||{},n.clobber="clobber"in n?!!n.clobber:!0,n.overwrite="overwrite"in n?!!n.overwrite:n.clobber,n.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
@@ -14,7 +14,7 @@ GFS4: `),console.error(e)});X[ue]||(Fc=global[ue]||[],Wc(X,Fc),X.close=(function
14
14
  `),o=null,r=[];for(let i of n){let s=i.match(/^##\s+(.+)$/);s?(o&&t.set(o,r.join(`
15
15
  `)),o=s[1].trim(),r=[]):o&&r.push(i)}return o&&t.set(o,r.join(`
16
16
  `)),t}function Qn(e){let t=[],n=e.split(`
17
- `);for(let o of n){let r=o.match(/^\s*[-*+]\s+(?:\[[ x]\]\s+)?(.+)$/);r&&t.push(r[1].trim())}return t}function Uk(e,t){let n=Fk(e);if(t==="intent-to-unit"){let s=Oi(n),a=[],c=s.get("Business Requirements");c&&a.push(...Qn(c));let l=s.get("Implementation Plan");return l&&a.push(...Qn(l)),a}if(t==="unit-to-bolt"){let s=Oi(n),a=[],c=s.get("Acceptance Criteria");c&&a.push(...Qn(c));let l=s.get("Target Files");return l&&a.push(...Qn(l)),a}let o=Oi(n),r=Lk[t],i=[];for(let s of r){let a=o.get(s);if(a){let c=Qn(a);i.push(...c)}}return i}function Wo(e,t,n){try{let o=Uk(e,n);if(o.length===0)return{conformance_score:100,coverage_percentage:100,missing_items:[],passed:!0};let r=t.toLowerCase(),i=[],s=0;for(let d of o){let p=d.toLowerCase();r.includes(p)?s++:i.push(d)}let a=Math.round(s/o.length*100),c=a,l=Iu[n],u=a>=l;return{conformance_score:a,coverage_percentage:c,missing_items:i,passed:u}}catch(o){return console.error("[Alignment] Verification computation failed:",o),{conformance_score:0,coverage_percentage:0,missing_items:["Verification computation error"],passed:!1}}}function Ru(e){let t=jk[e];return[{question:t.verification,answer:null,answered_by:null,passed:null},{question:t.validation,answer:null,answered_by:null,passed:null}]}function Ai(e,t,n,o,r){try{let i=Wo(e,t,r),s=Ru(r),a=s.every(m=>m.answer!==null),c=s.every(m=>m.passed===!0),u={alignment_score:a&&c?100:0,alignment_questions:s,passed:c},d=i.passed&&u.passed;return{source_artifact_id:n,target_artifact_id:o,verification:i,validation:u,alignment_passed:d,checked_at:new Date().toISOString()}}catch(i){return console.error("[Alignment] Alignment check failed:",i),{source_artifact_id:n,target_artifact_id:o,verification:{conformance_score:0,coverage_percentage:0,missing_items:["Alignment check error"],passed:!1},validation:{alignment_score:0,alignment_questions:[],passed:!1},alignment_passed:!1,checked_at:new Date().toISOString()}}}function ln(e,t,n,o,r,i,s,a){let c=Ai(t,e,i,s,o),l=Ai(n,e,a,s,r),u=c.alignment_passed&&l.alignment_passed;return{parentCheck:c,rootCheck:l,passed:u}}function Wk(e,t){let n=0;t>=2&&(n+=10),t>=3&&(n+=10);let o=e-n;return Math.max(0,o)}function Hk(e,t){try{let n=$(e);if(!n){console.error(`[Alignment] Manifest not found at ${e}`);return}n.alignment_checks.push(t),L(e,n)}catch(n){console.error("[Alignment] Failed to record alignment result:",n)}}function Gk(e){return Iu[e]}var Iu,jk,Lk,Ho=B(()=>{"use strict";K();Iu={"intent-to-unit":95,"unit-to-bolt":100,"unit-to-intent":80,"bolt-to-intent":70},jk={"intent-to-unit":{verification:"Does the UNIT cover its assigned scope from the INTENT?",validation:"Will this UNIT produce a working module that contributes to the feature?"},"unit-to-bolt":{verification:"Does the BOLT cover all acceptance criteria from the UNIT?",validation:"Does this BOLT deliver meaningful, testable progress?"},"unit-to-intent":{verification:"Does this UNIT contribute to the INTENT's problem statement?",validation:"Does this UNIT help achieve the INTENT's success metrics?"},"bolt-to-intent":{verification:"Does this BOLT contribute to solving the INTENT's stated problem?",validation:"Is this BOLT still aligned with the original INTENT's goals?"}},Lk={"intent-to-unit":["Business Requirements","Implementation Plan"],"unit-to-bolt":["Acceptance Criteria","Target Files"],"unit-to-intent":["Problem Statement","Success Metrics"],"bolt-to-intent":["Problem Statement","Success Metrics"]}});var Ht={};ot(Ht,{addGateAuditEntry:()=>Ce,cascadeInvalidation:()=>Vk,computeChecksum:()=>Go,createManifest:()=>Bk,detectStaleArtifacts:()=>qk,getArtifactById:()=>Jk,getArtifactsByPhase:()=>zk,getBoltArtifacts:()=>Ze,getBoltsByStatus:()=>$i,getUnitArtifacts:()=>Wt,isWorkflowComplete:()=>xu,linkArtifacts:()=>Pi,loadManifest:()=>$,normalizePath:()=>xi,recoverManifest:()=>Kk,registerArtifact:()=>Ae,revalidateStaleArtifacts:()=>Xk,runAlignmentCheck:()=>Yk,saveManifest:()=>L,transitionToActive:()=>Ni,transitionToDraft:()=>Pu,transitionToFulfilled:()=>Di,transitionToStale:()=>Nu,transitionToViolated:()=>$u,updateContractStatus:()=>Xe,updatePhaseStatus:()=>ct});function xi(e){return e.replace(/\\/g,"/")}function Et(){return{status:"not_started",started_at:null,completed_at:null,gate_result:null,gate_bypassed:!1,bypass_reason:null}}function Bk(e,t,n){let o=Qe.join(n,"aidlc-docs",e),r=Qe.join(o,"manifest.json");try{te.ensureDirSync(o);let i=new Date().toISOString(),s={schema_version:"2.0.0",workflow_id:e,feature_name:t,created_at:i,updated_at:i,phases:{discovery:Et(),inception:Et(),construction:Et(),operations:Et()},depth_assessment:null,artifacts:[],links:[],risks:[],gate_audit:[],metrics:null,alignment_checks:[],risk_tier:null};return te.writeFileSync(r,JSON.stringify(s,null,2),"utf-8"),r}catch(i){throw console.error(`Failed to create manifest at ${r}:`,i),i}}function $(e){try{if(!te.existsSync(e))return null;let t=te.readFileSync(e,"utf-8");return JSON.parse(t)}catch(t){return console.error(`Failed to load manifest at ${e}:`,t),null}}function L(e,t){try{t.updated_at=new Date().toISOString(),te.writeFileSync(e,JSON.stringify(t,null,2),"utf-8")}catch(n){throw console.error(`Failed to save manifest at ${e}:`,n),n}}function Go(e){try{if(!te.existsSync(e))return null;let t=te.readFileSync(e),n=(0,Au.createHash)("sha256");return n.update(t),n.digest("hex")}catch(t){return console.error(`Failed to compute checksum for ${e}:`,t),null}}function Ae(e,t){try{let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=new Date().toISOString(),r=xi(t.path),i=n.artifacts.findIndex(a=>a.id===t.id),s=Go(t.path);if(i>=0){let a=n.artifacts[i];n.artifacts[i]={...a,...t,path:r,updated_at:o,contract_version:a.contract_version+1,checksum:s}}else{let a={...t,path:r,created_at:o,updated_at:o,contract_version:1,contract_status:"draft",stale_reason:null,checksum:s};n.artifacts.push(a)}L(e,n)}catch(n){throw console.error(`Failed to register artifact in ${e}:`,n),n}}function Pi(e,t){try{let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.some(s=>s.id===t.source_id),r=n.artifacts.some(s=>s.id===t.target_id);if(!o)throw new Error(`Source artifact not found: ${t.source_id}`);if(!r)throw new Error(`Target artifact not found: ${t.target_id}`);n.links.some(s=>s.source_id===t.source_id&&s.target_id===t.target_id&&s.link_type===t.link_type)||(n.links.push(t),L(e,n))}catch(n){throw console.error(`Failed to link artifacts in ${e}:`,n),n}}function qk(e){try{let t=$(e);if(!t)return[];let n=[];for(let o of t.artifacts)if(o.checksum&&o.write_complete){let r=Go(o.path);r&&r!==o.checksum&&n.push(o.id)}return n}catch(t){return console.error(`Failed to detect stale artifacts in ${e}:`,t),[]}}function Vk(e,t){try{let n=$(e);if(!n)return;let o=new Set,r=[t];for(;r.length>0;){let i=r.shift();if(o.has(i))continue;o.add(i);let s=n.artifacts.find(c=>c.id===i);if(s){let c=i===t?"Artifact content was modified":`Parent artifact ${i} was modified`;Qk(s,c)}let a=n.links.filter(c=>c.source_id===i);for(let c of a)o.has(c.target_id)||r.push(c.target_id)}L(e,n)}catch(n){console.error(`Failed to cascade invalidation in ${e}:`,n)}}function Yk(e,t,n){try{let o=$(e);if(!o)return;let r=new Date().toISOString(),a={source_artifact_id:t,target_artifact_id:n,verification:{conformance_score:0,coverage_percentage:0,missing_items:[],passed:!1},validation:{alignment_score:0,alignment_questions:[],passed:!1},alignment_passed:!1,checked_at:r};o.alignment_checks.push(a),L(e,o)}catch(o){console.error(`Failed to run alignment check in ${e}:`,o)}}function Kk(e,t){try{let n=Qe.join(e,"aidlc-docs",t);if(!te.existsSync(n))return null;let o=new Date().toISOString(),r={schema_version:"2.0.0",workflow_id:t,feature_name:"Recovered Workflow",created_at:o,updated_at:o,phases:{discovery:Et(),inception:Et(),construction:Et(),operations:Et()},depth_assessment:null,artifacts:[],links:[],risks:[],gate_audit:[],metrics:null,alignment_checks:[],risk_tier:null},i=te.readdirSync(n,{recursive:!0,withFileTypes:!0});for(let s of i)if(s.isFile()&&s.name!=="manifest.json"){let a=Qe.join(s.path,s.name),c=Qe.relative(n,a),l=xi(a),u={id:`recovered-${Date.now()}-${r.artifacts.length}`,type:Qe.extname(s.name)||"unknown",phase:"inception",stage:"intent",path:l,created_at:o,updated_at:o,validation_passed:null,write_complete:!0,checksum:Go(a),contract_status:"draft",contract_version:1,stale_reason:null};r.artifacts.push(u)}return r}catch(n){return console.error(`Failed to recover manifest for workflow ${t}:`,n),null}}function ct(e,t,n,o,r){try{let i=$(e);if(!i)return;i.phases[t].status=n,o!==void 0&&(i.phases[t].started_at=o),r!==void 0&&(i.phases[t].completed_at=r),L(e,i)}catch(i){console.error(`Failed to update phase status in ${e}:`,i)}}function Ce(e,t){try{let n=$(e);if(!n)return;let o={...t,timestamp:new Date().toISOString()};n.gate_audit.push(o),L(e,n)}catch(n){console.error(`Failed to add gate audit entry in ${e}:`,n)}}function Jk(e,t){return e.artifacts.find(n=>n.id===t)}function zk(e,t){return e.artifacts.filter(n=>n.phase===t)}function Xe(e,t,n,o){try{switch(n){case"draft":Pu(e,t);break;case"active":Ni(e,t);break;case"fulfilled":Di(e,t);break;case"violated":$u(e,t);break;case"stale":if(!o)throw new Error('staleReason is required when setting status to "stale"');Nu(e,t,o);break}}catch(r){console.error(`Failed to update contract status in ${e}:`,r)}}function Wt(e){return e.artifacts.filter(t=>t.stage==="unit")}function Ze(e,t){let n=e.artifacts.filter(o=>o.stage==="code-generation");if(t){let o=new Set(e.links.filter(r=>r.source_id===t&&(r.link_type==="derives"||r.link_type==="implements")).map(r=>r.target_id));return n.filter(r=>o.has(r.id))}return n}function $i(e,t){return e.artifacts.filter(n=>n.stage==="code-generation"&&n.contract_status===t)}function xu(e){let t=e.artifacts.filter(n=>n.stage==="code-generation");return t.length===0?!1:t.every(n=>n.contract_status==="fulfilled")}function Qk(e,t){return e.contract_status==="stale"||e.contract_status==="violated"?!1:(e.contract_status="stale",e.stale_reason=t,e.statusHistory||(e.statusHistory=[]),e.statusHistory.push({status:"stale",timestamp:new Date().toISOString()}),!0)}function Pu(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="violated"&&o.contract_status!=="stale")throw new Error(`Cannot transition from '${o.contract_status}' to 'draft'`);o.contract_status="draft",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"draft",timestamp:new Date().toISOString()}),L(e,n)}function Ni(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="draft"&&o.contract_status!=="stale")throw new Error(`Cannot transition from '${o.contract_status}' to 'active'`);o.contract_status="active",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"active",timestamp:new Date().toISOString()}),L(e,n)}function Di(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="active")throw new Error(`Cannot transition from '${o.contract_status}' to 'fulfilled'`);o.contract_status="fulfilled",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"fulfilled",timestamp:new Date().toISOString()}),L(e,n)}function $u(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="active")throw new Error(`Cannot transition from '${o.contract_status}' to 'violated'`);o.contract_status="violated",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"violated",timestamp:new Date().toISOString()}),L(e,n)}function Nu(e,t,n){let o=$(e);if(!o)throw new Error(`Manifest not found at ${e}`);let r=o.artifacts.find(i=>i.id===t);if(!r)throw new Error(`Artifact ${t} not found in manifest`);if(r.contract_status!=="active"&&r.contract_status!=="fulfilled")throw new Error(`Cannot transition from '${r.contract_status}' to 'stale'`);r.contract_status="stale",r.stale_reason=n,r.statusHistory||(r.statusHistory=[]),r.statusHistory.push({status:"stale",timestamp:new Date().toISOString()}),L(e,o)}async function Xk(e,t){let n={restored:[],stillStale:[],errors:[]},o=Qe.join(e,"aidlc-docs",t,"manifest.json"),r=$(o);if(!r)return n.errors.push("Manifest not found"),n;let i=r.artifacts.filter(s=>s.contract_status==="stale");for(let s of i)try{let a=r.links.find(y=>y.target_id===s.id);if(!a){n.stillStale.push(s.id);continue}let c=r.artifacts.find(y=>y.id===a.source_id);if(!c){n.stillStale.push(s.id);continue}let l=r.artifacts.find(y=>y.stage==="intent");if(!l){n.stillStale.push(s.id);continue}let u=te.existsSync(s.path)?te.readFileSync(s.path,"utf-8"):null,d=te.existsSync(c.path)?te.readFileSync(c.path,"utf-8"):null,p=te.existsSync(l.path)?te.readFileSync(l.path,"utf-8"):null;if(!u||!d||!p){n.stillStale.push(s.id);continue}let{runDualValidation:m}=await Promise.resolve().then(()=>(Ho(),Ou)),f,g;if(s.stage==="unit")f="intent-to-unit",g="unit-to-intent";else if(s.stage==="code-generation")f="unit-to-bolt",g="bolt-to-intent";else{n.stillStale.push(s.id);continue}m(u,d,p,f,g,c.id,s.id,l.id).passed?(s.contract_status="active",s.stale_reason=null,s.statusHistory||(s.statusHistory=[]),s.statusHistory.push({status:"active",timestamp:new Date().toISOString()}),n.restored.push(s.id)):n.stillStale.push(s.id)}catch(a){n.errors.push(`Error revalidating ${s.id}: ${a}`),n.stillStale.push(s.id)}return L(o,r),n}var te,Qe,Au,K=B(()=>{"use strict";te=E(ae(),1),Qe=E(require("path"),1),Au=require("crypto")});async function Du(e,t){let n=N.join(e,"aidlc-docs",t),o=N.join(n,"checkpoint.json");try{await de.ensureDir(n),await de.ensureDir(N.join(n,"inception")),await de.ensureDir(N.join(n,"construction")),await de.ensureDir(N.join(n,"construction","design")),await de.ensureDir(N.join(n,"operations")),await de.pathExists(o)||await de.writeJson(o,{workflow_id:t,current_stage:"intent",created_at:new Date().toISOString(),updated_at:new Date().toISOString()},{spaces:2})}catch(r){let i=r;throw i.code==="ENOSPC"?(console.error("[Artifacts] Failed to create workflow directory: Disk full"),console.error("[Artifacts] Please free up disk space and try again."),console.error(`[Artifacts] Attempted path: ${n}`),new Error("Failed to create workflow directory: Disk is full. Please free up space and retry.")):i.code==="EACCES"||i.code==="EPERM"?(console.error("[Artifacts] Failed to create workflow directory: Permission denied"),console.error(`[Artifacts] Path: ${n}`),new Error(`Failed to create workflow directory: Permission denied for ${n}`)):i.code==="EROFS"?(console.error("[Artifacts] Failed to create workflow directory: Read-only filesystem"),console.error(`[Artifacts] Path: ${n}`),new Error("Failed to create workflow directory: Filesystem is read-only")):(console.error(`[Artifacts] Failed to create workflow directory: ${i.message}`),console.error(`[Artifacts] Workflow ID: ${t}`),console.error(`[Artifacts] Path: ${n}`),new Error(`Failed to create workflow directory for ${t}: ${i.message}`))}}function bt(e,t,n,o,r){let i=N.join(e,"aidlc-docs",t);switch(n){case"intent":return N.join(i,"inception","intent.md");case"nfr":return N.join(i,"inception","nfr.md");case"unit":if(!o)throw new Error("artifactId is required for unit artifacts");return N.join(i,"construction",o,"spec.md");case"code-generation":if(!o)throw new Error("artifactId is required for code-generation artifacts");if(!r)throw new Error("unitId is required for code-generation artifacts");return N.join(i,"construction",r,`${o}.md`);case"validation-report":if(!o)throw new Error("artifactId is required for validation-report artifacts");return N.join(i,"construction",o,"validation-report.md");case"interfaces":return N.join(i,"construction","design","interfaces.json");case"data-flow":return N.join(i,"construction","design","data-flow.json");case"components":return N.join(i,"construction","design","components.json");case"deploy-guide":return N.join(i,"operations","deploy-guide.md");case"runbook":return N.join(i,"operations","runbook.md");case"monitoring":return N.join(i,"operations","monitoring.json");case"release-notes":return N.join(i,"operations","release-notes.md");case"state":return N.join(i,"state.md");case"audit":return N.join(i,"audit.md");case"analysis-plan":return N.join(i,"discovery","analysis-plan.md");case"current-state-analysis":return N.join(i,"discovery","current-state-analysis.md");case"regression-baseline":return N.join(i,"discovery","regression-baseline.md");case"change-impact":return N.join(i,"discovery","change-impact.md");case"static-model":return N.join(i,"discovery","static-model.md");case"dynamic-model":return N.join(i,"discovery","dynamic-model.md");case"WORKFLOW_ROUTING":return N.join(i,"inception","plans","workflow-routing.md");case"requirements-qa":return N.join(i,"inception","requirements-questions.md");case"requirements":return N.join(i,"inception","requirements.md");case"personas":return N.join(i,"inception","personas.md");case"user-stories":return N.join(i,"inception","stories.md");case"execution-plan":return N.join(i,"inception","plans","execution-plan.md");case"units-generation":return N.join(i,"inception","unit-of-work.md");case"unit-dependency":return N.join(i,"inception","unit-of-work-dependency.md");case"unit-story-map":return N.join(i,"inception","unit-of-work-story-map.md");default:throw new Error(`Unknown artifact type: ${n}`)}}async function un(e,t,n,o,r,i){let s=bt(e,t,n,r,i),a=await de.pathExists(s);try{await de.ensureDir(N.dirname(s)),await de.writeFile(s,o,"utf-8")}catch(c){let l=c;throw l.code==="ENOSPC"?(console.error(`[Artifacts] Failed to write ${n} artifact: Disk full`),console.error("[Artifacts] Please free up disk space and try again."),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Disk is full. Please free up space and retry.`)):l.code==="EACCES"||l.code==="EPERM"?(console.error(`[Artifacts] Failed to write ${n} artifact: Permission denied`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Permission denied for ${s}`)):l.code==="EROFS"?(console.error(`[Artifacts] Failed to write ${n} artifact: Read-only filesystem`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Filesystem is read-only`)):(console.error(`[Artifacts] Failed to write ${n} artifact: ${l.message}`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: ${l.message}`))}if(a)try{let c=N.join(e,"aidlc-docs",t,"manifest.json"),{cascadeInvalidation:l,loadManifest:u,saveManifest:d,computeChecksum:p}=await Promise.resolve().then(()=>(K(),Ht)),m=u(c);if(m){let f=s.replace(/\\/g,"/"),g=m.artifacts.find(h=>h.path===f||h.path.endsWith(N.basename(s)));if(g){let h=p(s);h&&(g.checksum=h,g.updated_at=new Date().toISOString(),d(c,m)),l(c,g.id)}}}catch(c){console.error("[Artifacts] Cascade invalidation after write failed:",c)}}async function Mi(e,t){let n=N.join(e,"aidlc-docs",t,"discovery");await de.ensureDir(n)}var N,de,ji=B(()=>{"use strict";N=E(require("path"),1),de=E(ae(),1)});function Vu(e){let t={id:(0,qu.randomUUID)(),timestamp:new Date().toISOString(),session_id:e.sessionId,project_path:e.projectPath,event_type:e.success?"success":"revision",agent_used:e.agentName,original_task:e.taskDescription,user_message:`BOLT ${e.boltId} execution ${e.success?"succeeded":"failed"}`,feedback_category:e.success?"praise":"correction",confidence:1,token_usage:e.tokenUsage?{input_tokens:e.tokenUsage.input_tokens,output_tokens:e.tokenUsage.output_tokens,total_tokens:e.tokenUsage.input_tokens+e.tokenUsage.output_tokens,estimated:!0}:void 0};wt(t)}function Yu(e){let t=Io();return Ro(e,t)}var qu,qo=B(()=>{"use strict";qu=require("crypto");ye()});var Vo={};ot(Vo,{CODE_PLAN_FORMAT_INSTRUCTIONS:()=>vw,buildCodeGenerationPrompt:()=>Qu,buildCodePlanPath:()=>Sw,dispatchCodeGeneration:()=>_w,extractSections:()=>qi,extractTargetFiles:()=>Vi,selectAgentForCodeGeneration:()=>zu});function Sw(e,t,n){return(0,mn.join)(e,"aidlc-docs",t,"construction",n,"code-plan.md")}function qi(e,t){if(!e)return"";let n=[],o=e.split(`
17
+ `);for(let o of n){let r=o.match(/^\s*[-*+]\s+(?:\[[ x]\]\s+)?(.+)$/);r&&t.push(r[1].trim())}return t}function Uk(e,t){let n=Fk(e);if(t==="intent-to-unit"){let s=Oi(n),a=[],c=s.get("Business Requirements");c&&a.push(...Qn(c));let l=s.get("Implementation Plan");return l&&a.push(...Qn(l)),a}if(t==="unit-to-bolt"){let s=Oi(n),a=[],c=s.get("Acceptance Criteria");c&&a.push(...Qn(c));let l=s.get("Target Files");return l&&a.push(...Qn(l)),a}let o=Oi(n),r=Lk[t],i=[];for(let s of r){let a=o.get(s);if(a){let c=Qn(a);i.push(...c)}}return i}function Wo(e,t,n){try{let o=Uk(e,n);if(o.length===0)return{conformance_score:100,coverage_percentage:100,missing_items:[],passed:!0};let r=t.toLowerCase(),i=[],s=0;for(let d of o){let p=d.toLowerCase();r.includes(p)?s++:i.push(d)}let a=Math.round(s/o.length*100),c=a,l=Iu[n],u=a>=l;return{conformance_score:a,coverage_percentage:c,missing_items:i,passed:u}}catch(o){return console.error("[Alignment] Verification computation failed:",o),{conformance_score:0,coverage_percentage:0,missing_items:["Verification computation error"],passed:!1}}}function Ru(e){let t=jk[e];return[{question:t.verification,answer:null,answered_by:null,passed:null},{question:t.validation,answer:null,answered_by:null,passed:null}]}function Ai(e,t,n,o,r){try{let i=Wo(e,t,r),s=Ru(r),a=s.every(m=>m.answer!==null),c=s.every(m=>m.passed===!0),u={alignment_score:a&&c?100:0,alignment_questions:s,passed:c},d=i.passed&&u.passed;return{source_artifact_id:n,target_artifact_id:o,verification:i,validation:u,alignment_passed:d,checked_at:new Date().toISOString()}}catch(i){return console.error("[Alignment] Alignment check failed:",i),{source_artifact_id:n,target_artifact_id:o,verification:{conformance_score:0,coverage_percentage:0,missing_items:["Alignment check error"],passed:!1},validation:{alignment_score:0,alignment_questions:[],passed:!1},alignment_passed:!1,checked_at:new Date().toISOString()}}}function ln(e,t,n,o,r,i,s,a){let c=Ai(t,e,i,s,o),l=Ai(n,e,a,s,r),u=c.alignment_passed&&l.alignment_passed;return{parentCheck:c,rootCheck:l,passed:u}}function Wk(e,t){let n=0;t>=2&&(n+=10),t>=3&&(n+=10);let o=e-n;return Math.max(0,o)}function Hk(e,t){try{let n=$(e);if(!n){console.error(`[Alignment] Manifest not found at ${e}`);return}n.alignment_checks.push(t),L(e,n)}catch(n){console.error("[Alignment] Failed to record alignment result:",n)}}function Gk(e){return Iu[e]}var Iu,jk,Lk,Ho=B(()=>{"use strict";K();Iu={"intent-to-unit":95,"unit-to-bolt":100,"unit-to-intent":80,"bolt-to-intent":70},jk={"intent-to-unit":{verification:"Does the UNIT cover its assigned scope from the INTENT?",validation:"Will this UNIT produce a working module that contributes to the feature?"},"unit-to-bolt":{verification:"Does the BOLT cover all acceptance criteria from the UNIT?",validation:"Does this BOLT deliver meaningful, testable progress?"},"unit-to-intent":{verification:"Does this UNIT contribute to the INTENT's problem statement?",validation:"Does this UNIT help achieve the INTENT's success metrics?"},"bolt-to-intent":{verification:"Does this BOLT contribute to solving the INTENT's stated problem?",validation:"Is this BOLT still aligned with the original INTENT's goals?"}},Lk={"intent-to-unit":["Business Requirements","Implementation Plan"],"unit-to-bolt":["Acceptance Criteria","Target Files"],"unit-to-intent":["Problem Statement","Success Metrics"],"bolt-to-intent":["Problem Statement","Success Metrics"]}});var Ht={};ot(Ht,{addGateAuditEntry:()=>Ce,cascadeInvalidation:()=>Vk,computeChecksum:()=>Go,createManifest:()=>Bk,detectStaleArtifacts:()=>qk,getArtifactById:()=>Jk,getArtifactsByPhase:()=>zk,getBoltArtifacts:()=>Ze,getBoltsByStatus:()=>$i,getUnitArtifacts:()=>Wt,isWorkflowComplete:()=>xu,linkArtifacts:()=>Pi,loadManifest:()=>$,normalizePath:()=>xi,recoverManifest:()=>Kk,registerArtifact:()=>Ae,revalidateStaleArtifacts:()=>Xk,runAlignmentCheck:()=>Yk,saveManifest:()=>L,transitionToActive:()=>Ni,transitionToDraft:()=>Pu,transitionToFulfilled:()=>Di,transitionToStale:()=>Nu,transitionToViolated:()=>$u,updateContractStatus:()=>Xe,updatePhaseStatus:()=>ct});function xi(e){return e.replace(/\\/g,"/")}function Et(){return{status:"not_started",started_at:null,completed_at:null,gate_result:null,gate_bypassed:!1,bypass_reason:null}}function Bk(e,t,n){let o=Qe.join(n,"aidlc-docs",e),r=Qe.join(o,"manifest.json");try{te.ensureDirSync(o);let i=new Date().toISOString(),s={schema_version:"2.0.0",workflow_id:e,feature_name:t,created_at:i,updated_at:i,phases:{discovery:Et(),inception:Et(),construction:Et(),operations:Et()},depth_assessment:null,artifacts:[],links:[],risks:[],gate_audit:[],metrics:null,alignment_checks:[],risk_tier:null};return te.writeFileSync(r,JSON.stringify(s,null,2),"utf-8"),r}catch(i){throw console.error(`Failed to create manifest at ${r}:`,i),i}}function $(e){try{if(!te.existsSync(e))return null;let t=te.readFileSync(e,"utf-8");return JSON.parse(t)}catch(t){return console.error(`Failed to load manifest at ${e}:`,t),null}}function L(e,t){try{t.updated_at=new Date().toISOString(),te.writeFileSync(e,JSON.stringify(t,null,2),"utf-8")}catch(n){throw console.error(`Failed to save manifest at ${e}:`,n),n}}function Go(e){try{if(!te.existsSync(e))return null;let t=te.readFileSync(e),n=(0,Au.createHash)("sha256");return n.update(t),n.digest("hex")}catch(t){return console.error(`Failed to compute checksum for ${e}:`,t),null}}function Ae(e,t){try{let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=new Date().toISOString(),r=xi(t.path),i=n.artifacts.findIndex(a=>a.id===t.id),s=Go(t.path);if(i>=0){let a=n.artifacts[i];n.artifacts[i]={...a,...t,path:r,updated_at:o,contract_version:a.contract_version+1,checksum:s}}else{let a={...t,path:r,created_at:o,updated_at:o,contract_version:1,contract_status:"draft",stale_reason:null,checksum:s};n.artifacts.push(a)}L(e,n)}catch(n){throw console.error(`Failed to register artifact in ${e}:`,n),n}}function Pi(e,t){try{let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.some(s=>s.id===t.source_id),r=n.artifacts.some(s=>s.id===t.target_id);if(!o)throw new Error(`Source artifact not found: ${t.source_id}`);if(!r)throw new Error(`Target artifact not found: ${t.target_id}`);n.links.some(s=>s.source_id===t.source_id&&s.target_id===t.target_id&&s.link_type===t.link_type)||(n.links.push(t),L(e,n))}catch(n){throw console.error(`Failed to link artifacts in ${e}:`,n),n}}function qk(e){try{let t=$(e);if(!t)return[];let n=[];for(let o of t.artifacts)if(o.checksum&&o.write_complete){let r=Go(o.path);r&&r!==o.checksum&&n.push(o.id)}return n}catch(t){return console.error(`Failed to detect stale artifacts in ${e}:`,t),[]}}function Vk(e,t){try{let n=$(e);if(!n)return;let o=new Set,r=[t];for(;r.length>0;){let i=r.shift();if(o.has(i))continue;o.add(i);let s=n.artifacts.find(c=>c.id===i);if(s){let c=i===t?"Artifact content was modified":`Parent artifact ${i} was modified`;Qk(s,c)}let a=n.links.filter(c=>c.source_id===i);for(let c of a)o.has(c.target_id)||r.push(c.target_id)}L(e,n)}catch(n){console.error(`Failed to cascade invalidation in ${e}:`,n)}}function Yk(e,t,n){try{let o=$(e);if(!o)return;let r=new Date().toISOString(),a={source_artifact_id:t,target_artifact_id:n,verification:{conformance_score:0,coverage_percentage:0,missing_items:[],passed:!1},validation:{alignment_score:0,alignment_questions:[],passed:!1},alignment_passed:!1,checked_at:r};o.alignment_checks.push(a),L(e,o)}catch(o){console.error(`Failed to run alignment check in ${e}:`,o)}}function Kk(e,t){try{let n=Qe.join(e,"aidlc-docs",t);if(!te.existsSync(n))return null;let o=new Date().toISOString(),r={schema_version:"2.0.0",workflow_id:t,feature_name:"Recovered Workflow",created_at:o,updated_at:o,phases:{discovery:Et(),inception:Et(),construction:Et(),operations:Et()},depth_assessment:null,artifacts:[],links:[],risks:[],gate_audit:[],metrics:null,alignment_checks:[],risk_tier:null},i=te.readdirSync(n,{recursive:!0,withFileTypes:!0});for(let s of i)if(s.isFile()&&s.name!=="manifest.json"){let a=Qe.join(s.path,s.name),c=Qe.relative(n,a),l=xi(a),u={id:`recovered-${Date.now()}-${r.artifacts.length}`,type:Qe.extname(s.name)||"unknown",phase:"inception",stage:"intent",path:l,created_at:o,updated_at:o,validation_passed:null,write_complete:!0,checksum:Go(a),contract_status:"draft",contract_version:1,stale_reason:null};r.artifacts.push(u)}return r}catch(n){return console.error(`Failed to recover manifest for workflow ${t}:`,n),null}}function ct(e,t,n,o,r){try{let i=$(e);if(!i)return;i.phases[t].status=n,o!==void 0&&(i.phases[t].started_at=o),r!==void 0&&(i.phases[t].completed_at=r),L(e,i)}catch(i){console.error(`Failed to update phase status in ${e}:`,i)}}function Ce(e,t){try{let n=$(e);if(!n)return;let o={...t,timestamp:new Date().toISOString()};n.gate_audit.push(o),L(e,n)}catch(n){console.error(`Failed to add gate audit entry in ${e}:`,n)}}function Jk(e,t){return e.artifacts.find(n=>n.id===t)}function zk(e,t){return e.artifacts.filter(n=>n.phase===t)}function Xe(e,t,n,o){try{switch(n){case"draft":Pu(e,t);break;case"active":Ni(e,t);break;case"fulfilled":Di(e,t);break;case"violated":$u(e,t);break;case"stale":if(!o)throw new Error('staleReason is required when setting status to "stale"');Nu(e,t,o);break}}catch(r){console.error(`Failed to update contract status in ${e}:`,r)}}function Wt(e){return e.artifacts.filter(t=>t.stage==="unit")}function Ze(e,t){let n=e.artifacts.filter(o=>o.stage==="code-generation");if(t){let o=new Set(e.links.filter(r=>r.source_id===t&&(r.link_type==="derives"||r.link_type==="implements")).map(r=>r.target_id));return n.filter(r=>o.has(r.id))}return n}function $i(e,t){return e.artifacts.filter(n=>n.stage==="code-generation"&&n.contract_status===t)}function xu(e){let t=e.artifacts.filter(n=>n.stage==="code-generation");return t.length===0?!1:t.every(n=>n.contract_status==="fulfilled")}function Qk(e,t){return e.contract_status==="stale"||e.contract_status==="violated"?!1:(e.contract_status="stale",e.stale_reason=t,e.statusHistory||(e.statusHistory=[]),e.statusHistory.push({status:"stale",timestamp:new Date().toISOString()}),!0)}function Pu(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="violated"&&o.contract_status!=="stale")throw new Error(`Cannot transition from '${o.contract_status}' to 'draft'`);o.contract_status="draft",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"draft",timestamp:new Date().toISOString()}),L(e,n)}function Ni(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="draft"&&o.contract_status!=="stale")throw new Error(`Cannot transition from '${o.contract_status}' to 'active'`);o.contract_status="active",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"active",timestamp:new Date().toISOString()}),L(e,n)}function Di(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="active")throw new Error(`Cannot transition from '${o.contract_status}' to 'fulfilled'`);o.contract_status="fulfilled",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"fulfilled",timestamp:new Date().toISOString()}),L(e,n)}function $u(e,t){let n=$(e);if(!n)throw new Error(`Manifest not found at ${e}`);let o=n.artifacts.find(r=>r.id===t);if(!o)throw new Error(`Artifact ${t} not found in manifest`);if(o.contract_status!=="active")throw new Error(`Cannot transition from '${o.contract_status}' to 'violated'`);o.contract_status="violated",o.stale_reason=null,o.statusHistory||(o.statusHistory=[]),o.statusHistory.push({status:"violated",timestamp:new Date().toISOString()}),L(e,n)}function Nu(e,t,n){let o=$(e);if(!o)throw new Error(`Manifest not found at ${e}`);let r=o.artifacts.find(i=>i.id===t);if(!r)throw new Error(`Artifact ${t} not found in manifest`);if(r.contract_status!=="active"&&r.contract_status!=="fulfilled")throw new Error(`Cannot transition from '${r.contract_status}' to 'stale'`);r.contract_status="stale",r.stale_reason=n,r.statusHistory||(r.statusHistory=[]),r.statusHistory.push({status:"stale",timestamp:new Date().toISOString()}),L(e,o)}async function Xk(e,t){let n={restored:[],stillStale:[],errors:[]},o=Qe.join(e,"aidlc-docs",t,"manifest.json"),r=$(o);if(!r)return n.errors.push("Manifest not found"),n;let i=r.artifacts.filter(s=>s.contract_status==="stale");for(let s of i)try{let a=r.links.find(y=>y.target_id===s.id);if(!a){n.stillStale.push(s.id);continue}let c=r.artifacts.find(y=>y.id===a.source_id);if(!c){n.stillStale.push(s.id);continue}let l=r.artifacts.find(y=>y.stage==="intent");if(!l){n.stillStale.push(s.id);continue}let u=te.existsSync(s.path)?te.readFileSync(s.path,"utf-8"):null,d=te.existsSync(c.path)?te.readFileSync(c.path,"utf-8"):null,p=te.existsSync(l.path)?te.readFileSync(l.path,"utf-8"):null;if(!u||!d||!p){n.stillStale.push(s.id);continue}let{runDualValidation:m}=await Promise.resolve().then(()=>(Ho(),Ou)),f,g;if(s.stage==="unit")f="intent-to-unit",g="unit-to-intent";else if(s.stage==="code-generation")f="unit-to-bolt",g="bolt-to-intent";else{n.stillStale.push(s.id);continue}m(u,d,p,f,g,c.id,s.id,l.id).passed?(s.contract_status="active",s.stale_reason=null,s.statusHistory||(s.statusHistory=[]),s.statusHistory.push({status:"active",timestamp:new Date().toISOString()}),n.restored.push(s.id)):n.stillStale.push(s.id)}catch(a){n.errors.push(`Error revalidating ${s.id}: ${a}`),n.stillStale.push(s.id)}return L(o,r),n}var te,Qe,Au,K=B(()=>{"use strict";te=E(ae(),1),Qe=E(require("path"),1),Au=require("crypto")});async function Du(e,t){let n=N.join(e,"aidlc-docs",t),o=N.join(n,"checkpoint.json");try{await de.ensureDir(n),await de.ensureDir(N.join(n,"inception")),await de.ensureDir(N.join(n,"construction")),await de.ensureDir(N.join(n,"construction","design")),await de.ensureDir(N.join(n,"operations")),await de.pathExists(o)||await de.writeJson(o,{workflow_id:t,current_stage:"intent",created_at:new Date().toISOString(),updated_at:new Date().toISOString()},{spaces:2})}catch(r){let i=r;throw i.code==="ENOSPC"?(console.error("[Artifacts] Failed to create workflow directory: Disk full"),console.error("[Artifacts] Please free up disk space and try again."),console.error(`[Artifacts] Attempted path: ${n}`),new Error("Failed to create workflow directory: Disk is full. Please free up space and retry.")):i.code==="EACCES"||i.code==="EPERM"?(console.error("[Artifacts] Failed to create workflow directory: Permission denied"),console.error(`[Artifacts] Path: ${n}`),new Error(`Failed to create workflow directory: Permission denied for ${n}`)):i.code==="EROFS"?(console.error("[Artifacts] Failed to create workflow directory: Read-only filesystem"),console.error(`[Artifacts] Path: ${n}`),new Error("Failed to create workflow directory: Filesystem is read-only")):(console.error(`[Artifacts] Failed to create workflow directory: ${i.message}`),console.error(`[Artifacts] Workflow ID: ${t}`),console.error(`[Artifacts] Path: ${n}`),new Error(`Failed to create workflow directory for ${t}: ${i.message}`))}}function bt(e,t,n,o,r){let i=N.join(e,"aidlc-docs",t);switch(n){case"intent":return N.join(i,"inception","intent.md");case"nfr":return N.join(i,"inception","requirements","nfr.md");case"unit":if(!o)throw new Error("artifactId is required for unit artifacts");return N.join(i,"construction",o,"spec.md");case"code-generation":if(!o)throw new Error("artifactId is required for code-generation artifacts");if(!r)throw new Error("unitId is required for code-generation artifacts");return N.join(i,"construction",r,`${o}.md`);case"validation-report":if(!o)throw new Error("artifactId is required for validation-report artifacts");return N.join(i,"construction",o,"validation-report.md");case"interfaces":return N.join(i,"construction","design","interfaces.json");case"data-flow":return N.join(i,"construction","design","data-flow.json");case"components":return N.join(i,"construction","design","components.json");case"deploy-guide":return N.join(i,"operations","deploy-guide.md");case"runbook":return N.join(i,"operations","runbook.md");case"monitoring":return N.join(i,"operations","monitoring.json");case"release-notes":return N.join(i,"operations","release-notes.md");case"state":return N.join(i,"state.md");case"audit":return N.join(i,"audit.md");case"analysis-plan":return N.join(i,"discovery","analysis-plan.md");case"current-state-analysis":return N.join(i,"discovery","current-state-analysis.md");case"regression-baseline":return N.join(i,"discovery","regression-baseline.md");case"change-impact":return N.join(i,"discovery","change-impact.md");case"static-model":return N.join(i,"discovery","static-model.md");case"dynamic-model":return N.join(i,"discovery","dynamic-model.md");case"WORKFLOW_ROUTING":return N.join(i,"inception","plans","workflow-routing.md");case"requirements-qa":return N.join(i,"inception","requirements","requirements-analysis-questions.md");case"requirements":return N.join(i,"inception","requirements","requirements.md");case"personas":return N.join(i,"inception","user-stories","personas.md");case"user-stories":return N.join(i,"inception","user-stories","stories.md");case"execution-plan":return N.join(i,"inception","plans","execution-plan.md");case"units-generation":return N.join(i,"inception","application-design","unit-of-work.md");case"unit-dependency":return N.join(i,"inception","application-design","unit-of-work-dependency.md");case"unit-story-map":return N.join(i,"inception","application-design","unit-of-work-story-map.md");default:throw new Error(`Unknown artifact type: ${n}`)}}async function un(e,t,n,o,r,i){let s=bt(e,t,n,r,i),a=await de.pathExists(s);try{await de.ensureDir(N.dirname(s)),await de.writeFile(s,o,"utf-8")}catch(c){let l=c;throw l.code==="ENOSPC"?(console.error(`[Artifacts] Failed to write ${n} artifact: Disk full`),console.error("[Artifacts] Please free up disk space and try again."),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Disk is full. Please free up space and retry.`)):l.code==="EACCES"||l.code==="EPERM"?(console.error(`[Artifacts] Failed to write ${n} artifact: Permission denied`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Permission denied for ${s}`)):l.code==="EROFS"?(console.error(`[Artifacts] Failed to write ${n} artifact: Read-only filesystem`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: Filesystem is read-only`)):(console.error(`[Artifacts] Failed to write ${n} artifact: ${l.message}`),console.error(`[Artifacts] Path: ${s}`),new Error(`Failed to write ${n} artifact: ${l.message}`))}if(a)try{let c=N.join(e,"aidlc-docs",t,"manifest.json"),{cascadeInvalidation:l,loadManifest:u,saveManifest:d,computeChecksum:p}=await Promise.resolve().then(()=>(K(),Ht)),m=u(c);if(m){let f=s.replace(/\\/g,"/"),g=m.artifacts.find(h=>h.path===f||h.path.endsWith(N.basename(s)));if(g){let h=p(s);h&&(g.checksum=h,g.updated_at=new Date().toISOString(),d(c,m)),l(c,g.id)}}}catch(c){console.error("[Artifacts] Cascade invalidation after write failed:",c)}}async function Mi(e,t){let n=N.join(e,"aidlc-docs",t,"discovery");await de.ensureDir(n)}var N,de,ji=B(()=>{"use strict";N=E(require("path"),1),de=E(ae(),1)});function Vu(e){let t={id:(0,qu.randomUUID)(),timestamp:new Date().toISOString(),session_id:e.sessionId,project_path:e.projectPath,event_type:e.success?"success":"revision",agent_used:e.agentName,original_task:e.taskDescription,user_message:`BOLT ${e.boltId} execution ${e.success?"succeeded":"failed"}`,feedback_category:e.success?"praise":"correction",confidence:1,token_usage:e.tokenUsage?{input_tokens:e.tokenUsage.input_tokens,output_tokens:e.tokenUsage.output_tokens,total_tokens:e.tokenUsage.input_tokens+e.tokenUsage.output_tokens,estimated:!0}:void 0};wt(t)}function Yu(e){let t=Io();return Ro(e,t)}var qu,qo=B(()=>{"use strict";qu=require("crypto");ye()});var Vo={};ot(Vo,{CODE_PLAN_FORMAT_INSTRUCTIONS:()=>vw,buildCodeGenerationPrompt:()=>Qu,buildCodePlanPath:()=>Sw,dispatchCodeGeneration:()=>_w,extractSections:()=>qi,extractTargetFiles:()=>Vi,selectAgentForCodeGeneration:()=>zu});function Sw(e,t,n){return(0,mn.join)(e,"aidlc-docs",t,"construction",n,"code-plan.md")}function qi(e,t){if(!e)return"";let n=[],o=e.split(`
18
18
  `);for(let r=0;r<o.length;r++){let i=o[r],s=i.match(/^##\s+(.+)$/)||i.match(/^###\s+(.+)$/);if(s){let a=s[1].trim();if(t.some(c=>a.includes(c))){let c=[i],l=i.match(/^(#+)/)?.[1].length||2;for(let u=r+1;u<o.length;u++){let d=o[u],p=d.match(/^(#+)\s/);if(p&&p[1].length<=l)break;c.push(d)}n.push(c.join(`
19
19
  `))}}}return n.length>0?n.join(`
20
20
 
@@ -52,7 +52,7 @@ Generate code for this unit according to the spec above.
52
52
  3. Each step should be specific and actionable
53
53
  4. Steps should be ordered by dependency (prerequisites first)
54
54
  5. Include a "## Verification" section with test/validation checkboxes
55
- The plan file is saved at: aidlc-docs/{workflowId}/construction/{unitName}/code-plan.md`});async function Xu(e,t,n){let o=hn.default.join(e,"aidlc-docs",t,"inception","nfr.md"),r=hn.default.join(e,"aidlc-docs",t,"construction",n,"spec.md"),i=hn.default.join(e,"aidlc-docs",t,"construction",n,"nfr-requirements.md"),s="";try{await Bt.default.pathExists(o)&&(s=await Bt.default.readFile(o,"utf-8"))}catch{}let a="";try{await Bt.default.pathExists(r)&&(a=await Bt.default.readFile(r,"utf-8"))}catch{}let c=a.match(/^title:\s*(.+)$/m),l=c?c[1].trim().replace(/^["']|["']$/g,""):n,u=Tw(s,a,l),d=new Date().toISOString(),p=`---
55
+ The plan file is saved at: aidlc-docs/{workflowId}/construction/{unitName}/code-plan.md`});async function Xu(e,t,n){let o=hn.default.join(e,"aidlc-docs",t,"inception","requirements","nfr.md"),r=hn.default.join(e,"aidlc-docs",t,"construction",n,"spec.md"),i=hn.default.join(e,"aidlc-docs",t,"construction",n,"nfr-requirements.md"),s="";try{await Bt.default.pathExists(o)&&(s=await Bt.default.readFile(o,"utf-8"))}catch{}let a="";try{await Bt.default.pathExists(r)&&(a=await Bt.default.readFile(r,"utf-8"))}catch{}let c=a.match(/^title:\s*(.+)$/m),l=c?c[1].trim().replace(/^["']|["']$/g,""):n,u=Tw(s,a,l),d=new Date().toISOString(),p=`---
56
56
  id: ${n}-nfr-requirements
57
57
  parent_unit: ${n}
58
58
  generated_at: ${d}
@@ -337,7 +337,7 @@ ${r}
337
337
  `)}var qt,er,tr,Bw,Qi=B(()=>{"use strict";qt=E(require("path"),1),er=E(require("fs/promises"),1),tr=require("fs");Qo();K();Bw=[{pathway:"bugfix",keywords:["fix","bug","broken","regression","error","crash","issue","defect","patch"]},{pathway:"optimization",keywords:["optimize","performance","speed","cache","reduce","improve latency","memory","bottleneck"]},{pathway:"brownfield-refactor",keywords:["refactor","restructure","migrate","rewrite","reorganize","modernize","upgrade"]},{pathway:"brownfield-enhancement",keywords:["add","new","feature","implement","integrate","extend","support"]}]});function fS(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function mS(e){let t=e.split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");return t.length>80?t.substring(0,77)+"...":t}function gS(e){let{inception_stages:t,current_inception_stage:n}=e;if(!t)return[];let o=[];for(let r of pS){let i=t[r];if(!i)continue;let s=fS(r),a=n===r,c,l;i.status==="completed"?(c="[x]",l=i.completed_at?`(completed ${i.completed_at})`:"(completed)"):i.status==="skipped"?(c="[ ]",l=i.skip_reason?`(skipped -- ${i.skip_reason})`:"(skipped)"):(c="[ ]",l="");let u=` - ${c} ${s} ${l}`.trimEnd();a&&(u+=" <- CURRENT"),o.push(u)}return o}function hS(e){let t=["## Progress"];for(let n of dS){let o=e.phases[n],r,i;o?.completed_at?(r="[x]",i=`(completed ${o.completed_at})`):e.current_phase===n?(r="[ ]",i="(in progress)"):(r="[ ]",i="");let s=n.charAt(0).toUpperCase()+n.slice(1);if(t.push(`- ${r} ${s} ${i}`.trimEnd()),n==="inception"&&e.inception_stages){let a=gS(e);t.push(...a)}}return t.join(`
338
338
  `)}function yS(e){let t=["## Units of Work"];if(!e.construction_units||Object.keys(e.construction_units).length===0)return t.push(""),t.push("_No units defined yet. Populated during Units Generation._"),t.join(`
339
339
  `);t.push(""),t.push("| Unit | Status |"),t.push("|------|--------|");for(let[n,o]of Object.entries(e.construction_units))t.push(`| ${n} | ${o.code_generation_status} |`);return t.join(`
340
- `)}function kS(e,t){let n=["## Key Artifacts",""];n.push("| Artifact | Path | Status |"),n.push("|----------|------|--------|");let o=Sn.join(e,to,t),r=[{name:"Intent Analysis",path:"inception/intent.md"},{name:"Requirements",path:"inception/requirements.md"},{name:"User Stories",path:"inception/stories.md"},{name:"Workflow Plan",path:"inception/workflow-plan.md"},{name:"Unit Definitions",path:"inception/application-design/unit-of-work.md"},{name:"Dependency Matrix",path:"inception/application-design/unit-of-work-dependency.md"}];for(let i of r){let s=dt.existsSync(Sn.join(o,i.path));n.push(`| ${i.name} | ${i.path} | ${s?"created":"pending"} |`)}return n.join(`
340
+ `)}function kS(e,t){let n=["## Key Artifacts",""];n.push("| Artifact | Path | Status |"),n.push("|----------|------|--------|");let o=Sn.join(e,to,t),r=[{name:"Intent Analysis",path:"inception/intent.md"},{name:"Requirements",path:"inception/requirements/requirements.md"},{name:"NFR",path:"inception/requirements/nfr.md"},{name:"User Stories",path:"inception/user-stories/stories.md"},{name:"Personas",path:"inception/user-stories/personas.md"},{name:"Workflow Plan",path:"inception/workflow-plan.md"},{name:"Unit Definitions",path:"inception/application-design/unit-of-work.md"},{name:"Dependency Matrix",path:"inception/application-design/unit-of-work-dependency.md"}];for(let i of r){let s=dt.existsSync(Sn.join(o,i.path));n.push(`| ${i.name} | ${i.path} | ${s?"created":"pending"} |`)}return n.join(`
341
341
  `)}function Xi(e,t,n){let o=Sn.join(e,to,t,$d);try{let r=mS(n.feature_name),i=hS(n),s=yS(n),a=kS(e,t),c=`# ${r}
342
342
 
343
343
  | Field | Value |
@@ -811,7 +811,7 @@ Incomplete tasks remain in your todo list. Continue working on the next pending
811
811
 
812
812
  - Proceed without asking for permission
813
813
  - Mark each task complete when finished
814
- - Do not stop until all tasks are done`;var LE={hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\keyword-detector.mjs"':'node "$HOME/.claude/hooks/keyword-detector.mjs"'}]}],SessionStart:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\session-start.mjs"':'node "$HOME/.claude/hooks/session-start.mjs"'}]}],Stop:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\persistent-mode.mjs"':'node "$HOME/.claude/hooks/persistent-mode.mjs"'}]}]}},FE={hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=UserPromptSubmit`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=UserPromptSubmit`}]}],SessionStart:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=SessionStart`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=SessionStart`}]}],Stop:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Stop`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Stop`}]}],PreToolUse:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PreToolUse`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PreToolUse`}]}],PostToolUse:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUse`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUse`}]}],PostToolUseFailure:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUseFailure`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUseFailure`}]}],Notification:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Notification`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Notification`}]}]}};var hc=require("path");ye();var yc=require("crypto");function jt(e,t,n){return!n||n.sample_count<5?1e4:e&&n.by_project[e]!==void 0?n.by_project[e]:t&&n.by_task_type[t]!==void 0?n.by_task_type[t]:n.overall_avg}var Oh=10,Ah=1800*1e3;function kc(e){return(0,hc.join)(e,".olympus","session-state.json")}function gc(e,t){let n=jt(t);return{session_id:e||(0,yc.randomUUID)(),started_at:new Date().toISOString(),last_updated:new Date().toISOString(),recent_prompts:[],pending_completion:null,todo_snapshot:null,token_budget:{session_baseline:n,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()},discovery_volume:{session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()}}}function V(e,t){let n=kc(e),o=me(n,null);if(!o)return gc(t,e);let r=new Date(o.last_updated).getTime();if(Date.now()-r>Ah)return gc(t,e);if(t&&o.session_id!==t&&(o.session_id=t),o.token_budget)o.token_budget.input_tokens===void 0&&(o.token_budget.input_tokens=0),o.token_budget.output_tokens===void 0&&(o.token_budget.output_tokens=0);else{let s=jt(e);o.token_budget={session_baseline:s,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:o.started_at}}return o.discovery_volume||(o.discovery_volume={session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()}),o}function Q(e,t){let n=kc(e);t.last_updated=new Date().toISOString(),it(n,t)}function wc(e,t,n){let o={prompt:t,timestamp:new Date().toISOString(),detected_feedback:n};return e.recent_prompts=[o,...e.recent_prompts].slice(0,Oh),e.last_updated=new Date().toISOString(),e}function Sc(e,t,n){return e.pending_completion={claimed_at:new Date().toISOString(),task_description:t,agent_used:n},e.last_updated=new Date().toISOString(),e}function _c(e){return e.pending_completion=null,e.last_updated=new Date().toISOString(),e}function Oo(e){if(!e.pending_completion?.claimed_at)return!1;let t=new Date(e.pending_completion.claimed_at).getTime();return Date.now()-t<300*1e3}function vc(e,t){let n=jt(t);return e.token_budget={session_baseline:n,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()},e.last_updated=new Date().toISOString(),e}function Tc(e,t){return e.token_budget||(e.token_budget={session_baseline:jt(),current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()}),e.token_budget.current_usage+=t,e.last_updated=new Date().toISOString(),e}function Ec(e){return e.token_budget&&(e.token_budget.warning_issued=!0,e.last_updated=new Date().toISOString()),e}function bc(e){if(!e.token_budget||e.token_budget.warning_issued)return!1;let t=e.token_budget.session_baseline*e.token_budget.warning_threshold;return e.token_budget.current_usage>=t}function Cc(e){e.discovery_volume||(e.discovery_volume={session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()});let t=new Date(e.discovery_volume.daily_reset_at),n=new Date;return n.toDateString()!==t.toDateString()&&(e.discovery_volume.daily_count=0,e.discovery_volume.daily_reset_at=n.toISOString()),e.discovery_volume.session_count++,e.discovery_volume.daily_count++,e.last_updated=n.toISOString(),e}function Ic(e,t){if(!e.discovery_volume)return!1;let n=new Date(e.discovery_volume.daily_reset_at);return new Date().toDateString()!==n.toDateString()?!1:e.discovery_volume.session_count>=t.maxPerSession||e.discovery_volume.daily_count>=t.maxPerDay}ye();var Rc=require("crypto"),xh={correction:[{regex:/no[,.]?\s*(that's|thats)?\s*(not|wrong)/i,confidence:.9},{regex:/that's\s*(incorrect|not right|not what)/i,confidence:.9},{regex:/you\s*(misunderstood|got it wrong)/i,confidence:.85},{regex:/actually,?\s*(I|it|the)/i,confidence:.6}],rejection:[{regex:/\b(stop|cancel|abort|halt)\b/i,confidence:.95},{regex:/don't\s*(do|want|need)\s*(that|this)/i,confidence:.85},{regex:/never\s*mind/i,confidence:.9},{regex:/forget\s*(it|that|about)/i,confidence:.8}],clarification:[{regex:/I\s*(meant|wanted|asked for)/i,confidence:.85},{regex:/what I\s*(mean|want|need)/i,confidence:.8},{regex:/to clarify/i,confidence:.9},{regex:/let me\s*(rephrase|explain|be clearer)/i,confidence:.85}],explicit_preference:[{regex:/always\s+(use|do|include|add|prefer)/i,confidence:.95},{regex:/never\s+(use|do|include|add)/i,confidence:.95},{regex:/I\s*(prefer|like|want)\s*(you to)?/i,confidence:.7},{regex:/from now on/i,confidence:.9},{regex:/in the future,?\s*(please|always)/i,confidence:.85}],praise:[{regex:/\bperfect\b/i,confidence:.9},{regex:/exactly(\s+what I (wanted|needed))?/i,confidence:.85},{regex:/great(\s+job)?/i,confidence:.7},{regex:/\bthanks?\b/i,confidence:.5},{regex:/looks?\s+good/i,confidence:.75}],enhancement:[{regex:/also\s+(add|include|do)/i,confidence:.7},{regex:/can you (also|additionally)/i,confidence:.7},{regex:/one more thing/i,confidence:.75}]};function di(e){let t=e.replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,""),n=null;for(let[o,r]of Object.entries(xh))for(let{regex:i,confidence:s}of r)i.test(t)&&(!n||s>n.confidence)&&(n={category:o,confidence:s});return n}async function Oc(e){let{prompt:t,directory:n,sessionId:o}=e;if(!t||!n)return;let r=V(n,o),i=di(t),s=wc(r,t,i?.category);if(i){let a={id:(0,Rc.randomUUID)(),timestamp:new Date().toISOString(),session_id:r.session_id,project_path:n,event_type:i.category==="explicit_preference"?"explicit_preference":"revision",original_task:r.pending_completion?.task_description,agent_used:r.pending_completion?.agent_used,user_message:t,feedback_category:i.category,confidence:i.confidence};wt(a)}Q(n,s)}ye();var Ac=require("crypto");async function xc(e){let{prompt:t,directory:n,sessionId:o}=e;if(!t||!n)return;let r=V(n,o),i=di(t),s=i?.category==="praise"&&i.confidence>.7,a=Ph(t,r.pending_completion?.task_description||"");if(s||a){let c={id:(0,Ac.randomUUID)(),timestamp:new Date().toISOString(),session_id:r.session_id,project_path:n,event_type:"success",original_task:r.pending_completion?.task_description,agent_used:r.pending_completion?.agent_used,user_message:t,feedback_category:s?"praise":"enhancement",confidence:s?i.confidence:.6};if(wt(c),Oo(r)){let l=_c(r);Q(n,l)}}}function Ph(e,t){let n=c=>new Set(c.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(l=>l.length>3)),o=n(e),r=n(t),i=new Set([...o].filter(c=>r.has(c))),s=new Set([...o,...r]);return(s.size>0?i.size/s.size:0)<.2}var $e=E(require("fs"),1),ar=E(require("path"),1);Te();ji();var ju=require("fs"),Mu=new Map,Zk=1e4;function ew(e){let t=Mu.get(e);if(t&&Date.now()-t.timestamp<Zk)return t.content;let n=(0,ju.readFileSync)(e,"utf-8");return Mu.set(e,{content:n,timestamp:Date.now()}),n}function tw(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1];try{let o={},r=n.split(`
814
+ - Do not stop until all tasks are done`;var LE={hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\keyword-detector.mjs"':'node "$HOME/.claude/hooks/keyword-detector.mjs"'}]}],SessionStart:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\session-start.mjs"':'node "$HOME/.claude/hooks/session-start.mjs"'}]}],Stop:[{hooks:[{type:"command",command:Ke()?'node "%USERPROFILE%\\.claude\\hooks\\persistent-mode.mjs"':'node "$HOME/.claude/hooks/persistent-mode.mjs"'}]}]}},FE={hooks:{UserPromptSubmit:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=UserPromptSubmit`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=UserPromptSubmit`}]}],SessionStart:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=SessionStart`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=SessionStart`}]}],Stop:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Stop`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Stop`}]}],PreToolUse:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PreToolUse`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PreToolUse`}]}],PostToolUse:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUse`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUse`}]}],PostToolUseFailure:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUseFailure`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=PostToolUseFailure`}]}],Notification:[{hooks:[{type:"command",command:Ke()?`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Notification`:`node "${(0,le.join)(Ee(),"olympus-hooks.cjs")}" --event=Notification`}]}]}};var hc=require("path");ye();var yc=require("crypto");function jt(e,t,n){return!n||n.sample_count<5?1e4:e&&n.by_project[e]!==void 0?n.by_project[e]:t&&n.by_task_type[t]!==void 0?n.by_task_type[t]:n.overall_avg}var Ah=10,xh=1800*1e3;function kc(e){return(0,hc.join)(e,".olympus","session-state.json")}function gc(e,t){let n=jt(t);return{session_id:e||(0,yc.randomUUID)(),started_at:new Date().toISOString(),last_updated:new Date().toISOString(),recent_prompts:[],pending_completion:null,todo_snapshot:null,token_budget:{session_baseline:n,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()},discovery_volume:{session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()}}}function V(e,t){let n=kc(e),o=me(n,null);if(!o)return gc(t,e);let r=new Date(o.last_updated).getTime();if(Date.now()-r>xh)return gc(t,e);if(t&&o.session_id!==t&&(o.session_id=t),o.token_budget)o.token_budget.input_tokens===void 0&&(o.token_budget.input_tokens=0),o.token_budget.output_tokens===void 0&&(o.token_budget.output_tokens=0);else{let s=jt(e);o.token_budget={session_baseline:s,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:o.started_at}}return o.discovery_volume||(o.discovery_volume={session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()}),o}function Q(e,t){let n=kc(e);t.last_updated=new Date().toISOString(),it(n,t)}function wc(e,t,n){let o={prompt:t,timestamp:new Date().toISOString(),detected_feedback:n};return e.recent_prompts=[o,...e.recent_prompts].slice(0,Ah),e.last_updated=new Date().toISOString(),e}function Sc(e,t,n){return e.pending_completion={claimed_at:new Date().toISOString(),task_description:t,agent_used:n},e.last_updated=new Date().toISOString(),e}function _c(e){return e.pending_completion=null,e.last_updated=new Date().toISOString(),e}function Oo(e){if(!e.pending_completion?.claimed_at)return!1;let t=new Date(e.pending_completion.claimed_at).getTime();return Date.now()-t<300*1e3}function vc(e,t){let n=jt(t);return e.token_budget={session_baseline:n,current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()},e.last_updated=new Date().toISOString(),e}function Tc(e,t){return e.token_budget||(e.token_budget={session_baseline:jt(),current_usage:0,input_tokens:0,output_tokens:0,warning_threshold:1.5,warning_issued:!1,started_at:new Date().toISOString()}),e.token_budget.current_usage+=t,e.last_updated=new Date().toISOString(),e}function Ec(e){return e.token_budget&&(e.token_budget.warning_issued=!0,e.last_updated=new Date().toISOString()),e}function bc(e){if(!e.token_budget||e.token_budget.warning_issued)return!1;let t=e.token_budget.session_baseline*e.token_budget.warning_threshold;return e.token_budget.current_usage>=t}function Cc(e){e.discovery_volume||(e.discovery_volume={session_count:0,daily_count:0,daily_reset_at:new Date().toISOString()});let t=new Date(e.discovery_volume.daily_reset_at),n=new Date;return n.toDateString()!==t.toDateString()&&(e.discovery_volume.daily_count=0,e.discovery_volume.daily_reset_at=n.toISOString()),e.discovery_volume.session_count++,e.discovery_volume.daily_count++,e.last_updated=n.toISOString(),e}function Ic(e,t){if(!e.discovery_volume)return!1;let n=new Date(e.discovery_volume.daily_reset_at);return new Date().toDateString()!==n.toDateString()?!1:e.discovery_volume.session_count>=t.maxPerSession||e.discovery_volume.daily_count>=t.maxPerDay}ye();var Rc=require("crypto"),Ph={correction:[{regex:/no[,.]?\s*(that's|thats)?\s*(not|wrong)/i,confidence:.9},{regex:/that's\s*(incorrect|not right|not what)/i,confidence:.9},{regex:/you\s*(misunderstood|got it wrong)/i,confidence:.85},{regex:/actually,?\s*(I|it|the)/i,confidence:.6}],rejection:[{regex:/\b(stop|cancel|abort|halt)\b/i,confidence:.95},{regex:/don't\s*(do|want|need)\s*(that|this)/i,confidence:.85},{regex:/never\s*mind/i,confidence:.9},{regex:/forget\s*(it|that|about)/i,confidence:.8}],clarification:[{regex:/I\s*(meant|wanted|asked for)/i,confidence:.85},{regex:/what I\s*(mean|want|need)/i,confidence:.8},{regex:/to clarify/i,confidence:.9},{regex:/let me\s*(rephrase|explain|be clearer)/i,confidence:.85}],explicit_preference:[{regex:/always\s+(use|do|include|add|prefer)/i,confidence:.95},{regex:/never\s+(use|do|include|add)/i,confidence:.95},{regex:/I\s*(prefer|like|want)\s*(you to)?/i,confidence:.7},{regex:/from now on/i,confidence:.9},{regex:/in the future,?\s*(please|always)/i,confidence:.85}],praise:[{regex:/\bperfect\b/i,confidence:.9},{regex:/exactly(\s+what I (wanted|needed))?/i,confidence:.85},{regex:/great(\s+job)?/i,confidence:.7},{regex:/\bthanks?\b/i,confidence:.5},{regex:/looks?\s+good/i,confidence:.75}],enhancement:[{regex:/also\s+(add|include|do)/i,confidence:.7},{regex:/can you (also|additionally)/i,confidence:.7},{regex:/one more thing/i,confidence:.75}]};function di(e){let t=e.replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,""),n=null;for(let[o,r]of Object.entries(Ph))for(let{regex:i,confidence:s}of r)i.test(t)&&(!n||s>n.confidence)&&(n={category:o,confidence:s});return n}async function Oc(e){let{prompt:t,directory:n,sessionId:o}=e;if(!t||!n)return;let r=V(n,o),i=di(t),s=wc(r,t,i?.category);if(i){let a={id:(0,Rc.randomUUID)(),timestamp:new Date().toISOString(),session_id:r.session_id,project_path:n,event_type:i.category==="explicit_preference"?"explicit_preference":"revision",original_task:r.pending_completion?.task_description,agent_used:r.pending_completion?.agent_used,user_message:t,feedback_category:i.category,confidence:i.confidence};wt(a)}Q(n,s)}ye();var Ac=require("crypto");async function xc(e){let{prompt:t,directory:n,sessionId:o}=e;if(!t||!n)return;let r=V(n,o),i=di(t);if(i?.category==="praise"&&i.confidence>.7){let a={id:(0,Ac.randomUUID)(),timestamp:new Date().toISOString(),session_id:r.session_id,project_path:n,event_type:"success",original_task:r.pending_completion?.task_description,agent_used:r.pending_completion?.agent_used,user_message:t,feedback_category:"praise",confidence:i.confidence};if(wt(a),Oo(r)){let c=_c(r);Q(n,c)}}}var $e=E(require("fs"),1),ar=E(require("path"),1);Te();ji();var ju=require("fs"),Mu=new Map,Zk=1e4;function ew(e){let t=Mu.get(e);if(t&&Date.now()-t.timestamp<Zk)return t.content;let n=(0,ju.readFileSync)(e,"utf-8");return Mu.set(e,{content:n,timestamp:Date.now()}),n}function tw(e){let t=e.match(/^---\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1];try{let o={},r=n.split(`
815
815
  `);for(let i of r){let s=i.match(/^(\w+):\s*(.+)$/);if(s){let[,a,c]=s;o[a]=c.trim()}}return o}catch{return null}}function nw(e){return e.replace(/^---\n[\s\S]*?\n---\n/,"")}function ow(e){let t=new Map,n=e.split(`
816
816
  `),o=null,r=[];for(let i of n){let s=i.match(/^##\s+(.+)$/);s?(o&&t.set(o,r.join(`
817
817
  `)),o=s[1].trim(),r=[]):o&&r.push(i)}return o&&t.set(o,r.join(`
@@ -1120,7 +1120,7 @@ created: ${r}
1120
1120
 
1121
1121
  ---
1122
1122
  *Generated by WorkflowEngine based on ${o}*
1123
- `;await un(this.projectPath,this.workflowId,"nfr",a),console.log("[WorkflowEngine] Generated NFR artifact at inception/nfr.md");let c=bt(this.projectPath,this.workflowId,"intent");console.log(`[WorkflowEngine] Validating INTENT artifact at: ${c}`);let l=await Bo(c);l.passed?(console.log("[WorkflowEngine] INTENT validation passed"),console.log(`[WorkflowEngine] Coverage: ${l.coverage_percentage}%`)):(console.log("[WorkflowEngine] INTENT validation failed:",l.blocking_issues),console.log(`[WorkflowEngine] Coverage: ${l.coverage_percentage}%`));let u=await R(this.projectPath,this.workflowId);if(u){let d=u;d.interview_progress={stage:"intent",questions_asked:0,draft_artifact_path:c},u.updated_at=new Date().toISOString(),await M(this.projectPath,u)}}async executeUnitStage(t){throw console.log(`[WorkflowEngine] Executing UNIT stage for feature: ${this.featureName}`),new Error("UNIT stage execution not yet implemented")}async executeCodeGenerationStage(t){throw console.log(`[WorkflowEngine] Executing CODE-GENERATION stage for feature: ${this.featureName}`),new Error("Code generation stage execution not yet implemented")}};Te();var ip={intent:null,unit:null,"code-generation":null,complete:null};function sp(e){switch(e){case"intent":return"capture the problem statement, personas, success metrics, constraints, and define business requirements, technical approach, and proposed UNITs";case"unit":return"decompose into module-scoped UNITs with interface contracts";case"code-generation":return"generate code from the approved code plan";case"complete":return"finalize and validate all workflow artifacts";default:return"proceed with the next stage"}}function ap(e,t,n=!1){let o=t.current_stage,r=ip[o],i=sp(o),s=`You are beginning a structured workflow for feature: ${e}
1123
+ `;await un(this.projectPath,this.workflowId,"nfr",a),console.log("[WorkflowEngine] Generated NFR artifact at inception/requirements/nfr.md");let c=bt(this.projectPath,this.workflowId,"intent");console.log(`[WorkflowEngine] Validating INTENT artifact at: ${c}`);let l=await Bo(c);l.passed?(console.log("[WorkflowEngine] INTENT validation passed"),console.log(`[WorkflowEngine] Coverage: ${l.coverage_percentage}%`)):(console.log("[WorkflowEngine] INTENT validation failed:",l.blocking_issues),console.log(`[WorkflowEngine] Coverage: ${l.coverage_percentage}%`));let u=await R(this.projectPath,this.workflowId);if(u){let d=u;d.interview_progress={stage:"intent",questions_asked:0,draft_artifact_path:c},u.updated_at=new Date().toISOString(),await M(this.projectPath,u)}}async executeUnitStage(t){throw console.log(`[WorkflowEngine] Executing UNIT stage for feature: ${this.featureName}`),new Error("UNIT stage execution not yet implemented")}async executeCodeGenerationStage(t){throw console.log(`[WorkflowEngine] Executing CODE-GENERATION stage for feature: ${this.featureName}`),new Error("Code generation stage execution not yet implemented")}};Te();var ip={intent:null,unit:null,"code-generation":null,complete:null};function sp(e){switch(e){case"intent":return"capture the problem statement, personas, success metrics, constraints, and define business requirements, technical approach, and proposed UNITs";case"unit":return"decompose into module-scoped UNITs with interface contracts";case"code-generation":return"generate code from the approved code plan";case"complete":return"finalize and validate all workflow artifacts";default:return"proceed with the next stage"}}function ap(e,t,n=!1){let o=t.current_stage,r=ip[o],i=sp(o),s=`You are beginning a structured workflow for feature: ${e}
1124
1124
 
1125
1125
  `;return s+=`Current stage: ${o}
1126
1126
  `,s+=`Status: ${t.status}
@@ -1957,7 +1957,7 @@ ${u.map(m=>` - ${m}`).join(`
1957
1957
 
1958
1958
  ${d}${p}
1959
1959
 
1960
- Fix the failing checks and re-run the BOLT execution.`}}}catch(t){return console.error("[Olympus CI Review] Error in ciReviewPipeline:",t),{continue:!0}}}function Rg(){_({name:"ciReviewPipeline",event:"PostToolUse",priority:79,matcher:"task",handler:kT})}ye();function Og(e,t=2){let o=e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(i=>i.length>0);if(o.length<t)return new Set(o);let r=new Set;for(let i=0;i<=o.length-t;i++)r.add(o.slice(i,i+t).join(" "));return r}function ba(e,t){let n=Og(e),o=Og(t),r=new Set([...n].filter(s=>o.has(s))),i=new Set([...n,...o]);return i.size>0?r.size/i.size:0}function wT(e,t=.1){let n=[],o=new Set;for(let r of e){if(o.has(r.id))continue;let i=[r];o.add(r.id);for(let s of e){if(o.has(s.id))continue;ba(r.user_message,s.user_message)>=t&&(i.push(s),o.add(s.id))}n.push(i)}return n}function Ag(e,t=3,n=1e3){let r=e.slice(-n).filter(s=>s.feedback_category==="correction"||s.feedback_category==="clarification"||s.feedback_category==="explicit_preference");return wT(r).filter(s=>s.length>=t).map(s=>{let a=s.sort((p,m)=>new Date(m.timestamp).getTime()-new Date(p.timestamp).getTime())[0],c=s.reduce((p,m)=>p+m.confidence,0)/s.length,u=new Set(s.map(p=>p.project_path)).size===1?"project":"global",d=_T(s);return{pattern:ST(s),confidence:c,evidence_count:s.length,evidence_examples:s.slice(0,3).map(p=>p.user_message),scope:u,category:d}})}function ST(e){let t=new Map;for(let r of e){let i=r.user_message.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(s=>s.length>3);for(let s of i)t.set(s,(t.get(s)||0)+1)}let n=[...t.entries()].sort((r,i)=>i[1]-r[1]).slice(0,3).map(([r])=>r);return e[0].user_message.substring(0,100)+(n.length>0?` [themes: ${n.join(", ")}]`:"")}function _T(e){let t=e.map(n=>n.user_message).join(" ").toLowerCase();return/typescript|eslint|prettier|format|indent|naming/i.test(t)?"style":/test|build|npm|yarn|run|command|install/i.test(t)?"tooling":/verbose|brief|explain|detail|ask|confirm/i.test(t)?"communication":"behavior"}var vT={verbosity:"unknown",autonomy:"unknown",explanation_depth:"unknown",explicit_rules:[],inferred_preferences:[],recurring_corrections:[],last_updated:new Date().toISOString()},TT=30;function ET(e){let t=e.filter(o=>o.feedback_category==="explicit_preference"),n=[];for(let o of t){let r=o.user_message.match(/always\s+(.+?)(?:\.|$)/i),i=o.user_message.match(/never\s+(.+?)(?:\.|$)/i);r&&n.push(`Always: ${r[1].trim()}`),i&&n.push(`Never: ${i[1].trim()}`)}return[...new Set(n)]}function bT(e){let t=e.filter(o=>/too (long|verbose|much|wordy)/i.test(o.user_message)).length,n=e.filter(o=>/more (detail|info|explanation)|too (brief|short)/i.test(o.user_message)).length;return t>=3&&t>n?"concise":n>=3&&n>t?"detailed":"unknown"}function CT(e){let t=e.filter(o=>/ask (me )?(first|before)|don't assume|confirm/i.test(o.user_message)).length,n=e.filter(o=>/just (do|make|fix)|don't ask|stop asking/i.test(o.user_message)).length;return t>=3&&t>n?"ask_first":n>=3&&n>t?"just_do_it":t>=2&&n>=2?"balanced":"unknown"}function xg(e,t,n){let o={...e},r=ET(t);o.explicit_rules=[...new Set([...o.explicit_rules,...r])];let i=bT(t);i!=="unknown"&&(o.verbosity=i);let s=CT(t);s!=="unknown"&&(o.autonomy=s);let a=n.filter(l=>l.confidence>.7&&l.scope==="global").map(l=>l.pattern);o.inferred_preferences=[...new Set([...o.inferred_preferences,...a])];for(let l of n){let u=o.recurring_corrections.find(d=>ba(d.pattern,l.pattern)>.5);u?(u.count=l.evidence_count,u.last_seen=new Date().toISOString(),u.examples=l.evidence_examples):o.recurring_corrections.push({pattern:l.pattern,count:l.evidence_count,last_seen:new Date().toISOString(),examples:l.evidence_examples})}let c=Date.now();if(o.recurring_corrections=o.recurring_corrections.filter(l=>{if(!l.last_seen)return!0;let u=Date.parse(l.last_seen);return isNaN(u)?!0:c-u<=TT*864e5}),n.length>0){let l=new Set(n.map(u=>u.pattern));o.inferred_preferences=o.inferred_preferences.filter(u=>l.has(u))}return o.last_updated=new Date().toISOString(),o}function Pg(){return{...vT,last_updated:new Date().toISOString()}}var wo=require("path"),Wn=require("fs"),IT=3,RT=10;function OT(e){let t=(0,wo.join)(e,"feedback-log.jsonl"),n=(0,wo.join)(e,"agent-performance.json");if(!(0,Wn.existsSync)(t))return!1;if(!(0,Wn.existsSync)(n))return!0;try{let o=(0,Wn.statSync)(t),r=(0,Wn.statSync)(n);return o.mtime>r.mtime}catch(o){return console.error("[Olympus Learning Aggregation] Failed to check file times:",o),!0}}function $g(){_({name:"learningAggregation",event:"Stop",priority:95,handler:async e=>{try{if(!e.directory)return{continue:!0};let t=fe();if(!OT(t))return{continue:!0};let n=Io();if(n.length<IT)return{continue:!0};let o=new Set;for(let d of n)d.agent_used&&o.add(d.agent_used);let r=Array.from(o);if(r.length===0)return{continue:!0};let i={};for(let d of r){let p=Ro(d,n);p&&(i[d]=p)}let s=(0,wo.join)(t,"agent-performance.json");it(s,i);let a=(0,wo.join)(t,"user-preferences.json"),c=me(a,Pg()),l=[];if(n.length>=RT)try{l=Ag(n)}catch(d){console.error("[Olympus Learning Aggregation] Pattern extraction failed:",d)}let u=xg(c,n,l);it(a,u)}catch(t){console.error("[Olympus Learning Aggregation] Error in aggregation handler:",t)}return{continue:!0}}})}var Ia=["discovery","inception","construction","operations"],AT={draft:"o",active:"+",fulfilled:"++",violated:"X",stale:"!"},xT={0:"Baseline",1:"Earned",2:"Extended",3:"Trusted"};function Ng(e,t=null,n=null){let o=PT(e),r=NT(e),i=DT(e.risks),s=MT(e.gate_audit),a=jT(t),c=LT(e.alignment_checks),l=FT(e.depth_assessment),u=UT(e.risk_tier),d=HT(e,o),p=WT(e),m=n?.inception_stages?BT(n.inception_stages,n.current_inception_stage):null,f=[`# Workflow Status: ${e.feature_name}`,`ID: ${e.workflow_id}`,"",d,"","## Phase Progress",...o.map(g=>$T(g)),"",...m?[m,""]:[],p,l,u,a,"","## Artifacts",r,"","## Alignment",c,"","## Risk Summary",i,"","## Gate Audit",s].filter(g=>g!==null).join(`
1960
+ Fix the failing checks and re-run the BOLT execution.`}}}catch(t){return console.error("[Olympus CI Review] Error in ciReviewPipeline:",t),{continue:!0}}}function Rg(){_({name:"ciReviewPipeline",event:"PostToolUse",priority:79,matcher:"task",handler:kT})}ye();function Og(e,t=2){let o=e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(i=>i.length>0);if(o.length<t)return new Set(o);let r=new Set;for(let i=0;i<=o.length-t;i++)r.add(o.slice(i,i+t).join(" "));return r}function ba(e,t){let n=Og(e),o=Og(t),r=new Set([...n].filter(s=>o.has(s))),i=new Set([...n,...o]);return i.size>0?r.size/i.size:0}function wT(e,t=.1){let n=[],o=new Set;for(let r of e){if(o.has(r.id))continue;let i=[r];o.add(r.id);for(let s of e){if(o.has(s.id))continue;ba(r.user_message,s.user_message)>=t&&(i.push(s),o.add(s.id))}n.push(i)}return n}function Ag(e,t=3,n=1e3){let r=e.slice(-n).filter(s=>s.feedback_category==="correction"||s.feedback_category==="clarification"||s.feedback_category==="explicit_preference");return wT(r).filter(s=>s.length>=t).map(s=>{let a=s.sort((p,m)=>new Date(m.timestamp).getTime()-new Date(p.timestamp).getTime())[0],c=s.reduce((p,m)=>p+m.confidence,0)/s.length,u=new Set(s.map(p=>p.project_path)).size===1?"project":"global",d=_T(s);return{pattern:ST(s),confidence:c,evidence_count:s.length,evidence_examples:s.slice(0,3).map(p=>p.user_message.substring(0,150)),scope:u,category:d}})}function ST(e){let t=new Map;for(let r of e){let i=r.user_message.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(s=>s.length>3);for(let s of i)t.set(s,(t.get(s)||0)+1)}let n=[...t.entries()].sort((r,i)=>i[1]-r[1]).slice(0,3).map(([r])=>r);return e[0].user_message.substring(0,100)+(n.length>0?` [themes: ${n.join(", ")}]`:"")}function _T(e){let t=e.map(n=>n.user_message).join(" ").toLowerCase();return/typescript|eslint|prettier|format|indent|naming/i.test(t)?"style":/test|build|npm|yarn|run|command|install/i.test(t)?"tooling":/verbose|brief|explain|detail|ask|confirm/i.test(t)?"communication":"behavior"}var vT={verbosity:"unknown",autonomy:"unknown",explanation_depth:"unknown",explicit_rules:[],inferred_preferences:[],recurring_corrections:[],last_updated:new Date().toISOString()},TT=30;function ET(e){let t=e.filter(o=>o.feedback_category==="explicit_preference"),n=[];for(let o of t){let r=o.user_message.match(/always\s+(.+?)(?:\.|$)/i),i=o.user_message.match(/never\s+(.+?)(?:\.|$)/i);r&&n.push(`Always: ${r[1].trim()}`),i&&n.push(`Never: ${i[1].trim()}`)}return[...new Set(n)]}function bT(e){let t=e.filter(o=>/too (long|verbose|much|wordy)/i.test(o.user_message)).length,n=e.filter(o=>/more (detail|info|explanation)|too (brief|short)/i.test(o.user_message)).length;return t>=3&&t>n?"concise":n>=3&&n>t?"detailed":"unknown"}function CT(e){let t=e.filter(o=>/ask (me )?(first|before)|don't assume|confirm/i.test(o.user_message)).length,n=e.filter(o=>/just (do|make|fix)|don't ask|stop asking/i.test(o.user_message)).length;return t>=3&&t>n?"ask_first":n>=3&&n>t?"just_do_it":t>=2&&n>=2?"balanced":"unknown"}function xg(e,t,n){let o={...e},r=ET(t);o.explicit_rules=[...new Set([...o.explicit_rules,...r])];let i=bT(t);i!=="unknown"&&(o.verbosity=i);let s=CT(t);s!=="unknown"&&(o.autonomy=s);let a=n.filter(l=>l.confidence>.7&&l.scope==="global").map(l=>l.pattern);o.inferred_preferences=[...new Set([...o.inferred_preferences,...a])];for(let l of n){let u=o.recurring_corrections.find(d=>ba(d.pattern,l.pattern)>.5);u?(u.count=l.evidence_count,u.last_seen=new Date().toISOString(),u.examples=l.evidence_examples):o.recurring_corrections.push({pattern:l.pattern,count:l.evidence_count,last_seen:new Date().toISOString(),examples:l.evidence_examples})}let c=Date.now();if(o.recurring_corrections=o.recurring_corrections.filter(l=>{if(!l.last_seen)return!0;let u=Date.parse(l.last_seen);return isNaN(u)?!0:c-u<=TT*864e5}),n.length>0){let l=new Set(n.map(u=>u.pattern));o.inferred_preferences=o.inferred_preferences.filter(u=>l.has(u))}return o.last_updated=new Date().toISOString(),o}function Pg(){return{...vT,last_updated:new Date().toISOString()}}var wo=require("path"),Wn=require("fs"),IT=3,RT=10;function OT(e){let t=(0,wo.join)(e,"feedback-log.jsonl"),n=(0,wo.join)(e,"agent-performance.json");if(!(0,Wn.existsSync)(t))return!1;if(!(0,Wn.existsSync)(n))return!0;try{let o=(0,Wn.statSync)(t),r=(0,Wn.statSync)(n);return o.mtime>r.mtime}catch(o){return console.error("[Olympus Learning Aggregation] Failed to check file times:",o),!0}}function $g(){_({name:"learningAggregation",event:"Stop",priority:95,handler:async e=>{try{if(!e.directory)return{continue:!0};let t=fe();if(!OT(t))return{continue:!0};let n=Io();if(n.length<IT)return{continue:!0};let o=new Set;for(let d of n)d.agent_used&&o.add(d.agent_used);let r=Array.from(o);if(r.length===0)return{continue:!0};let i={};for(let d of r){let p=Ro(d,n);p&&(i[d]=p)}let s=(0,wo.join)(t,"agent-performance.json");it(s,i);let a=(0,wo.join)(t,"user-preferences.json"),c=me(a,Pg()),l=[];if(n.length>=RT)try{l=Ag(n)}catch(d){console.error("[Olympus Learning Aggregation] Pattern extraction failed:",d)}let u=xg(c,n,l);it(a,u)}catch(t){console.error("[Olympus Learning Aggregation] Error in aggregation handler:",t)}return{continue:!0}}})}var Ia=["discovery","inception","construction","operations"],AT={draft:"o",active:"+",fulfilled:"++",violated:"X",stale:"!"},xT={0:"Baseline",1:"Earned",2:"Extended",3:"Trusted"};function Ng(e,t=null,n=null){let o=PT(e),r=NT(e),i=DT(e.risks),s=MT(e.gate_audit),a=jT(t),c=LT(e.alignment_checks),l=FT(e.depth_assessment),u=UT(e.risk_tier),d=HT(e,o),p=WT(e),m=n?.inception_stages?BT(n.inception_stages,n.current_inception_stage):null,f=[`# Workflow Status: ${e.feature_name}`,`ID: ${e.workflow_id}`,"",d,"","## Phase Progress",...o.map(g=>$T(g)),"",...m?[m,""]:[],p,l,u,a,"","## Artifacts",r,"","## Alignment",c,"","## Risk Summary",i,"","## Gate Audit",s].filter(g=>g!==null).join(`
1961
1961
  `);return{summary:d,phaseProgress:o,artifactTree:r,riskSummary:i,gateSummary:s,trustDisplay:a,alignmentSummary:c,fullReport:f}}function PT(e){return Ia.map(t=>{let n=e.phases[t],o=e.artifacts.filter(a=>a.phase===t),r=o.length;if(r===0)return{phase:t,percentage:n.status==="complete"?100:0,status:n.status,artifactCount:0};let i=o.filter(a=>a.contract_status==="active"||a.contract_status==="fulfilled").length,s=Math.round(i/r*100);return{phase:t,percentage:s,status:n.status,artifactCount:r}})}function $T(e){let n=Math.round(e.percentage/100*20),o=20-n,r="=".repeat(n)+"-".repeat(o);return`${(e.phase.charAt(0).toUpperCase()+e.phase.slice(1)).padEnd(8)} [${r}] ${String(e.percentage).padStart(3)}% (${e.status}) ${e.artifactCount} artifacts`}function NT(e){let t=[];for(let n of Ia){let o=e.artifacts.filter(s=>s.phase===n);if(o.length===0)continue;let r=n.charAt(0).toUpperCase()+n.slice(1);t.push(`[${r}]`);let i=new Map;for(let s of o){let a=s.stage;i.has(a)||i.set(a,[]),i.get(a).push(s)}for(let[s,a]of i){t.push(` ${s}/`);for(let c of a){let l=AT[c.contract_status]??"?",u=c.validation_passed===!0?"v":c.validation_passed===!1?"x":"-";t.push(` [${l}] ${c.id} (${c.type}) [${u}]`)}}}return t.join(`
1962
1962
  `)}function DT(e){if(e.length===0)return"No risks registered";let t=e.filter(a=>a.status==="open").length,n=e.filter(a=>a.status==="mitigated").length,o=e.filter(a=>a.status==="accepted").length,r=e.filter(a=>a.status==="closed").length,i=[`Total: ${e.length} | Open: ${t} | Mitigated: ${n} | Accepted: ${o} | Closed: ${r}`],s=e.filter(a=>a.status==="open");for(let a of s)i.push(` [OPEN] ${a.id}: ${a.description} (${a.likelihood}/${a.impact})`);return i.join(`
1963
1963
  `)}function MT(e){if(e.length===0)return"No gate transitions recorded";let t=e.filter(i=>i.action==="approved").length,n=e.filter(i=>i.action==="rejected").length,o=e.filter(i=>i.action==="bypassed").length,r=[`Total: ${e.length} | Approved: ${t} | Rejected: ${n} | Bypassed: ${o}`];for(let i of e){let s=i.phase.charAt(0).toUpperCase()+i.phase.slice(1);r.push(` [${i.action.toUpperCase()}] ${s} by ${i.actor}${i.reason?": "+i.reason:""}`)}return r.join(`
@@ -24,7 +24,7 @@ export declare const HOOKS_DIR: string;
24
24
  export declare const SETTINGS_FILE: string;
25
25
  export declare const VERSION_FILE: string;
26
26
  /** Current version - MUST match package.json */
27
- export declare const VERSION = "4.0.2";
27
+ export declare const VERSION = "4.0.4";
28
28
  /** Installation result */
29
29
  export interface InstallResult {
30
30
  success: boolean;
@@ -40,7 +40,7 @@ export const HOOKS_DIR = join(CLAUDE_CONFIG_DIR, 'hooks');
40
40
  export const SETTINGS_FILE = join(CLAUDE_CONFIG_DIR, 'settings.json');
41
41
  export const VERSION_FILE = join(CLAUDE_CONFIG_DIR, '.olympus-version.json');
42
42
  /** Current version - MUST match package.json */
43
- export const VERSION = '4.0.2';
43
+ export const VERSION = '4.0.4';
44
44
  /**
45
45
  * Read a content file from the resources/ directory.
46
46
  *
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=project-resolver.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-resolver.test.d.ts","sourceRoot":"","sources":["../../../src/learning/__tests__/project-resolver.test.ts"],"names":[],"mappings":""}