storymode-cli 1.1.0 → 1.1.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.
- package/package.json +1 -1
- package/src/api.mjs +6 -5
- package/src/cli.mjs +16 -8
package/package.json
CHANGED
package/src/api.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import https from 'node:https';
|
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import { gunzipSync } from 'node:zlib';
|
|
4
4
|
|
|
5
|
-
const BASE = 'https://
|
|
5
|
+
const BASE = process.env.STORYMODE_BASE_URL || 'https://pixterm-server.proudisland-84e92871.westus2.azurecontainerapps.io';
|
|
6
6
|
|
|
7
7
|
function request(url) {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
@@ -28,11 +28,12 @@ export async function fetchGallery() {
|
|
|
28
28
|
return JSON.parse(buffer.toString('utf-8'));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export async function fetchFrames(galleryId, { size } = {}) {
|
|
31
|
+
export async function fetchFrames(galleryId, { size, mode } = {}) {
|
|
32
32
|
let url = `${BASE}/gallery/${galleryId}/frames`;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
33
|
+
const params = [];
|
|
34
|
+
if (size && size !== 'full') params.push(`size=${size}`);
|
|
35
|
+
if (mode) params.push(`mode=${mode}`);
|
|
36
|
+
if (params.length) url += '?' + params.join('&');
|
|
36
37
|
const { buffer, contentType } = await request(url);
|
|
37
38
|
let json;
|
|
38
39
|
if (contentType.includes('gzip') || buffer[0] === 0x1f) {
|
package/src/cli.mjs
CHANGED
|
@@ -14,10 +14,11 @@ const HELP = `
|
|
|
14
14
|
storymode browse Browse the gallery interactively
|
|
15
15
|
storymode mcp Start MCP server (for Claude Code)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
Options:
|
|
18
|
+
--sextant Use sextant rendering (2x3 sub-pixels, sharper but needs
|
|
19
|
+
a modern terminal). Works with play, companion, show.
|
|
20
|
+
--size=compact|tiny Size for companion mode (default: compact).
|
|
21
|
+
--detach Return control immediately (companion mode).
|
|
21
22
|
|
|
22
23
|
Controls (during playback):
|
|
23
24
|
space pause / resume
|
|
@@ -55,7 +56,9 @@ export async function run(args) {
|
|
|
55
56
|
}
|
|
56
57
|
try {
|
|
57
58
|
process.stderr.write(' Loading animation...\n');
|
|
58
|
-
const
|
|
59
|
+
const fetchOpts = {};
|
|
60
|
+
if (flags.sextant) { fetchOpts.size = 'compact'; fetchOpts.mode = 'sextant'; }
|
|
61
|
+
const framesData = await fetchFrames(id, fetchOpts);
|
|
59
62
|
await playAnimation(framesData);
|
|
60
63
|
} catch (err) {
|
|
61
64
|
console.error(`Error: ${err.message}`);
|
|
@@ -76,7 +79,9 @@ export async function run(args) {
|
|
|
76
79
|
// If we're already the companion pane (spawned by tmux split), play inline
|
|
77
80
|
if (process.env.STORYMODE_COMPANION === '1') {
|
|
78
81
|
try {
|
|
79
|
-
const
|
|
82
|
+
const fetchOpts = { size };
|
|
83
|
+
if (flags.sextant) fetchOpts.mode = 'sextant';
|
|
84
|
+
const framesData = await fetchFrames(id, fetchOpts);
|
|
80
85
|
await playCompanion(framesData);
|
|
81
86
|
} catch (err) {
|
|
82
87
|
console.error(`Error: ${err.message}`);
|
|
@@ -87,7 +92,8 @@ export async function run(args) {
|
|
|
87
92
|
|
|
88
93
|
// Otherwise, open a tmux side pane
|
|
89
94
|
const inTmux = !!process.env.TMUX;
|
|
90
|
-
const
|
|
95
|
+
const sextantFlag = flags.sextant ? ' --sextant' : '';
|
|
96
|
+
const companionCmd = `STORYMODE_COMPANION=1 npx storymode-cli companion ${id} --size=${size}${sextantFlag}`;
|
|
91
97
|
|
|
92
98
|
try {
|
|
93
99
|
if (inTmux) {
|
|
@@ -132,8 +138,10 @@ export async function run(args) {
|
|
|
132
138
|
}
|
|
133
139
|
try {
|
|
134
140
|
process.stderr.write(' Loading...\n');
|
|
141
|
+
const fetchOpts = {};
|
|
142
|
+
if (flags.sextant) { fetchOpts.size = 'compact'; fetchOpts.mode = 'sextant'; }
|
|
135
143
|
const [framesData, character] = await Promise.all([
|
|
136
|
-
fetchFrames(id),
|
|
144
|
+
fetchFrames(id, fetchOpts),
|
|
137
145
|
fetchCharacter(id).catch(() => null),
|
|
138
146
|
]);
|
|
139
147
|
const info = character
|