ima2-gen 1.1.21 → 1.1.23
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 +44 -7
- package/bin/commands/video.js +14 -0
- package/bin/ima2.js +14 -4
- package/bin/lib/platform.js +34 -5
- package/docs/README.ko.md +43 -2
- package/lib/agentQueueWorker.js +6 -0
- package/lib/agentRuntime.js +3 -2
- package/lib/atomicWrite.js +14 -0
- package/lib/grokImageAdapter.js +6 -0
- package/lib/grokProxyLauncher.js +5 -3
- package/lib/grokVideoAdapter.js +1 -1
- package/lib/grokVideoPlannerPrompt.js +10 -0
- package/lib/inflight.js +1 -1
- package/lib/oauthLauncher.js +5 -0
- package/lib/videoFrameExtract.js +3 -3
- package/package.json +5 -7
- package/routes/capabilities.js +13 -0
- package/routes/edit.js +2 -1
- package/routes/generate.js +32 -6
- package/routes/health.js +4 -3
- package/routes/multimode.js +2 -1
- package/routes/video.js +35 -3
- package/server.js +29 -2
- package/skills/ima2/SKILL.md +48 -6
- package/ui/dist/.vite/manifest.json +12 -12
- package/ui/dist/assets/{AgentWorkspace-B_hq9CLg.js → AgentWorkspace-C21zqdTZ.js} +1 -1
- package/ui/dist/assets/{CardNewsWorkspace-wD12J7qk.js → CardNewsWorkspace-BN-ga1lG.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-CI_wuPMf.js → NodeCanvas-BbMa4IhI.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-CUTujJUV.js → PromptBuilderPanel-DRwBJRDQ.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-CUi66jPK.js → PromptImportDialog-Dp85kHCq.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-Cm3vrjY4.js → PromptImportDiscoverySection-BE8Q8MLD.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DOtWTD9n.js → PromptImportFolderSection-PtH5x0sc.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-BMjQegRa.js → PromptLibraryPanel-FnM9tHI9.js} +2 -2
- package/ui/dist/assets/SettingsWorkspace-MARPGyBL.js +1 -0
- package/ui/dist/assets/index-BAFI6htx.js +42 -0
- package/ui/dist/assets/{index-31uVIdt4.js → index-BSXxr_Bt.js} +1 -1
- package/ui/dist/assets/index-DS-ADE7U.css +1 -0
- package/ui/dist/index.html +2 -2
- package/bin/commands/annotate.ts +0 -119
- package/bin/commands/cancel.ts +0 -48
- package/bin/commands/canvas-versions.ts +0 -80
- package/bin/commands/capabilities.ts +0 -110
- package/bin/commands/cardnews.ts +0 -249
- package/bin/commands/comfy.ts +0 -54
- package/bin/commands/config.ts +0 -186
- package/bin/commands/defaults.ts +0 -192
- package/bin/commands/doctor.ts +0 -202
- package/bin/commands/edit.ts +0 -150
- package/bin/commands/gen.ts +0 -214
- package/bin/commands/grok.ts +0 -90
- package/bin/commands/history.ts +0 -146
- package/bin/commands/ls.ts +0 -64
- package/bin/commands/metadata.ts +0 -39
- package/bin/commands/multimode.ts +0 -196
- package/bin/commands/node.ts +0 -166
- package/bin/commands/observability.ts +0 -176
- package/bin/commands/ping.ts +0 -31
- package/bin/commands/prompt-sub/build.ts +0 -101
- package/bin/commands/prompt.ts +0 -492
- package/bin/commands/ps.ts +0 -81
- package/bin/commands/session.ts +0 -266
- package/bin/commands/show.ts +0 -72
- package/bin/commands/skill.ts +0 -70
- package/bin/commands/video.ts +0 -442
- package/bin/ima2.ts +0 -430
- package/bin/lib/args.ts +0 -92
- package/bin/lib/browser-id.ts +0 -16
- package/bin/lib/client.ts +0 -122
- package/bin/lib/config-store.ts +0 -120
- package/bin/lib/destructive-confirm.ts +0 -19
- package/bin/lib/doctor-checks.ts +0 -91
- package/bin/lib/error-hints.ts +0 -23
- package/bin/lib/files.ts +0 -39
- package/bin/lib/output.ts +0 -73
- package/bin/lib/platform.ts +0 -99
- package/bin/lib/recover-output.ts +0 -139
- package/bin/lib/sse.ts +0 -73
- package/bin/lib/star-prompt.ts +0 -97
- package/bin/lib/storage-doctor.ts +0 -39
- package/bin/lib/ui-build.ts +0 -85
- package/config.ts +0 -354
- package/lib/agentCommandParser.ts +0 -69
- package/lib/agentGenerationPlanner.ts +0 -273
- package/lib/agentQuestionResponder.ts +0 -266
- package/lib/agentQueueStore.ts +0 -270
- package/lib/agentQueueWorker.ts +0 -89
- package/lib/agentRuntime.ts +0 -604
- package/lib/agentSettings.ts +0 -72
- package/lib/agentStore.ts +0 -422
- package/lib/agentStoreRows.ts +0 -136
- package/lib/agentTypes.ts +0 -154
- package/lib/apiCachePolicy.ts +0 -11
- package/lib/assetLifecycle.ts +0 -146
- package/lib/canvasVersionStore.ts +0 -223
- package/lib/capabilities.ts +0 -126
- package/lib/cardNewsGenerator.ts +0 -271
- package/lib/cardNewsJobStore.ts +0 -142
- package/lib/cardNewsManifestStore.ts +0 -154
- package/lib/cardNewsPlanner.ts +0 -236
- package/lib/cardNewsPlannerClient.ts +0 -155
- package/lib/cardNewsPlannerPrompt.ts +0 -62
- package/lib/cardNewsPlannerSchema.ts +0 -321
- package/lib/cardNewsRoleTemplateStore.ts +0 -47
- package/lib/cardNewsTemplateStore.ts +0 -252
- package/lib/codexDetect.ts +0 -71
- package/lib/comfyBridge.ts +0 -235
- package/lib/composerSnapshot.ts +0 -33
- package/lib/configKeys.ts +0 -62
- package/lib/db.ts +0 -295
- package/lib/errInfo.ts +0 -43
- package/lib/errorClassify.ts +0 -100
- package/lib/generationCancel.ts +0 -28
- package/lib/generationErrors.ts +0 -238
- package/lib/grokImageAdapter.ts +0 -513
- package/lib/grokMultimodeAdapter.ts +0 -84
- package/lib/grokProxyLauncher.ts +0 -153
- package/lib/grokRuntime.ts +0 -23
- package/lib/grokSizeMapper.ts +0 -71
- package/lib/grokVideoAdapter.ts +0 -458
- package/lib/grokVideoCanvas.ts +0 -26
- package/lib/grokVideoDownload.ts +0 -59
- package/lib/grokVideoPlannerPrompt.ts +0 -67
- package/lib/historyIndex.ts +0 -51
- package/lib/historyList.ts +0 -181
- package/lib/imageMetadata.ts +0 -113
- package/lib/imageMetadataStore.ts +0 -67
- package/lib/imageModels.ts +0 -165
- package/lib/inflight.ts +0 -281
- package/lib/localImportStore.ts +0 -114
- package/lib/logger.ts +0 -161
- package/lib/nodeStore.ts +0 -91
- package/lib/oauthLauncher.ts +0 -94
- package/lib/oauthNormalize.ts +0 -30
- package/lib/oauthProxy/errors.ts +0 -128
- package/lib/oauthProxy/generators.ts +0 -494
- package/lib/oauthProxy/index.ts +0 -28
- package/lib/oauthProxy/prompts.ts +0 -123
- package/lib/oauthProxy/references.ts +0 -45
- package/lib/oauthProxy/runtime.ts +0 -115
- package/lib/oauthProxy/streams.ts +0 -232
- package/lib/oauthProxy/types.ts +0 -9
- package/lib/oauthProxy.ts +0 -3
- package/lib/openDirectory.ts +0 -47
- package/lib/pngInfo.ts +0 -26
- package/lib/promptBuilder/attachments.ts +0 -74
- package/lib/promptBuilder/client.ts +0 -130
- package/lib/promptBuilder/constants.ts +0 -9
- package/lib/promptBuilder/context.ts +0 -36
- package/lib/promptBuilder/errors.ts +0 -12
- package/lib/promptBuilder/requestSchema.ts +0 -56
- package/lib/promptBuilder/responseParser.ts +0 -219
- package/lib/promptBuilder/systemPrompt.ts +0 -135
- package/lib/promptBuilder/transport.ts +0 -94
- package/lib/promptBuilder/types.ts +0 -109
- package/lib/promptImport/curatedSources.ts +0 -141
- package/lib/promptImport/discoveryRegistry.ts +0 -329
- package/lib/promptImport/errors.ts +0 -18
- package/lib/promptImport/githubDiscovery.ts +0 -309
- package/lib/promptImport/githubFolder.ts +0 -397
- package/lib/promptImport/githubSource.ts +0 -257
- package/lib/promptImport/gptImageHints.ts +0 -70
- package/lib/promptImport/parsePromptCandidates.ts +0 -179
- package/lib/promptImport/promptIndex.ts +0 -326
- package/lib/promptImport/rankPromptCandidates.ts +0 -65
- package/lib/promptImport/types.ts +0 -103
- package/lib/promptSafetyPolicy.ts +0 -5
- package/lib/providerOptions.ts +0 -56
- package/lib/referenceImageCompress.ts +0 -84
- package/lib/refs.ts +0 -133
- package/lib/requestLogger.ts +0 -49
- package/lib/responsesDoctor.ts +0 -456
- package/lib/responsesErrors.ts +0 -83
- package/lib/responsesFallback.ts +0 -114
- package/lib/responsesImageAdapter.ts +0 -466
- package/lib/responsesParse.ts +0 -452
- package/lib/responsesTools.ts +0 -28
- package/lib/runtimeContext.ts +0 -146
- package/lib/runtimePorts.ts +0 -105
- package/lib/sessionStore.ts +0 -308
- package/lib/storageMigration.ts +0 -310
- package/lib/styleSheet.ts +0 -139
- package/lib/systemTrash.ts +0 -20
- package/lib/videoContinuity.ts +0 -180
- package/lib/videoFrameExtract.ts +0 -78
- package/lib/videoSeriesChain.ts +0 -29
- package/lib/visibleTextLanguagePolicy.ts +0 -7
- package/routes/agent.ts +0 -308
- package/routes/annotations.ts +0 -118
- package/routes/canvasVersions.ts +0 -69
- package/routes/capabilities.ts +0 -18
- package/routes/cardNews.ts +0 -211
- package/routes/comfy.ts +0 -43
- package/routes/edit.ts +0 -352
- package/routes/generate.ts +0 -492
- package/routes/grok.ts +0 -24
- package/routes/health.ts +0 -123
- package/routes/history.ts +0 -221
- package/routes/imageImport.ts +0 -37
- package/routes/index.ts +0 -52
- package/routes/metadata.ts +0 -77
- package/routes/multimode.ts +0 -499
- package/routes/nodes.ts +0 -578
- package/routes/promptBuilder.ts +0 -37
- package/routes/promptImport.ts +0 -379
- package/routes/prompts.ts +0 -428
- package/routes/quota.ts +0 -89
- package/routes/sessions.ts +0 -317
- package/routes/storage.ts +0 -47
- package/routes/video.ts +0 -300
- package/routes/videoExtended.ts +0 -284
- package/server.ts +0 -293
- package/ui/dist/assets/SettingsWorkspace-PiaVnsdA.js +0 -1
- package/ui/dist/assets/index-CjgnNtgt.css +0 -1
- package/ui/dist/assets/index-Da2s4_-5.js +0 -36
package/bin/commands/session.ts
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { parseArgs, type ParsedArgs } from "../lib/args.js";
|
|
3
|
-
import { resolveServer, request } from "../lib/client.js";
|
|
4
|
-
import { out, die, color, json, exitCodeForError, table } from "../lib/output.js";
|
|
5
|
-
|
|
6
|
-
const HELP = `
|
|
7
|
-
ima2 session <subcommand> [options]
|
|
8
|
-
|
|
9
|
-
Subcommands:
|
|
10
|
-
ls [--json] List sessions
|
|
11
|
-
show <id> [--json] Show session details
|
|
12
|
-
create <title> Create a new session
|
|
13
|
-
rm <id> [--yes] Delete a session
|
|
14
|
-
rename <id> <title> Rename a session
|
|
15
|
-
graph save <id> <file> Save graph JSON (uses If-Match for concurrency)
|
|
16
|
-
graph load <id> [--out <file>] Load graph JSON (stdout or --out)
|
|
17
|
-
style-sheet get <id> [--json]
|
|
18
|
-
style-sheet put <id> <file> Replace full style sheet
|
|
19
|
-
style-sheet enable <id>
|
|
20
|
-
style-sheet disable <id>
|
|
21
|
-
style-sheet extract <id> LLM-extract style sheet from session content
|
|
22
|
-
|
|
23
|
-
Common options:
|
|
24
|
-
--server <url> Override server URL
|
|
25
|
-
--json JSON output
|
|
26
|
-
--yes Skip destructive confirmation
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const COMMON_FLAGS = {
|
|
30
|
-
json: { type: "boolean" },
|
|
31
|
-
server: { type: "string" },
|
|
32
|
-
yes: { type: "boolean" },
|
|
33
|
-
out: { type: "string" },
|
|
34
|
-
help: { short: "h", type: "boolean" },
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
async function getServer(args: ParsedArgs) {
|
|
38
|
-
try { return await resolveServer({ serverFlag: args.server }); }
|
|
39
|
-
catch (e: any) { die(exitCodeForError(e), e.message); throw e; }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function lsSub(argv: string[]) {
|
|
43
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
44
|
-
const server = await getServer(args);
|
|
45
|
-
const resp = await request(server.base, "/api/sessions").catch(handle);
|
|
46
|
-
const sessions = resp.sessions || [];
|
|
47
|
-
if (args.json) { json({ sessions }); return; }
|
|
48
|
-
if (sessions.length === 0) { out(color.dim("(no sessions)")); return; }
|
|
49
|
-
table(sessions, [
|
|
50
|
-
{ key: "id", label: "ID" },
|
|
51
|
-
{ key: "title", label: "TITLE" },
|
|
52
|
-
{ key: "createdAt", label: "WHEN", format: (v: unknown) => v ? new Date(v as string | number).toISOString().slice(0, 19) : "" },
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function showSub(argv: string[]) {
|
|
57
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
58
|
-
const id = args.positional[0];
|
|
59
|
-
if (!id) die(2, "session id required");
|
|
60
|
-
const server = await getServer(args);
|
|
61
|
-
const resp = await request(server.base, `/api/sessions/${encodeURIComponent(id)}`).catch(handle);
|
|
62
|
-
if (args.json) { json(resp); return; }
|
|
63
|
-
const s = resp.session || resp;
|
|
64
|
-
out(color.bold(s.id || id));
|
|
65
|
-
out(color.dim(" title: ") + (s.title || ""));
|
|
66
|
-
if (s.graph) out(color.dim(" graph: ") + `${s.graph.nodes?.length ?? 0} nodes, ${s.graph.edges?.length ?? 0} edges, version ${s.graph.version}`);
|
|
67
|
-
if (s.styleSheet) out(color.dim(" styleSheet: ") + (s.styleSheet.enabled ? "enabled" : "disabled"));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function createSub(argv: string[]) {
|
|
71
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
72
|
-
const title = args.positional.join(" ").trim();
|
|
73
|
-
if (!title) die(2, "title required");
|
|
74
|
-
const server = await getServer(args);
|
|
75
|
-
const resp = await request(server.base, "/api/sessions", {
|
|
76
|
-
method: "POST",
|
|
77
|
-
body: { title },
|
|
78
|
-
}).catch(handle);
|
|
79
|
-
if (args.json) { json(resp); return; }
|
|
80
|
-
out(color.green("✓ ") + (resp.session?.id || "(no id returned)"));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function rmSub(argv: string[]) {
|
|
84
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
85
|
-
const id = args.positional[0];
|
|
86
|
-
if (!id) die(2, "session id required");
|
|
87
|
-
if (!args.yes && !process.stdin.isTTY) die(2, "destructive: pass --yes for non-TTY");
|
|
88
|
-
if (!args.yes) {
|
|
89
|
-
process.stdout.write(`Delete session ${id}? [y/N] `);
|
|
90
|
-
const ans = await readLine();
|
|
91
|
-
if (!/^y(es)?$/i.test(ans.trim())) { out("(canceled)"); return; }
|
|
92
|
-
}
|
|
93
|
-
const server = await getServer(args);
|
|
94
|
-
await request(server.base, `/api/sessions/${encodeURIComponent(id)}`, { method: "DELETE" }).catch(handle);
|
|
95
|
-
out(color.green("✓ deleted"));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async function renameSub(argv: string[]) {
|
|
99
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
100
|
-
const [id, ...rest] = args.positional;
|
|
101
|
-
const title = rest.join(" ").trim();
|
|
102
|
-
if (!id || !title) die(2, "usage: session rename <id> <title>");
|
|
103
|
-
const server = await getServer(args);
|
|
104
|
-
await request(server.base, `/api/sessions/${encodeURIComponent(id)}`, {
|
|
105
|
-
method: "PATCH",
|
|
106
|
-
body: { title },
|
|
107
|
-
}).catch(handle);
|
|
108
|
-
out(color.green("✓ renamed"));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async function graphSub(argv: string[]) {
|
|
112
|
-
const action = argv[0];
|
|
113
|
-
const rest = argv.slice(1);
|
|
114
|
-
if (action === "save") return graphSave(rest);
|
|
115
|
-
if (action === "load") return graphLoad(rest);
|
|
116
|
-
die(2, "usage: session graph <save|load> ...");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function graphSave(argv: string[]) {
|
|
120
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
121
|
-
const [id, file] = args.positional;
|
|
122
|
-
if (!id || !file) die(2, "usage: session graph save <id> <file>");
|
|
123
|
-
const buf = await readFile(file, "utf-8");
|
|
124
|
-
let parsed;
|
|
125
|
-
try { parsed = JSON.parse(buf); } catch { die(2, "graph file is not valid JSON"); }
|
|
126
|
-
const { nodes, edges } = parsed;
|
|
127
|
-
if (!Array.isArray(nodes) || !Array.isArray(edges))
|
|
128
|
-
die(2, "graph file must contain { nodes: [], edges: [] }");
|
|
129
|
-
const server = await getServer(args);
|
|
130
|
-
// Step 1: fetch current version
|
|
131
|
-
const current: any = await request(server.base, `/api/sessions/${encodeURIComponent(id)}`).catch(handle);
|
|
132
|
-
const version = current?.session?.graph?.version;
|
|
133
|
-
if (typeof version !== "number") die(1, "could not resolve current graph version");
|
|
134
|
-
// Step 2: PUT with If-Match
|
|
135
|
-
try {
|
|
136
|
-
const result: any = await request(server.base, `/api/sessions/${encodeURIComponent(id)}/graph`, {
|
|
137
|
-
method: "PUT",
|
|
138
|
-
body: { nodes, edges },
|
|
139
|
-
headers: { "If-Match": `"${version}"` },
|
|
140
|
-
});
|
|
141
|
-
if (args.json) { json(result); return; }
|
|
142
|
-
out(color.green(`✓ saved (graphVersion: ${result.graphVersion})`));
|
|
143
|
-
} catch (e: any) {
|
|
144
|
-
if (e.status === 412 || e.code === "GRAPH_VERSION_CONFLICT") die(1, "graph version conflict — fetch latest and retry");
|
|
145
|
-
if (e.status === 413) die(1, e.message);
|
|
146
|
-
handle(e);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function graphLoad(argv: string[]) {
|
|
151
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
152
|
-
const id = args.positional[0];
|
|
153
|
-
if (!id) die(2, "usage: session graph load <id>");
|
|
154
|
-
const server = await getServer(args);
|
|
155
|
-
const resp: any = await request(server.base, `/api/sessions/${encodeURIComponent(id)}`).catch(handle);
|
|
156
|
-
const graph = resp?.session?.graph;
|
|
157
|
-
if (!graph) die(1, "no graph for session");
|
|
158
|
-
const text = JSON.stringify(graph, null, 2);
|
|
159
|
-
if (args.out) {
|
|
160
|
-
const { writeFile } = await import("fs/promises");
|
|
161
|
-
await writeFile(String(args.out), text);
|
|
162
|
-
out(color.green("✓ ") + String(args.out));
|
|
163
|
-
} else {
|
|
164
|
-
process.stdout.write(text + "\n");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function styleSheetSub(argv: string[]) {
|
|
169
|
-
const action = argv[0];
|
|
170
|
-
const rest = argv.slice(1);
|
|
171
|
-
if (action === "get") return ssGet(rest);
|
|
172
|
-
if (action === "put") return ssPut(rest);
|
|
173
|
-
if (action === "enable") return ssEnable(rest, true);
|
|
174
|
-
if (action === "disable") return ssEnable(rest, false);
|
|
175
|
-
if (action === "extract") return ssExtract(rest);
|
|
176
|
-
die(2, "usage: session style-sheet <get|put|enable|disable|extract> ...");
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
async function ssGet(argv: string[]) {
|
|
180
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
181
|
-
const id = args.positional[0];
|
|
182
|
-
if (!id) die(2, "session id required");
|
|
183
|
-
const server = await getServer(args);
|
|
184
|
-
const resp = await request(server.base, `/api/sessions/${encodeURIComponent(id)}/style-sheet`).catch(handle);
|
|
185
|
-
json(resp);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
async function ssPut(argv: string[]) {
|
|
189
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
190
|
-
const [id, file] = args.positional;
|
|
191
|
-
if (!id || !file) die(2, "usage: session style-sheet put <id> <file>");
|
|
192
|
-
const buf = await readFile(file, "utf-8");
|
|
193
|
-
let parsed;
|
|
194
|
-
try { parsed = JSON.parse(buf); } catch { die(2, "style-sheet file is not valid JSON"); }
|
|
195
|
-
const server = await getServer(args);
|
|
196
|
-
await request(server.base, `/api/sessions/${encodeURIComponent(id)}/style-sheet`, {
|
|
197
|
-
method: "PUT",
|
|
198
|
-
body: parsed,
|
|
199
|
-
}).catch(handle);
|
|
200
|
-
out(color.green("✓ style-sheet updated"));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
async function ssEnable(argv: string[], enabled: boolean) {
|
|
204
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
205
|
-
const id = args.positional[0];
|
|
206
|
-
if (!id) die(2, "session id required");
|
|
207
|
-
const server = await getServer(args);
|
|
208
|
-
await request(server.base, `/api/sessions/${encodeURIComponent(id)}/style-sheet/enabled`, {
|
|
209
|
-
method: "PATCH",
|
|
210
|
-
body: { enabled },
|
|
211
|
-
}).catch(handle);
|
|
212
|
-
out(color.green(enabled ? "✓ enabled" : "✓ disabled"));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async function ssExtract(argv: string[]) {
|
|
216
|
-
const args = parseArgs(argv, { flags: COMMON_FLAGS });
|
|
217
|
-
const id = args.positional[0];
|
|
218
|
-
if (!id) die(2, "session id required");
|
|
219
|
-
const server = await getServer(args);
|
|
220
|
-
const resp = await request(server.base, `/api/sessions/${encodeURIComponent(id)}/style-sheet/extract`, {
|
|
221
|
-
method: "POST",
|
|
222
|
-
timeoutMs: 120_000,
|
|
223
|
-
}).catch(handle);
|
|
224
|
-
json(resp);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function handle(e: unknown) {
|
|
228
|
-
const err = e as { message?: string; code?: string };
|
|
229
|
-
die(exitCodeForError(e), `${err.message}${err.code ? ` (${err.code})` : ""}`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async function readLine(): Promise<string> {
|
|
233
|
-
return new Promise((resolve) => {
|
|
234
|
-
let buf = "";
|
|
235
|
-
process.stdin.setEncoding("utf-8");
|
|
236
|
-
const onData = (chunk: Buffer | string) => {
|
|
237
|
-
buf += chunk;
|
|
238
|
-
const nl = buf.indexOf("\n");
|
|
239
|
-
if (nl !== -1) {
|
|
240
|
-
process.stdin.removeListener("data", onData);
|
|
241
|
-
process.stdin.pause();
|
|
242
|
-
resolve(buf.slice(0, nl));
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
process.stdin.resume();
|
|
246
|
-
process.stdin.on("data", onData);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const SUB: Record<string, (argv: any[]) => Promise<void>> = {
|
|
251
|
-
ls: lsSub,
|
|
252
|
-
show: showSub,
|
|
253
|
-
create: createSub,
|
|
254
|
-
rm: rmSub,
|
|
255
|
-
rename: renameSub,
|
|
256
|
-
graph: graphSub,
|
|
257
|
-
"style-sheet": styleSheetSub,
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export default async function sessionCmd(argv: string[]) {
|
|
261
|
-
const sub = argv[0];
|
|
262
|
-
if (!sub || sub === "--help" || sub === "-h") { out(HELP); return; }
|
|
263
|
-
const handler = SUB[sub];
|
|
264
|
-
if (!handler) die(2, `unknown subcommand: ${sub}\n${HELP}`);
|
|
265
|
-
return handler(argv.slice(1));
|
|
266
|
-
}
|
package/bin/commands/show.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from "../lib/args.js";
|
|
2
|
-
import { resolveServer, request } from "../lib/client.js";
|
|
3
|
-
import { openUrl } from "../lib/platform.js";
|
|
4
|
-
import { out, die, color, json, exitCodeForError } from "../lib/output.js";
|
|
5
|
-
import { fileToDataUri } from "../lib/files.js";
|
|
6
|
-
import { config } from "../../config.js";
|
|
7
|
-
|
|
8
|
-
import { errInfo } from "../../lib/errInfo.js";
|
|
9
|
-
const SPEC = {
|
|
10
|
-
flags: {
|
|
11
|
-
json: { type: "boolean" },
|
|
12
|
-
reveal: { type: "boolean" },
|
|
13
|
-
metadata: { type: "boolean" },
|
|
14
|
-
server: { type: "string" },
|
|
15
|
-
help: { short: "h", type: "boolean" },
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default async function showCmd(argv: string[]) {
|
|
20
|
-
const args = parseArgs(argv, SPEC);
|
|
21
|
-
if (args.help) { out("ima2 show <filename> [--json] [--reveal] [--metadata]"); return; }
|
|
22
|
-
const name = args.positional[0];
|
|
23
|
-
if (!name) die(2, "filename required");
|
|
24
|
-
|
|
25
|
-
let server;
|
|
26
|
-
try { server = await resolveServer({ serverFlag: args.server }); }
|
|
27
|
-
catch (e) {
|
|
28
|
-
const err = errInfo(e); die(exitCodeForError(e), err.message); }
|
|
29
|
-
|
|
30
|
-
let resp;
|
|
31
|
-
try { resp = await request(server.base, "/api/history"); }
|
|
32
|
-
catch (e) {
|
|
33
|
-
const err = errInfo(e); die(exitCodeForError(e), err.message); }
|
|
34
|
-
|
|
35
|
-
const items: Record<string, any>[] = resp.items || resp.history || [];
|
|
36
|
-
const item = items.find((it: Record<string, any>) => it.filename === name || (it.filename && it.filename.endsWith(name)));
|
|
37
|
-
if (!item) die(1, `not found: ${name}`);
|
|
38
|
-
|
|
39
|
-
let metadata: any = null;
|
|
40
|
-
if (args.metadata) {
|
|
41
|
-
try {
|
|
42
|
-
const dataUrl = await fileToDataUri(`${config.storage.generatedDir}/${item.filename}`);
|
|
43
|
-
metadata = await request(server.base, "/api/metadata/read", {
|
|
44
|
-
method: "POST",
|
|
45
|
-
body: { dataUrl },
|
|
46
|
-
});
|
|
47
|
-
} catch (e: any) {
|
|
48
|
-
out(color.dim(`(metadata unavailable: ${e?.message || e})`));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (args.json) { json(args.metadata ? { ...item, metadata } : item); }
|
|
53
|
-
else {
|
|
54
|
-
out(color.bold(item.filename));
|
|
55
|
-
out(color.dim(` prompt:`) + ` ${item.prompt || ""}`);
|
|
56
|
-
out(color.dim(` size:`) + ` ${item.size || ""} quality: ${item.quality || ""}`);
|
|
57
|
-
if (item.createdAt) out(color.dim(` when:`) + ` ${new Date(item.createdAt).toISOString()}`);
|
|
58
|
-
if (item.url) out(color.dim(` url:`) + ` ${server.base}${item.url}`);
|
|
59
|
-
if (metadata) {
|
|
60
|
-
out(color.dim(` metadata:`));
|
|
61
|
-
const dump = JSON.stringify(metadata, null, 2).split("\n").map(l => " " + l).join("\n");
|
|
62
|
-
out(dump);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (args.reveal) {
|
|
67
|
-
const url = item.url ? `${server.base}${item.url}` : null;
|
|
68
|
-
if (!url) { out(color.yellow("(no url)")); return; }
|
|
69
|
-
const res = openUrl(url);
|
|
70
|
-
if (!res.ok) out(color.yellow("(could not reveal)"));
|
|
71
|
-
}
|
|
72
|
-
}
|
package/bin/commands/skill.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "fs";
|
|
2
|
-
import { dirname, join, relative } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { parseArgs } from "../lib/args.js";
|
|
5
|
-
import { die, json, out } from "../lib/output.js";
|
|
6
|
-
|
|
7
|
-
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
8
|
-
const SKILL_PATH = join(ROOT, "skills", "ima2", "SKILL.md");
|
|
9
|
-
const PACKAGE_PATH = join(ROOT, "package.json");
|
|
10
|
-
|
|
11
|
-
const HELP = `
|
|
12
|
-
ima2 skill [path] [--json]
|
|
13
|
-
|
|
14
|
-
Print the packaged ima2 Markdown skill for agents.
|
|
15
|
-
|
|
16
|
-
Commands:
|
|
17
|
-
ima2 skill Print skills/ima2/SKILL.md
|
|
18
|
-
ima2 skill path Print resolved skill path
|
|
19
|
-
ima2 skill --json Print a JSON wrapper around the Markdown skill
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
const FLAGS = {
|
|
23
|
-
json: { type: "boolean" },
|
|
24
|
-
help: { short: "h", type: "boolean" },
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function readPackageVersion(): string {
|
|
28
|
-
try {
|
|
29
|
-
const pkg = JSON.parse(readFileSync(PACKAGE_PATH, "utf-8")) as { version?: string };
|
|
30
|
-
return pkg.version || "?";
|
|
31
|
-
} catch {
|
|
32
|
-
return "?";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function readSkill(): string {
|
|
37
|
-
if (!existsSync(SKILL_PATH)) {
|
|
38
|
-
die(5, `packaged skill not found: ${SKILL_PATH}`);
|
|
39
|
-
}
|
|
40
|
-
return readFileSync(SKILL_PATH, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default async function skillCmd(argv: string[]) {
|
|
44
|
-
const args = parseArgs(argv, { flags: FLAGS });
|
|
45
|
-
if (args.help) {
|
|
46
|
-
out(HELP);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (args.positional[0] === "path") {
|
|
51
|
-
out(SKILL_PATH);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const content = readSkill();
|
|
56
|
-
if (args.json) {
|
|
57
|
-
json({
|
|
58
|
-
name: "ima2",
|
|
59
|
-
format: "markdown-skill",
|
|
60
|
-
formatVersion: "1",
|
|
61
|
-
packageVersion: readPackageVersion(),
|
|
62
|
-
path: relative(ROOT, SKILL_PATH),
|
|
63
|
-
source: "package",
|
|
64
|
-
content,
|
|
65
|
-
});
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
out(content.replace(/\n$/, ""));
|
|
70
|
-
}
|