infernoflow 0.44.1 → 0.44.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- import*as s from"node:fs";import*as a from"node:path";import*as y from"node:os";import*as O from"node:http";import{execSync as P,spawnSync as v}from"node:child_process";import{fileURLToPath as A}from"node:url";import{bold as C,cyan as b,gray as j,green as w,yellow as S,red as k}from"../ui/output.mjs";import{detectAvailableProviders as _}from"../ai/providerRouter.mjs";import{readEntries as I}from"../amp/io.mjs";function u(e,n){try{const o=n();return{label:e,...o}}catch(o){return{label:e,status:"error",message:o.message,fix:null}}}function c(e,n){return{status:"pass",message:e,detail:n||null,fix:null}}function l(e,n){return{status:"warn",message:e,detail:null,fix:n||null}}function h(e,n){return{status:"fail",message:e,detail:null,fix:n||null}}function E(){const e=process.version,n=parseInt(e.slice(1).split(".")[0],10);return n>=20?c(`Node.js ${e}`,"Node 20+ recommended"):n>=18?c(`Node.js ${e}`):h(`Node.js ${e} \u2014 infernoflow requires Node 18+`,"Install Node 20 from nodejs.org")}function M(){try{const e=v("infernoflow",["--version"],{encoding:"utf8",timeout:5e3,shell:process.platform==="win32"});return e.status===0?c(`infernoflow v${e.stdout.trim()} installed`):c("infernoflow CLI on PATH (version probe failed but doctor itself ran)")}catch{return c("infernoflow CLI on PATH (version probe threw but doctor itself ran)")}}function T(e){try{return P("git rev-parse --git-dir",{cwd:e,stdio:"ignore"}),c("Git repository detected")}catch{return h("Not a git repository","git init && git add . && git commit -m 'init'")}}function F(e){const n=a.join(e,"inferno");return s.existsSync(n)?c("inferno/ directory exists"):h("inferno/ not found","infernoflow init")}function G(e){const n=a.join(e,"inferno");if((()=>{try{return JSON.parse(s.readFileSync(a.join(n,"config.json"),"utf8"))}catch{return{}}})().mode==="memory"){let t=0;try{t=I(e).length}catch{}return c(t===0?"Memory mode \u2014 sessions.jsonl will be created on first log":`Memory mode \u2014 ${t} session entr${t===1?"y":"ies"}`)}for(const t of["contract.json","capabilities.json"]){const r=a.join(n,t);if(s.existsSync(r))try{const m=(JSON.parse(s.readFileSync(r,"utf8")).capabilities||[]).length;return c(`${t} valid \u2014 ${m} capabilities`)}catch{return h(`${t} contains invalid JSON`,`Fix the JSON syntax in inferno/${t}`)}}return h("No contract.json/capabilities.json (and not in memory mode)","infernoflow init or infernoflow init --mode full")}function $(e){try{return JSON.parse(s.readFileSync(a.join(e,"inferno","config.json"),"utf8")).mode==="memory"}catch{return!1}}function L(e){if($(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=a.join(e,"inferno","scenarios");if(!s.existsSync(n))return l("No scenarios/ directory","infernoflow init");const o=s.readdirSync(n).filter(t=>t.endsWith(".json"));return o.length?c(`${o.length} scenario file${o.length!==1?"s":""} found`):l("scenarios/ is empty","Add scenario files or run infernoflow suggest")}function R(e){if($(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=a.join(e,"inferno","CHANGELOG.md");return s.existsSync(n)?c("inferno/CHANGELOG.md exists"):l("No inferno/CHANGELOG.md","infernoflow init")}function D(e){if($(e))return{status:"info",message:"n/a in memory mode (CLAUDE.md is auto-maintained)",detail:null,fix:null};const n=a.join(e,"inferno","CONTEXT.md");if(!s.existsSync(n))return l("No CONTEXT.md generated","infernoflow context");const o=(Date.now()-s.statSync(n).mtimeMs)/(1e3*60*60*24);return o>7?l(`CONTEXT.md is ${Math.round(o)} days old \u2014 may be stale`,"infernoflow context"):c(`CONTEXT.md present (${Math.round(o)}d old)`)}function J(e){const n=a.join(e,".git","hooks"),o=a.join(n,"post-commit"),t=a.join(n,"pre-push"),r=s.existsSync(o)&&s.readFileSync(o,"utf8").includes("infernoflow"),i=s.existsSync(t)&&s.readFileSync(t,"utf8").includes("infernoflow");return r&&i?c("Git hooks installed (post-commit + pre-push)"):l(r||i?"Partial git hooks installed":"Git hooks not installed","infernoflow setup --yes")}function H(e){const n=[a.join(e,".cursor","mcp.json"),a.join(e,".mcp.json"),a.join(y.homedir(),".cursor","mcp.json"),a.join(y.homedir(),"Library","Application Support","Claude","claude_desktop_config.json"),a.join(y.homedir(),"AppData","Roaming","Claude","claude_desktop_config.json")];for(const o of n)if(s.existsSync(o))try{const t=JSON.parse(s.readFileSync(o,"utf8")),r=t.mcpServers||t.mcp_servers||{};if(Object.keys(r).some(i=>i.toLowerCase().includes("inferno")))return c(`MCP server configured in ${a.basename(o)}`)}catch{}return l("MCP server not configured","infernoflow setup --yes (adds to Cursor/Claude config)")}function W(e,n){const o=a.join(e,".ai-memory",".mcp-runtime.json");if(!s.existsSync(o))return c("MCP runtime stamp not present yet \u2014 start your AI tool to write one");let t;try{t=JSON.parse(s.readFileSync(o,"utf8"))}catch{return l(".mcp-runtime.json present but unreadable","Delete .ai-memory/.mcp-runtime.json and restart your AI tool")}return!t||typeof t.version!="string"?l(".mcp-runtime.json malformed","Delete it; the next MCP boot will rewrite it"):t.version===n?c(`MCP runtime v${t.version} matches CLI`):n.startsWith("0.0.0")||t.version.startsWith("0.0.0")?c(`MCP runtime v${t.version} (dev/source) \u2014 skipping version-skew check`):l(`MCP server is running v${t.version} but CLI is v${n} \u2014 restart your AI tool to load the new code.`,"Quit and reopen Cursor / Claude Code / VS Code (the long-running MCP process keeps the old code in memory until restart)")}function X(e){const n=_(e),o=Object.entries(n).filter(([,t])=>t).map(([t])=>t);return o.length?c(`AI provider${o.length!==1?"s":""}: ${o.join(", ")}`):l("No AI provider configured",`Set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_AI_API_KEY, or OPENROUTER_API_KEY
1
+ import*as s from"node:fs";import*as a from"node:path";import*as y from"node:os";import*as O from"node:http";import{execSync as P,spawnSync as v}from"node:child_process";import{fileURLToPath as A}from"node:url";import{bold as C,cyan as b,gray as S,green as w,yellow as k,red as $}from"../ui/output.mjs";import{detectAvailableProviders as _}from"../ai/providerRouter.mjs";import{readEntries as I}from"../amp/io.mjs";function u(e,n){try{const o=n();return{label:e,...o}}catch(o){return{label:e,status:"error",message:o.message,fix:null}}}function c(e,n){return{status:"pass",message:e,detail:n||null,fix:null}}function l(e,n){return{status:"warn",message:e,detail:null,fix:n||null}}function h(e,n){return{status:"fail",message:e,detail:null,fix:n||null}}function E(){const e=process.version,n=parseInt(e.slice(1).split(".")[0],10);return n>=20?c(`Node.js ${e}`,"Node 20+ recommended"):n>=18?c(`Node.js ${e}`):h(`Node.js ${e} \u2014 infernoflow requires Node 18+`,"Install Node 20 from nodejs.org")}function M(){try{const e=v("infernoflow",["--version"],{encoding:"utf8",timeout:5e3,shell:process.platform==="win32"});return e.status===0?c(`infernoflow v${e.stdout.trim()} installed`):c("infernoflow CLI on PATH (version probe failed but doctor itself ran)")}catch{return c("infernoflow CLI on PATH (version probe threw but doctor itself ran)")}}function T(e){try{return P("git rev-parse --git-dir",{cwd:e,stdio:"ignore"}),c("Git repository detected")}catch{return h("Not a git repository","git init && git add . && git commit -m 'init'")}}function D(e){const n=a.join(e,".ai-memory"),o=a.join(e,"inferno");return s.existsSync(n)&&s.existsSync(o)?c(".ai-memory/ + inferno/ both present"):s.existsSync(n)?c(".ai-memory/ directory exists (memory mode)"):s.existsSync(o)?c("inferno/ directory exists"):h("No memory directory found (.ai-memory/ or inferno/)","infernoflow init")}function G(e){if(x(e)){let o=0;try{o=I(e).length}catch{}return c(o===0?"Memory mode \u2014 sessions.jsonl will be created on first log":`Memory mode \u2014 ${o} session entr${o===1?"y":"ies"}`)}const n=a.join(e,"inferno");for(const o of["contract.json","capabilities.json"]){const t=a.join(n,o);if(s.existsSync(t))try{const i=(JSON.parse(s.readFileSync(t,"utf8")).capabilities||[]).length;return c(`${o} valid \u2014 ${i} capabilities`)}catch{return h(`${o} contains invalid JSON`,`Fix the JSON syntax in inferno/${o}`)}}return h("No contract.json/capabilities.json (and not in memory mode)","infernoflow init or infernoflow init --mode full")}function x(e){const n=a.join(e,".ai-memory"),o=a.join(e,"inferno","contract.json");if(s.existsSync(n)&&!s.existsSync(o))return!0;try{return JSON.parse(s.readFileSync(a.join(e,"inferno","config.json"),"utf8")).mode==="memory"}catch{return!1}}function F(e){if(x(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=a.join(e,"inferno","scenarios");if(!s.existsSync(n))return l("No scenarios/ directory","infernoflow init");const o=s.readdirSync(n).filter(t=>t.endsWith(".json"));return o.length?c(`${o.length} scenario file${o.length!==1?"s":""} found`):l("scenarios/ is empty","Add scenario files or run infernoflow suggest")}function L(e){if(x(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=a.join(e,"inferno","CHANGELOG.md");return s.existsSync(n)?c("inferno/CHANGELOG.md exists"):l("No inferno/CHANGELOG.md","infernoflow init")}function R(e){if(x(e))return{status:"info",message:"n/a in memory mode (CLAUDE.md is auto-maintained)",detail:null,fix:null};const n=a.join(e,"inferno","CONTEXT.md");if(!s.existsSync(n))return l("No CONTEXT.md generated","infernoflow context");const o=(Date.now()-s.statSync(n).mtimeMs)/(1e3*60*60*24);return o>7?l(`CONTEXT.md is ${Math.round(o)} days old \u2014 may be stale`,"infernoflow context"):c(`CONTEXT.md present (${Math.round(o)}d old)`)}function J(e){const n=a.join(e,".git","hooks"),o=a.join(n,"post-commit"),t=a.join(n,"pre-push"),r=s.existsSync(o)&&s.readFileSync(o,"utf8").includes("infernoflow"),i=s.existsSync(t)&&s.readFileSync(t,"utf8").includes("infernoflow");return r&&i?c("Git hooks installed (post-commit + pre-push)"):l(r||i?"Partial git hooks installed":"Git hooks not installed","infernoflow setup --yes")}function H(e){const n=[a.join(e,".cursor","mcp.json"),a.join(e,".mcp.json"),a.join(y.homedir(),".cursor","mcp.json"),a.join(y.homedir(),"Library","Application Support","Claude","claude_desktop_config.json"),a.join(y.homedir(),"AppData","Roaming","Claude","claude_desktop_config.json")];for(const o of n)if(s.existsSync(o))try{const t=JSON.parse(s.readFileSync(o,"utf8")),r=t.mcpServers||t.mcp_servers||{};if(Object.keys(r).some(i=>i.toLowerCase().includes("inferno")))return c(`MCP server configured in ${a.basename(o)}`)}catch{}return l("MCP server not configured","infernoflow setup --yes (adds to Cursor/Claude config)")}function W(e,n){const o=a.join(e,".ai-memory",".mcp-runtime.json");if(!s.existsSync(o))return c("MCP runtime stamp not present yet \u2014 start your AI tool to write one");let t;try{t=JSON.parse(s.readFileSync(o,"utf8"))}catch{return l(".mcp-runtime.json present but unreadable","Delete .ai-memory/.mcp-runtime.json and restart your AI tool")}return!t||typeof t.version!="string"?l(".mcp-runtime.json malformed","Delete it; the next MCP boot will rewrite it"):t.version===n?c(`MCP runtime v${t.version} matches CLI`):n.startsWith("0.0.0")||t.version.startsWith("0.0.0")?c(`MCP runtime v${t.version} (dev/source) \u2014 skipping version-skew check`):l(`MCP server is running v${t.version} but CLI is v${n} \u2014 restart your AI tool to load the new code.`,"Quit and reopen Cursor / Claude Code / VS Code (the long-running MCP process keeps the old code in memory until restart)")}function X(e){const n=_(e),o=Object.entries(n).filter(([,t])=>t).map(([t])=>t);return o.length?c(`AI provider${o.length!==1?"s":""}: ${o.join(", ")}`):l("No AI provider configured",`Set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_AI_API_KEY, or OPENROUTER_API_KEY
2
2
  Or install Ollama (ollama.com) for free local AI
3
- Or use VS Code with GitHub Copilot (zero config)`)}async function K(){return new Promise(e=>{const n=O.get({hostname:"localhost",port:11434,path:"/api/tags",timeout:1500},o=>{e(c("Ollama running on localhost:11434"))});n.on("error",()=>e({status:"info",message:"Ollama not running (optional)",fix:"ollama serve",detail:null})),n.on("timeout",()=>{n.destroy(),e({status:"info",message:"Ollama not running (optional)",fix:null,detail:null})})})}function U(){const e=a.join(y.homedir(),".infernoflow","credentials.json");if(!s.existsSync(e))return{status:"info",message:"Not logged in to cloud (optional)",fix:"infernoflow login",detail:null};try{const n=JSON.parse(s.readFileSync(e,"utf8")),o=n.user?.login||n.user?.name||n.user?.email||"unknown";if(n.mode==="supabase"&&n.access_token){if(n.expires_at){const t=new Date(n.expires_at).getTime();if(Date.now()>t)return l(`JWT expired for ${o} \u2014 refresh on next log will retry`,"infernoflow login")}return c(`Authenticated as ${o} (Supabase JWT \u2014 auth.uid() writes)`)}return n.mode==="device-flow"&&n.github_access_token?{status:"info",message:`Identity-only as ${o} (device flow \u2014 anon-mode writes)`,fix:"infernoflow login (without --device-flow, for full auth)",detail:null}:n.access_token?l(`Legacy login for ${o} \u2014 re-run for authenticated cloud writes`,"infernoflow logout && infernoflow login"):{status:"info",message:"Credentials file present but no recognised token",fix:"infernoflow logout && infernoflow login",detail:null}}catch{return l("Credentials file unreadable","infernoflow logout && infernoflow login")}}function V(){try{const e=A(import.meta.url),n=a.resolve(a.dirname(e),"..","..","bin","infernoflow.mjs");if(!s.existsSync(n))return{status:"info",message:"bin/infernoflow.mjs not found from doctor location",fix:null,detail:null};const t=[...s.readFileSync(n,"utf8").matchAll(/import\("\.\.\/lib\/(commands\/[^"]+|telemetry\.mjs)"\)/g)],r=[],i=a.resolve(a.dirname(n),"..");for(const m of t){const d=m[1],p=a.join(i,"lib",d);s.existsSync(p)||r.push(d)}return r.length?h(`${r.length} routed command(s) missing module files: ${r.slice(0,3).join(", ")}${r.length>3?"\u2026":""}`,"Restore the missing files or remove their entries from bin/infernoflow.mjs"):c(`All ${t.length} routed commands resolve to real files`)}catch(e){return{status:"info",message:`Router integrity check skipped: ${e.message}`,fix:null,detail:null}}}function Y(e){const n=a.join(e,"package.json");if(!s.existsSync(n))return c("No package.json to audit");let o;try{o=JSON.parse(s.readFileSync(n,"utf8"))}catch{return{status:"info",message:"package.json unreadable; skipping audit",detail:null,fix:null}}const t=o.scripts||{},r=new Set(["log","ask","switch","recap","status","init","doctor","graph","watch","amp","contract","dev","demo","setup","log-decision","log-attempt","context","stats","test"]),i=[];for(const[d,p]of Object.entries(t)){const x=/\binfernoflow\s+([a-z][a-z0-9-]*)/.exec(String(p));if(!x)continue;const f=x[1];r.has(f)||i.push({scriptName:d,verb:f})}if(i.length===0)return c("npm scripts use current command surface");const m=i.map(d=>`${d.scriptName} \u2192 infernoflow ${d.verb}`).join(", ");return l(`package.json references ${i.length} deprecated command(s): ${m}`,"Edit package.json scripts to use the current surface (run `infernoflow --help` to list verbs)")}function z(e){const n=a.join(e,".gitignore");if(!s.existsSync(n))return{status:"info",message:".gitignore not found",fix:null,detail:null};const o=s.readFileSync(n,"utf8");return/^(?:\*\*\/)?node_modules\/?$/m.test(o)?c(".gitignore excludes node_modules"):l(".gitignore does not exclude node_modules","Add 'node_modules/' (and '**/node_modules/') to .gitignore")}function q(e,n){const o=e.filter(r=>r.status==="warn"&&r.fix),t=[];for(const r of o){const i=r.fix;if(i.startsWith("infernoflow ")){const m=i.slice(12).split(" ");v("infernoflow",m,{cwd:n,encoding:"utf8",timeout:3e4}).status===0&&t.push(r.label)}}return t}function B(e){return e==="pass"?w("\u2714"):e==="warn"?S("\u26A0"):e==="fail"?k("\u2717"):j("\xB7")}function Q(e,n){const o={pass:0,warn:0,fail:0,info:0,error:0};for(const i of e)o[i.status]=(o[i.status]||0)+1;console.log(),console.log(` ${C("\u{1F525} infernoflow doctor")}`),console.log();const t=Math.max(...e.map(i=>i.label.length))+2;for(const i of e)console.log(` ${B(i.status)} ${C(i.label.padEnd(t))} ${i.message}`),i.detail&&console.log(` ${" ".repeat(t)} ${j(i.detail)}`),i.fix&&(i.status==="warn"||i.status==="fail")&&console.log(` ${" ".repeat(t)} ${b("fix:")} ${j(i.fix)}`);console.log();const r=o.fail>0?k("issues found"):o.warn>0?S("warnings"):w("all good");console.log(` ${r} \u2014 ${w(String(o.pass))} pass \xB7 ${S(String(o.warn))} warn \xB7 ${k(String(o.fail))} fail (${n}ms)`),console.log(),(o.warn>0||o.fail>0)&&(console.log(` Run ${b("infernoflow doctor --fix")} to auto-fix warnings`),console.log())}async function Z(e){const n=e.slice(1),o=n.includes("--json"),t=n.includes("--fix"),r=process.cwd(),i=Date.now();let m="0.0.0-unknown";try{const{fileURLToPath:f}=await import("node:url"),g=a.dirname(f(import.meta.url)),N=a.join(g,"..","..","package.json");m=JSON.parse(s.readFileSync(N,"utf8")).version||m}catch{}const d=[u("Node.js version",()=>E()),u("infernoflow CLI",()=>M()),u("Git repository",()=>T(r)),u("inferno/ directory",()=>F(r)),u("Contract / mode",()=>G(r)),u("Scenarios",()=>L(r)),u("Changelog",()=>R(r)),u("CONTEXT.md",()=>D(r)),u("Git hooks",()=>J(r)),u("MCP server",()=>H(r)),u("MCP runtime version",()=>W(r,m)),u("AI providers",()=>X(r)),u("Cloud sync",()=>U()),u(".gitignore",()=>z(r)),u("Router integrity",()=>V()),u("npm scripts",()=>Y(r)),await K().then(f=>({label:"Ollama (local AI)",...f}))],p=Date.now()-i;if(t){const f=q(d,r);if(f.length)return o||(console.log(),f.forEach(g=>console.log(` ${w("\u2714")} Fixed: ${g}`)),console.log()),Z(["doctor","--json"])}if(o){const f={pass:0,warn:0,fail:0,info:0};d.forEach(g=>f[g.status]=(f[g.status]||0)+1),console.log(JSON.stringify({ok:f.fail===0,counts:f,results:d,elapsed:p}));return}Q(d,p),d.some(f=>f.status==="fail")&&process.exit(1)}export{Z as doctorCommand};
3
+ Or use VS Code with GitHub Copilot (zero config)`)}async function K(){return new Promise(e=>{const n=O.get({hostname:"localhost",port:11434,path:"/api/tags",timeout:1500},o=>{e(c("Ollama running on localhost:11434"))});n.on("error",()=>e({status:"info",message:"Ollama not running (optional)",fix:"ollama serve",detail:null})),n.on("timeout",()=>{n.destroy(),e({status:"info",message:"Ollama not running (optional)",fix:null,detail:null})})})}function U(){const e=a.join(y.homedir(),".infernoflow","credentials.json");if(!s.existsSync(e))return{status:"info",message:"Not logged in to cloud (optional)",fix:"infernoflow login",detail:null};try{const n=JSON.parse(s.readFileSync(e,"utf8")),o=n.user?.login||n.user?.name||n.user?.email||"unknown";if(n.mode==="supabase"&&n.access_token){if(n.expires_at){const t=new Date(n.expires_at).getTime();if(Date.now()>t)return l(`JWT expired for ${o} \u2014 refresh on next log will retry`,"infernoflow login")}return c(`Authenticated as ${o} (Supabase JWT \u2014 auth.uid() writes)`)}return n.mode==="device-flow"&&n.github_access_token?{status:"info",message:`Identity-only as ${o} (device flow \u2014 anon-mode writes)`,fix:"infernoflow login (without --device-flow, for full auth)",detail:null}:n.access_token?l(`Legacy login for ${o} \u2014 re-run for authenticated cloud writes`,"infernoflow logout && infernoflow login"):{status:"info",message:"Credentials file present but no recognised token",fix:"infernoflow logout && infernoflow login",detail:null}}catch{return l("Credentials file unreadable","infernoflow logout && infernoflow login")}}function V(){try{const e=A(import.meta.url),n=a.resolve(a.dirname(e),"..","..","bin","infernoflow.mjs");if(!s.existsSync(n))return{status:"info",message:"bin/infernoflow.mjs not found from doctor location",fix:null,detail:null};const t=[...s.readFileSync(n,"utf8").matchAll(/import\("\.\.\/lib\/(commands\/[^"]+|telemetry\.mjs)"\)/g)],r=[],i=a.resolve(a.dirname(n),"..");for(const m of t){const d=m[1],p=a.join(i,"lib",d);s.existsSync(p)||r.push(d)}return r.length?h(`${r.length} routed command(s) missing module files: ${r.slice(0,3).join(", ")}${r.length>3?"\u2026":""}`,"Restore the missing files or remove their entries from bin/infernoflow.mjs"):c(`All ${t.length} routed commands resolve to real files`)}catch(e){return{status:"info",message:`Router integrity check skipped: ${e.message}`,fix:null,detail:null}}}function Y(e){const n=a.join(e,"package.json");if(!s.existsSync(n))return c("No package.json to audit");let o;try{o=JSON.parse(s.readFileSync(n,"utf8"))}catch{return{status:"info",message:"package.json unreadable; skipping audit",detail:null,fix:null}}const t=o.scripts||{},r=new Set(["log","ask","switch","recap","status","init","doctor","graph","watch","amp","contract","dev","demo","setup","log-decision","log-attempt","context","stats","test"]),i=[];for(const[d,p]of Object.entries(t)){const j=/\binfernoflow\s+([a-z][a-z0-9-]*)/.exec(String(p));if(!j)continue;const f=j[1];r.has(f)||i.push({scriptName:d,verb:f})}if(i.length===0)return c("npm scripts use current command surface");const m=i.map(d=>`${d.scriptName} \u2192 infernoflow ${d.verb}`).join(", ");return l(`package.json references ${i.length} deprecated command(s): ${m}`,"Edit package.json scripts to use the current surface (run `infernoflow --help` to list verbs)")}function z(e){const n=a.join(e,".gitignore");if(!s.existsSync(n))return{status:"info",message:".gitignore not found",fix:null,detail:null};const o=s.readFileSync(n,"utf8");return/^(?:\*\*\/)?node_modules\/?$/m.test(o)?c(".gitignore excludes node_modules"):l(".gitignore does not exclude node_modules","Add 'node_modules/' (and '**/node_modules/') to .gitignore")}function q(e,n){const o=e.filter(r=>r.status==="warn"&&r.fix),t=[];for(const r of o){const i=r.fix;if(i.startsWith("infernoflow ")){const m=i.slice(12).split(" ");v("infernoflow",m,{cwd:n,encoding:"utf8",timeout:3e4}).status===0&&t.push(r.label)}}return t}function B(e){return e==="pass"?w("\u2714"):e==="warn"?k("\u26A0"):e==="fail"?$("\u2717"):S("\xB7")}function Q(e,n){const o={pass:0,warn:0,fail:0,info:0,error:0};for(const i of e)o[i.status]=(o[i.status]||0)+1;console.log(),console.log(` ${C("\u{1F525} infernoflow doctor")}`),console.log();const t=Math.max(...e.map(i=>i.label.length))+2;for(const i of e)console.log(` ${B(i.status)} ${C(i.label.padEnd(t))} ${i.message}`),i.detail&&console.log(` ${" ".repeat(t)} ${S(i.detail)}`),i.fix&&(i.status==="warn"||i.status==="fail")&&console.log(` ${" ".repeat(t)} ${b("fix:")} ${S(i.fix)}`);console.log();const r=o.fail>0?$("issues found"):o.warn>0?k("warnings"):w("all good");console.log(` ${r} \u2014 ${w(String(o.pass))} pass \xB7 ${k(String(o.warn))} warn \xB7 ${$(String(o.fail))} fail (${n}ms)`),console.log(),(o.warn>0||o.fail>0)&&(console.log(` Run ${b("infernoflow doctor --fix")} to auto-fix warnings`),console.log())}async function Z(e){const n=e.slice(1),o=n.includes("--json"),t=n.includes("--fix"),r=process.cwd(),i=Date.now();let m="0.0.0-unknown";try{const{fileURLToPath:f}=await import("node:url"),g=a.dirname(f(import.meta.url)),N=a.join(g,"..","..","package.json");m=JSON.parse(s.readFileSync(N,"utf8")).version||m}catch{}const d=[u("Node.js version",()=>E()),u("infernoflow CLI",()=>M()),u("Git repository",()=>T(r)),u("inferno/ directory",()=>D(r)),u("Contract / mode",()=>G(r)),u("Scenarios",()=>F(r)),u("Changelog",()=>L(r)),u("CONTEXT.md",()=>R(r)),u("Git hooks",()=>J(r)),u("MCP server",()=>H(r)),u("MCP runtime version",()=>W(r,m)),u("AI providers",()=>X(r)),u("Cloud sync",()=>U()),u(".gitignore",()=>z(r)),u("Router integrity",()=>V()),u("npm scripts",()=>Y(r)),await K().then(f=>({label:"Ollama (local AI)",...f}))],p=Date.now()-i;if(t){const f=q(d,r);if(f.length)return o||(console.log(),f.forEach(g=>console.log(` ${w("\u2714")} Fixed: ${g}`)),console.log()),Z(["doctor","--json"])}if(o){const f={pass:0,warn:0,fail:0,info:0};d.forEach(g=>f[g.status]=(f[g.status]||0)+1),console.log(JSON.stringify({ok:f.fail===0,counts:f,results:d,elapsed:p}));return}Q(d,p),d.some(f=>f.status==="fail")&&process.exit(1)}export{Z as doctorCommand};
@@ -1,5 +1,5 @@
1
- import*as C from"node:fs";import*as D from"node:path";import{execSync as M}from"node:child_process";import{bold as b,cyan as u,gray as n,green as k,yellow as $,red as I}from"../ui/output.mjs";import{readEntries as L}from"../amp/io.mjs";const x="inferno",R=D.join(x,"contract.json");function v(e){try{return JSON.parse(C.readFileSync(e,"utf8"))}catch{return null}}function P(e,s){if(s){const o=s.match(/^(\d+)h$/i),t=s.match(/^(\d+)d$/i);if(o)return new Date(Date.now()-parseInt(o[1])*36e5);if(t)return new Date(Date.now()-parseInt(t[1])*864e5);const c=new Date(s);if(!isNaN(c.getTime()))return c}for(let o=e.length-1;o>=0;o--)if(e[o].type==="handoff"){const t=new Date(e[o].ts||0),c=new Date(Date.now()-864e5);return t>c?t:c}return new Date(Date.now()-864e5)}function A(e){const s=process.cwd(),o=p=>{try{return M(p,{cwd:s,encoding:"utf8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()}catch{return""}},t=e.toISOString().slice(0,19),c=o("git diff --cached --name-only"),m=o("git diff --name-only"),r=o(`git log --since="${t}" --name-only --pretty=format:""`);return[...new Set([...c.split(`
2
- `),...m.split(`
3
- `),...r.split(`
4
- `)].map(p=>p.trim()).filter(Boolean))]}function B(e,s){const o=[{keywords:["auth","login","logout","session","jwt","token","password"],topic:"authentication"},{keywords:["stripe","payment","checkout","billing","subscription"],topic:"payments"},{keywords:["upload","file","s3","storage","bucket","cdn"],topic:"file handling"},{keywords:["email","sendgrid","ses","smtp","nodemailer","twilio"],topic:"notifications"},{keywords:["db","database","prisma","mongoose","postgres","mysql","migration"],topic:"database"},{keywords:["deploy","docker","ci","workflow","action","kubernetes"],topic:"deployment"},{keywords:["cache","redis","memcache"],topic:"caching"},{keywords:["test","spec","jest","vitest","cypress","playwright"],topic:"testing"},{keywords:["config","env",".env","environment","secret"],topic:"configuration"},{keywords:["api","route","endpoint","controller","handler"],topic:"API routes"},{keywords:["ui","component","style","css","tailwind","theme"],topic:"UI/styles"}],t=s.map(r=>(r.summary||"").toLowerCase()).join(" "),c=[],m=new Set;for(const r of o){if(m.has(r.topic))continue;const y=e.filter(g=>r.keywords.some(w=>g.toLowerCase().includes(w)));!y.length||r.keywords.some(g=>t.includes(g))||(m.add(r.topic),c.push({topic:r.topic,files:y.slice(0,3),suggestedType:"gotcha"}))}return c}function _(e){const s=new Set(e.map(c=>c.type));let o=0;const t=[];return e.length>0?(o+=20,t.push({ok:!0,label:`${e.length} entr${e.length!==1?"ies":"y"} logged`})):t.push({ok:!1,label:"nothing logged this session"}),s.has("gotcha")?(o+=35,t.push({ok:!0,label:"gotchas captured"})):t.push({ok:!1,label:"no gotchas (most valuable \u2014 log landmines!)"}),s.has("decision")?(o+=25,t.push({ok:!0,label:"decisions recorded"})):t.push({ok:!1,label:"no decisions recorded"}),s.has("attempt")&&(o+=10,t.push({ok:!0,label:"attempts tracked"})),s.has("preference")&&(o+=10,t.push({ok:!0,label:"preferences noted"})),{score:Math.min(o,100),checks:t}}function J(e){if(!e)return"";const s=new Date(e),o=Date.now()-s.getTime(),t=Math.floor(o/6e4);if(t<60)return`${t}m ago`;const c=Math.floor(o/36e5);return c<24?`${c}h ago`:`${Math.floor(o/864e5)}d ago`}const U={gotcha:"\u26A0",decision:"\u2713",attempt:"\u21BA",preference:"\u2666",theme:"\u25C8",note:"\xB7",error:"\u2717",handoff:"\u2192"},G={gotcha:$,decision:k,attempt:u,preference:u,theme:u,note:n,error:I,handoff:n};function H(e){const s=G[e.type]||n,o=U[e.type]||"\xB7",t=e.result?n(` [${e.result}]`):"",c=n(` (${J(e.ts)})`);console.log(` ${s(o+" "+(e.type||"note").padEnd(11))}${t}${c}`),console.log(` ${e.summary}`)}async function Q(e=[]){const s=e,o=s.includes("--json"),t=s.includes("--brief"),c=s.indexOf("--since"),m=c!==-1?s[c+1]:null,r=process.cwd();!C.existsSync(D.join(r,x))&&!C.existsSync(D.join(r,".ai-memory"))&&(o||console.error(I(` \u2718 not initialized \u2014 run: infernoflow init
5
- `)),process.exit(1));const y=L(r),p=P(y,m),g=y.filter(a=>new Date(a.ts||0)>p),w=A(p),h=B(w,g),{score:l,checks:O}=_(g),j=v(D.join(r,R));if(o){console.log(JSON.stringify({sessionStart:p.toISOString(),entries:g,changedFiles:w,unloggedTopics:h,health:{score:l,checks:O}},null,2));return}if(t){const a=l>=80?"A":l>=60?"B":l>=40?"C":"D",f=l>=60?k:l>=40?$:I;console.log(f(`Session health: ${a} (${l}/100)`)+n(` \u2014 ${g.length} entries logged`)),h.length&&console.log($(` ${h.length} topic${h.length!==1?"s":""} changed but not logged: `)+h.map(i=>i.topic).join(", "));return}const S=n(" "+"\u2500".repeat(52));console.log(),console.log(" "+b("\u{1F525} infernoflow recap")),j?.policyId&&console.log(n(` Project: ${j.policyId}`));const E=p.toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"});if(console.log(n(` Session since: ${E}`)),console.log(S),console.log(),console.log(" "+b("Captured this session")),console.log(),g.length===0)console.log(n(" Nothing logged yet this session."));else{const a=["gotcha","decision","attempt","preference","theme","note","error"],f=new Map;for(const i of g){const d=i.type||"note";f.has(d)||f.set(d,[]),f.get(d).push(i)}for(const i of a){const d=f.get(i);if(d?.length)for(const F of d)console.log(),H(F)}}if(h.length>0){console.log(),console.log(S),console.log(),console.log(" "+b("Changed but not logged")+n(" (git diff since session start)")),console.log();for(const{topic:a,files:f}of h){console.log($(` ? ${a}`));for(const i of f)console.log(n(` ${i}`))}console.log(),console.log(n(" Any gotchas or decisions from these areas worth capturing?")),console.log(n(" Run: ")+u('infernoflow log "<what happened>" --type gotcha'))}else w.length>0&&(console.log(),console.log(S),console.log(),console.log(k(" \u2714 ")+n(`${w.length} changed files \u2014 all topics appear to be logged`)));console.log(),console.log(S),console.log(),console.log(" "+b("Session health")),console.log();const N=l>=80?"A":l>=60?"B":l>=40?"C":"D",T=l>=60?k:l>=40?$:I;console.log(` ${T(b(`${N}`))} ${T(`${l}/100`)}`),console.log();for(const{ok:a,label:f}of O){const i=a?k(" \u2714"):$(" \xB7");console.log(`${i} ${a?f:n(f)}`)}{const a=g.filter(d=>d.type==="gotcha").length,f=g.filter(d=>d.type==="decision").length,i=[];if(a===0?i.push(u('infernoflow log "..." --type gotcha')+n(" \u2014 adds 35 pts")):a<3&&l<80&&i.push(n(` ${3-a} more gotcha(s) would push you higher`)),f===0&&i.push(u('infernoflow log "..." --type decision')+n(" \u2014 adds 25 pts")),l>=60&&l<80&&i.push(n(" Almost B! One more entry gets you there.")),l>=80&&i.push(k(" Great session \u2014 your handoff will be excellent.")),i.length){console.log(),console.log(n(" How to improve:"));for(const d of i)console.log(" "+d)}}(g.length>0||h.length>0)&&(console.log(),console.log(S),console.log(),console.log(n(" Before your next session:")),console.log(n(" ")+u("infernoflow switch")+n(" \u2014 generate a handoff summary for the next AI agent")),console.log(n(" ")+u("infernoflow ask --recent")+n(" \u2014 review what's in memory before starting"))),console.log()}export{Q as recapCommand};
1
+ import*as C from"node:fs";import*as I from"node:path";import{execSync as M}from"node:child_process";import{bold as b,cyan as y,gray as t,green as k,yellow as $,red as D}from"../ui/output.mjs";import{readEntries as R}from"../amp/io.mjs";const N="inferno",v=I.join(N,"contract.json");function L(n){try{return JSON.parse(C.readFileSync(n,"utf8"))}catch{return null}}function A(n,s){if(s){const g=s.match(/^(\d+)h$/i),f=s.match(/^(\d+)d$/i);if(g)return new Date(Date.now()-parseInt(g[1])*36e5);if(f)return new Date(Date.now()-parseInt(f[1])*864e5);const r=new Date(s);if(!isNaN(r.getTime()))return r}const o=new Date(Date.now()-864e5),e=[];for(const g of n)if(g.type==="handoff"){const f=new Date(g.ts||0);isNaN(f.getTime())||e.push(f)}if(e.length===0)return o;const l=300*1e3,u=e[e.length-1];if(Date.now()-u.getTime()<l){if(e.length>=2){const g=e[e.length-2];return g>o?g:o}return o}return u>o?u:o}function P(n){const s=process.cwd(),o=f=>{try{return M(f,{cwd:s,encoding:"utf8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()}catch{return""}},e=n.toISOString().slice(0,19),l=o("git diff --cached --name-only"),u=o("git diff --name-only"),a=o(`git log --since="${e}" --name-only --pretty=format:""`);return[...new Set([...l.split(`
2
+ `),...u.split(`
3
+ `),...a.split(`
4
+ `)].map(f=>f.trim()).filter(Boolean))]}function _(n,s){const o=[{keywords:["auth","login","logout","session","jwt","token","password"],topic:"authentication"},{keywords:["stripe","payment","checkout","billing","subscription"],topic:"payments"},{keywords:["upload","file","s3","storage","bucket","cdn"],topic:"file handling"},{keywords:["email","sendgrid","ses","smtp","nodemailer","twilio"],topic:"notifications"},{keywords:["db","database","prisma","mongoose","postgres","mysql","migration"],topic:"database"},{keywords:["deploy","docker","ci","workflow","action","kubernetes"],topic:"deployment"},{keywords:["cache","redis","memcache"],topic:"caching"},{keywords:["test","spec","jest","vitest","cypress","playwright"],topic:"testing"},{keywords:["config","env",".env","environment","secret"],topic:"configuration"},{keywords:["api","route","endpoint","controller","handler"],topic:"API routes"},{keywords:["ui","component","style","css","tailwind","theme"],topic:"UI/styles"}],e=s.map(a=>(a.summary||"").toLowerCase()).join(" "),l=[],u=new Set;for(const a of o){if(u.has(a.topic))continue;const g=n.filter(r=>a.keywords.some(w=>r.toLowerCase().includes(w)));!g.length||a.keywords.some(r=>e.includes(r))||(u.add(a.topic),l.push({topic:a.topic,files:g.slice(0,3),suggestedType:"gotcha"}))}return l}function B(n){const s=new Set(n.map(l=>l.type));let o=0;const e=[];return n.length>0?(o+=20,e.push({ok:!0,label:`${n.length} entr${n.length!==1?"ies":"y"} logged`})):e.push({ok:!1,label:"nothing logged this session"}),s.has("gotcha")?(o+=35,e.push({ok:!0,label:"gotchas captured"})):e.push({ok:!1,label:"no gotchas (most valuable \u2014 log landmines!)"}),s.has("decision")?(o+=25,e.push({ok:!0,label:"decisions recorded"})):e.push({ok:!1,label:"no decisions recorded"}),s.has("attempt")&&(o+=10,e.push({ok:!0,label:"attempts tracked"})),s.has("preference")&&(o+=10,e.push({ok:!0,label:"preferences noted"})),{score:Math.min(o,100),checks:e}}function H(n){if(!n)return"";const s=new Date(n),o=Date.now()-s.getTime(),e=Math.floor(o/6e4);if(e<60)return`${e}m ago`;const l=Math.floor(o/36e5);return l<24?`${l}h ago`:`${Math.floor(o/864e5)}d ago`}const J={gotcha:"\u26A0",decision:"\u2713",attempt:"\u21BA",preference:"\u2666",theme:"\u25C8",note:"\xB7",error:"\u2717",handoff:"\u2192"},U={gotcha:$,decision:k,attempt:y,preference:y,theme:y,note:t,error:D,handoff:t};function G(n){const s=U[n.type]||t,o=J[n.type]||"\xB7",e=n.result?t(` [${n.result}]`):"",l=t(` (${H(n.ts)})`);console.log(` ${s(o+" "+(n.type||"note").padEnd(11))}${e}${l}`),console.log(` ${n.summary}`)}async function Q(n=[]){const s=n,o=s.includes("--json"),e=s.includes("--brief"),l=s.indexOf("--since"),u=l!==-1?s[l+1]:null,a=process.cwd();!C.existsSync(I.join(a,N))&&!C.existsSync(I.join(a,".ai-memory"))&&(o||console.error(D(` \u2718 not initialized \u2014 run: infernoflow init
5
+ `)),process.exit(1));const g=R(a),f=A(g,u),r=g.filter(d=>new Date(d.ts||0)>f),w=P(f),m=_(w,r),{score:i,checks:O}=B(r),F=L(I.join(a,v));if(o){console.log(JSON.stringify({sessionStart:f.toISOString(),entries:r,changedFiles:w,unloggedTopics:m,health:{score:i,checks:O}},null,2));return}if(e){const d=i>=80?"A":i>=60?"B":i>=40?"C":"D",p=i>=60?k:i>=40?$:D;console.log(p(`Session health: ${d} (${i}/100)`)+t(` \u2014 ${r.length} entries logged`)),m.length&&console.log($(` ${m.length} topic${m.length!==1?"s":""} changed but not logged: `)+m.map(c=>c.topic).join(", "));return}const S=t(" "+"\u2500".repeat(52));console.log(),console.log(" "+b("\u{1F525} infernoflow recap")),F?.policyId&&console.log(t(` Project: ${F.policyId}`));const j=f.toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"});if(console.log(t(` Session since: ${j}`)),console.log(S),console.log(),console.log(" "+b("Captured this session")),console.log(),r.length===0)console.log(t(" Nothing logged yet this session."));else{const d=["gotcha","decision","attempt","preference","theme","note","error"],p=new Map;for(const c of r){const h=c.type||"note";p.has(h)||p.set(h,[]),p.get(h).push(c)}for(const c of d){const h=p.get(c);if(h?.length)for(const x of h)console.log(),G(x)}}if(m.length>0){console.log(),console.log(S),console.log(),console.log(" "+b("Changed but not logged")+t(" (git diff since session start)")),console.log();for(const{topic:d,files:p}of m){console.log($(` ? ${d}`));for(const c of p)console.log(t(` ${c}`))}console.log(),console.log(t(" Any gotchas or decisions from these areas worth capturing?")),console.log(t(" Run: ")+y('infernoflow log "<what happened>" --type gotcha'))}else w.length>0&&(console.log(),console.log(S),console.log(),console.log(k(" \u2714 ")+t(`${w.length} changed files \u2014 all topics appear to be logged`)));console.log(),console.log(S),console.log(),console.log(" "+b("Session health")),console.log();const E=i>=80?"A":i>=60?"B":i>=40?"C":"D",T=i>=60?k:i>=40?$:D;console.log(` ${T(b(`${E}`))} ${T(`${i}/100`)}`),console.log();for(const{ok:d,label:p}of O){const c=d?k(" \u2714"):$(" \xB7");console.log(`${c} ${d?p:t(p)}`)}{const d=r.filter(h=>h.type==="gotcha").length,p=r.filter(h=>h.type==="decision").length,c=[];if(d===0?c.push(y('infernoflow log "..." --type gotcha')+t(" \u2014 adds 35 pts")):d<3&&i<80&&c.push(t(` ${3-d} more gotcha(s) would push you higher`)),p===0&&c.push(y('infernoflow log "..." --type decision')+t(" \u2014 adds 25 pts")),i>=60&&i<80&&c.push(t(" Almost B! One more entry gets you there.")),i>=80&&c.push(k(" Great session \u2014 your handoff will be excellent.")),c.length){console.log(),console.log(t(" How to improve:"));for(const h of c)console.log(" "+h)}}(r.length>0||m.length>0)&&(console.log(),console.log(S),console.log(),console.log(t(" Before your next session:")),console.log(t(" ")+y("infernoflow switch")+t(" \u2014 generate a handoff summary for the next AI agent")),console.log(t(" ")+y("infernoflow ask --recent")+t(" \u2014 review what's in memory before starting"))),console.log()}export{Q as recapCommand};
@@ -1,11 +1,11 @@
1
- import*as b from"node:fs";import*as m from"node:path";import"node:os";import{execSync as S}from"node:child_process";import{bold as V,cyan as $,gray as it,green as rt,yellow as J,red as pt}from"../ui/output.mjs";import{ampPaths as ut,readEntries as dt,appendEntry as ht}from"../amp/io.mjs";const F="inferno";function z(){return ut(process.cwd())}const gt=m.join(F,"HANDOFF.md"),Tt=m.join(F,"sessions.jsonl"),K=m.join(F,"context-state.json"),X=m.join(F,"contract.json"),q=m.join(F,"theme.json"),Q=m.join(F,"adoption_profile.json");function u(t){try{return JSON.parse(b.readFileSync(t,"utf8"))}catch{return null}}function mt(t){try{return b.readFileSync(t,"utf8")}catch{return null}}function Y(t){return t?new Date(t).toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}):"unknown"}function Z(t){if(t<0)return"unknown";const i=Math.floor(t/36e5),l=Math.floor(t%36e5/6e4);return i>0?`${i}h ${l}m`:`${l}m`}function tt(){return dt(process.cwd())}function et(t,i,l){if(l)return new Date(0);if(i){const o=i.match(/^(\d+)h$/i),c=i.match(/^(\d+)d$/i);if(o)return new Date(Date.now()-parseInt(o[1])*36e5);if(c)return new Date(Date.now()-parseInt(c[1])*864e5);const s=new Date(i);if(!isNaN(s.getTime()))return s}for(let o=t.length-1;o>=0;o--)if(t[o].type==="handoff"){const c=new Date(t[o].ts||0),s=new Date(Date.now()-864e5);return c>s?c:s}return new Date(Date.now()-864e5)}function yt(t){try{const i=process.platform;if(i==="win32")S("clip",{input:t});else if(i==="darwin")S("pbcopy",{input:t});else try{S("xclip -selection clipboard",{input:t})}catch{S("xsel --clipboard --input",{input:t})}return!0}catch{return!1}}function ot(){if(process.env.CURSOR_SESSION)return"Cursor";if(process.env.COPILOT_SESSION)return"GitHub Copilot";if(process.env.CLAUDE_CODE_SESSION)return"Claude Code";if(process.env.WINDSURF_SESSION)return"Windsurf";if(process.env.TERM_PROGRAM==="vscode")return"VS Code";const t=u(Q);return t?.ide?t.ide:null}function wt(){try{const t=S("git diff --stat HEAD 2>/dev/null || git diff --cached --stat 2>/dev/null",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();return t||S("git log --stat -1 --pretty= 2>/dev/null",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function ct(t){try{const i=t&&t.getTime()>0?`--after="${t.toISOString()}"`:"-10",l=S(`git log ${i} --name-only --pretty=format: 2>/dev/null`,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!l)return[];const o={};for(const c of l.split(`
2
- `)){const s=c.trim();s&&(o[s]=(o[s]||0)+1)}return Object.entries(o).sort((c,s)=>s[1]-c[1]).slice(0,5).map(([c,s])=>({file:c,edits:s}))}catch{return[]}}function nt(t){try{const i=t?`--after="${t.toISOString()}"`:"-5",l=S(`git log ${i} --pretty=format:"%h %s" 2>/dev/null`,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();return l?l.split(`
3
- `).filter(Boolean):[]}catch{return[]}}function lt(t){const i=[],l=t.filter(o=>o.type==="attempt"&&(o.result==="failed"||o.result==="partial"||!o.result));for(const o of l)t.find(s=>s.type==="attempt"&&s.result==="worked"&&new Date(s.ts)>new Date(o.ts)&&s.summary.toLowerCase().includes(o.summary.split(" ")[0].toLowerCase()))||i.push({text:o.summary,ts:o.ts,kind:"unresolved-attempt"});for(const o of t)/\b(TODO|WIP|FIXME|BLOCKED|pending)\b/i.test(o.summary)&&(i.find(c=>c.text===o.summary)||i.push({text:o.summary,ts:o.ts,kind:"flagged"}));return i.slice(0,8)}function St(t,i,l){const o=u(K)||{},c=u(X)||{},s=u(q),A=u(Q),D=tt(),a=et(D,i,l),N=D.filter(n=>new Date(n.ts||0)>a),H=D.slice(-5),I=new Date,d=I.toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),j=c.policyId||m.basename(process.cwd()),E=c.policyVersion||"?",O=(c.capabilities||[]).slice(0,20),x=ot(),M=a.getTime()>0?I.getTime()-a.getTime():-1,k=Z(M),L=a.getTime()>0?a.getTime().toString(16).slice(-6).toUpperCase():"ALL",C=nt(a.getTime()>0?a:null),_=wt(),R=ct(a.getTime()>0?a:null),y=N.length>0?N:H,r=y.filter(n=>n.type==="gotcha"),h=y.filter(n=>n.type==="decision"),v=y.filter(n=>n.type==="attempt").filter(n=>n.result==="failed"||n.result==="partial"),G=y.filter(n=>n.type==="preference"),W=y.slice(-8),g=lt(y),st=a.getTime()===0?"all time":a.toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}),w=["sessions.jsonl"];(o.working||o.intent)&&w.push("context-state.json"),s&&w.push("theme.json"),c.capabilities?.length&&w.push("contract.json"),A&&w.push("adoption_profile.json"),C.length&&w.push("git log");const B=r.length,P=h.length,at=v.length;let T=Math.min(B*20,40)+Math.min(P*15,30)+Math.min(at*15,20);T=Math.min(T,100);const ft=T>=80?"A":T>=60?"B":T>=40?"C":T>=20?"D":"F",e=[`# \u{1F525} infernoflow Handoff \u2014 ${j}`,`> Generated: ${d}${t?` | Handing off to: **${t}**`:""}`,`> Session: **#${L}** \xB7 ${k} \xB7 **${N.length} entries** \xB7 Health: **${ft}** (${T}/100)`,`> Sources: ${w.join(" \xB7 ")}${x?` \xB7 IDE: ${x}`:""}`,"","---",""];if((o.working||o.intent)&&(e.push("## \u{1F3AF} Working on",""),o.working&&e.push(`**${o.working}** _(${Y(o.workingUpdated)})_`),o.intent&&e.push(`Intent: ${o.intent} _(${Y(o.intentUpdated)})_`),e.push("")),r.length&&(e.push(`## \u26A0\uFE0F STOP \u2014 Read These Before Doing Anything (${r.length} gotcha${r.length===1?"":"s"})`,""),r.forEach((n,p)=>{e.push(`${p+1}. **${n.summary}**`);const f=n.file||n.source;if(f&&/[\\/.]/.test(f)){const U=n.line?`${f}:${n.line}`:f;e.push(` \u2192 File: \`${U}\``)}}),e.push("")),h.length&&(e.push("## \u2713 Decisions In Effect \u2014 Follow These",""),h.forEach((n,p)=>{const f=n.result?` \u2192 **${n.result}**`:"";e.push(`${p+1}. ${n.summary}${f}`)}),e.push("")),v.length&&(e.push("## \u274C Already Tried \u2014 Don't Repeat",""),v.forEach((n,p)=>{const f=n.file||n.source,U=f&&/[\\/.]/.test(f)?` (\`${f}\`)`:"";e.push(`${p+1}. ${n.summary}${U} _(${Y(n.ts)})_`)}),e.push("")),R.length){e.push("## \u{1F4C1} Hot Files This Session","");for(const{file:n,edits:p}of R)e.push(`- \`${n}\` \u2014 ${p} edit${p!==1?"s":""}`);e.push("")}if(G.length){e.push("## Developer preferences","");for(const n of G)e.push(`- ${n.summary}`);e.push("")}if(C.length||_){if(e.push("## Git activity this session",""),C.length){e.push("**Commits:**");for(const n of C)e.push(`- \`${n}\``);e.push("")}_&&(e.push("**Uncommitted changes:**"),e.push("```"),e.push(_.split(`
1
+ import*as A from"node:fs";import*as m from"node:path";import"node:os";import{execSync as T}from"node:child_process";import{bold as z,cyan as O,gray as rt,green as ct,yellow as K,red as ut}from"../ui/output.mjs";import{ampPaths as ht,readEntries as dt,appendEntry as gt}from"../amp/io.mjs";const _="inferno";function M(){return ht(process.cwd())}const mt=m.join(_,"HANDOFF.md"),Ot=m.join(_,"sessions.jsonl"),X=m.join(_,"context-state.json"),q=m.join(_,"contract.json"),Q=m.join(_,"theme.json"),Y=m.join(_,"adoption_profile.json");function u(t){try{return JSON.parse(A.readFileSync(t,"utf8"))}catch{return null}}function lt(t){try{return A.readFileSync(t,"utf8")}catch{return null}}function Z(t){return t?new Date(t).toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}):"unknown"}function tt(t){if(t<0)return"unknown";const i=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return i>0?`${i}h ${a}m`:`${a}m`}function et(){return dt(process.cwd())}function ot(t,i,a){if(a)return new Date(0);if(i){const r=i.match(/^(\d+)h$/i),h=i.match(/^(\d+)d$/i);if(r)return new Date(Date.now()-parseInt(r[1])*36e5);if(h)return new Date(Date.now()-parseInt(h[1])*864e5);const F=new Date(i);if(!isNaN(F.getTime()))return F}const o=new Date(Date.now()-864e5),c=[];for(const r of t)if(r.type==="handoff"){const h=new Date(r.ts||0);isNaN(h.getTime())||c.push(h)}if(c.length===0)return o;const s=300*1e3,y=c[c.length-1];if(Date.now()-y.getTime()<s){if(c.length>=2){const r=c[c.length-2];return r>o?r:o}return o}return y>o?y:o}function yt(t){try{const i=process.platform;if(i==="win32")T("clip",{input:t});else if(i==="darwin")T("pbcopy",{input:t});else try{T("xclip -selection clipboard",{input:t})}catch{T("xsel --clipboard --input",{input:t})}return!0}catch{return!1}}function nt(){if(process.env.CURSOR_SESSION)return"Cursor";if(process.env.COPILOT_SESSION)return"GitHub Copilot";if(process.env.CLAUDE_CODE_SESSION)return"Claude Code";if(process.env.WINDSURF_SESSION)return"Windsurf";if(process.env.TERM_PROGRAM==="vscode")return"VS Code";const t=u(Y);return t?.ide?t.ide:null}function wt(){try{const t=T("git diff --stat HEAD 2>/dev/null || git diff --cached --stat 2>/dev/null",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();return t||T("git log --stat -1 --pretty= 2>/dev/null",{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function at(t){try{const i=t&&t.getTime()>0?`--after="${t.toISOString()}"`:"-10",a=T(`git log ${i} --name-only --pretty=format: 2>/dev/null`,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(!a)return[];const o={};for(const c of a.split(`
2
+ `)){const s=c.trim();s&&(o[s]=(o[s]||0)+1)}return Object.entries(o).sort((c,s)=>s[1]-c[1]).slice(0,5).map(([c,s])=>({file:c,edits:s}))}catch{return[]}}function st(t){try{const i=t?`--after="${t.toISOString()}"`:"-5",a=T(`git log ${i} --pretty=format:"%h %s" 2>/dev/null`,{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();return a?a.split(`
3
+ `).filter(Boolean):[]}catch{return[]}}function ft(t){const i=[],a=t.filter(o=>o.type==="attempt"&&(o.result==="failed"||o.result==="partial"||!o.result));for(const o of a)t.find(s=>s.type==="attempt"&&s.result==="worked"&&new Date(s.ts)>new Date(o.ts)&&s.summary.toLowerCase().includes(o.summary.split(" ")[0].toLowerCase()))||i.push({text:o.summary,ts:o.ts,kind:"unresolved-attempt"});for(const o of t)/\b(TODO|WIP|FIXME|BLOCKED|pending)\b/i.test(o.summary)&&(i.find(c=>c.text===o.summary)||i.push({text:o.summary,ts:o.ts,kind:"flagged"}));return i.slice(0,8)}function St(t,i,a){const o=u(X)||{},c=u(q)||{},s=u(Q),y=u(Y),S=et(),r=ot(S,i,a),h=S.filter(n=>new Date(n.ts||0)>r),F=S.slice(-5),E=new Date,d=E.toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),b=c.policyId||m.basename(process.cwd()),N=c.policyVersion||"?",j=(c.capabilities||[]).slice(0,20),x=nt(),R=r.getTime()>0?E.getTime()-r.getTime():-1,v=tt(R),H=r.getTime()>0?r.getTime().toString(16).slice(-6).toUpperCase():"ALL",k=st(r.getTime()>0?r:null),L=wt(),G=at(r.getTime()>0?r:null),$=h.length>0?h:F,D=$.filter(n=>n.type==="gotcha"),l=$.filter(n=>n.type==="decision"),g=$.filter(n=>n.type==="attempt").filter(n=>n.result==="failed"||n.result==="partial"),W=$.filter(n=>n.type==="preference"),it=$.slice(-8),B=ft($),w=r.getTime()===0?"all time":r.toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}),I=["sessions.jsonl"];(o.working||o.intent)&&I.push("context-state.json"),s&&I.push("theme.json"),c.capabilities?.length&&I.push("contract.json"),y&&I.push("adoption_profile.json"),k.length&&I.push("git log");const P=D.length,U=l.length,V=g.length;let C=Math.min(P*20,40)+Math.min(U*15,30)+Math.min(V*15,20);C=Math.min(C,100);const pt=C>=80?"A":C>=60?"B":C>=40?"C":C>=20?"D":"F",e=[`# \u{1F525} infernoflow Handoff \u2014 ${b}`,`> Generated: ${d}${t?` | Handing off to: **${t}**`:""}`,`> Session: **#${H}** \xB7 ${v} \xB7 **${h.length} entries** \xB7 Health: **${pt}** (${C}/100)`,`> Sources: ${I.join(" \xB7 ")}${x?` \xB7 IDE: ${x}`:""}`,"","---",""];if((o.working||o.intent)&&(e.push("## \u{1F3AF} Working on",""),o.working&&e.push(`**${o.working}** _(${Z(o.workingUpdated)})_`),o.intent&&e.push(`Intent: ${o.intent} _(${Z(o.intentUpdated)})_`),e.push("")),D.length&&(e.push(`## \u26A0\uFE0F STOP \u2014 Read These Before Doing Anything (${D.length} gotcha${D.length===1?"":"s"})`,""),D.forEach((n,p)=>{e.push(`${p+1}. **${n.summary}**`);const f=n.file||n.source;if(f&&/[\\/.]/.test(f)){const J=n.line?`${f}:${n.line}`:f;e.push(` \u2192 File: \`${J}\``)}}),e.push("")),l.length&&(e.push("## \u2713 Decisions In Effect \u2014 Follow These",""),l.forEach((n,p)=>{const f=n.result?` \u2192 **${n.result}**`:"";e.push(`${p+1}. ${n.summary}${f}`)}),e.push("")),g.length&&(e.push("## \u274C Already Tried \u2014 Don't Repeat",""),g.forEach((n,p)=>{const f=n.file||n.source,J=f&&/[\\/.]/.test(f)?` (\`${f}\`)`:"";e.push(`${p+1}. ${n.summary}${J} _(${Z(n.ts)})_`)}),e.push("")),G.length){e.push("## \u{1F4C1} Hot Files This Session","");for(const{file:n,edits:p}of G)e.push(`- \`${n}\` \u2014 ${p} edit${p!==1?"s":""}`);e.push("")}if(W.length){e.push("## Developer preferences","");for(const n of W)e.push(`- ${n.summary}`);e.push("")}if(k.length||L){if(e.push("## Git activity this session",""),k.length){e.push("**Commits:**");for(const n of k)e.push(`- \`${n}\``);e.push("")}L&&(e.push("**Uncommitted changes:**"),e.push("```"),e.push(L.split(`
4
4
  `).slice(0,15).join(`
5
- `)),e.push("```"),e.push(""))}if(s){if(e.push("## Design system",""),s.fonts?.primary&&e.push(`- **Font:** ${s.fonts.primary}${s.fonts.mono?` \xB7 mono: ${s.fonts.mono}`:""}`),s.colors?.mode&&e.push(`- **Mode:** ${s.colors.mode}`),s.colors?.palette){const n=Object.entries(s.colors.palette).map(([p,f])=>`${p}=${f}`).join(" ");e.push(`- **Palette:** ${n}`)}if(s.cssVars&&Object.keys(s.cssVars).length){const n=Object.entries(s.cssVars).slice(0,6).map(([p,f])=>`${p}: ${f}`).join(" | ");e.push(`- **CSS vars:** ${n}`)}s.framework&&e.push(`- **Framework:** ${s.framework}`),e.push("","> \u26A0 Always match these exactly. Do not introduce new colors or fonts.","")}return O.length&&(e.push("## Capability contract",""),e.push(`Project: **${j}** v${E}`),e.push(`Capabilities: ${O.join(", ")}`),e.push("")),e.push("---"),e.push(`_Session #${L} \xB7 ${k} \xB7 Generated by infernoflow._`),e.join(`
6
- `)}async function Ft(t){const i=r=>t.includes(r),l=r=>{const h=t.indexOf(r);return h!==-1&&t[h+1]?t[h+1]:null},o=i("--show")||i("-s"),c=i("--copy")||i("-c"),s=i("--json"),A=i("--all"),D=l("--since"),a=l("--to")||t.find(r=>!r.startsWith("-")&&!["switch"].includes(r))||null;console.log(`
7
- `+V("\u{1F525} infernoflow \u2014 switch")),console.log(" "+"\u2500".repeat(50)+`
8
- `);const N=m.join(process.cwd(),".ai-memory");if(!b.existsSync(F)&&!b.existsSync(N)&&(console.error(pt(` \u2718 not initialized \u2014 run: infernoflow init
9
- `)),process.exit(1)),o){const r=mt(gt);if(!r){console.log(J(` \u26A0 No HANDOFF.md yet \u2014 run: infernoflow switch
10
- `));return}console.log(r);return}const H=St(a,D,A);if(s){const r=u(K)||{},h=u(X)||{},v=u(q),G=u(Q),W=tt(),g=et(W,D,A),st=W.filter(P=>new Date(P.ts||0)>g),w=nt(g.getTime()>0?g:null),B=ot();console.log(JSON.stringify({state:r,contract:{policyId:h.policyId,policyVersion:h.policyVersion,capabilities:h.capabilities},theme:v,adoption:G,sessions:st,commits:w,ide:B,sessionStart:g.toISOString(),sessionId:g.getTime()>0?g.getTime().toString(16).slice(-6).toUpperCase():"ALL",sessionDuration:Z(g.getTime()>0?Date.now()-g.getTime():-1),generatedAt:new Date().toISOString()},null,2));return}b.writeFileSync(z().handoff,H,"utf8"),console.log(rt(" \u2714 Written \u2192 "+m.relative(process.cwd(),z().handoff)+`
11
- `));const I=tt(),d=et(I,D,A),j=I.filter(r=>new Date(r.ts||0)>d),E=u(K)||{},O=u(q),x=u(X)||{},M=nt(d.getTime()>0?d:null),k=ct(d.getTime()>0?d:null),L=ot(),C=j.length>0?j:I.slice(-5),_=lt(C),R=Z(d.getTime()>0?Date.now()-d.getTime():-1),y=d.getTime()>0?d.getTime().toString(16).slice(-6).toUpperCase():"ALL";if(console.log(" "+V("Handoff ready")),console.log(" "+"\u2500".repeat(50)),console.log(" "+it("Session #"+y+" \xB7 "+R)),E.working&&console.log(" Working on "+$(E.working)),E.intent&&console.log(" Intent "+$(E.intent)),console.log(" Memory "+j.length+" entries this session (total: "+I.length+")"),_.length&&console.log(" Open threads "+J(_.length+" unresolved")),M.length&&console.log(" Git commits "+M.length+" this session"),k.length&&console.log(" Hot files "+k.map(r=>$(r.file)).join(", ")),console.log(" Capabilities "+(x.capabilities||[]).length+" registered"),O?.fonts?.primary&&console.log(" Font "+O.fonts.primary),O?.colors?.mode&&console.log(" Color mode "+O.colors.mode),L&&console.log(" IDE "+L),a&&console.log(" Handing off \u2192 "+$(a)),console.log(),c){const r=yt(H);console.log(r?rt(" \u2714 Copied to clipboard \u2014 paste at the start of your next AI session"):J(" \u26A0 Clipboard failed \u2014 open inferno/HANDOFF.md manually"))}else console.log(" "+V("Ready to use:")),console.log(" "+$("1.")+" Open "+$("inferno/HANDOFF.md")),console.log(" "+$("2.")+" Copy all"),console.log(" "+$("3.")+" Paste at the start of your next AI session"),console.log(" "+it(" tip: use --copy to skip steps 1-2 automatically"));if(console.log(),b.existsSync(z().sessions)){const r={ts:new Date().toISOString(),agent:"infernoflow",type:"handoff",summary:a?`Handed off to ${a}`:"Handoff generated"};ht(process.cwd(),r)}}export{Ft as switchCommand};
5
+ `)),e.push("```"),e.push(""))}if(s){if(e.push("## Design system",""),s.fonts?.primary&&e.push(`- **Font:** ${s.fonts.primary}${s.fonts.mono?` \xB7 mono: ${s.fonts.mono}`:""}`),s.colors?.mode&&e.push(`- **Mode:** ${s.colors.mode}`),s.colors?.palette){const n=Object.entries(s.colors.palette).map(([p,f])=>`${p}=${f}`).join(" ");e.push(`- **Palette:** ${n}`)}if(s.cssVars&&Object.keys(s.cssVars).length){const n=Object.entries(s.cssVars).slice(0,6).map(([p,f])=>`${p}: ${f}`).join(" | ");e.push(`- **CSS vars:** ${n}`)}s.framework&&e.push(`- **Framework:** ${s.framework}`),e.push("","> \u26A0 Always match these exactly. Do not introduce new colors or fonts.","")}return j.length&&(e.push("## Capability contract",""),e.push(`Project: **${b}** v${N}`),e.push(`Capabilities: ${j.join(", ")}`),e.push("")),e.push("---"),e.push(`_Session #${H} \xB7 ${v} \xB7 Generated by infernoflow._`),e.join(`
6
+ `)}async function Ft(t){const i=l=>t.includes(l),a=l=>{const g=t.indexOf(l);return g!==-1&&t[g+1]?t[g+1]:null},o=i("--show")||i("-s"),c=i("--copy")||i("-c"),s=i("--json"),y=i("--all"),S=a("--since"),r=a("--to")||t.find(l=>!l.startsWith("-")&&!["switch"].includes(l))||null;console.log(`
7
+ `+z("\u{1F525} infernoflow \u2014 switch")),console.log(" "+"\u2500".repeat(50)+`
8
+ `);const h=m.join(process.cwd(),".ai-memory");if(!A.existsSync(_)&&!A.existsSync(h)&&(console.error(ut(` \u2718 not initialized \u2014 run: infernoflow init
9
+ `)),process.exit(1)),o){const l=lt(M().handoff)||lt(mt);if(!l){console.log(K(` \u26A0 No handoff yet \u2014 run: infernoflow switch
10
+ `));return}console.log(l);return}const F=St(r,S,y);if(s){const l=u(X)||{},g=u(q)||{},W=u(Q),it=u(Y),B=et(),w=ot(B,S,y),I=B.filter(V=>new Date(V.ts||0)>w),P=st(w.getTime()>0?w:null),U=nt();console.log(JSON.stringify({state:l,contract:{policyId:g.policyId,policyVersion:g.policyVersion,capabilities:g.capabilities},theme:W,adoption:it,sessions:I,commits:P,ide:U,sessionStart:w.toISOString(),sessionId:w.getTime()>0?w.getTime().toString(16).slice(-6).toUpperCase():"ALL",sessionDuration:tt(w.getTime()>0?Date.now()-w.getTime():-1),generatedAt:new Date().toISOString()},null,2));return}A.writeFileSync(M().handoff,F,"utf8"),console.log(ct(" \u2714 Written \u2192 "+m.relative(process.cwd(),M().handoff)+`
11
+ `));const E=et(),d=ot(E,S,y),b=E.filter(l=>new Date(l.ts||0)>d),N=u(X)||{},j=u(Q),x=u(q)||{},R=st(d.getTime()>0?d:null),v=at(d.getTime()>0?d:null),H=nt(),k=b.length>0?b:E.slice(-5),L=ft(k),G=tt(d.getTime()>0?Date.now()-d.getTime():-1),$=d.getTime()>0?d.getTime().toString(16).slice(-6).toUpperCase():"ALL";console.log(" "+z("Handoff ready")),console.log(" "+"\u2500".repeat(50)),console.log(" "+rt("Session #"+$+" \xB7 "+G)),N.working&&console.log(" Working on "+O(N.working)),N.intent&&console.log(" Intent "+O(N.intent)),console.log(" Memory "+b.length+" entries this session (total: "+E.length+")"),L.length&&console.log(" Open threads "+K(L.length+" unresolved")),R.length&&console.log(" Git commits "+R.length+" this session"),v.length&&console.log(" Hot files "+v.map(l=>O(l.file)).join(", ")),console.log(" Capabilities "+(x.capabilities||[]).length+" registered"),j?.fonts?.primary&&console.log(" Font "+j.fonts.primary),j?.colors?.mode&&console.log(" Color mode "+j.colors.mode),H&&console.log(" IDE "+H),r&&console.log(" Handing off \u2192 "+O(r)),console.log();const D=m.relative(process.cwd(),M().handoff)||".ai-memory/handoff.md";if(c){const l=yt(F);console.log(l?ct(" \u2714 Copied to clipboard \u2014 paste at the start of your next AI session"):K(" \u26A0 Clipboard failed \u2014 open "+D+" manually"))}else console.log(" "+z("Ready to use:")),console.log(" "+O("1.")+" Open "+O(D)),console.log(" "+O("2.")+" Copy all"),console.log(" "+O("3.")+" Paste at the start of your next AI session"),console.log(" "+rt(" tip: use --copy to skip steps 1-2 automatically"));if(console.log(),A.existsSync(M().sessions)){const l={ts:new Date().toISOString(),agent:"infernoflow",type:"handoff",summary:r?`Handed off to ${r}`:"Handoff generated"};gt(process.cwd(),l)}}export{Ft as switchCommand};
@@ -18,8 +18,10 @@ const require = createRequire(import.meta.url);
18
18
  * in node_modules of the CWD or one of its parents.
19
19
  * Returns null if neither finds infernoflow.
20
20
  */
21
- function findInfernoflowRoot() {
22
- let dir = path.dirname(fileURLToPath(import.meta.url));
21
+ function walkUpForInfernoflow(startFile) {
22
+ let dir;
23
+ try { dir = path.dirname(fs.realpathSync(startFile)); }
24
+ catch { dir = path.dirname(startFile); }
23
25
  while (true) {
24
26
  const pj = path.join(dir, "package.json");
25
27
  if (fs.existsSync(pj)) {
@@ -32,9 +34,46 @@ function findInfernoflowRoot() {
32
34
  if (parent === dir) break;
33
35
  dir = parent;
34
36
  }
37
+ return null;
38
+ }
39
+
40
+ function findInfernoflowRoot() {
41
+ // 1. Walk up from this template's own location.
42
+ // Works when the template runs from inside infernoflow-pkg/ or from a
43
+ // project's .cursor/ copy that has node_modules/infernoflow/ in scope.
44
+ const fromHere = walkUpForInfernoflow(fileURLToPath(import.meta.url));
45
+ if (fromHere) return fromHere;
46
+
47
+ // 2. require.resolve — works when infernoflow is in CWD's node_modules.
35
48
  try {
36
49
  return path.dirname(require.resolve("infernoflow/package.json"));
37
50
  } catch {}
51
+
52
+ // 3. Resolve via the global install on PATH.
53
+ // When the user runs `npm install -g infernoflow` and `init` copies this
54
+ // template into their .cursor/, neither (1) nor (2) can find the package
55
+ // — there's no parent package.json above .cursor/ with name=infernoflow,
56
+ // and the user's project doesn't depend on infernoflow locally. Without
57
+ // this branch the MCP server boots with v0.0.0-unknown.
58
+ try {
59
+ const lookup = process.platform === "win32" ? "where infernoflow" : "which infernoflow";
60
+ const out = execSync(lookup, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
61
+ for (const candidate of out.split(/\r?\n/).map(s => s.trim()).filter(Boolean)) {
62
+ if (!fs.existsSync(candidate)) continue;
63
+ const binDir = path.dirname(candidate);
64
+ // Windows layout: <npm-prefix>/infernoflow.cmd + <npm-prefix>/node_modules/infernoflow/
65
+ // Unix layout: <npm-prefix>/bin/infernoflow + <npm-prefix>/lib/node_modules/infernoflow/
66
+ for (const layout of [
67
+ path.join(binDir, "node_modules", "infernoflow"),
68
+ path.join(binDir, "..", "lib", "node_modules", "infernoflow"),
69
+ ]) {
70
+ if (fs.existsSync(path.join(layout, "package.json"))) {
71
+ try { return fs.realpathSync(layout); } catch { return layout; }
72
+ }
73
+ }
74
+ }
75
+ } catch {}
76
+
38
77
  return null;
39
78
  }
40
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infernoflow",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
4
4
  "description": "Persistent memory for AI coding sessions — captures what agents can't infer from code alone. Works with Copilot, Cursor, Claude, and Windsurf.",
5
5
  "type": "module",
6
6
  "bin": {