infernoflow 0.44.3 → 0.44.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/infernoflow.mjs +7 -7
- package/dist/lib/amp/io.mjs +16 -10
- package/dist/lib/commands/doctor.mjs +2 -2
- package/dist/lib/commands/log.mjs +8 -8
- package/dist/lib/commands/prune.mjs +4 -0
- package/dist/lib/commands/refresh.mjs +5 -5
- package/dist/lib/commands/setup.mjs +5 -5
- package/dist/lib/ruleFiles.mjs +11 -8
- package/dist/templates/cursor/hooks/inferno-session-draft.mjs +88 -0
- package/dist/templates/cursor/hooks.json +5 -0
- package/package.json +1 -1
package/dist/bin/infernoflow.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
(function(){if(process.platform!=="win32"||process.env.WT_SESSION||process.env.ConEmuPID||process.env.TERM_PROGRAM==="vscode")return;const
|
|
3
|
-
`)}const O={"Memory (the 5-command core)":["log","ask","switch","recap","status","refresh","forget"],Setup:["init","setup","doctor","context"],"IDE wiring":["install-cursor-hooks","install-vscode-copilot-hooks","generate-skills"],Configuration:["ai","telemetry","sync","uninstall"],Contract:["check"],"AMP (use: infernoflow amp <verb>)":["status","migrate","validate","version"]};function b(){return Object.entries(O).map(([o,
|
|
4
|
-
${
|
|
2
|
+
(function(){if(process.platform!=="win32"||process.env.WT_SESSION||process.env.ConEmuPID||process.env.TERM_PROGRAM==="vscode")return;const s={"\u2500":"-","\u2501":"-","\u2550":"=","\u2502":"|","\u2503":"|","\u2551":"|","\u250C":"+","\u2510":"+","\u2514":"+","\u2518":"+","\u251C":"+","\u2524":"+","\u252C":"+","\u2534":"+","\u253C":"+","\xB7":"*","\u2192":"->","\u2190":"<-","\u2714":"[OK]","\u2713":"[OK]","\u2718":"[X]","\u2717":"[X]","\u26A0":"[!]",\u2139:"[i]"},r=new RegExp(Object.keys(s).join("|"),"g"),l=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}\u{2B00}-\u{2BFF}\u{200D}]\u{FE0F}? ?/gu,f=c=>c.replace(r,p=>s[p]).replace(l,"");function u(c){const p=c.write.bind(c);c.write=function(a,...C){return typeof a=="string"?a=f(a):Buffer.isBuffer(a)&&(a=Buffer.from(f(a.toString("utf8")),"utf8")),p(a,...C)}}u(process.stdout),u(process.stderr)})();import{readFileSync as $}from"node:fs";import{dirname as k,join as y}from"node:path";import{fileURLToPath as v}from"node:url";import{bold as i,gray as e,cyan as t,red as g}from"../lib/ui/output.mjs";const A=k(v(import.meta.url));function I(o){for(const s of[y(o,"..","..","package.json"),y(o,"..","package.json")])try{return JSON.parse($(s,"utf8"))}catch{}return{version:"0.0.0-source"}}const M=I(A),m=M.version||"0.0.0",h={log:"Append to session memory (decisions, gotchas, failed attempts)",ask:"Query memory by keyword (gotchas surface first)",switch:"Generate a handoff doc for the next AI agent / session",recap:"End-of-session summary + health score + unlogged-change surfacing",status:"Quick health check \u2014 entries, gotchas, decisions, last activity",refresh:"Rebuild CLAUDE.md / .cursorrules / copilot-instructions.md from memory",forget:"Delete a memory entry by id or unique prefix (--last for the newest)",prune:"Archive stale notes/attempts (gotchas/decisions never touched) \u2014 see --apply",init:"Scaffold .ai-memory/ and wire the current IDE in one command",setup:"Re-run wiring (idempotent) \u2014 detects IDE, installs MCP + hooks",doctor:"Diagnose your setup \u2014 Node, git, contract, AI provider, MCP, hooks",context:"Generate AI-ready context for new sessions","install-cursor-hooks":"Install Cursor hooks (afterAgentResponse + stop)","install-vscode-copilot-hooks":"Install VS Code + Copilot agent hooks (Preview)","generate-skills":"Generate Cursor rules + skill files from your developer profile",ai:"Manage AI providers \u2014 setup, status, test, clear",telemetry:"Opt-in anonymous telemetry (on | off | status)",uninstall:"Remove infernoflow from a project (--dry-run to preview)",check:"Validate contract, capabilities, scenarios, changelog",sync:"Cross-machine sync for personal memory \u2014 status/set/clear/migrate",amp:"AI Memory Protocol \u2014 status, migrate, validate (run: infernoflow amp)"},d={log:async o=>(await import("../lib/commands/log.mjs")).logCommand(o),ask:async o=>(await import("../lib/commands/ask.mjs")).askCommand(o),switch:async o=>(await import("../lib/commands/switch.mjs")).switchCommand(o),recap:async o=>(await import("../lib/commands/recap.mjs")).recapCommand(o),status:async o=>(await import("../lib/commands/status.mjs")).statusCommand(o),refresh:async o=>(await import("../lib/commands/refresh.mjs")).refreshCommand(o),forget:async o=>(await import("../lib/commands/forget.mjs")).forgetCommand(o),prune:async o=>(await import("../lib/commands/prune.mjs")).pruneCommand(o),init:async o=>(await import("../lib/commands/init.mjs")).initCommand(o),setup:async o=>(await import("../lib/commands/setup.mjs")).setupCommand(o),doctor:async o=>(await import("../lib/commands/doctor.mjs")).doctorCommand(o),context:async o=>(await import("../lib/commands/context.mjs")).contextCommand(o),"install-cursor-hooks":async o=>(await import("../lib/commands/installCursorHooks.mjs")).installCursorHooksCommand(o),"install-vscode-copilot-hooks":async o=>(await import("../lib/commands/installVsCodeCopilotHooks.mjs")).installVsCodeCopilotHooksCommand(o),"generate-skills":async o=>(await import("../lib/commands/generateSkills.mjs")).generateSkillsCommand(o),ai:async o=>(await import("../lib/commands/ai.mjs")).aiCommand(o),telemetry:async o=>(await import("../lib/telemetry.mjs")).telemetryCommand(o),uninstall:async o=>(await import("../lib/commands/uninstall.mjs")).uninstallCommand(o),check:async o=>(await import("../lib/commands/check.mjs")).checkCommand(o),sync:async o=>(await import("../lib/commands/sync.mjs")).syncCommand(o),amp:async o=>(await import("../lib/commands/amp.mjs")).ampCommand(o)};function G(){const o=Object.keys(h),s=Math.max(...o.map(r=>r.length),8)+1;return Object.entries(h).map(([r,l])=>` ${r.padEnd(s," ")}${l}`).join(`
|
|
3
|
+
`)}const O={"Memory (the 5-command core)":["log","ask","switch","recap","status","refresh","forget","prune"],Setup:["init","setup","doctor","context"],"IDE wiring":["install-cursor-hooks","install-vscode-copilot-hooks","generate-skills"],Configuration:["ai","telemetry","sync","uninstall"],Contract:["check"],"AMP (use: infernoflow amp <verb>)":["status","migrate","validate","version"]};function b(){return Object.entries(O).map(([o,s])=>` ${i(o+":")}
|
|
4
|
+
${s.join(" ")}`).join(`
|
|
5
5
|
|
|
6
6
|
`)}const w=Object.keys(d).length,E=`
|
|
7
7
|
${i("\u{1F525} infernoflow")} ${e("v"+m)}
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
|
|
29
29
|
${e("Run")} ${t("infernoflow commands")} ${e("to see all "+w+" commands grouped.")}
|
|
30
30
|
${e("Run")} ${t("infernoflow <command> --help")} ${e("for command-specific options.")}
|
|
31
|
-
`;import*as R from"node:fs";import*as S from"node:path";try{const o=S.join(process.cwd(),"inferno");if(R.existsSync(o)){const{observeCommandStart:
|
|
31
|
+
`;import*as R from"node:fs";import*as S from"node:path";try{const o=S.join(process.cwd(),"inferno");if(R.existsSync(o)){const{observeCommandStart:s}=await import("../lib/learning/observe.mjs"),r=process.argv[2];r&&!r.startsWith("-")&&s(o,r)}}catch{}const[,,n,...x]=process.argv;(!n||n==="--help"||n==="-h")&&(console.log(E),process.exit(0)),(n==="--version"||n==="-v")&&(console.log(m),process.exit(0)),n==="commands"&&(console.log(`
|
|
32
32
|
${i("\u{1F525} infernoflow")} ${e("v"+m)} ${e("\u2014 all "+w+" commands")}
|
|
33
33
|
`),console.log(b()),console.log(`
|
|
34
34
|
${e("Run")} ${t("infernoflow <command> --help")} ${e("for options.")}
|
|
35
|
-
`),process.exit(0));const D=Object.keys(d);D.includes(
|
|
36
|
-
Unknown command: ${
|
|
37
|
-
`)),process.exit(1));const P=[
|
|
35
|
+
`),process.exit(0));const D=Object.keys(d);D.includes(n)||(console.error(g(`
|
|
36
|
+
Unknown command: ${n}`)),console.error(e("Run: infernoflow commands (see all commands)")),console.error(e(`Run: infernoflow --help (quick start)
|
|
37
|
+
`)),process.exit(1));const P=[n,...x];try{const{runUpgradeBackfillIfNeeded:o}=await import("../lib/upgradeCheck.mjs");await o(m,n)}catch{}d[n](P).catch(o=>{console.error(g(`
|
|
38
38
|
Error: `)+o.message),process.exit(1)});
|
package/dist/lib/amp/io.mjs
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import*as i from"node:fs";import*as
|
|
2
|
-
`).filter(Boolean).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(Boolean).map(
|
|
3
|
-
`;if(i.mkdirSync(r.dirname(n),{recursive:!0}),i.appendFileSync(n,l,"utf8"),n!==o.sessions)try{i.mkdirSync(r.dirname(o.sessions),{recursive:!0}),i.appendFileSync(o.sessions,l,"utf8")}catch{}return
|
|
4
|
-
`)}catch{continue}const
|
|
1
|
+
import*as i from"node:fs";import*as C from"node:os";import*as r from"node:path";import{findProjectRoot as B}from"../projectRoot.mjs";import{getBranchInfo as J}from"../git/branch.mjs";const E="1.0",M=new Set(["gotcha","decision","attempt","note","detection","pattern"]),_=new Set(["copilot","cursor","claude","windsurf","other"]);function L(e){let t=r.basename(r.resolve(e));try{const o=r.join(e,".ai-memory","amp.json");if(i.existsSync(o)){const n=JSON.parse(i.readFileSync(o,"utf8"));n&&typeof n.project=="string"&&n.project.trim()&&(t=n.project.trim())}}catch{}return t.toLowerCase().replace(/[^a-z0-9_.\-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"unnamed-project"}function P(e,t){let o=process.env.INFERNOFLOW_GLOBAL_DIR;if(!o)try{const l=JSON.parse(i.readFileSync(r.join(t,"amp.json"),"utf8"));l&&typeof l.globalDir=="string"&&l.globalDir.trim()&&(o=l.globalDir.trim())}catch{}if(!o)return r.join(t,"global.jsonl");let n=o;n.startsWith("~")&&(n=r.join(C.homedir(),n.slice(1).replace(/^[\/\\]/,""))),r.isAbsolute(n)||(n=r.resolve(e,n));const c=L(e);return r.join(n,c,"global.jsonl")}function S(e,t={}){const o=t.literal?r.resolve(e):B(e),n=r.join(o,".ai-memory"),c=r.join(o,"inferno"),l=t.forWrite||i.existsSync(n)||!i.existsSync(c),a=l?n:c,s=l,u=r.join(a,"branches"),f=J(o),d=r.join(u,`${f.currentSlug}.jsonl`),p=f.defaultSlug?r.join(u,`${f.defaultSlug}.jsonl`):null,m=W(o,a);return{root:a,projectRoot:o,isAmp:s,sessions:r.join(a,"sessions.jsonl"),config:r.join(a,s?"amp.json":"config.json"),handoff:r.join(a,s?"handoff.md":"HANDOFF.md"),globalFile:m,branchesDir:u,currentBranchFile:d,defaultBranchFile:p,branch:f}}function W(e,t){try{return P(e,t)}catch{return r.join(t,"global.jsonl")}}function v(e){const t=B(e),o=r.join(t,".ai-memory");return i.existsSync(o)||i.mkdirSync(o,{recursive:!0}),o}const N="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function $(){let e=Date.now(),t="";for(let n=0;n<10;n++)t=N[e%32]+t,e=Math.floor(e/32);let o="";for(let n=0;n<16;n++)o+=N[Math.floor(Math.random()*32)];return t+o}function k(e){const t={...e.meta||{}};let o=e.type||"note";M.has(o)||(t.subtype=o,o="note"),e.result&&(t.result=e.result);let n;const c=e.agent;c&&_.has(c)?n=c:c&&(t.agent=c);const l=typeof e.ts=="number"?e.ts:e.ts?Date.parse(e.ts):Date.now(),a=e.confidence!=null?e.confidence:e.auto?.7:void 0,s={type:o,msg:e.summary||e.msg||"",ts:l,id:e.id||`amp_${$()}`};return e.file&&(s.file=e.file),e.line&&(s.line=e.line),e.function&&(s.function=e.function),e.tags&&e.tags.length&&(s.tags=e.tags),e.source&&(s.source=e.source),n&&(s.tool=n),e.session&&(s.session=e.session),a!=null&&(s.confidence=a),Object.keys(t).length&&(s.meta=t),s}function Y(e){if(e.summary&&!e.msg)return e;const t=e.meta||{},o=t.subtype||e.type||"note",n={ts:e.ts,type:o,summary:e.msg||""};e.id&&(n.id=e.id),e.file&&(n.file=e.file),e.line&&(n.line=e.line),e.function&&(n.function=e.function),e.tags&&(n.tags=e.tags),e.source&&(n.source=e.source),e.tool&&(n.agent=e.tool),t.agent&&(n.agent=t.agent),t.result&&(n.result=t.result),e.confidence!=null&&(n.confidence=e.confidence,e.confidence<1&&(n.auto=!0));const{subtype:c,agent:l,result:a,...s}=t;return Object.keys(s).length&&(n.meta=s),n}function G(e){if(!e||!i.existsSync(e))return[];try{return i.readFileSync(e,"utf8").split(`
|
|
2
|
+
`).filter(Boolean).map(t=>{try{return JSON.parse(t)}catch{return null}}).filter(Boolean).map(Y)}catch{return[]}}function te(e){const t=S(e),o=new Set,n=[],c=[t.sessions,t.globalFile,t.defaultBranchFile,t.currentBranchFile],l=[...new Set(c.filter(Boolean))];for(const a of l)for(const s of G(a)){const u=s.id||`${s.ts}|${s.summary}`;o.has(u)||(o.add(u),n.push(s))}return n.sort((a,s)=>{const u=typeof a.ts=="number"?a.ts:Date.parse(a.ts||0),f=typeof s.ts=="number"?s.ts:Date.parse(s.ts||0);return u-f})}function U(e,t){return t.target==="global"?e.globalFile:t.target==="legacy"?e.sessions:t.target==="branch"?e.currentBranchFile:t.type==="preference"?e.globalFile:e.currentBranchFile}function ne(e,t){v(e);const o=S(e,{forWrite:!0}),n=U(o,t),c=k(t),l=JSON.stringify(c)+`
|
|
3
|
+
`;if(i.mkdirSync(r.dirname(n),{recursive:!0}),i.appendFileSync(n,l,"utf8"),n!==o.sessions)try{i.mkdirSync(r.dirname(o.sessions),{recursive:!0}),i.appendFileSync(o.sessions,l,"utf8")}catch{}return c}function oe(e,t){if(!t)return{removed:0,files:[]};const o=S(e),n=[o.sessions,o.globalFile,o.currentBranchFile,o.defaultBranchFile].filter(Boolean);try{if(i.existsSync(o.branchesDir))for(const s of i.readdirSync(o.branchesDir))s.endsWith(".jsonl")&&n.push(r.join(o.branchesDir,s))}catch{}const c=[...new Set(n)];let l=0;const a=[];for(const s of c){if(!i.existsSync(s))continue;let u;try{u=i.readFileSync(s,"utf8").split(`
|
|
4
|
+
`)}catch{continue}const f=[];let d=0;for(const p of u){if(!p.trim())continue;let m;try{m=JSON.parse(p).id}catch{f.push(p);continue}if(m===t){d++,l++;continue}f.push(p)}d>0&&(i.writeFileSync(s,f.length?f.join(`
|
|
5
5
|
`)+`
|
|
6
|
-
`:"","utf8"),
|
|
7
|
-
|
|
8
|
-
`)
|
|
9
|
-
|
|
6
|
+
`:"","utf8"),a.push(s))}return{removed:l,files:a}}const H=30,V=["note","attempt","detection"],w=new Set(["gotcha","decision","pattern"]);function z(e){const t=e&&e.config&&e.config.rotation&&typeof e.config.rotation=="object"?e.config.rotation:{};return{archiveAfterDays:Number.isInteger(t.archiveAfterDays)&&t.archiveAfterDays>0?t.archiveAfterDays:H,archivableTypes:Array.isArray(t.archivableTypes)&&t.archivableTypes.length?t.archivableTypes:V,auto:t.auto===!0}}function q(e){const t=[e.sessions,e.currentBranchFile,e.defaultBranchFile].filter(Boolean);try{if(i.existsSync(e.branchesDir))for(const o of i.readdirSync(e.branchesDir))o.endsWith(".jsonl")&&t.push(r.join(e.branchesDir,o))}catch{}return[...new Set(t)]}function K(e,t){const o=new Date(t),n=o.getUTCFullYear(),c=String(o.getUTCMonth()+1).padStart(2,"0");return r.join(e,"archive",`sessions-${n}-${c}.jsonl`)}function se(e,t={}){const o=S(e,{forWrite:!t.dryRun}),n=z(Q(e)),c=Number.isFinite(t.maxAgeDays)?t.maxAgeDays:n.archiveAfterDays,l=t.archive!==!1,a=new Set((Array.isArray(t.types)&&t.types.length?t.types:n.archivableTypes).filter(h=>!w.has(h))),s=Date.now()-c*24*60*60*1e3,u=q(o),f={scanned:0,archived:0,kept:0,files:[],byType:{},dryRun:!!t.dryRun},d=new Map,p=new Set,m=new Set,T=new Set;for(const h of u){if(!i.existsSync(h))continue;let b;try{b=i.readFileSync(h,"utf8").split(`
|
|
7
|
+
`)}catch{continue}const F=[];let x=0;for(const j of b){if(!j.trim())continue;let g;try{g=JSON.parse(j)}catch{F.push(j);continue}const y=g&&g.id,D=g&&typeof g.type=="string"?g.type:"note",A=typeof g.ts=="number"?g.ts:Date.parse(g.ts||0),I=Number.isFinite(A)&&A<s,R=a.has(D)&&!w.has(D);if(y&&!m.has(y)&&(m.add(y),f.scanned++),y||f.scanned++,I&&R){if(x++,(!y||!p.has(y))&&(y&&p.add(y),f.archived++,f.byType[D]=(f.byType[D]||0)+1,l)){const O=K(o.root,A);d.has(O)||d.set(O,[]),d.get(O).push(j)}}else y&&!T.has(y)&&(T.add(y),f.kept++),y||f.kept++,F.push(j)}x>0&&!t.dryRun?(i.writeFileSync(h,F.length?F.join(`
|
|
8
|
+
`)+`
|
|
9
|
+
`:"","utf8"),f.files.push(h)):x>0&&f.files.push(h)}if(!t.dryRun&&l&&d.size>0)for(const[h,b]of d)try{i.mkdirSync(r.dirname(h),{recursive:!0}),i.appendFileSync(h,b.join(`
|
|
10
|
+
`)+`
|
|
11
|
+
`,"utf8")}catch{}return f}function Q(e){const{config:t}=S(e);try{return JSON.parse(i.readFileSync(t,"utf8"))}catch{return null}}function ie(e,t={}){v(e);const{config:o}=S(e,{forWrite:!0});if(i.existsSync(o))return!1;const n={amp:E,project:t.project||r.basename(e),stack:t.stack||{},config:{autoCapture:!0,maxEntries:1e3,rotationStrategy:"archive",inject:["all"],injection:{maxEntries:4,maxCommits:5,maxEntryChars:200},rotation:{archiveAfterDays:30,archivableTypes:["note","attempt","detection"],auto:!1},...t.config||{}}};return i.writeFileSync(o,JSON.stringify(n,null,2)+`
|
|
12
|
+
`,"utf8"),!0}function re(e,t={}){v(e);const{config:o}=S(e,{forWrite:!0});let n={};try{n=JSON.parse(i.readFileSync(o,"utf8"))}catch{n={}}(!n||typeof n!="object")&&(n={}),n.amp||(n.amp=E),n.project||(n.project=r.basename(e)),(!n.config||typeof n.config!="object")&&(n.config={});const c=n.config.injection&&typeof n.config.injection=="object"?n.config.injection:{};return n.config.injection={...c,...t},i.writeFileSync(o,JSON.stringify(n,null,2)+`
|
|
13
|
+
`,"utf8"),n.config.injection}function ce(e){const t=r.join(e,"inferno"),o=r.join(t,"sessions.jsonl");if(!i.existsSync(o))return{migrated:0,reason:"no legacy sessions.jsonl"};const n=r.join(e,".ai-memory"),c=r.join(n,"sessions.jsonl");if(i.existsSync(c))return{migrated:0,reason:".ai-memory/sessions.jsonl already exists"};v(e);const l=i.readFileSync(o,"utf8").split(`
|
|
14
|
+
`).filter(Boolean);let a=0;for(const s of l)try{const u=JSON.parse(s),f=k(u);i.appendFileSync(c,JSON.stringify(f)+`
|
|
15
|
+
`,"utf8"),a++}catch{}return i.writeFileSync(r.join(n,"MIGRATED.md"),`# Migrated from inferno/
|
|
10
16
|
|
|
11
|
-
Copied ${
|
|
17
|
+
Copied ${a} entries from inferno/sessions.jsonl on ${new Date().toISOString()}.
|
|
12
18
|
|
|
13
19
|
The original inferno/sessions.jsonl is untouched. You can delete it once you're confident the new layout works.
|
|
14
|
-
`,"utf8"),{migrated:
|
|
20
|
+
`,"utf8"),{migrated:a,reason:"ok"}}export{E as AMP_VERSION,S as ampPaths,ne as appendEntry,oe as deleteEntry,v as ensureAmpDir,Y as fromAmp,$ as generateULID,ce as migrateLegacy,L as projectSlug,se as pruneEntries,Q as readConfig,te as readEntries,P as resolveGlobalFile,z as resolveRotationSettings,k as toAmp,re as updateInjectionConfig,ie as writeDefaultConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as s from"node:fs";import*as c from"node:path";import*as y from"node:os";import*as
|
|
1
|
+
import*as s from"node:fs";import*as c from"node:path";import*as y from"node:os";import*as P from"node:http";import{execSync as A,spawnSync as v}from"node:child_process";import{fileURLToPath as O}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 I}from"../ai/providerRouter.mjs";import{readEntries as _,readConfig as M}from"../amp/io.mjs";import{resolveInjectionSettings as E}from"../ruleFiles.mjs";function f(e,n){try{const o=n();return{label:e,...o}}catch(o){return{label:e,status:"error",message:o.message,fix:null}}}function a(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 T(){const e=process.version,n=parseInt(e.slice(1).split(".")[0],10);return n>=20?a(`Node.js ${e}`,"Node 20+ recommended"):n>=18?a(`Node.js ${e}`):h(`Node.js ${e} \u2014 infernoflow requires Node 18+`,"Install Node 20 from nodejs.org")}function D(){try{const e=v("infernoflow",["--version"],{encoding:"utf8",timeout:5e3,shell:process.platform==="win32"});return e.status===0?a(`infernoflow v${e.stdout.trim()} installed`):a("infernoflow CLI on PATH (version probe failed but doctor itself ran)")}catch{return a("infernoflow CLI on PATH (version probe threw but doctor itself ran)")}}function F(e){try{return A("git rev-parse --git-dir",{cwd:e,stdio:"ignore"}),a("Git repository detected")}catch{return h("Not a git repository","git init && git add . && git commit -m 'init'")}}function G(e){const n=c.join(e,".ai-memory"),o=c.join(e,"inferno");return s.existsSync(n)&&s.existsSync(o)?a(".ai-memory/ + inferno/ both present"):s.existsSync(n)?a(".ai-memory/ directory exists (memory mode)"):s.existsSync(o)?a("inferno/ directory exists"):h("No memory directory found (.ai-memory/ or inferno/)","infernoflow init")}function L(e){if(x(e)){let o=0;try{o=_(e).length}catch{}return a(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=c.join(e,"inferno");for(const o of["contract.json","capabilities.json"]){const t=c.join(n,o);if(s.existsSync(t))try{const i=(JSON.parse(s.readFileSync(t,"utf8")).capabilities||[]).length;return a(`${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=c.join(e,".ai-memory"),o=c.join(e,"inferno","contract.json");if(s.existsSync(n)&&!s.existsSync(o))return!0;try{return JSON.parse(s.readFileSync(c.join(e,"inferno","config.json"),"utf8")).mode==="memory"}catch{return!1}}function R(e){if(x(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=c.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?a(`${o.length} scenario file${o.length!==1?"s":""} found`):l("scenarios/ is empty","Add scenario files or run infernoflow suggest")}function J(e){if(x(e))return{status:"info",message:"n/a in memory mode",detail:null,fix:null};const n=c.join(e,"inferno","CHANGELOG.md");return s.existsSync(n)?a("inferno/CHANGELOG.md exists"):l("No inferno/CHANGELOG.md","infernoflow init")}function H(e){if(x(e))return{status:"info",message:"n/a in memory mode (CLAUDE.md is auto-maintained)",detail:null,fix:null};const n=c.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"):a(`CONTEXT.md present (${Math.round(o)}d old)`)}function W(e){const n=c.join(e,".git","hooks"),o=c.join(n,"post-commit"),t=c.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?a("Git hooks installed (post-commit + pre-push)"):l(r||i?"Partial git hooks installed":"Git hooks not installed","infernoflow setup --yes")}function X(e){const n=[c.join(e,".cursor","mcp.json"),c.join(e,".mcp.json"),c.join(y.homedir(),".cursor","mcp.json"),c.join(y.homedir(),"Library","Application Support","Claude","claude_desktop_config.json"),c.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 a(`MCP server configured in ${c.basename(o)}`)}catch{}return l("MCP server not configured","infernoflow setup --yes (adds to Cursor/Claude config)")}function K(e,n){const o=c.join(e,".ai-memory",".mcp-runtime.json");if(!s.existsSync(o))return a("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?a(`MCP runtime v${t.version} matches CLI`):n.startsWith("0.0.0")||t.version.startsWith("0.0.0")?a(`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 U(e){const n=E(M(e));if(!n.includeProtocol)return a("Memory-protocol injection disabled in config (injection.includeProtocol=false)");const o=n.targets,t=[];for(const r of o)try{const i=s.readFileSync(c.join(e,String(r)),"utf8");i.includes("amp_write")&&/Memory protocol/i.test(i)&&t.push(r)}catch{}return t.length?a(`Memory protocol in ${t.length}/${o.length} configured rule file(s) \u2014 AI knows when to auto-capture`):l("Memory protocol missing from rule files \u2014 the AI won't auto-capture gotchas","infernoflow refresh (writes the amp_write capture protocol into your rule files)")}function V(e){const n=I(e),o=Object.entries(n).filter(([,t])=>t).map(([t])=>t);return o.length?a(`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
|
|
3
|
+
Or use VS Code with GitHub Copilot (zero config)`)}async function Y(){return new Promise(e=>{const n=P.get({hostname:"localhost",port:11434,path:"/api/tags",timeout:1500},o=>{e(a("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 z(){const e=c.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 a(`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 q(){try{const e=O(import.meta.url),n=c.resolve(c.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=c.resolve(c.dirname(n),"..");for(const d of t){const m=d[1],p=c.join(i,"lib",m);s.existsSync(p)||r.push(m)}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"):a(`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 B(e){const n=c.join(e,"package.json");if(!s.existsSync(n))return a("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[m,p]of Object.entries(t)){const j=/\binfernoflow\s+([a-z][a-z0-9-]*)/.exec(String(p));if(!j)continue;const u=j[1];r.has(u)||i.push({scriptName:m,verb:u})}if(i.length===0)return a("npm scripts use current command surface");const d=i.map(m=>`${m.scriptName} \u2192 infernoflow ${m.verb}`).join(", ");return l(`package.json references ${i.length} deprecated command(s): ${d}`,"Edit package.json scripts to use the current surface (run `infernoflow --help` to list verbs)")}function Q(e){const n=c.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)?a(".gitignore excludes node_modules"):l(".gitignore does not exclude node_modules","Add 'node_modules/' (and '**/node_modules/') to .gitignore")}function Z(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 d=i.slice(12).split(" ");v("infernoflow",d,{cwd:n,encoding:"utf8",timeout:3e4}).status===0&&t.push(r.label)}}return t}function ee(e){return e==="pass"?w("\u2714"):e==="warn"?k("\u26A0"):e==="fail"?$("\u2717"):S("\xB7")}function ne(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(` ${ee(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 oe(e){const n=e.slice(1),o=n.includes("--json"),t=n.includes("--fix"),r=process.cwd(),i=Date.now();let d="0.0.0-unknown";try{const{fileURLToPath:u}=await import("node:url"),g=c.dirname(u(import.meta.url)),N=c.join(g,"..","..","package.json");d=JSON.parse(s.readFileSync(N,"utf8")).version||d}catch{}const m=[f("Node.js version",()=>T()),f("infernoflow CLI",()=>D()),f("Git repository",()=>F(r)),f("inferno/ directory",()=>G(r)),f("Contract / mode",()=>L(r)),f("Scenarios",()=>R(r)),f("Changelog",()=>J(r)),f("CONTEXT.md",()=>H(r)),f("Git hooks",()=>W(r)),f("Auto-capture protocol",()=>U(r)),f("MCP server",()=>X(r)),f("MCP runtime version",()=>K(r,d)),f("AI providers",()=>V(r)),f("Cloud sync",()=>z()),f(".gitignore",()=>Q(r)),f("Router integrity",()=>q()),f("npm scripts",()=>B(r)),await Y().then(u=>({label:"Ollama (local AI)",...u}))],p=Date.now()-i;if(t){const u=Z(m,r);if(u.length)return o||(console.log(),u.forEach(g=>console.log(` ${w("\u2714")} Fixed: ${g}`)),console.log()),oe(["doctor","--json"])}if(o){const u={pass:0,warn:0,fail:0,info:0};m.forEach(g=>u[g.status]=(u[g.status]||0)+1),console.log(JSON.stringify({ok:u.fail===0,counts:u,results:m,elapsed:p}));return}ne(m,p),m.some(u=>u.status==="fail")&&process.exit(1)}export{oe as doctorCommand};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import*as g from"node:fs";import*as $ from"node:path";import"node:os";import{bold as N,cyan as k,gray as t,green as b,red as x}from"../ui/output.mjs";import{ampPaths as T,appendEntry as
|
|
2
|
-
`)),process.exit(1)),
|
|
3
|
-
`+N("\u{1F525} infernoflow \u2014 session memory")),console.log(" "+"\u2500".repeat(50)),!
|
|
1
|
+
import*as g from"node:fs";import*as $ from"node:path";import"node:os";import{bold as N,cyan as k,gray as t,green as b,red as x}from"../ui/output.mjs";import{ampPaths as T,appendEntry as C,readEntries as P,readConfig as U,resolveRotationSettings as V,pruneEntries as q}from"../amp/io.mjs";import{refreshRuleFilesFromMemory as v}from"../ruleFiles.mjs";function W(){return T(process.cwd())}const A=["gotcha","decision","attempt","note","detection","pattern","preference","theme","handoff","error"],F=["worked","failed","partial","unknown"];function B(){return P(process.cwd())}function G(e,{auto:l=!1,quiet:o=!1}={}){const s=process.cwd(),f=$.join(s,".ai-memory"),i=$.join(s,"inferno");if(l&&!g.existsSync(f)&&!g.existsSync(i))return!1;!g.existsSync(f)&&!g.existsSync(i)&&(o||console.error(x(` \u2718 no .ai-memory/ or inferno/ \u2014 run: infernoflow init
|
|
2
|
+
`)),process.exit(1)),C(s,e);try{V(U(s)).auto&&q(s)}catch{}try{v(s)}catch{}return!0}function J(){return process.env.CURSOR_SESSION?"cursor":process.env.COPILOT_SESSION?"copilot":process.env.CLAUDE_CODE_SESSION?"claude":process.env.WINDSURF_SESSION?"windsurf":process.env.INFERNOFLOW_AGENT?process.env.INFERNOFLOW_AGENT:"human"}function Y(e,l){const o=new Date(e.ts).toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}),s=e.type||"note",f=s==="gotcha"?"\x1B[33m":s==="decision"?"\x1B[36m":s==="theme"?"\x1B[35m":s==="preference"?"\x1B[34m":s==="attempt"?"\x1B[90m":s==="error"?"\x1B[31m":"\x1B[0m",i="\x1B[0m",p=e.result?` [${e.result}]`:"",u=e.agent&&e.agent!=="human"?t(` (${e.agent})`):"";return` ${t(String(l+1).padStart(3))} ${t(o)} ${f}${s}${i}${p} ${e.summary}${u}`}async function ee(e){const l=n=>e.includes(n),o=(n,r)=>{const a=e.indexOf(n);return a!==-1&&e[a+1]?e[a+1]:r},s=l("--show"),f=l("--clear"),i=l("--json"),p=l("--auto"),u=l("--quiet"),h=o("--source",null);if(s||i){const n=B(),r=e[e.indexOf("--show")+1],a=r&&/^\d+$/.test(r)?parseInt(r):20,d=n.slice(-a);if(i){console.log(JSON.stringify(d,null,2));return}if(console.log(`
|
|
3
|
+
`+N("\u{1F525} infernoflow \u2014 session memory")),console.log(" "+"\u2500".repeat(50)),!d.length){console.log(t(`
|
|
4
4
|
No entries yet. Start logging with: infernoflow log "<what happened>"
|
|
5
|
-
`));return}console.log(t(` Showing last ${
|
|
6
|
-
`)),
|
|
5
|
+
`));return}console.log(t(` Showing last ${d.length} of ${n.length} entries
|
|
6
|
+
`)),d.forEach((R,_)=>console.log(Y(R,n.length-d.length+_))),console.log();return}if(f){const{sessions:n}=W();if(!g.existsSync(n)){console.log(t(` Nothing to clear.
|
|
7
7
|
`));return}const r=n.replace(".jsonl",`-archive-${Date.now()}.jsonl`);g.renameSync(n,r),console.log(b(` \u2714 Session log archived \u2192 ${$.basename(r)}
|
|
8
8
|
`));return}const L=new Set([o("--type",""),o("--result",""),o("--agent",""),o("--source",""),o("--file",""),o("--line",""),o("--tags","")].filter(Boolean)),y=e.slice(1).filter(n=>!n.startsWith("--")&&!L.has(n)).join(" ").trim();if(!y){console.log(`
|
|
9
9
|
`+N("\u{1F525} infernoflow log")+` \u2014 append to session memory
|
|
10
10
|
`),console.log(t(" Usage:")),console.log(t(' infernoflow log "what happened"')),console.log(t(' infernoflow log "tried X, failed because Y" --type attempt --result failed')),console.log(t(' infernoflow log "always use multipart/form-data" --type gotcha')),console.log(t(' infernoflow log "switched to dark mode" --type theme')),console.log(t(" infernoflow log --show Print last 20 entries")),console.log(t(" infernoflow log --json Print as JSON")),console.log(),console.log(t(" Types: note \xB7 attempt \xB7 decision \xB7 gotcha \xB7 preference \xB7 theme \xB7 handoff \xB7 error")),console.log(t(" Results: worked \xB7 failed \xB7 partial \xB7 unknown")),console.log(t(` Auto-capture: --auto (silent skip if no inferno/) \xB7 --quiet \xB7 --source <name>
|
|
11
|
-
`));return}const
|
|
11
|
+
`));return}const m=o("--type","note"),c=o("--result",null),j=o("--agent",J()),E=o("--file",null),w=o("--line",null),O=o("--tags",null);A.includes(m)||(u||console.error(x(` \u2718 Invalid type: ${m}. Valid: ${A.join(", ")}
|
|
12
12
|
`)),process.exit(1)),c&&!F.includes(c)&&(u||console.error(x(` \u2718 Invalid result: ${c}. Valid: ${F.join(", ")}
|
|
13
|
-
`)),process.exit(1));const I=w&&/^\d+$/.test(w)?parseInt(w,10):null,S=O?O.split(",").map(n=>n.trim()).filter(Boolean):null,D={ts:new Date().toISOString(),agent:j,type:
|
|
14
|
-
`)}}}export{
|
|
13
|
+
`)),process.exit(1));const I=w&&/^\d+$/.test(w)?parseInt(w,10):null,S=O?O.split(",").map(n=>n.trim()).filter(Boolean):null,D={ts:new Date().toISOString(),agent:j,type:m,summary:y,...c?{result:c}:{},...h?{source:h}:{},...E?{file:E}:{},...I?{line:I}:{},...S&&S.length?{tags:S}:{},...p?{auto:!0}:{}};if(G(D,{auto:p,quiet:u})){if(e.includes("--refresh-rules"))try{v(process.cwd())}catch{}if(!u){const n=m!=="note"?k(` [${m}]`):"",r=c?t(` \u2192 ${c}`):"",a=h?t(` (via ${h})`):"";console.log(b(` \u2714 Logged${n}${r}${a}: `)+y+`
|
|
14
|
+
`)}}}export{ee as logCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{bold as u,cyan as r,gray as e,green as f,yellow as w,red as x}from"../ui/output.mjs";import{findProjectRoot as F}from"../projectRoot.mjs";import{pruneEntries as N,resolveRotationSettings as O,readConfig as R}from"../amp/io.mjs";function m(s,n){const o=s.indexOf(n);if(o!==-1)return s[o+1]}function k(s,n){const o=m(s,n);if(o===void 0)return;const i=parseInt(o,10);return Number.isFinite(i)&&i>0?i:void 0}async function S(s=[]){const n=s[0]==="prune"?s.slice(1):s,o=n.includes("--apply")||n.includes("-y"),i=n.includes("--json"),c=n.includes("--no-archive"),v=n.includes("--yes"),a=k(n,"--max-age-days"),g=m(n,"--types"),p=g?g.split(",").map(l=>l.trim()).filter(Boolean):void 0,d=F(process.cwd());c&&o&&!v&&(i?console.log(JSON.stringify({ok:!1,error:"no-archive requires --yes"},null,2)):console.error(x(`
|
|
2
|
+
\u2718 --no-archive deletes entries permanently. Add --yes to confirm.
|
|
3
|
+
`)),process.exit(1));const t=N(d,{dryRun:!o,maxAgeDays:a,types:p,archive:!c});if(i){console.log(JSON.stringify({ok:!0,projectRoot:d,...t},null,2));return}const y=O(R(d)),b=Number.isFinite(a)?a:y.archiveAfterDays;console.log(`
|
|
4
|
+
`+u("\u{1F525} infernoflow prune")+(o?"":e(" \u2014 dry run"))),console.log(" "+"\u2500".repeat(50)),console.log(" "+e("threshold: ")+r(`${b} days`)),console.log(" "+e("archivable: ")+r((p||y.archivableTypes).join(", "))),console.log(" "+e("protected: ")+r("gotcha, decision, pattern")+e(" (never auto-pruned)")),console.log(" "+e("destination: ")+r(c?"(deleted \u2014 no archive)":".ai-memory/archive/sessions-YYYY-MM.jsonl")),console.log(),console.log(" "+e("scanned: ")+t.scanned),console.log(" "+e("kept: ")+f(t.kept)),console.log(" "+e(o?"archived: ":"would archive: ")+w(t.archived));const h=Object.entries(t.byType);if(h.length&&console.log(" "+e(" by type: ")+h.map(([l,j])=>`${l}=${j}`).join(", ")),t.files.length){console.log(" "+e(o?"rewrote files:":"would rewrite:"));for(const l of t.files)console.log(" "+e(l))}console.log(),o?(console.log(" "+f("\u2714 done")+e(" \u2014 readEntries / sidebar / injection no longer see archived entries.")),console.log()):(t.archived===0?console.log(" "+f("nothing to prune \u2014 store is already clean.")):console.log(" "+u("Run with ")+r("--apply")+u(" to actually archive.")),console.log())}export{S as pruneCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{refreshRuleFilesFromMemory as
|
|
2
|
-
`+
|
|
3
|
-
\u2718 refresh failed: `)+
|
|
4
|
-
`),process.exit(1)}if(
|
|
5
|
-
`+
|
|
1
|
+
import{refreshRuleFilesFromMemory as d}from"../ruleFiles.mjs";import{updateInjectionConfig as m}from"../amp/io.mjs";import{findProjectRoot as a}from"../projectRoot.mjs";import{bold as f,cyan as p,gray as c,green as g,red as u}from"../ui/output.mjs";function s(o,r){const t=o.indexOf(r);if(t===-1)return;const n=parseInt(o[t+1],10);return Number.isFinite(n)?n:void 0}function y(o){const r={},t=s(o,"--max-memory");t!==void 0&&(r.maxEntries=t);const n=s(o,"--max-commits");n!==void 0&&(r.maxCommits=n);const l=s(o,"--max-entry-chars");return l!==void 0&&(r.maxEntryChars=l),o.includes("--no-protocol")&&(r.includeProtocol=!1),o.includes("--protocol")&&(r.includeProtocol=!0),r}async function w(o){const r=o.includes("--dry-run")||o.includes("-n"),t=o.includes("--json"),n=a(process.cwd()),l=y(o);if(!r&&Object.keys(l).length)try{m(n,l)}catch{}if(r){if(t){console.log(JSON.stringify({dryRun:!0,projectRoot:n},null,2));return}console.log(`
|
|
2
|
+
`+f("\u{1F525} infernoflow refresh")+c(" \u2014 dry run")),console.log(" "+c("Project root: ")+p(n)),console.log(" "+c("Would rewrite: ")+".cursorrules, CLAUDE.md, .github/copilot-instructions.md"),console.log();return}let i;try{i=d(n)}catch(e){t?console.log(JSON.stringify({ok:!1,error:e.message},null,2)):console.error(u(`
|
|
3
|
+
\u2718 refresh failed: `)+e.message+`
|
|
4
|
+
`),process.exit(1)}if(t){console.log(JSON.stringify({ok:!0,projectRoot:n,results:i},null,2));return}console.log(`
|
|
5
|
+
`+f("\u{1F525} infernoflow refresh")),console.log(" "+"\u2500".repeat(50));for(const e of i)"error"in e&&e.error?console.log(" "+u("\u2718 ")+e.rel+c(" \u2014 "+e.error)):"created"in e&&(e.created||e.updated)?console.log(" "+g("\u2714 ")+e.rel+c(e.created?" \u2014 created":" \u2014 updated")):console.log(" "+c("\xB7 ")+e.rel+c(" \u2014 unchanged"));console.log()}export{y as injectionPatchFromArgs,w as refreshCommand};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`,"utf8"),{updated:!0,path:o})}function
|
|
3
|
-
`,"utf8"),i.cursorMcp=!0,o("Registered MCP server in "+
|
|
1
|
+
import*as s from"node:fs";import*as a from"node:path";import*as P from"node:os";import{fileURLToPath as J}from"node:url";import{execSync as O}from"node:child_process";import{detectIdeContext as F}from"../ai/ideDetection.mjs";import{header as N,ok as y,warn as R,info as w,done as T,cyan as p,yellow as v,bold as g,green as u,gray as I}from"../ui/output.mjs";import"../cursorHooksInstall.mjs";import"../vsCodeCopilotHooksInstall.mjs";import{updateInjectionConfig as V}from"../amp/io.mjs";import{injectionPatchFromArgs as L}from"./refresh.mjs";const A=a.dirname(J(import.meta.url));function j(){return a.resolve(A,"../../templates")}function D(n){try{return O(`npx infernoflow ${n}`,{encoding:"utf8",cwd:process.cwd(),timeout:6e4,stdio:["inherit","pipe","pipe"]})}catch(t){return t.stdout||t.stderr||t.message}}const W=["infernoflow_status","infernoflow_run","infernoflow_apply","infernoflow_check","infernoflow_context","infernoflow_implement","infernoflow_git_drift","infernoflow_scan_ui","infernoflow_review","amp_read","amp_write","amp_search","amp_handoff","amp_health"];function b(n){const t=a.join(P.homedir(),".claude.json");let c={};if(s.existsSync(t))try{c=JSON.parse(s.readFileSync(t,"utf8"))}catch{c={}}c.mcpServers||(c.mcpServers={});const o=c.mcpServers.infernoflow;if(o&&o.args&&o.args[0]===n)return{updated:!1};c.mcpServers.infernoflow={command:"node",args:[n]};const r=JSON.stringify(c,null,2).replace(/\u0000+/g,"");return s.writeFileSync(t,r,"utf8"),{updated:!0,path:t}}function H(n,t){const c=a.join(n,".vscode"),o=a.join(c,"mcp.json");let r={};if(s.existsSync(o))try{r=JSON.parse(s.readFileSync(o,"utf8"))}catch{r={}}r.servers||(r.servers={});const i=r.servers.infernoflow;return i&&i.args&&i.args[0]===t?{updated:!1}:(r.servers.infernoflow={type:"stdio",command:"node",args:[t]},s.mkdirSync(c,{recursive:!0}),s.writeFileSync(o,JSON.stringify(r,null,2)+`
|
|
2
|
+
`,"utf8"),{updated:!0,path:o})}function U(n,t){const c=a.join(n,".claude"),o=a.join(c,"settings.json");let r={};if(s.existsSync(o))try{r=JSON.parse(s.readFileSync(o,"utf8"))}catch{r={}}const i=new Set(r.allowedTools||[]);for(const f of W)i.add(`mcp__infernoflow__${f}`);const m={...r,allowedTools:[...i]};return s.mkdirSync(c,{recursive:!0}),s.writeFileSync(o,JSON.stringify(m,null,2),"utf8"),o}function q(n,{silent:t=!1}={}){const c=j(),o=t?()=>{}:e=>y(e),r=t?()=>{}:e=>R(e),i={mcpServer:!1,claudeJson:!1,claudeSettings:!1},m=a.join(c,"cursor","inferno-mcp-server.mjs"),f=a.join(n,".cursor","inferno-mcp-server.mjs");try{s.existsSync(f)||(s.mkdirSync(a.dirname(f),{recursive:!0}),s.copyFileSync(m,f),i.mcpServer=!0,o("Copied MCP server \u2192 "+p(".cursor/inferno-mcp-server.mjs")))}catch(e){r("MCP server copy skipped: "+e.message)}try{b(f).updated&&(i.claudeJson=!0,o("Registered MCP server in "+p("~/.claude.json")))}catch(e){r("~/.claude.json update skipped: "+e.message)}try{H(n,f).updated&&(i.vscodeMcp=!0,o("Registered MCP server in "+p(".vscode/mcp.json")+I(" (Copilot Chat)")))}catch(e){r(".vscode/mcp.json update skipped: "+e.message)}try{const e=a.join(n,".cursor","mcp.json");let l={};if(s.existsSync(e))try{l=JSON.parse(s.readFileSync(e,"utf8"))}catch{l={}}l.mcpServers||(l.mcpServers={});const d=l.mcpServers.infernoflow;(!d||!d.args||d.args[0]!==f)&&(l.mcpServers.infernoflow={command:"node",args:[f],env:{}},s.mkdirSync(a.dirname(e),{recursive:!0}),s.writeFileSync(e,JSON.stringify(l,null,2)+`
|
|
3
|
+
`,"utf8"),i.cursorMcp=!0,o("Registered MCP server in "+p(".cursor/mcp.json")))}catch(e){r(".cursor/mcp.json update skipped: "+e.message)}try{U(n,!1),i.claudeSettings=!0,o("Pre-approved infernoflow tools in "+p(".claude/settings.json"))}catch(e){r(".claude/settings.json skipped: "+e.message)}return i}async function oe(n){const t=process.cwd(),c=n.includes("--force")||n.includes("-f"),o=n.includes("--yes")||n.includes("-y"),r=j();N("infernoflow setup");const{ideDetected:i}=F("auto");w(`IDE detected: ${g(i==="cursor"?"Cursor":i==="vscode"?"VS Code":i==="windsurf"?"Windsurf":"unknown")}`);const f=a.join(t,".ai-memory");s.existsSync(f)?y(".ai-memory/ already exists \u2014 skipping init"):(console.log(`
|
|
4
4
|
${v(".ai-memory/")} not found \u2014 running init ...
|
|
5
|
-
`),
|
|
6
|
-
${g("What was set up:")}`),console.log(` ${
|
|
5
|
+
`),D(o?"init --yes":"init"));const e=L(n);if(Object.keys(e).length)try{V(t,e),y("Injection config updated \u2192 "+JSON.stringify(e))}catch{}console.log(),w("Wiring up MCP servers for Cursor / VS Code Copilot / Claude Code ...");const l=q(t,{silent:!1});console.log(),T("infernoflow ready"),console.log(`
|
|
6
|
+
${g("What was set up:")}`),console.log(` ${u("\u2714")} MCP server installed \u2192 ${p(".cursor/inferno-mcp-server.mjs")}`),l.cursorMcp&&console.log(` ${u("\u2714")} Cursor MCP config \u2192 ${p(".cursor/mcp.json")}`),l.vscodeMcp&&console.log(` ${u("\u2714")} VS Code Copilot MCP config \u2192 ${p(".vscode/mcp.json")}`),l.claudeJson&&console.log(` ${u("\u2714")} Claude Code MCP config \u2192 ${p("~/.claude.json")}`),l.claudeSettings&&console.log(` ${u("\u2714")} Auto-approved tools \u2192 ${p(".claude/settings.json")}`);try{const{detectStaleMcpRuntime:d}=await import("../mcpRuntime.mjs"),{readFileSync:C}=await import("node:fs"),{dirname:h,join:_}=await import("node:path"),{fileURLToPath:x}=await import("node:url"),M=h(x(import.meta.url)),$=_(M,"..","..","package.json"),k=JSON.parse(C($,"utf8")).version,S=d(t,k);S&&(console.log(),console.log(` ${v("\u26A0")} ${g("Restart required:")} ${S.message}`))}catch{}console.log(),console.log(` ${g("Next step:")} Restart your AI tool. Test by asking:`),console.log(` ${p('"call the amp_write tool with a test note"')}`),console.log()}export{W as MCP_TOOLS,q as autoSetupMcp,oe as setupCommand,b as updateClaudeJson,H as updateVscodeMcpJson,U as writeClaudeSettings};
|
package/dist/lib/ruleFiles.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`)}function A(){return[m,"<!-- Auto-managed by infernoflow. Don't edit between these markers. -->","## Project memory (infernoflow)","",y(),"",'_No entries yet. They\'ll appear here as you and your AI tools log them \u2014 run `infernoflow log "..."` or call `amp_write` from any MCP-aware AI._',h].join(`
|
|
3
|
-
`)}function x(e){const r=e.indexOf("<!-- AMP:START -->"),o=e.indexOf("<!-- AMP:END -->");if(r===-1||o===-1||o<=r)return e;const t=e.slice(0,r).replace(/\s+$/,""),i=e.slice(o+16).replace(/^\s+/,"");return(t?t+(i?`
|
|
1
|
+
import*as l from"node:fs";import*as d from"node:path";import{execSync as I}from"node:child_process";import{readEntries as j,readConfig as _}from"./amp/io.mjs";const y="<!-- infernoflow:start -->",f="<!-- infernoflow:end -->",x=[".cursorrules","CLAUDE.md",d.join(".github","copilot-instructions.md")],b=4,A=5,C=200;function k(e){const n=e&&e.config||{},t=n.injection&&typeof n.injection=="object"?n.injection:{},r=Array.isArray(n.inject)&&!n.inject.includes("all")?n.inject:null;return{maxEntries:Number.isInteger(t.maxEntries)&&t.maxEntries>=0?t.maxEntries:b,maxCommits:Number.isInteger(t.maxCommits)&&t.maxCommits>=0?t.maxCommits:A,maxEntryChars:Number.isInteger(t.maxEntryChars)&&t.maxEntryChars>0?t.maxEntryChars:C,targets:Array.isArray(t.targets)&&t.targets.length?t.targets:r||x,includeProtocol:t.includeProtocol!==!1}}function T(e){if(!l.existsSync(e))return{stripped:!1};const n=l.readFileSync(e,"utf8"),t=n.indexOf(y),r=n.indexOf(f);if(t===-1||r===-1||r<=t)return{stripped:!1};const s=n.slice(0,t).replace(/\s+$/,""),o=n.slice(r+f.length).replace(/^\s+/,""),i=s&&o?s+`
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
`+o:s||o;return l.writeFileSync(e,i?i.replace(/\s*$/,"")+`
|
|
4
|
+
`:"","utf8"),{stripped:!0}}function E(){const e=[];return e.push("### Memory protocol \u2014 capture as you go"),e.push(""),e.push("You have the `amp_write` MCP tool. **Use it proactively** (without the user asking) whenever you detect any of these moments. Capture the lesson in one sentence so the next AI session inherits it."),e.push(""),e.push("| When you see\u2026 | Call `amp_write` with\u2026 |"),e.push("|---|---|"),e.push("| User types `!!`, `!!!`, `not working`, `still broken`, `no change`, `same error`, `retry` / `retrying`, repeated frustration | `{type: 'attempt', msg: '<one-line: what was tried and how it failed>', file: '<active file>'}` |"),e.push("| You generate a plan, numbered steps, or `Plan:` / `Approach:` block | `{type: 'note', msg: 'Plan: <one-line summary>', file: '<focus file>'}` |"),e.push("| User picks X over Y, decides an architectural approach, or you both agree on a direction | `{type: 'decision', msg: '<X> chosen over <Y> because <reason>', file: '<file>'}` |"),e.push("| Discovered non-obvious behavior, API quirk, or `aha \u2014 turns out\u2026` moment | `{type: 'gotcha', msg: '<one-line>', file: '<file>', line: <line if known>}` |"),e.push("| User says `switching` / `back to X`, or ~30 min passed without logging | `{type: 'note', msg: 'Session snapshot \u2014 worked on: <X>. Open threads: <Y>.'}` |"),e.push(""),e.push("**Do NOT log:** typos, syntax errors, obvious bugs visible in the code, anything the next AI can infer by re-reading the file."),e.push("**Do log:** anything that taught you something non-derivable from code."),e.push("**Be concise:** entries should be one sentence. Future-you will skim them."),e.join(`
|
|
5
|
+
`)}function F(){return[y,"<!-- Auto-managed by infernoflow. Don't edit between these markers. -->","## Project memory (infernoflow)","",E(),"",'_No entries yet. They\'ll appear here as you and your AI tools log them \u2014 run `infernoflow log "..."` or call `amp_write` from any MCP-aware AI._',f].join(`
|
|
6
|
+
`)}function v(e){const n=e.indexOf("<!-- AMP:START -->"),t=e.indexOf("<!-- AMP:END -->");if(n===-1||t===-1||t<=n)return e;const r=e.slice(0,n).replace(/\s+$/,""),s=e.slice(t+16).replace(/^\s+/,"");return(r?r+(s?`
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
`:""):"")+s}function S(e,n){const t=d.dirname(e);if(l.existsSync(t)||l.mkdirSync(t,{recursive:!0}),!l.existsSync(e))return l.writeFileSync(e,n+`
|
|
9
|
+
`,"utf8"),{created:!0,updated:!1};let r=l.readFileSync(e,"utf8");r=v(r);const s=r.indexOf(y),o=r.indexOf(f);if(s===-1||o===-1){const g=n+`
|
|
10
|
+
|
|
11
|
+
`+r;return l.writeFileSync(e,g,"utf8"),{created:!1,updated:!0}}const i=r.slice(0,s),p=r.slice(o+f.length),u=i+n+p;return u===r?{created:!1,updated:!1}:(l.writeFileSync(e,u,"utf8"),{created:!1,updated:!0})}function O(e){const n=F(),t=[];for(const r of x){const s=d.join(e,r);try{const o=S(s,n);t.push({rel:r,...o})}catch(o){t.push({rel:r,error:o.message})}}return t}function D(e){return j(e)}function M(e,n=10){try{return I(`git log --pretty=format:"%h%x09%ad%x09%s" --date=short -n ${n}`,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).split(`
|
|
12
|
+
`).filter(Boolean).map(r=>{const[s,o,i]=r.split(" ");return{hash:(s||"").slice(0,7),date:o||"",subject:i||""}})}catch{return[]}}function N(e,n={}){const{maxEntries:t=b,maxCommits:r=A,maxEntryChars:s=C,includeProtocol:o=!0}=n,i=D(e),p=M(e,r);i.sort((c,m)=>{const h=typeof c.ts=="number"?c.ts:Date.parse(c.ts||0);return(typeof m.ts=="number"?m.ts:Date.parse(m.ts||0))-h});const u=i.slice(0,t),g={gotcha:"\u26A0",decision:"\u2713",attempt:"\u2717",note:"\xB7",detection:"\u25CB",pattern:"\u25C7"},a=[];if(a.push(y),a.push("<!-- Auto-managed by infernoflow. Don't edit between these markers. -->"),a.push("## Project memory (infernoflow)"),a.push(""),o&&(a.push(E()),a.push("")),p.length>0){a.push("### Recent commits");for(const c of p)a.push(`- \`${c.hash}\` _${c.date}_ ${c.subject}`);a.push("")}if(u.length>0){a.push("### Recent memory");for(const c of u){const m=c.file?` (\`${c.file}${c.line?":"+c.line:""}\`)`:"",h=(c.msg||c.summary||"").replace(/\n/g," "),w=s&&h.length>s?h.slice(0,s).trimEnd()+"\u2026":h;a.push(`- \u{1F525} ${g[c.type]||"\xB7"} **${c.type||"note"}**${m}: ${w}`)}a.push("")}return i.length===0&&p.length===0&&a.push('_No entries yet. They\'ll appear here as you and your AI tools log them \u2014 run `infernoflow log "..."` or call `amp_write` from any MCP-aware AI._'),a.push(f),a.join(`
|
|
13
|
+
`)}function P(e){const n=k(_(e)),t=N(e,n),r=i=>String(i).replace(/\\/g,"/"),s=new Set(n.targets.map(r)),o=[];for(const i of x){const p=d.join(e,i);try{if(s.has(r(i))){const u=S(p,t);o.push({rel:i,...u})}else T(p).stripped&&o.push({rel:i,stripped:!0})}catch(u){o.push({rel:i,error:u.message})}}return o}export{P as refreshRuleFilesFromMemory,k as resolveInjectionSettings,O as writeInitRuleFiles};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import * as fs from "node:fs";
|
|
18
18
|
import * as path from "node:path";
|
|
19
|
+
import { spawnSync } from "node:child_process";
|
|
19
20
|
|
|
20
21
|
/** Keep in sync with templates/scripts/inferno-promote-draft.mjs */
|
|
21
22
|
const DRAFT_HEADER = `# CONTEXT draft (gitignored)
|
|
@@ -132,6 +133,83 @@ async function readStdin() {
|
|
|
132
133
|
return Buffer.concat(chunks).toString("utf8");
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
// ── Deterministic trigger capture (beforeSubmitPrompt) ──────────────────────
|
|
137
|
+
// Cursor's beforeSubmitPrompt hook hands us the USER's prompt text before it
|
|
138
|
+
// goes to the model. The Memory-protocol block already asks the AI to log on
|
|
139
|
+
// these signals, but the AI doesn't always obey — so this is a deterministic
|
|
140
|
+
// backstop: if the prompt itself contains a trouble signal (!!, retry, "not
|
|
141
|
+
// working", …) we write an `attempt` entry ourselves. Bounded hard against
|
|
142
|
+
// noise: a 90s cooldown + identical-prompt dedupe, so a frustrated burst of
|
|
143
|
+
// "still broken!! retry!!" produces ONE entry, not ten.
|
|
144
|
+
const TRIGGER_RES = [
|
|
145
|
+
/(?:^|\s)!!+/,
|
|
146
|
+
/\bretry(?:ing)?\b/i,
|
|
147
|
+
/\bnot working\b/i,
|
|
148
|
+
/\bstill (?:broken|failing|not working|doesn['’]?t)\b/i,
|
|
149
|
+
/\bsame (?:error|issue|problem)\b/i,
|
|
150
|
+
/\bno change\b/i,
|
|
151
|
+
/\bdoesn['’]?t work\b/i,
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
function memoryRootExists() {
|
|
155
|
+
return fs.existsSync(path.join(projectRoot(), ".ai-memory")) ||
|
|
156
|
+
fs.existsSync(path.join(projectRoot(), "inferno"));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function triggerStatePath() {
|
|
160
|
+
return path.join(projectRoot(), ".ai-memory", ".trigger-state.json");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function cheapHash(s) {
|
|
164
|
+
let h = 0;
|
|
165
|
+
for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0;
|
|
166
|
+
return String(h);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function handleUserPrompt(text) {
|
|
170
|
+
const trimmed = (text || "").trim();
|
|
171
|
+
if (!trimmed) return;
|
|
172
|
+
if (!memoryRootExists()) return; // only inside infernoflow projects
|
|
173
|
+
if (!TRIGGER_RES.some((re) => re.test(trimmed))) return;
|
|
174
|
+
|
|
175
|
+
const now = Date.now();
|
|
176
|
+
const stateFile = triggerStatePath();
|
|
177
|
+
let state = {};
|
|
178
|
+
try { state = JSON.parse(fs.readFileSync(stateFile, "utf8")); } catch {}
|
|
179
|
+
const h = cheapHash(trimmed.slice(0, 200));
|
|
180
|
+
const COOLDOWN_MS = 90_000;
|
|
181
|
+
if (state.lastHash === h) return; // exact same prompt — skip
|
|
182
|
+
if (state.lastTs && now - state.lastTs < COOLDOWN_MS) return; // rate-limit
|
|
183
|
+
|
|
184
|
+
const msg = "Auto-trigger — user signalled trouble: " +
|
|
185
|
+
trimmed.replace(/\s+/g, " ").slice(0, 180);
|
|
186
|
+
|
|
187
|
+
// Prefer the CLI (correct id / branch routing / AMP shape); fall back to a
|
|
188
|
+
// direct sessions.jsonl append so capture still works without a global CLI.
|
|
189
|
+
let wrote = false;
|
|
190
|
+
try {
|
|
191
|
+
const bin = process.platform === "win32" ? "infernoflow.cmd" : "infernoflow";
|
|
192
|
+
const r = spawnSync(bin, ["log", msg, "--type", "attempt", "--source", "cursor-trigger", "--tags", "auto-trigger"], {
|
|
193
|
+
cwd: projectRoot(), encoding: "utf8", timeout: 8000, shell: process.platform === "win32",
|
|
194
|
+
});
|
|
195
|
+
wrote = r.status === 0;
|
|
196
|
+
} catch { /* fall through to direct write */ }
|
|
197
|
+
if (!wrote) {
|
|
198
|
+
try {
|
|
199
|
+
const sess = path.join(projectRoot(), ".ai-memory", "sessions.jsonl");
|
|
200
|
+
fs.mkdirSync(path.dirname(sess), { recursive: true });
|
|
201
|
+
const entry = { type: "attempt", msg, ts: now, id: "amp_hook_" + now.toString(36), source: "cursor-trigger", tags: ["auto-trigger"], meta: { agent: "cursor-hook" } };
|
|
202
|
+
fs.appendFileSync(sess, JSON.stringify(entry) + "\n", "utf8");
|
|
203
|
+
wrote = true;
|
|
204
|
+
} catch { /* best effort */ }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (wrote) {
|
|
208
|
+
try { fs.writeFileSync(stateFile, JSON.stringify({ lastTs: now, lastHash: h }), "utf8"); } catch {}
|
|
209
|
+
process.stderr.write("[inferno-session-draft] auto-captured trigger to memory\n");
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
135
213
|
// ── main ───────────────────────────────────────────────────────────────────
|
|
136
214
|
|
|
137
215
|
function main() {
|
|
@@ -149,6 +227,16 @@ function main() {
|
|
|
149
227
|
return;
|
|
150
228
|
}
|
|
151
229
|
|
|
230
|
+
// beforeSubmitPrompt: deterministic trigger capture on the USER's prompt.
|
|
231
|
+
if (process.argv.includes("--user-prompt")) {
|
|
232
|
+
const t = typeof data.prompt === "string" ? data.prompt
|
|
233
|
+
: typeof data.text === "string" ? data.text : "";
|
|
234
|
+
try { handleUserPrompt(t); } catch (e) { console.error("[inferno-session-draft] trigger:", e?.message); }
|
|
235
|
+
console.log("{}");
|
|
236
|
+
process.exit(0);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
152
240
|
const file = draftPath();
|
|
153
241
|
|
|
154
242
|
if (agentStop) {
|
package/package.json
CHANGED