stage-ai 0.2.0 → 0.2.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.
@@ -0,0 +1,7 @@
1
+ interface OutputOptions {
2
+ json?: boolean;
3
+ quiet?: boolean;
4
+ session: string;
5
+ }
6
+ export declare function status(_args: string[], options: OutputOptions): Promise<void>;
7
+ export {};
@@ -0,0 +1,73 @@
1
+ import { getStatus as getSessionStatus } from "../convex-client.js";
2
+ import { error, output, dim, bold } from "../utils/output.js";
3
+ import { EXIT_ERROR } from "../utils/exit-codes.js";
4
+ export async function status(_args, options) {
5
+ const { session } = options;
6
+ try {
7
+ const result = await getSessionStatus(session);
8
+ if (!result || !result.session) {
9
+ error(`Session not found: ${session}`);
10
+ process.exit(EXIT_ERROR);
11
+ }
12
+ output(options, {
13
+ json: () => ({
14
+ sessionId: session,
15
+ ...result,
16
+ }),
17
+ quiet: () => {
18
+ // Just output error if any, or "ok"
19
+ if (result.render?.error) {
20
+ process.stdout.write(result.render.error);
21
+ }
22
+ else {
23
+ process.stdout.write("ok");
24
+ }
25
+ },
26
+ human: () => {
27
+ console.log();
28
+ console.log(bold("Session"), dim(session));
29
+ console.log();
30
+ if (result.render) {
31
+ const status = result.render.error ? "❌ Error" : "✓ OK";
32
+ console.log(bold("Status"), status);
33
+ console.log(bold("Entry"), result.render.entry);
34
+ console.log(bold("Version"), `v${result.render.version}`);
35
+ if (result.render.renderedAt) {
36
+ const ago = formatTimeAgo(result.render.renderedAt);
37
+ console.log(bold("Rendered"), ago);
38
+ }
39
+ if (result.render.error) {
40
+ console.log();
41
+ console.log(bold("Error:"));
42
+ console.log(dim("─".repeat(50)));
43
+ console.log(result.render.error);
44
+ console.log(dim("─".repeat(50)));
45
+ }
46
+ }
47
+ else {
48
+ console.log(bold("Status"), dim("Not rendered yet"));
49
+ }
50
+ console.log();
51
+ console.log(bold("Files"), `(${result.files.length})`);
52
+ for (const file of result.files) {
53
+ console.log(` ${file.path} ${dim(`v${file.version} ${file.size}b`)}`);
54
+ }
55
+ console.log();
56
+ },
57
+ });
58
+ }
59
+ catch (e) {
60
+ error(e.message);
61
+ process.exit(EXIT_ERROR);
62
+ }
63
+ }
64
+ function formatTimeAgo(timestamp) {
65
+ const seconds = Math.floor((Date.now() - timestamp) / 1000);
66
+ if (seconds < 60)
67
+ return `${seconds}s ago`;
68
+ if (seconds < 3600)
69
+ return `${Math.floor(seconds / 60)}m ago`;
70
+ if (seconds < 86400)
71
+ return `${Math.floor(seconds / 3600)}h ago`;
72
+ return `${Math.floor(seconds / 86400)}d ago`;
73
+ }
@@ -43,6 +43,24 @@ export declare function getRenderState(sessionId: string): Promise<{
43
43
  entry: string;
44
44
  version: number;
45
45
  } | null>;
46
+ export interface SessionStatus {
47
+ session: {
48
+ createdAt: number;
49
+ lastAccessedAt: number;
50
+ } | null;
51
+ render: {
52
+ entry: string;
53
+ version: number;
54
+ error: string | null;
55
+ renderedAt: number | null;
56
+ } | null;
57
+ files: Array<{
58
+ path: string;
59
+ version: number;
60
+ size: number;
61
+ }>;
62
+ }
63
+ export declare function getStatus(sessionId: string): Promise<SessionStatus>;
46
64
  export declare function createSnapshot(sessionId: string, name?: string): Promise<string>;
47
65
  export declare function getSnapshots(sessionId: string): Promise<Array<{
48
66
  name?: string;
@@ -124,6 +124,9 @@ export async function triggerRender(sessionId, entry) {
124
124
  export async function getRenderState(sessionId) {
125
125
  return await query("getRenderState", { sessionId });
126
126
  }
127
+ export async function getStatus(sessionId) {
128
+ return await query("getStatus", { sessionId });
129
+ }
127
130
  export async function createSnapshot(sessionId, name) {
128
131
  return await mutation("createSnapshot", { sessionId, name });
129
132
  }
package/dist/main.js CHANGED
@@ -10,6 +10,7 @@ import { render } from "./commands/render.js";
10
10
  import { ls } from "./commands/ls.js";
11
11
  import { push } from "./commands/push.js";
12
12
  import { onboard } from "./commands/onboard.js";
13
+ import { status } from "./commands/status.js";
13
14
  const require = createRequire(import.meta.url);
14
15
  const { version } = require("../package.json");
15
16
  const program = new Command();
@@ -73,6 +74,14 @@ program
73
74
  const root = cmd.optsWithGlobals();
74
75
  await render(entry, { json: root.json, quiet: root.quiet, session: opts.session });
75
76
  });
77
+ program
78
+ .command("status")
79
+ .description("Get session status including render state and errors")
80
+ .requiredOption("-s, --session <id>", "Session ID")
81
+ .action(async (opts, cmd) => {
82
+ const root = cmd.optsWithGlobals();
83
+ await status([], { json: root.json, quiet: root.quiet, session: opts.session });
84
+ });
76
85
  program
77
86
  .command("ls [path]")
78
87
  .description("List files in session")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stage-ai",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI client for Stage — a sandboxed React runtime for AI-generated applications",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",