infernoflow 0.33.0 → 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 -0
- 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,2 +1,342 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* infernoflow link
|
|
3
|
+
*
|
|
4
|
+
* Link capabilities to tickets in Jira, Linear, or GitHub Issues.
|
|
5
|
+
* Stored in inferno/links.json — travels with the repo.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* infernoflow link --jira PROJ-123 --capability CreateTask
|
|
9
|
+
* infernoflow link --linear LIN-456 --capability FilterByTag
|
|
10
|
+
* infernoflow link --github 78 --capability ExportToCsv
|
|
11
|
+
* infernoflow link list Show all links
|
|
12
|
+
* infernoflow link status Show which caps have open tickets
|
|
13
|
+
* infernoflow link remove --capability CreateTask
|
|
14
|
+
* infernoflow link --json Machine-readable
|
|
15
|
+
*
|
|
16
|
+
* Config (inferno/integrations.json):
|
|
17
|
+
* {
|
|
18
|
+
* "jira": { "baseUrl": "https://myorg.atlassian.net", "token": "...", "email": "..." },
|
|
19
|
+
* "linear": { "apiKey": "lin_api_..." },
|
|
20
|
+
* "github": { "repo": "owner/repo", "token": "ghp_..." }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* Env vars (override config):
|
|
24
|
+
* JIRA_BASE_URL, JIRA_TOKEN, JIRA_EMAIL
|
|
25
|
+
* LINEAR_API_KEY
|
|
26
|
+
* GITHUB_TOKEN, GITHUB_REPOSITORY
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import * as fs from "node:fs";
|
|
30
|
+
import * as path from "node:path";
|
|
31
|
+
import * as https from "node:https";
|
|
32
|
+
import { done, warn, info, bold, cyan, gray, green, yellow, red } from "../ui/output.mjs";
|
|
33
|
+
|
|
34
|
+
const LINKS_FILE = "links.json";
|
|
35
|
+
const CONFIG_FILE = "integrations.json";
|
|
36
|
+
|
|
37
|
+
// ── Storage ───────────────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
function readLinks(infernoDir) {
|
|
40
|
+
const p = path.join(infernoDir, LINKS_FILE);
|
|
41
|
+
if (!fs.existsSync(p)) return [];
|
|
42
|
+
try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return []; }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function writeLinks(infernoDir, links) {
|
|
46
|
+
fs.writeFileSync(path.join(infernoDir, LINKS_FILE), JSON.stringify(links, null, 2) + "\n");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readIntegrationConfig(infernoDir) {
|
|
50
|
+
const p = path.join(infernoDir, CONFIG_FILE);
|
|
51
|
+
if (!fs.existsSync(p)) return {};
|
|
52
|
+
try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return {}; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ── HTTP helper ───────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
function httpsGet(url, headers = {}) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const parsed = new URL(url);
|
|
60
|
+
https.get({
|
|
61
|
+
hostname: parsed.hostname,
|
|
62
|
+
path: parsed.pathname + (parsed.search || ""),
|
|
63
|
+
headers: { "User-Agent": "infernoflow-cli", "Accept": "application/json", ...headers },
|
|
64
|
+
}, (res) => {
|
|
65
|
+
let data = "";
|
|
66
|
+
res.on("data", d => (data += d));
|
|
67
|
+
res.on("end", () => {
|
|
68
|
+
try { resolve({ status: res.statusCode, body: JSON.parse(data) }); }
|
|
69
|
+
catch { resolve({ status: res.statusCode, body: data }); }
|
|
70
|
+
});
|
|
71
|
+
}).on("error", reject);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ── Ticket fetchers ───────────────────────────────────────────────────────────
|
|
76
|
+
|
|
77
|
+
async function fetchJiraTicket(ticketId, config) {
|
|
78
|
+
const base = process.env.JIRA_BASE_URL || config.jira?.baseUrl;
|
|
79
|
+
const token = process.env.JIRA_TOKEN || config.jira?.token;
|
|
80
|
+
const email = process.env.JIRA_EMAIL || config.jira?.email;
|
|
81
|
+
if (!base || !token) return null;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const creds = Buffer.from(`${email}:${token}`).toString("base64");
|
|
85
|
+
const resp = await httpsGet(`${base}/rest/api/3/issue/${ticketId}`, {
|
|
86
|
+
"Authorization": `Basic ${creds}`,
|
|
87
|
+
});
|
|
88
|
+
if (resp.status === 200) {
|
|
89
|
+
return {
|
|
90
|
+
id: ticketId,
|
|
91
|
+
title: resp.body.fields?.summary || ticketId,
|
|
92
|
+
status: resp.body.fields?.status?.name || "unknown",
|
|
93
|
+
url: `${base}/browse/${ticketId}`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
} catch {}
|
|
97
|
+
return { id: ticketId, title: ticketId, status: "unknown", url: null };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function fetchLinearTicket(ticketId, config) {
|
|
101
|
+
const apiKey = process.env.LINEAR_API_KEY || config.linear?.apiKey;
|
|
102
|
+
if (!apiKey) return null;
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const query = JSON.stringify({
|
|
106
|
+
query: `{ issue(id: "${ticketId}") { title state { name } url } }`
|
|
107
|
+
});
|
|
108
|
+
const resp = await new Promise((resolve, reject) => {
|
|
109
|
+
const body = query;
|
|
110
|
+
const req = https.request({
|
|
111
|
+
hostname: "api.linear.app",
|
|
112
|
+
path: "/graphql",
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "Content-Type": "application/json", "Authorization": apiKey, "Content-Length": Buffer.byteLength(body) },
|
|
115
|
+
}, (res) => {
|
|
116
|
+
let data = "";
|
|
117
|
+
res.on("data", d => (data += d));
|
|
118
|
+
res.on("end", () => resolve(JSON.parse(data)));
|
|
119
|
+
});
|
|
120
|
+
req.on("error", reject);
|
|
121
|
+
req.write(body);
|
|
122
|
+
req.end();
|
|
123
|
+
});
|
|
124
|
+
const issue = resp.data?.issue;
|
|
125
|
+
if (issue) return { id: ticketId, title: issue.title, status: issue.state?.name || "unknown", url: issue.url };
|
|
126
|
+
} catch {}
|
|
127
|
+
return { id: ticketId, title: ticketId, status: "unknown", url: null };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function fetchGithubIssue(issueNum, config) {
|
|
131
|
+
const token = process.env.GITHUB_TOKEN || config.github?.token;
|
|
132
|
+
const repo = process.env.GITHUB_REPOSITORY || config.github?.repo;
|
|
133
|
+
if (!repo) return null;
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const headers = { "Authorization": token ? `Bearer ${token}` : undefined };
|
|
137
|
+
const resp = await httpsGet(`https://api.github.com/repos/${repo}/issues/${issueNum}`, headers);
|
|
138
|
+
if (resp.status === 200) {
|
|
139
|
+
return {
|
|
140
|
+
id: `#${issueNum}`,
|
|
141
|
+
title: resp.body.title || `Issue #${issueNum}`,
|
|
142
|
+
status: resp.body.state || "unknown",
|
|
143
|
+
url: resp.body.html_url,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
} catch {}
|
|
147
|
+
return { id: `#${issueNum}`, title: `Issue #${issueNum}`, status: "unknown", url: null };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── Sub-commands ──────────────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
async function subcmdAdd(args, infernoDir, config) {
|
|
153
|
+
const jsonMode = args.includes("--json");
|
|
154
|
+
const capIdx = args.indexOf("--capability");
|
|
155
|
+
const jiraIdx = args.indexOf("--jira");
|
|
156
|
+
const linearIdx = args.indexOf("--linear");
|
|
157
|
+
const githubIdx = args.indexOf("--github");
|
|
158
|
+
|
|
159
|
+
const capability = capIdx !== -1 ? args[capIdx + 1] : null;
|
|
160
|
+
const jiraId = jiraIdx !== -1 ? args[jiraIdx + 1] : null;
|
|
161
|
+
const linearId = linearIdx !== -1 ? args[linearIdx + 1] : null;
|
|
162
|
+
const githubNum = githubIdx !== -1 ? args[githubIdx + 1] : null;
|
|
163
|
+
|
|
164
|
+
if (!capability) {
|
|
165
|
+
const msg = "Usage: infernoflow link --capability <id> --jira <TICKET> | --linear <ID> | --github <NUM>";
|
|
166
|
+
if (jsonMode) { console.log(JSON.stringify({ ok: false, error: msg })); } else { warn(msg); }
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let ticket = null;
|
|
171
|
+
let platform = null;
|
|
172
|
+
|
|
173
|
+
if (jiraId) {
|
|
174
|
+
if (!jsonMode) process.stdout.write(` Fetching Jira ${jiraId}… `);
|
|
175
|
+
ticket = await fetchJiraTicket(jiraId, config);
|
|
176
|
+
platform = "jira";
|
|
177
|
+
} else if (linearId) {
|
|
178
|
+
if (!jsonMode) process.stdout.write(` Fetching Linear ${linearId}… `);
|
|
179
|
+
ticket = await fetchLinearTicket(linearId, config);
|
|
180
|
+
platform = "linear";
|
|
181
|
+
} else if (githubNum) {
|
|
182
|
+
if (!jsonMode) process.stdout.write(` Fetching GitHub #${githubNum}… `);
|
|
183
|
+
ticket = await fetchGithubIssue(githubNum, config);
|
|
184
|
+
platform = "github";
|
|
185
|
+
} else {
|
|
186
|
+
const msg = "Specify --jira, --linear, or --github";
|
|
187
|
+
if (jsonMode) { console.log(JSON.stringify({ ok: false, error: msg })); } else { warn(msg); }
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const links = readLinks(infernoDir);
|
|
192
|
+
const existing = links.findIndex(l => l.capability === capability);
|
|
193
|
+
|
|
194
|
+
const link = {
|
|
195
|
+
capability,
|
|
196
|
+
platform,
|
|
197
|
+
ticketId: ticket?.id || jiraId || linearId || `#${githubNum}`,
|
|
198
|
+
title: ticket?.title || "",
|
|
199
|
+
status: ticket?.status || "unknown",
|
|
200
|
+
url: ticket?.url || null,
|
|
201
|
+
linkedAt: new Date().toISOString(),
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
if (existing !== -1) {
|
|
205
|
+
links[existing] = link;
|
|
206
|
+
} else {
|
|
207
|
+
links.push(link);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
writeLinks(infernoDir, links);
|
|
211
|
+
|
|
212
|
+
if (!jsonMode) console.log(green("done"));
|
|
213
|
+
|
|
214
|
+
if (jsonMode) {
|
|
215
|
+
console.log(JSON.stringify({ ok: true, link }));
|
|
216
|
+
} else {
|
|
217
|
+
done(`Linked: ${bold(capability)} → ${cyan(link.ticketId)} (${link.status})`);
|
|
218
|
+
if (link.url) console.log(` ${gray(link.url)}`);
|
|
219
|
+
console.log();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function subcmdList(args, infernoDir) {
|
|
224
|
+
const jsonMode = args.includes("--json");
|
|
225
|
+
const links = readLinks(infernoDir);
|
|
226
|
+
|
|
227
|
+
if (jsonMode) {
|
|
228
|
+
console.log(JSON.stringify({ ok: true, links }));
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!links.length) {
|
|
233
|
+
info("No links yet. Use: infernoflow link --capability <id> --jira <TICKET>");
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
console.log();
|
|
238
|
+
console.log(` ${bold(`${links.length} capability link${links.length !== 1 ? "s" : ""}`)}`);
|
|
239
|
+
console.log();
|
|
240
|
+
|
|
241
|
+
const w = Math.max(...links.map(l => l.capability.length), 10) + 2;
|
|
242
|
+
for (const l of links) {
|
|
243
|
+
const statusColor = l.status?.toLowerCase() === "done" || l.status?.toLowerCase() === "closed"
|
|
244
|
+
? green : l.status?.toLowerCase() === "in progress" ? yellow : gray;
|
|
245
|
+
console.log(` ${bold(l.capability.padEnd(w))} ${cyan(l.ticketId.padEnd(14))} ${statusColor(l.status || "unknown")}`);
|
|
246
|
+
if (l.title && l.title !== l.ticketId) console.log(` ${" ".repeat(w + 2)}${gray(l.title)}`);
|
|
247
|
+
}
|
|
248
|
+
console.log();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function subcmdStatus(args, infernoDir) {
|
|
252
|
+
const jsonMode = args.includes("--json");
|
|
253
|
+
const links = readLinks(infernoDir);
|
|
254
|
+
|
|
255
|
+
// Load contract to find unlinked capabilities
|
|
256
|
+
let contract = null;
|
|
257
|
+
for (const f of ["contract.json", "capabilities.json"]) {
|
|
258
|
+
const p = path.join(infernoDir, f);
|
|
259
|
+
if (fs.existsSync(p)) { try { contract = JSON.parse(fs.readFileSync(p, "utf8")); break; } catch {} }
|
|
260
|
+
}
|
|
261
|
+
const allCaps = (contract?.capabilities || []).map(c => typeof c === "string" ? c : c.id);
|
|
262
|
+
const linkedIds = new Set(links.map(l => l.capability));
|
|
263
|
+
const unlinked = allCaps.filter(id => !linkedIds.has(id));
|
|
264
|
+
|
|
265
|
+
if (jsonMode) {
|
|
266
|
+
console.log(JSON.stringify({ ok: true, linked: links.length, unlinked: unlinked.length, links, unlinkedCapabilities: unlinked }));
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
console.log();
|
|
271
|
+
console.log(` ${bold("Capability link status")}`);
|
|
272
|
+
console.log();
|
|
273
|
+
|
|
274
|
+
if (links.length) {
|
|
275
|
+
console.log(` ${gray("Linked:")}`);
|
|
276
|
+
for (const l of links) {
|
|
277
|
+
const icon = l.status?.toLowerCase() === "done" ? green("✔") : l.status?.toLowerCase() === "in progress" ? yellow("⟳") : gray("○");
|
|
278
|
+
console.log(` ${icon} ${bold(l.capability)} ${cyan(l.ticketId)} ${gray(l.status || "")}`);
|
|
279
|
+
}
|
|
280
|
+
console.log();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (unlinked.length) {
|
|
284
|
+
console.log(` ${gray("Unlinked capabilities:")}`);
|
|
285
|
+
unlinked.forEach(id => console.log(` ${gray("·")} ${id}`));
|
|
286
|
+
console.log();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
console.log(` ${green(String(links.length))} linked · ${gray(String(unlinked.length))} unlinked`);
|
|
290
|
+
console.log();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async function subcmdRemove(args, infernoDir) {
|
|
294
|
+
const jsonMode = args.includes("--json");
|
|
295
|
+
const capIdx = args.indexOf("--capability");
|
|
296
|
+
const capId = capIdx !== -1 ? args[capIdx + 1] : null;
|
|
297
|
+
|
|
298
|
+
if (!capId) {
|
|
299
|
+
if (jsonMode) { console.log(JSON.stringify({ ok: false, error: "Usage: infernoflow link remove --capability <id>" })); }
|
|
300
|
+
else { warn("Usage: infernoflow link remove --capability <id>"); }
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const links = readLinks(infernoDir);
|
|
305
|
+
const before = links.length;
|
|
306
|
+
const updated = links.filter(l => l.capability !== capId);
|
|
307
|
+
|
|
308
|
+
if (updated.length === before) {
|
|
309
|
+
if (jsonMode) { console.log(JSON.stringify({ ok: false, error: `No link found for: ${capId}` })); }
|
|
310
|
+
else { warn(`No link found for: ${capId}`); }
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
writeLinks(infernoDir, updated);
|
|
315
|
+
if (jsonMode) { console.log(JSON.stringify({ ok: true, removed: capId })); }
|
|
316
|
+
else { done(`Removed link for ${bold(capId)}`); console.log(); }
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ── Entry ─────────────────────────────────────────────────────────────────────
|
|
320
|
+
|
|
321
|
+
export async function linkCommand(rawArgs) {
|
|
322
|
+
const args = rawArgs.slice(1);
|
|
323
|
+
const cwd = process.cwd();
|
|
324
|
+
const infernoDir = path.join(cwd, "inferno");
|
|
325
|
+
|
|
326
|
+
if (!fs.existsSync(infernoDir)) {
|
|
327
|
+
const msg = "inferno/ not found. Run: infernoflow init";
|
|
328
|
+
if (args.includes("--json")) { console.log(JSON.stringify({ ok: false, error: msg })); }
|
|
329
|
+
else { warn(msg); }
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const config = readIntegrationConfig(infernoDir);
|
|
334
|
+
const subcmd = args[0];
|
|
335
|
+
|
|
336
|
+
if (subcmd === "list") return subcmdList(args.slice(1), infernoDir);
|
|
337
|
+
if (subcmd === "status") return subcmdStatus(args.slice(1), infernoDir);
|
|
338
|
+
if (subcmd === "remove") return subcmdRemove(args.slice(1), infernoDir);
|
|
339
|
+
|
|
340
|
+
// Default: add a link
|
|
341
|
+
return subcmdAdd(args, infernoDir, config);
|
|
342
|
+
}
|
|
@@ -1,16 +1,164 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
/**
|
|
2
|
+
* infernoflow log
|
|
3
|
+
*
|
|
4
|
+
* Appends a human or agent entry to inferno/sessions.jsonl —
|
|
5
|
+
* the append-only memory file that captures what AI can't infer from code:
|
|
6
|
+
* failed attempts, decisions, gotchas, preferences, theme changes.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* infernoflow log "tried streaming upload, server rejected chunked transfer"
|
|
10
|
+
* infernoflow log "API expects multipart/form-data" --type gotcha
|
|
11
|
+
* infernoflow log "switched primary color to #f97316" --type theme
|
|
12
|
+
* infernoflow log "user prefers inline styles" --type preference
|
|
13
|
+
* infernoflow log "axios over fetch because of progress events" --type decision --result worked
|
|
14
|
+
* infernoflow log --show Print last 20 entries
|
|
15
|
+
* infernoflow log --show 5 Print last 5 entries
|
|
16
|
+
* infernoflow log --clear Archive and clear the log
|
|
17
|
+
* infernoflow log --json Print entries as JSON array
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import * as fs from "node:fs";
|
|
21
|
+
import * as path from "node:path";
|
|
22
|
+
import * as os from "node:os";
|
|
23
|
+
import { bold, cyan, gray, green, yellow, red } from "../ui/output.mjs";
|
|
24
|
+
|
|
25
|
+
const INFERNO_DIR = "inferno";
|
|
26
|
+
const SESSIONS_FILE = path.join(INFERNO_DIR, "sessions.jsonl");
|
|
27
|
+
|
|
28
|
+
const VALID_TYPES = ["note","attempt","decision","gotcha","preference","theme","handoff","error"];
|
|
29
|
+
const VALID_RESULTS = ["worked","failed","partial","unknown"];
|
|
30
|
+
|
|
31
|
+
function readEntries() {
|
|
32
|
+
if (!fs.existsSync(SESSIONS_FILE)) return [];
|
|
33
|
+
return fs.readFileSync(SESSIONS_FILE, "utf8")
|
|
34
|
+
.split("\n")
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.map(l => { try { return JSON.parse(l); } catch { return null; } })
|
|
37
|
+
.filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function appendEntry(entry) {
|
|
41
|
+
if (!fs.existsSync(INFERNO_DIR)) {
|
|
42
|
+
console.error(red(" ✘ inferno/ not found — run: infernoflow init\n"));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
fs.appendFileSync(SESSIONS_FILE, JSON.stringify(entry) + "\n", "utf8");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function detectAgent() {
|
|
49
|
+
// Try to detect which AI agent is running this
|
|
50
|
+
if (process.env.CURSOR_SESSION) return "cursor";
|
|
51
|
+
if (process.env.COPILOT_SESSION) return "copilot";
|
|
52
|
+
if (process.env.CLAUDE_CODE_SESSION) return "claude";
|
|
53
|
+
if (process.env.WINDSURF_SESSION) return "windsurf";
|
|
54
|
+
if (process.env.INFERNOFLOW_AGENT) return process.env.INFERNOFLOW_AGENT;
|
|
55
|
+
return "human";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function formatEntry(e, i) {
|
|
59
|
+
const ts = new Date(e.ts).toLocaleString("en-GB", { day:"2-digit", month:"short", hour:"2-digit", minute:"2-digit" });
|
|
60
|
+
const type = e.type || "note";
|
|
61
|
+
const color = type === "gotcha" ? "\x1b[33m" // yellow
|
|
62
|
+
: type === "decision" ? "\x1b[36m" // cyan
|
|
63
|
+
: type === "theme" ? "\x1b[35m" // magenta
|
|
64
|
+
: type === "preference" ? "\x1b[34m" // blue
|
|
65
|
+
: type === "attempt" ? "\x1b[90m" // dark gray
|
|
66
|
+
: type === "error" ? "\x1b[31m" // red
|
|
67
|
+
: "\x1b[0m";
|
|
68
|
+
const reset = "\x1b[0m";
|
|
69
|
+
const result = e.result ? ` [${e.result}]` : "";
|
|
70
|
+
const agent = e.agent && e.agent !== "human" ? gray(` (${e.agent})`) : "";
|
|
71
|
+
return ` ${gray(String(i+1).padStart(3))} ${gray(ts)} ${color}${type}${reset}${result} ${e.summary}${agent}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function logCommand(args) {
|
|
75
|
+
const has = (f) => args.includes(f);
|
|
76
|
+
const flag = (f, def) => { const i = args.indexOf(f); return i !== -1 && args[i+1] ? args[i+1] : def; };
|
|
77
|
+
|
|
78
|
+
const showFlag = has("--show");
|
|
79
|
+
const clearFlag = has("--clear");
|
|
80
|
+
const jsonFlag = has("--json");
|
|
81
|
+
|
|
82
|
+
// ── Show mode ───────────────────────────────────────────────────────────────
|
|
83
|
+
if (showFlag || jsonFlag) {
|
|
84
|
+
const entries = readEntries();
|
|
85
|
+
const countArg = args[args.indexOf("--show") + 1];
|
|
86
|
+
const count = countArg && /^\d+$/.test(countArg) ? parseInt(countArg) : 20;
|
|
87
|
+
const recent = entries.slice(-count);
|
|
88
|
+
|
|
89
|
+
if (jsonFlag) {
|
|
90
|
+
console.log(JSON.stringify(recent, null, 2));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log("\n " + bold("🔥 infernoflow — session memory"));
|
|
95
|
+
console.log(" " + "─".repeat(50));
|
|
96
|
+
if (!recent.length) {
|
|
97
|
+
console.log(gray("\n No entries yet. Start logging with: infernoflow log \"<what happened>\"\n"));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
console.log(gray(` Showing last ${recent.length} of ${entries.length} entries\n`));
|
|
101
|
+
recent.forEach((e, i) => console.log(formatEntry(e, entries.length - recent.length + i)));
|
|
102
|
+
console.log();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ── Clear mode ──────────────────────────────────────────────────────────────
|
|
107
|
+
if (clearFlag) {
|
|
108
|
+
if (!fs.existsSync(SESSIONS_FILE)) {
|
|
109
|
+
console.log(gray(" Nothing to clear.\n"));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const archive = SESSIONS_FILE.replace(".jsonl", `-archive-${Date.now()}.jsonl`);
|
|
113
|
+
fs.renameSync(SESSIONS_FILE, archive);
|
|
114
|
+
console.log(green(` ✔ Session log archived → ${path.basename(archive)}\n`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ── Append mode ─────────────────────────────────────────────────────────────
|
|
119
|
+
// Collect the message — everything that's not a flag
|
|
120
|
+
const messageTokens = args.filter(a => !a.startsWith("--") && a !== flag("--type","") && a !== flag("--result","") && a !== flag("--agent",""));
|
|
121
|
+
const summary = messageTokens.join(" ").trim();
|
|
122
|
+
|
|
123
|
+
if (!summary) {
|
|
124
|
+
console.log("\n " + bold("🔥 infernoflow log") + " — append to session memory\n");
|
|
125
|
+
console.log(gray(" Usage:"));
|
|
126
|
+
console.log(gray(' infernoflow log "what happened"'));
|
|
127
|
+
console.log(gray(' infernoflow log "tried X, failed because Y" --type attempt --result failed'));
|
|
128
|
+
console.log(gray(' infernoflow log "always use multipart/form-data" --type gotcha'));
|
|
129
|
+
console.log(gray(' infernoflow log "switched to dark mode" --type theme'));
|
|
130
|
+
console.log(gray(' infernoflow log --show Print last 20 entries'));
|
|
131
|
+
console.log(gray(' infernoflow log --json Print as JSON'));
|
|
132
|
+
console.log();
|
|
133
|
+
console.log(gray(" Types: note · attempt · decision · gotcha · preference · theme · handoff · error"));
|
|
134
|
+
console.log(gray(" Results: worked · failed · partial · unknown\n"));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const type = flag("--type", "note");
|
|
139
|
+
const result = flag("--result", null);
|
|
140
|
+
const agent = flag("--agent", detectAgent());
|
|
141
|
+
|
|
142
|
+
if (!VALID_TYPES.includes(type)) {
|
|
143
|
+
console.error(red(` ✘ Invalid type: ${type}. Valid: ${VALID_TYPES.join(", ")}\n`));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
if (result && !VALID_RESULTS.includes(result)) {
|
|
147
|
+
console.error(red(` ✘ Invalid result: ${result}. Valid: ${VALID_RESULTS.join(", ")}\n`));
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const entry = {
|
|
152
|
+
ts: new Date().toISOString(),
|
|
153
|
+
agent,
|
|
154
|
+
type,
|
|
155
|
+
summary,
|
|
156
|
+
...(result ? { result } : {}),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
appendEntry(entry);
|
|
160
|
+
|
|
161
|
+
const typeLabel = type !== "note" ? cyan(` [${type}]`) : "";
|
|
162
|
+
const resultLabel = result ? gray(` → ${result}`) : "";
|
|
163
|
+
console.log(green(` ✔ Logged${typeLabel}${resultLabel}: `) + summary + "\n");
|
|
164
|
+
}
|