infernoflow 0.33.1 → 0.34.0
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/README.md +208 -120
- package/dist/bin/infernoflow.mjs +271 -85
- package/dist/lib/adopters/angular.mjs +128 -1
- package/dist/lib/adopters/css.mjs +111 -1
- package/dist/lib/adopters/react.mjs +104 -1
- package/dist/lib/ai/ideDetection.mjs +31 -1
- package/dist/lib/ai/localProvider.mjs +88 -1
- package/dist/lib/ai/providerRouter.mjs +295 -2
- package/dist/lib/commands/adopt.mjs +869 -20
- package/dist/lib/commands/adoptWizard.mjs +320 -9
- package/dist/lib/commands/agent.mjs +191 -5
- package/dist/lib/commands/ai.mjs +407 -2
- package/dist/lib/commands/ask.mjs +299 -0
- package/dist/lib/commands/audit.mjs +300 -13
- package/dist/lib/commands/changelog.mjs +594 -26
- package/dist/lib/commands/check.mjs +184 -3
- package/dist/lib/commands/ci.mjs +208 -3
- package/dist/lib/commands/claudeMd.mjs +139 -28
- package/dist/lib/commands/cloud.mjs +521 -5
- package/dist/lib/commands/context.mjs +346 -34
- package/dist/lib/commands/coverage.mjs +282 -2
- package/dist/lib/commands/dashboard.mjs +635 -123
- package/dist/lib/commands/demo.mjs +465 -8
- package/dist/lib/commands/diff.mjs +274 -5
- package/dist/lib/commands/docGate.mjs +81 -2
- package/dist/lib/commands/doctor.mjs +321 -3
- package/dist/lib/commands/explain.mjs +438 -8
- package/dist/lib/commands/export.mjs +239 -10
- package/dist/lib/commands/generateSkills.mjs +163 -38
- package/dist/lib/commands/graph.mjs +378 -11
- package/dist/lib/commands/health.mjs +309 -2
- package/dist/lib/commands/impact.mjs +325 -2
- package/dist/lib/commands/implement.mjs +103 -7
- package/dist/lib/commands/init.mjs +545 -23
- package/dist/lib/commands/installCursorHooks.mjs +36 -1
- package/dist/lib/commands/installVsCodeCopilotHooks.mjs +37 -1
- package/dist/lib/commands/link.mjs +342 -2
- package/dist/lib/commands/log.mjs +164 -16
- package/dist/lib/commands/monorepo.mjs +428 -4
- package/dist/lib/commands/notify.mjs +258 -4
- package/dist/lib/commands/onboard.mjs +296 -4
- package/dist/lib/commands/prComment.mjs +361 -2
- package/dist/lib/commands/prImpact.mjs +157 -2
- package/dist/lib/commands/publish.mjs +316 -15
- package/dist/lib/commands/recap.mjs +359 -0
- package/dist/lib/commands/report.mjs +272 -28
- package/dist/lib/commands/review.mjs +223 -9
- package/dist/lib/commands/run.mjs +336 -8
- package/dist/lib/commands/scaffold.mjs +419 -54
- package/dist/lib/commands/scan.mjs +1118 -5
- package/dist/lib/commands/scout.mjs +291 -2
- package/dist/lib/commands/setup.mjs +310 -5
- package/dist/lib/commands/share.mjs +196 -13
- package/dist/lib/commands/snapshot.mjs +383 -3
- package/dist/lib/commands/stability.mjs +293 -2
- package/dist/lib/commands/stats.mjs +402 -0
- package/dist/lib/commands/status.mjs +172 -4
- package/dist/lib/commands/suggest.mjs +563 -21
- package/dist/lib/commands/switch.mjs +310 -9
- package/dist/lib/commands/syncAuto.mjs +96 -1
- package/dist/lib/commands/synthesize.mjs +228 -10
- package/dist/lib/commands/teamSync.mjs +388 -2
- package/dist/lib/commands/test.mjs +363 -6
- package/dist/lib/commands/theme.mjs +195 -18
- package/dist/lib/commands/upgrade.mjs +153 -0
- package/dist/lib/commands/version.mjs +282 -2
- package/dist/lib/commands/vibe.mjs +357 -7
- package/dist/lib/commands/watch.mjs +203 -4
- package/dist/lib/commands/why.mjs +358 -4
- package/dist/lib/cursorHooksInstall.mjs +60 -1
- package/dist/lib/draftToolingInstall.mjs +68 -7
- package/dist/lib/git/detect-drift.mjs +208 -4
- package/dist/lib/learning/adapt.mjs +101 -6
- package/dist/lib/learning/observe.mjs +119 -1
- package/dist/lib/learning/patternDetector.mjs +298 -1
- package/dist/lib/learning/profile.mjs +279 -2
- package/dist/lib/learning/skillSynthesizer.mjs +145 -24
- package/dist/lib/templates/index.mjs +131 -1
- package/dist/lib/theme/scanner.mjs +343 -4
- package/dist/lib/ui/errors.mjs +142 -1
- package/dist/lib/ui/output.mjs +72 -6
- package/dist/lib/ui/prompts.mjs +147 -6
- package/dist/lib/vsCodeCopilotHooksInstall.mjs +42 -1
- package/package.json +1 -1
|
@@ -1,9 +1,310 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
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
|
+
|