infernoflow 0.33.1 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +208 -120
  2. package/dist/bin/infernoflow.mjs +273 -85
  3. package/dist/lib/adopters/angular.mjs +128 -1
  4. package/dist/lib/adopters/css.mjs +111 -1
  5. package/dist/lib/adopters/react.mjs +104 -1
  6. package/dist/lib/ai/ideDetection.mjs +31 -1
  7. package/dist/lib/ai/localProvider.mjs +88 -1
  8. package/dist/lib/ai/providerRouter.mjs +295 -2
  9. package/dist/lib/commands/adopt.mjs +869 -20
  10. package/dist/lib/commands/adoptWizard.mjs +320 -9
  11. package/dist/lib/commands/agent.mjs +191 -5
  12. package/dist/lib/commands/ai.mjs +407 -2
  13. package/dist/lib/commands/ask.mjs +299 -0
  14. package/dist/lib/commands/audit.mjs +300 -13
  15. package/dist/lib/commands/changelog.mjs +594 -26
  16. package/dist/lib/commands/check.mjs +184 -3
  17. package/dist/lib/commands/ci.mjs +208 -3
  18. package/dist/lib/commands/claudeMd.mjs +139 -28
  19. package/dist/lib/commands/cloud.mjs +521 -5
  20. package/dist/lib/commands/context.mjs +346 -34
  21. package/dist/lib/commands/coverage.mjs +282 -2
  22. package/dist/lib/commands/dashboard.mjs +635 -123
  23. package/dist/lib/commands/demo.mjs +465 -8
  24. package/dist/lib/commands/diff.mjs +274 -5
  25. package/dist/lib/commands/docGate.mjs +81 -2
  26. package/dist/lib/commands/doctor.mjs +321 -3
  27. package/dist/lib/commands/explain.mjs +438 -8
  28. package/dist/lib/commands/export.mjs +239 -10
  29. package/dist/lib/commands/generateSkills.mjs +163 -38
  30. package/dist/lib/commands/graph.mjs +378 -11
  31. package/dist/lib/commands/health.mjs +309 -2
  32. package/dist/lib/commands/impact.mjs +325 -2
  33. package/dist/lib/commands/implement.mjs +103 -7
  34. package/dist/lib/commands/init.mjs +545 -23
  35. package/dist/lib/commands/installCursorHooks.mjs +36 -1
  36. package/dist/lib/commands/installVsCodeCopilotHooks.mjs +37 -1
  37. package/dist/lib/commands/link.mjs +342 -2
  38. package/dist/lib/commands/log.mjs +164 -16
  39. package/dist/lib/commands/monorepo.mjs +428 -4
  40. package/dist/lib/commands/notify.mjs +258 -4
  41. package/dist/lib/commands/onboard.mjs +296 -4
  42. package/dist/lib/commands/prComment.mjs +361 -2
  43. package/dist/lib/commands/prImpact.mjs +157 -2
  44. package/dist/lib/commands/publish.mjs +316 -15
  45. package/dist/lib/commands/recap.mjs +359 -0
  46. package/dist/lib/commands/report.mjs +272 -28
  47. package/dist/lib/commands/review.mjs +223 -9
  48. package/dist/lib/commands/run.mjs +336 -8
  49. package/dist/lib/commands/scaffold.mjs +419 -54
  50. package/dist/lib/commands/scan.mjs +1118 -5
  51. package/dist/lib/commands/scout.mjs +291 -2
  52. package/dist/lib/commands/setup.mjs +310 -5
  53. package/dist/lib/commands/share.mjs +196 -13
  54. package/dist/lib/commands/snapshot.mjs +383 -3
  55. package/dist/lib/commands/stability.mjs +293 -2
  56. package/dist/lib/commands/stats.mjs +402 -0
  57. package/dist/lib/commands/status.mjs +172 -4
  58. package/dist/lib/commands/suggest.mjs +563 -21
  59. package/dist/lib/commands/switch.mjs +310 -9
  60. package/dist/lib/commands/syncAuto.mjs +96 -1
  61. package/dist/lib/commands/synthesize.mjs +228 -10
  62. package/dist/lib/commands/teamSync.mjs +388 -2
  63. package/dist/lib/commands/test.mjs +363 -6
  64. package/dist/lib/commands/theme.mjs +195 -18
  65. package/dist/lib/commands/uninstall.mjs +375 -0
  66. package/dist/lib/commands/upgrade.mjs +153 -0
  67. package/dist/lib/commands/version.mjs +282 -2
  68. package/dist/lib/commands/vibe.mjs +357 -7
  69. package/dist/lib/commands/watch.mjs +203 -4
  70. package/dist/lib/commands/why.mjs +358 -4
  71. package/dist/lib/cursorHooksInstall.mjs +60 -1
  72. package/dist/lib/draftToolingInstall.mjs +68 -7
  73. package/dist/lib/git/detect-drift.mjs +208 -4
  74. package/dist/lib/learning/adapt.mjs +101 -6
  75. package/dist/lib/learning/observe.mjs +119 -1
  76. package/dist/lib/learning/patternDetector.mjs +298 -1
  77. package/dist/lib/learning/profile.mjs +279 -2
  78. package/dist/lib/learning/skillSynthesizer.mjs +145 -24
  79. package/dist/lib/templates/index.mjs +131 -1
  80. package/dist/lib/theme/scanner.mjs +343 -4
  81. package/dist/lib/ui/errors.mjs +142 -1
  82. package/dist/lib/ui/output.mjs +72 -6
  83. package/dist/lib/ui/prompts.mjs +147 -6
  84. package/dist/lib/vsCodeCopilotHooksInstall.mjs +42 -1
  85. package/package.json +1 -1
@@ -1,9 +1,310 @@
1
- import*as f from"node:fs";import*as m from"node:path";import{execSync as O}from"node:child_process";import{bold as k,cyan as d,gray as R,green as x,yellow as E,red as T}from"../ui/output.mjs";const y="inferno",L=m.join(y,"HANDOFF.md"),_=m.join(y,"sessions.jsonl"),N=m.join(y,"context-state.json"),D=m.join(y,"contract.json"),A=m.join(y,"theme.json");function r(t){try{return JSON.parse(f.readFileSync(t,"utf8"))}catch{return null}}function V(t){try{return f.readFileSync(t,"utf8")}catch{return null}}function g(t){return t?new Date(t).toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}):"unknown"}function C(t=8){return f.existsSync(_)?f.readFileSync(_,"utf8").split(`
2
- `).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(Boolean).slice(-t):[]}function G(t){try{const e=process.platform;if(e==="win32")O("clip",{input:t});else if(e==="darwin")O("pbcopy",{input:t});else try{O("xclip -selection clipboard",{input:t})}catch{O("xsel --clipboard --input",{input:t})}return!0}catch{return!1}}function J(t){const e=r(N)||{},w=r(D)||{},i=r(A),c=C(8),b=new Date().toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),l=w.policyId||m.basename(process.cwd()),$=w.policyVersion||"?",F=(w.capabilities||[]).slice(0,20),p=c.filter(n=>n.type==="gotcha"),u=c.filter(n=>n.type==="decision"),j=c.filter(n=>n.type==="attempt"),s=c.filter(n=>n.type==="preference"),a=c.filter(n=>n.type==="theme"),S=c.slice(-5),o=[`# \u{1F525} infernoflow Handoff \u2014 ${l}`,`> Generated: ${b}${t?` | Handing off to: **${t}**`:""}`,"","---","","## Pick up here",""];if(e.working||e.intent?(e.working&&o.push(`**Working on:** ${e.working} _(${g(e.workingUpdated)})_`),e.intent&&o.push(`**Intent:** ${e.intent} _(${g(e.intentUpdated)})_`),o.push("")):o.push('_No working state set. Run: `infernoflow context --working "..."` to set it._',""),p.length){o.push("## \u26A0 Gotchas \u2014 read these first","");for(const n of p)o.push(`- ${n.summary} _(${g(n.ts)})_`);o.push("")}if(u.length){o.push("## Decisions made","");for(const n of u){const h=n.result?` \u2192 **${n.result}**`:"";o.push(`- ${n.summary}${h} _(${g(n.ts)})_`)}o.push("")}const H=j.filter(n=>n.result==="failed"||n.result==="partial");if(H.length){o.push("## \u2717 Already tried \u2014 don't repeat","");for(const n of H)o.push(`- ${n.summary} _(${g(n.ts)})_`);o.push("")}if(s.length){o.push("## Developer preferences","");for(const n of s)o.push(`- ${n.summary}`);o.push("")}if(i){if(o.push("## Design system",""),i.fonts?.primary&&o.push(`- **Font:** ${i.fonts.primary}${i.fonts.mono?` \xB7 mono: ${i.fonts.mono}`:""}`),i.colors?.mode&&o.push(`- **Mode:** ${i.colors.mode}`),i.colors?.palette){const n=Object.entries(i.colors.palette).map(([h,I])=>`${h}=${I}`).join(" ");o.push(`- **Palette:** ${n}`)}if(i.cssVars&&Object.keys(i.cssVars).length){const n=Object.entries(i.cssVars).slice(0,6).map(([h,I])=>`${h}: ${I}`).join(" | ");o.push(`- **CSS vars:** ${n}`)}i.framework&&o.push(`- **Framework:** ${i.framework}`),o.push("","> \u26A0 Always match these exactly. Do not introduce new colors or fonts.","")}if(F.length&&(o.push("## Capability contract",""),o.push(`Project: **${l}** v${$}`),o.push(`Capabilities: ${F.join(", ")}`),o.push("")),S.length){o.push("## Recent session log","");for(const n of S){const h=n.result?` [${n.result}]`:"";o.push(`- **${n.type}**${h}: ${n.summary} _(${g(n.ts)})_`)}o.push("")}return o.push("---"),o.push("_Paste this at the start of your next AI session. Generated by infernoflow._"),o.join(`
3
- `)}async function B(t){const e=s=>t.includes(s),w=s=>{const a=t.indexOf(s);return a!==-1&&t[a+1]?t[a+1]:null},i=e("--show")||e("-s"),c=e("--copy")||e("-c"),b=e("--json"),l=w("--to")||t.find(s=>!s.startsWith("-")&&!["switch"].includes(s))||null;if(console.log(`
4
- `+k("\u{1F525} infernoflow \u2014 switch")),console.log(" "+"\u2500".repeat(50)+`
5
- `),f.existsSync(y)||(console.error(T(` \u2718 inferno/ not found \u2014 run: infernoflow init
6
- `)),process.exit(1)),i){const s=V(L);if(!s){console.log(E(` \u26A0 No HANDOFF.md yet \u2014 run: infernoflow switch
7
- `));return}console.log(s);return}const $=J(l);if(b){const s=r(N)||{},a=r(D)||{},S=r(A),o=C(8);console.log(JSON.stringify({state:s,contract:{policyId:a.policyId,policyVersion:a.policyVersion,capabilities:a.capabilities},theme:S,sessions:o,generatedAt:new Date().toISOString()},null,2));return}if(f.writeFileSync(L,$,"utf8"),console.log(x(` \u2714 Written \u2192 inferno/HANDOFF.md
8
- `)),f.existsSync(_)){const s={ts:new Date().toISOString(),agent:"infernoflow",type:"handoff",summary:l?`Handed off to ${l}`:"Handoff generated"};f.appendFileSync(_,JSON.stringify(s)+`
9
- `,"utf8")}const F=C(100).length,p=r(N)||{},u=r(A),j=r(D)||{};if(console.log(" "+k("Handoff summary")),console.log(" "+"\u2500".repeat(50)),p.working&&console.log(" Working on "+d(p.working)),p.intent&&console.log(" Intent "+d(p.intent)),console.log(" Sessions "+F+" entries in memory"),console.log(" Capabilities "+(j.capabilities||[]).length+" registered"),u?.fonts?.primary&&console.log(" Font "+u.fonts.primary),u?.colors?.mode&&console.log(" Color mode "+u.colors.mode),l&&console.log(" Handing off \u2192 "+d(l)),console.log(),c){const s=G($);console.log(s?x(" \u2714 Copied to clipboard \u2014 paste at the start of your next AI session"):E(" \u26A0 Clipboard failed \u2014 open inferno/HANDOFF.md manually"))}else console.log(" "+k("Ready to use:")),console.log(" "+d("1.")+" Open "+d("inferno/HANDOFF.md")),console.log(" "+d("2.")+" Copy all"),console.log(" "+d("3.")+" Paste at the start of your next AI session"),console.log(" "+R(" tip: use --copy to skip steps 1-2 automatically"));console.log()}export{B as switchCommand};
1
+ /**
2
+ * infernoflow switch
3
+ *
4
+ * Generates a handoff summary when switching between AI agents
5
+ * (Copilot Cursor Claude Windsurf → etc.).
6
+ *
7
+ * Captures the full session state — what was tried, what worked, what's
8
+ * in progress, the design system, and the capability context — into a
9
+ * single pasteable block so the next agent picks up exactly where you left off.
10
+ *
11
+ * Session boundary detection (same logic as `infernoflow recap`):
12
+ * - All entries since the last `handoff` entry, or the last 24h — whichever is more recent
13
+ * - Use --since to override (e.g. --since 48h, --since 2026-04-20)
14
+ * - Use --all to include every entry ever logged
15
+ *
16
+ * Also writes inferno/HANDOFF.md (auto-loaded by some IDEs).
17
+ *
18
+ * Usage:
19
+ * infernoflow switch Generate handoff + write HANDOFF.md
20
+ * infernoflow switch --to cursor Label the handoff for a specific agent
21
+ * infernoflow switch --copy Copy to clipboard
22
+ * infernoflow switch --show Print current HANDOFF.md
23
+ * infernoflow switch --json Output as JSON
24
+ * infernoflow switch --since 48h Include entries from the last 48 hours
25
+ * infernoflow switch --all Include all entries ever logged
26
+ */
27
+
28
+ import * as fs from "node:fs";
29
+ import * as path from "node:path";
30
+ import { execSync } from "node:child_process";
31
+ import { bold, cyan, gray, green, yellow, red } from "../ui/output.mjs";
32
+
33
+ const INFERNO_DIR = "inferno";
34
+ const HANDOFF_FILE = path.join(INFERNO_DIR, "HANDOFF.md");
35
+ const SESSIONS_FILE = path.join(INFERNO_DIR, "sessions.jsonl");
36
+ const STATE_FILE = path.join(INFERNO_DIR, "context-state.json");
37
+ const CONTRACT_FILE = path.join(INFERNO_DIR, "contract.json");
38
+ const THEME_FILE = path.join(INFERNO_DIR, "theme.json");
39
+
40
+ function readJSON(f) { try { return JSON.parse(fs.readFileSync(f, "utf8")); } catch { return null; } }
41
+ function readFile(f) { try { return fs.readFileSync(f, "utf8"); } catch { return null; } }
42
+
43
+ function fmtDate(iso) {
44
+ if (!iso) return "unknown";
45
+ return new Date(iso).toLocaleString("en-GB", { day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit" });
46
+ }
47
+
48
+ function getAllEntries() {
49
+ if (!fs.existsSync(SESSIONS_FILE)) return [];
50
+ return fs.readFileSync(SESSIONS_FILE, "utf8")
51
+ .split("\n").filter(Boolean)
52
+ .map(l => { try { return JSON.parse(l); } catch { return null; } })
53
+ .filter(Boolean);
54
+ }
55
+
56
+ /**
57
+ * Find the start of the "current session":
58
+ * - The timestamp of the last `handoff` entry, OR 24h ago — whichever is more recent
59
+ * - --since overrides both; --all returns epoch (everything)
60
+ */
61
+ function findSessionStart(allEntries, sinceArg, allFlag) {
62
+ if (allFlag) return new Date(0);
63
+
64
+ if (sinceArg) {
65
+ const hoursMatch = sinceArg.match(/^(\d+)h$/i);
66
+ const daysMatch = sinceArg.match(/^(\d+)d$/i);
67
+ if (hoursMatch) return new Date(Date.now() - parseInt(hoursMatch[1]) * 3600000);
68
+ if (daysMatch) return new Date(Date.now() - parseInt(daysMatch[1]) * 86400000);
69
+ const parsed = new Date(sinceArg);
70
+ if (!isNaN(parsed)) return parsed;
71
+ }
72
+
73
+ // Find last handoff entry
74
+ for (let i = allEntries.length - 1; i >= 0; i--) {
75
+ if (allEntries[i].type === "handoff") {
76
+ const ts = new Date(allEntries[i].ts || 0);
77
+ const dayAgo = new Date(Date.now() - 86400000);
78
+ return ts > dayAgo ? ts : dayAgo;
79
+ }
80
+ }
81
+
82
+ return new Date(Date.now() - 86400000);
83
+ }
84
+
85
+ function copyToClipboard(text) {
86
+ try {
87
+ const p = process.platform;
88
+ if (p === "win32") execSync("clip", { input: text });
89
+ else if (p === "darwin") execSync("pbcopy", { input: text });
90
+ else { try { execSync("xclip -selection clipboard", { input: text }); } catch { execSync("xsel --clipboard --input", { input: text }); } }
91
+ return true;
92
+ } catch { return false; }
93
+ }
94
+
95
+ function buildHandoff(toAgent, sinceArg, allFlag) {
96
+ const state = readJSON(STATE_FILE) || {};
97
+ const contract = readJSON(CONTRACT_FILE) || {};
98
+ const theme = readJSON(THEME_FILE);
99
+ const allEntries = getAllEntries();
100
+ const sessionStart = findSessionStart(allEntries, sinceArg, allFlag);
101
+ // Session entries: everything since boundary; also keep last 5 for "recent log"
102
+ const sessions = allEntries.filter(e => new Date(e.ts || 0) > sessionStart);
103
+ const recentFallback = allEntries.slice(-5); // fallback if session is empty
104
+ const now = new Date().toLocaleString("en-GB", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" });
105
+
106
+ const projectId = contract.policyId || path.basename(process.cwd());
107
+ const version = contract.policyVersion || "?";
108
+ const caps = (contract.capabilities || []).slice(0, 20);
109
+
110
+ // ── Session memory grouped by type ────────────────────────────────────────
111
+ const pool = sessions.length > 0 ? sessions : recentFallback;
112
+ const gotchas = pool.filter(e => e.type === "gotcha");
113
+ const decisions = pool.filter(e => e.type === "decision");
114
+ const attempts = pool.filter(e => e.type === "attempt").filter(e => e.result === "failed" || e.result === "partial");
115
+ const prefs = pool.filter(e => e.type === "preference");
116
+ const recent = pool.slice(-8); // last 8 regardless of type
117
+
118
+ const sinceStr = sessionStart.getTime() === 0
119
+ ? "all time"
120
+ : sessionStart.toLocaleString("en-GB", { day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit" });
121
+
122
+ const lines = [
123
+ `# 🔥 infernoflow Handoff — ${projectId}`,
124
+ `> Generated: ${now}${toAgent ? ` | Handing off to: **${toAgent}**` : ""}`,
125
+ `> Session memory: **${sessions.length} entries** since ${sinceStr}`,
126
+ "",
127
+ "---",
128
+ "",
129
+ "## Pick up here",
130
+ "",
131
+ ];
132
+
133
+ // Current working state
134
+ if (state.working || state.intent) {
135
+ if (state.working) lines.push(`**Working on:** ${state.working} _(${fmtDate(state.workingUpdated)})_`);
136
+ if (state.intent) lines.push(`**Intent:** ${state.intent} _(${fmtDate(state.intentUpdated)})_`);
137
+ lines.push("");
138
+ } else {
139
+ lines.push("_No working state set. Run: `infernoflow context --working \"...\"` to set it._", "");
140
+ }
141
+
142
+ // ── Gotchas first — most critical for a new agent ─────────────────────────
143
+ if (gotchas.length) {
144
+ lines.push("## ⚠ Gotchas — read these first", "");
145
+ for (const e of gotchas) {
146
+ lines.push(`- ${e.summary} _(${fmtDate(e.ts)})_`);
147
+ }
148
+ lines.push("");
149
+ }
150
+
151
+ // ── Decisions ──────────────────────────────────────────────────────────────
152
+ if (decisions.length) {
153
+ lines.push("## Decisions made", "");
154
+ for (const e of decisions) {
155
+ const result = e.result ? ` → **${e.result}**` : "";
156
+ lines.push(`- ${e.summary}${result} _(${fmtDate(e.ts)})_`);
157
+ }
158
+ lines.push("");
159
+ }
160
+
161
+ // ── Failed attempts — don't repeat them ───────────────────────────────────
162
+ if (attempts.length) {
163
+ lines.push("## ✗ Already tried — don't repeat", "");
164
+ for (const e of attempts) {
165
+ lines.push(`- ${e.summary} _(${fmtDate(e.ts)})_`);
166
+ }
167
+ lines.push("");
168
+ }
169
+
170
+ // ── Preferences ───────────────────────────────────────────────────────────
171
+ if (prefs.length) {
172
+ lines.push("## Developer preferences", "");
173
+ for (const e of prefs) {
174
+ lines.push(`- ${e.summary}`);
175
+ }
176
+ lines.push("");
177
+ }
178
+
179
+ // ── Design system ─────────────────────────────────────────────────────────
180
+ if (theme) {
181
+ lines.push("## Design system", "");
182
+ if (theme.fonts?.primary) lines.push(`- **Font:** ${theme.fonts.primary}${theme.fonts.mono ? ` · mono: ${theme.fonts.mono}` : ""}`);
183
+ if (theme.colors?.mode) lines.push(`- **Mode:** ${theme.colors.mode}`);
184
+ if (theme.colors?.palette) {
185
+ const pal = Object.entries(theme.colors.palette).map(([k,v]) => `${k}=${v}`).join(" ");
186
+ lines.push(`- **Palette:** ${pal}`);
187
+ }
188
+ if (theme.cssVars && Object.keys(theme.cssVars).length) {
189
+ const top = Object.entries(theme.cssVars).slice(0, 6).map(([k,v]) => `${k}: ${v}`).join(" | ");
190
+ lines.push(`- **CSS vars:** ${top}`);
191
+ }
192
+ if (theme.framework) lines.push(`- **Framework:** ${theme.framework}`);
193
+ lines.push("", "> ⚠ Always match these exactly. Do not introduce new colors or fonts.", "");
194
+ }
195
+
196
+ // ── Capabilities ──────────────────────────────────────────────────────────
197
+ if (caps.length) {
198
+ lines.push("## Capability contract", "");
199
+ lines.push(`Project: **${projectId}** v${version}`);
200
+ lines.push(`Capabilities: ${caps.join(", ")}`);
201
+ lines.push("");
202
+ }
203
+
204
+ // ── Recent session log ────────────────────────────────────────────────────
205
+ if (recent.length) {
206
+ lines.push("## Recent session log", "");
207
+ for (const e of recent) {
208
+ const result = e.result ? ` [${e.result}]` : "";
209
+ lines.push(`- **${e.type}**${result}: ${e.summary} _(${fmtDate(e.ts)})_`);
210
+ }
211
+ lines.push("");
212
+ }
213
+
214
+ lines.push("---");
215
+ lines.push("_Paste this at the start of your next AI session. Generated by infernoflow._");
216
+
217
+ return lines.join("\n");
218
+ }
219
+
220
+ export async function switchCommand(args) {
221
+ const has = (f) => args.includes(f);
222
+ const flag = (f) => { const i = args.indexOf(f); return i !== -1 && args[i+1] ? args[i+1] : null; };
223
+ const showOnly = has("--show") || has("-s");
224
+ const copyFlag = has("--copy") || has("-c");
225
+ const jsonFlag = has("--json");
226
+ const allFlag = has("--all");
227
+ const sinceArg = flag("--since");
228
+ const toAgent = flag("--to") || args.find(a => !a.startsWith("-") && !["switch"].includes(a)) || null;
229
+
230
+ console.log("\n " + bold("🔥 infernoflow — switch"));
231
+ console.log(" " + "─".repeat(50) + "\n");
232
+
233
+ if (!fs.existsSync(INFERNO_DIR)) {
234
+ console.error(red(" ✘ inferno/ not found — run: infernoflow init\n"));
235
+ process.exit(1);
236
+ }
237
+
238
+ // ── Show existing handoff ─────────────────────────────────────────────────
239
+ if (showOnly) {
240
+ const existing = readFile(HANDOFF_FILE);
241
+ if (!existing) {
242
+ console.log(yellow(" ⚠ No HANDOFF.md yet — run: infernoflow switch\n"));
243
+ return;
244
+ }
245
+ console.log(existing);
246
+ return;
247
+ }
248
+
249
+ const handoff = buildHandoff(toAgent, sinceArg, allFlag);
250
+
251
+ if (jsonFlag) {
252
+ const state = readJSON(STATE_FILE) || {};
253
+ const contract = readJSON(CONTRACT_FILE) || {};
254
+ const theme = readJSON(THEME_FILE);
255
+ const allEntries = getAllEntries();
256
+ const sessionStart = findSessionStart(allEntries, sinceArg, allFlag);
257
+ const sessions = allEntries.filter(e => new Date(e.ts || 0) > sessionStart);
258
+ console.log(JSON.stringify({ state, contract: { policyId: contract.policyId, policyVersion: contract.policyVersion, capabilities: contract.capabilities }, theme, sessions, sessionStart: sessionStart.toISOString(), generatedAt: new Date().toISOString() }, null, 2));
259
+ return;
260
+ }
261
+
262
+ // Write HANDOFF.md
263
+ fs.writeFileSync(HANDOFF_FILE, handoff, "utf8");
264
+ console.log(green(" ✔ Written → inferno/HANDOFF.md\n"));
265
+
266
+ // Also log the handoff itself to sessions.jsonl
267
+ if (fs.existsSync(SESSIONS_FILE)) {
268
+ const entry = {
269
+ ts: new Date().toISOString(),
270
+ agent: "infernoflow",
271
+ type: "handoff",
272
+ summary: toAgent ? `Handed off to ${toAgent}` : "Handoff generated",
273
+ };
274
+ fs.appendFileSync(SESSIONS_FILE, JSON.stringify(entry) + "\n", "utf8");
275
+ }
276
+
277
+ // Print preview
278
+ const allEntriesForCount = getAllEntries();
279
+ const sessionStartForCount = findSessionStart(allEntriesForCount, sinceArg, allFlag);
280
+ const sessionEntries = allEntriesForCount.filter(e => new Date(e.ts || 0) > sessionStartForCount);
281
+ const state = readJSON(STATE_FILE) || {};
282
+ const theme = readJSON(THEME_FILE);
283
+ const contract = readJSON(CONTRACT_FILE) || {};
284
+
285
+ console.log(" " + bold("Handoff summary"));
286
+ console.log(" " + "─".repeat(50));
287
+ if (state.working) console.log(" Working on " + cyan(state.working));
288
+ if (state.intent) console.log(" Intent " + cyan(state.intent));
289
+ console.log(" Session " + sessionEntries.length + " entries (total: " + allEntriesForCount.length + ")");
290
+ console.log(" Capabilities " + (contract.capabilities || []).length + " registered");
291
+ if (theme?.fonts?.primary) console.log(" Font " + theme.fonts.primary);
292
+ if (theme?.colors?.mode) console.log(" Color mode " + theme.colors.mode);
293
+ if (toAgent) console.log(" Handing off → " + cyan(toAgent));
294
+ console.log();
295
+
296
+ if (copyFlag) {
297
+ const ok = copyToClipboard(handoff);
298
+ console.log(ok
299
+ ? green(" ✔ Copied to clipboard — paste at the start of your next AI session")
300
+ : yellow(" ⚠ Clipboard failed — open inferno/HANDOFF.md manually")
301
+ );
302
+ } else {
303
+ console.log(" " + bold("Ready to use:"));
304
+ console.log(" " + cyan("1.") + " Open " + cyan("inferno/HANDOFF.md"));
305
+ console.log(" " + cyan("2.") + " Copy all");
306
+ console.log(" " + cyan("3.") + " Paste at the start of your next AI session");
307
+ console.log(" " + gray(" tip: use --copy to skip steps 1-2 automatically"));
308
+ }
309
+ console.log();
310
+ }
@@ -1 +1,96 @@
1
- import{execFileSync as w}from"node:child_process";import*as y from"node:path";import{fileURLToPath as P}from"node:url";import{header as h,section as d,ok as e,warn as f,yellow as g,gray as p}from"../ui/output.mjs";const S=P(import.meta.url),C=y.dirname(S),N=y.resolve(C,"..","..","bin","infernoflow.mjs");function D(o){const n=w(process.execPath,[N,...o],{encoding:"utf8",stdio:["ignore","pipe","pipe"]});return JSON.parse(n)}function _(o){try{return{ok:!0,data:D(o)}}catch(n){const s=n?.stdout?.toString?.()||"";try{return{ok:!1,data:JSON.parse(s)}}catch{return{ok:!1,data:{ok:!1,errors:["command_failed"]}}}}}async function E(o=[]){const n=o.includes("--auto"),s=o.includes("--json"),u=o.includes("--dry-run");n||(s&&(console.log(JSON.stringify({ok:!1,error:"missing_required_flag",hint:"Use: infernoflow sync --auto"},null,2)),process.exit(1)),h("sync"),f("missing --auto flag"),console.log(` ${g("\u2192")} infernoflow sync --auto`),console.log(),process.exit(1));const c=_(["pr-impact","--json"]),i=!c.data?.ok,a=c.data?.confidence||"low",r=a==="high"?"auto":a==="medium"?"ask":"block",k=i?["Generate inferno update proposal (suggest)","Review changes","Validate with check --json"]:["No inferno drift detected","Validate with check --json"],t=_(["check","--json"]),l={ok:c.ok&&t.ok&&!!t.data?.ok,mode:"auto-skeleton",dryRun:u,needsSync:i,didApply:!1,confidence:a,policyDecision:r,actions:k,prImpact:c.data,postCheck:t.data,reasonCodes:[...i?["DRIFT_DETECTED"]:["NO_DRIFT"],`POLICY_${r.toUpperCase()}`,...r==="auto"?["AUTO_APPLY_DISABLED_IN_SKELETON"]:[]]};s&&(console.log(JSON.stringify(l,null,2)),process.exit(l.ok?0:1)),h("sync --auto"),d("State"),i?f("Inferno drift detected"):e("No inferno drift detected"),e(`Confidence: ${p(a)}`),e(`Policy decision: ${p(r)}`),e(`Apply mode: ${p("skeleton (no file writes)")}`),u&&e("Dry run enabled"),d("Plan"),k.forEach(m=>console.log(` ${g("\u2192")} ${m}`)),d("Validation"),t.ok&&t.data?.ok?e("Post-check passed"):f("Post-check failed; see infernoflow check --json"),console.log(),process.exit(l.ok?0:1)}export{E as syncCommand};
1
+ import { execFileSync } from "node:child_process";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { header, section, ok, warn, yellow, gray } from "../ui/output.mjs";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ const binPath = path.resolve(__dirname, "..", "..", "bin", "infernoflow.mjs");
9
+
10
+ function runCliJson(args) {
11
+ const out = execFileSync(process.execPath, [binPath, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
12
+ return JSON.parse(out);
13
+ }
14
+
15
+ function tryRunCliJson(args) {
16
+ try {
17
+ return { ok: true, data: runCliJson(args) };
18
+ } catch (err) {
19
+ const stdout = err?.stdout?.toString?.() || "";
20
+ try {
21
+ return { ok: false, data: JSON.parse(stdout) };
22
+ } catch {
23
+ return { ok: false, data: { ok: false, errors: ["command_failed"] } };
24
+ }
25
+ }
26
+ }
27
+
28
+ export async function syncCommand(args = []) {
29
+ const auto = args.includes("--auto");
30
+ const asJson = args.includes("--json");
31
+ const dryRun = args.includes("--dry-run");
32
+
33
+ if (!auto) {
34
+ const payload = { ok: false, error: "missing_required_flag", hint: "Use: infernoflow sync --auto" };
35
+ if (asJson) {
36
+ console.log(JSON.stringify(payload, null, 2));
37
+ process.exit(1);
38
+ }
39
+ header("sync");
40
+ warn("missing --auto flag");
41
+ console.log(` ${yellow("→")} infernoflow sync --auto`);
42
+ console.log();
43
+ process.exit(1);
44
+ }
45
+
46
+ const impact = tryRunCliJson(["pr-impact", "--json"]);
47
+ const needsSync = !impact.data?.ok;
48
+ const confidence = impact.data?.confidence || "low";
49
+ const policyDecision = confidence === "high" ? "auto" : confidence === "medium" ? "ask" : "block";
50
+ const actions = needsSync
51
+ ? ["Generate inferno update proposal (suggest)", "Review changes", "Validate with check --json"]
52
+ : ["No inferno drift detected", "Validate with check --json"];
53
+
54
+ const check = tryRunCliJson(["check", "--json"]);
55
+ const payload = {
56
+ ok: impact.ok && check.ok && !!check.data?.ok,
57
+ mode: "auto-skeleton",
58
+ dryRun,
59
+ needsSync,
60
+ didApply: false,
61
+ confidence,
62
+ policyDecision,
63
+ actions,
64
+ prImpact: impact.data,
65
+ postCheck: check.data,
66
+ reasonCodes: [
67
+ ...(needsSync ? ["DRIFT_DETECTED"] : ["NO_DRIFT"]),
68
+ `POLICY_${policyDecision.toUpperCase()}`,
69
+ ...(policyDecision === "auto" ? ["AUTO_APPLY_DISABLED_IN_SKELETON"] : []),
70
+ ],
71
+ };
72
+
73
+ if (asJson) {
74
+ console.log(JSON.stringify(payload, null, 2));
75
+ process.exit(payload.ok ? 0 : 1);
76
+ }
77
+
78
+ header("sync --auto");
79
+ section("State");
80
+ if (needsSync) warn("Inferno drift detected");
81
+ else ok("No inferno drift detected");
82
+ ok(`Confidence: ${gray(confidence)}`);
83
+ ok(`Policy decision: ${gray(policyDecision)}`);
84
+ ok(`Apply mode: ${gray("skeleton (no file writes)")}`);
85
+ if (dryRun) ok("Dry run enabled");
86
+
87
+ section("Plan");
88
+ actions.forEach((a) => console.log(` ${yellow("→")} ${a}`));
89
+
90
+ section("Validation");
91
+ if (check.ok && check.data?.ok) ok("Post-check passed");
92
+ else warn("Post-check failed; see infernoflow check --json");
93
+ console.log();
94
+ process.exit(payload.ok ? 0 : 1);
95
+ }
96
+