cassian-cli 0.3.5 → 0.3.7

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.
@@ -3,7 +3,6 @@ export interface InitOptions {
3
3
  gpu?: string;
4
4
  gpuCount?: string;
5
5
  disk?: string;
6
- storage?: string;
7
6
  yes?: boolean;
8
7
  }
9
8
  export declare function init(options?: InitOptions): Promise<void>;
@@ -1,18 +1,17 @@
1
- import { createInterface } from "readline";
2
- import { writeFileSync, existsSync } from "fs";
3
- import { green, dim, bold } from "../lib/output.js";
4
- import { fatal } from "../lib/errors.js";
1
+ import { existsSync } from "fs";
2
+ import { writeFileSync } from "fs";
3
+ import * as p from "@clack/prompts";
5
4
  import { AGENT_URL } from "../lib/constants.js";
6
5
  const ALL_GPUS = [
7
- { label: "H100 SXM", value: "h100-sxm", memory: "80GB", hint: "best for large training" },
8
- { label: "H100 PCIe", value: "h100-pcie", memory: "80GB" },
9
- { label: "A100 SXM", value: "a100-sxm", memory: "80GB", hint: "reliable workhorse" },
10
- { label: "A100 PCIe", value: "a100-pcie", memory: "80GB" },
11
- { label: "L40S", value: "l40s", memory: "48GB", hint: "great for inference" },
12
- { label: "L4", value: "l4", memory: "24GB", hint: "efficient inference" },
13
- { label: "A10G", value: "a10g", memory: "24GB", hint: "good all-rounder" },
14
- { label: "RTX 4090", value: "rtx4090", memory: "24GB", hint: "fast, affordable" },
15
- { label: "RTX 3090", value: "rtx3090", memory: "24GB" },
6
+ { value: "h100-sxm", label: "H100 SXM", memory: "80GB", hint: "best for large training" },
7
+ { value: "h100-pcie", label: "H100 PCIe", memory: "80GB" },
8
+ { value: "a100-sxm", label: "A100 SXM", memory: "80GB", hint: "reliable workhorse" },
9
+ { value: "a100-pcie", label: "A100 PCIe", memory: "80GB" },
10
+ { value: "l40s", label: "L40S", memory: "48GB", hint: "great for inference" },
11
+ { value: "l4", label: "L4", memory: "24GB", hint: "efficient inference" },
12
+ { value: "a10g", label: "A10G", memory: "24GB", hint: "good all-rounder" },
13
+ { value: "rtx4090", label: "RTX 4090", memory: "24GB", hint: "fast, affordable" },
14
+ { value: "rtx3090", label: "RTX 3090", memory: "24GB" },
16
15
  ];
17
16
  async function fetchAvailability() {
18
17
  try {
@@ -29,43 +28,8 @@ async function fetchAvailability() {
29
28
  return {};
30
29
  }
31
30
  }
32
- function buildGpuOptions(availability) {
33
- return ALL_GPUS.map(gpu => {
34
- const count = availability[gpu.value] ?? 0;
35
- const parts = [gpu.memory];
36
- if (gpu.hint)
37
- parts.push(gpu.hint);
38
- if (count > 0) {
39
- parts.push(`${count} available`);
40
- }
41
- else {
42
- parts.push("unavailable");
43
- }
44
- return { label: gpu.label, value: gpu.value, hint: parts.join(" — ") };
45
- });
46
- }
47
- function prompt(rl, question, fallback) {
48
- return new Promise((resolve) => {
49
- rl.question(question, (answer) => resolve(answer.trim() || fallback));
50
- });
51
- }
52
- function promptChoice(rl, question, choices, fallback) {
53
- return new Promise((resolve) => {
54
- console.log(question);
55
- choices.forEach((c, i) => {
56
- const marker = c.value === fallback ? green("›") : " ";
57
- const hint = c.hint ? dim(` — ${c.hint}`) : "";
58
- console.log(` ${marker} ${i + 1}) ${c.label}${hint}`);
59
- });
60
- rl.question(dim(` [1-${choices.length}, default ${choices.findIndex(c => c.value === fallback) + 1}]: `), (answer) => {
61
- const idx = parseInt(answer.trim()) - 1;
62
- resolve(idx >= 0 && idx < choices.length ? choices[idx].value : fallback);
63
- });
64
- });
65
- }
66
31
  function buildYaml(opts) {
67
- const storageLines = opts.storage.length
68
- ? `\nstorage:\n${opts.storage.map(p => ` - ${p}`).join("\n")}\n` : "";
32
+ const storageLine = opts.storage ? "\nstorage: true\n" : "";
69
33
  const excludeLines = opts.exclude.length
70
34
  ? `\nworkspace:\n exclude:\n${opts.exclude.map(p => ` - "${p}"`).join("\n")}\n` : "";
71
35
  return `name: ${opts.name}
@@ -75,76 +39,113 @@ gpu:
75
39
  type: ${opts.gpuType}
76
40
 
77
41
  disk: ${opts.diskSize}
78
- ${storageLines}${excludeLines}`;
42
+ ${storageLine}${excludeLines}`;
79
43
  }
80
44
  export async function init(options = {}) {
81
45
  if (existsSync("cassian.yaml")) {
82
- fatal("cassian.yaml already exists in this directory.");
46
+ p.log.error("cassian.yaml already exists in this directory.");
47
+ process.exit(1);
83
48
  }
84
49
  const dirName = process.cwd().split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-");
85
- const skipPrompts = options.yes ?? false;
86
- if (skipPrompts) {
50
+ if (options.yes) {
87
51
  const yaml = buildYaml({
88
52
  name: options.name || dirName,
89
53
  gpuType: options.gpu || "rtx3090",
90
54
  gpuCount: parseInt(options.gpuCount || "1"),
91
55
  diskSize: options.disk || "50G",
92
- storage: [],
56
+ storage: true,
93
57
  exclude: ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"],
94
58
  });
95
59
  writeFileSync("cassian.yaml", yaml);
96
- console.log();
97
- console.log(` ${green("✓")} Created cassian.yaml`);
98
- console.log();
99
- console.log(` Run ${green("cassian up")} to start your instance.`);
100
- console.log();
60
+ p.log.success("Created cassian.yaml");
61
+ p.log.info("Run \x1b[32mcassian up\x1b[0m to start your instance.");
101
62
  return;
102
63
  }
103
- // Interactive wizard
104
- const rl = createInterface({ input: process.stdin, output: process.stdout });
105
- console.log();
106
- console.log(bold(" Let's set up your Cassian project."));
107
- console.log(dim(" Press enter to accept defaults.\n"));
108
- const name = options.name || await prompt(rl, ` Instance name ${dim(`[${dirName}]`)}: `, dirName);
109
- console.log();
64
+ p.intro("\x1b[36m⚡ Cassian Setup\x1b[0m");
65
+ const name = options.name || await p.text({
66
+ message: "Instance name",
67
+ placeholder: dirName,
68
+ defaultValue: dirName,
69
+ validate: (v) => {
70
+ if (!v || !/^[a-z0-9][a-z0-9-]*$/.test(v))
71
+ return "Lowercase letters, numbers, and hyphens only";
72
+ },
73
+ });
74
+ if (p.isCancel(name)) {
75
+ p.cancel("Setup cancelled.");
76
+ process.exit(0);
77
+ }
110
78
  const availability = await fetchAvailability();
111
- const gpuOptions = buildGpuOptions(availability);
112
- const availableTypes = Object.keys(availability).filter(k => availability[k] > 0);
113
- const defaultGpu = availableTypes[0] || "rtx3090";
114
- const gpuType = options.gpu || await promptChoice(rl, " GPU type:", gpuOptions, defaultGpu);
115
- console.log();
116
- const gpuCountStr = options.gpuCount || await promptChoice(rl, " Number of GPUs:", [
117
- { label: "1", value: "1" }, { label: "2", value: "2" },
118
- { label: "4", value: "4" }, { label: "8", value: "8" },
119
- ], "1");
79
+ const gpuType = options.gpu || await p.select({
80
+ message: "GPU type",
81
+ options: ALL_GPUS.map(gpu => {
82
+ const count = availability[gpu.value] ?? 0;
83
+ const parts = [gpu.memory];
84
+ if (gpu.hint)
85
+ parts.push(gpu.hint);
86
+ if (count > 0) {
87
+ parts.push(`\x1b[32m${count} available\x1b[0m`);
88
+ }
89
+ else {
90
+ parts.push(`\x1b[90munavailable\x1b[0m`);
91
+ }
92
+ return { value: gpu.value, label: gpu.label, hint: parts.join(" · ") };
93
+ }),
94
+ initialValue: Object.keys(availability).find(k => availability[k] > 0) || "rtx3090",
95
+ });
96
+ if (p.isCancel(gpuType)) {
97
+ p.cancel("Setup cancelled.");
98
+ process.exit(0);
99
+ }
100
+ const gpuCountStr = options.gpuCount || await p.select({
101
+ message: "Number of GPUs",
102
+ options: [
103
+ { value: "1", label: "1" },
104
+ { value: "2", label: "2" },
105
+ { value: "4", label: "4" },
106
+ { value: "8", label: "8" },
107
+ ],
108
+ initialValue: "1",
109
+ });
110
+ if (p.isCancel(gpuCountStr)) {
111
+ p.cancel("Setup cancelled.");
112
+ process.exit(0);
113
+ }
120
114
  const gpuCount = parseInt(gpuCountStr);
121
- console.log();
122
- const diskSize = options.disk || await promptChoice(rl, " Disk size (fast storage for code + training):", [
123
- { label: "20 GB", value: "20G" },
124
- { label: "50 GB", value: "50G", hint: "recommended" },
125
- { label: "100 GB", value: "100G" },
126
- { label: "200 GB", value: "200G" },
127
- { label: "500 GB", value: "500G" },
128
- ], "50G");
129
- console.log();
130
- console.log(dim(" Large folders that need more storage (datasets, pretrained models)"));
131
- console.log(dim(" These get unlimited storage, accessible at /workspace/<folder>"));
132
- const storageRaw = options.storage ?? await prompt(rl, ` Storage folders ${dim("[none]")}: `, "");
133
- const storage = storageRaw
134
- ? storageRaw.split(",").map(s => s.trim().replace(/\/+$/, "/")).filter(Boolean)
135
- : [];
136
- console.log();
137
- console.log(dim(" Folders to exclude (build artifacts, can be recreated)"));
138
- const excludeRaw = await prompt(rl, ` Exclude ${dim("[node_modules/, .venv/, __pycache__/, *.pyc, wandb/]")}: `, "");
139
- const exclude = excludeRaw
140
- ? excludeRaw.split(",").map(s => s.trim()).filter(Boolean)
141
- : ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"];
142
- rl.close();
143
- const yaml = buildYaml({ name, gpuType, gpuCount, diskSize, storage, exclude });
115
+ const diskSize = options.disk || await p.select({
116
+ message: "Disk size (fast NVMe storage)",
117
+ options: [
118
+ { value: "20G", label: "20 GB" },
119
+ { value: "50G", label: "50 GB", hint: "recommended" },
120
+ { value: "100G", label: "100 GB" },
121
+ { value: "200G", label: "200 GB" },
122
+ { value: "500G", label: "500 GB" },
123
+ ],
124
+ initialValue: "50G",
125
+ });
126
+ if (p.isCancel(diskSize)) {
127
+ p.cancel("Setup cancelled.");
128
+ process.exit(0);
129
+ }
130
+ const storageEnabled = await p.confirm({
131
+ message: "Enable cloud storage? \x1b[90m(unlimited, persists at /workspace/storage)\x1b[0m",
132
+ initialValue: true,
133
+ });
134
+ if (p.isCancel(storageEnabled)) {
135
+ p.cancel("Setup cancelled.");
136
+ process.exit(0);
137
+ }
138
+ const excludeRaw = await p.text({
139
+ message: "Exclude patterns \x1b[90m(comma-separated, not persisted)\x1b[0m",
140
+ placeholder: "node_modules/, .venv/, __pycache__/, *.pyc, wandb/",
141
+ defaultValue: "node_modules/, .venv/, __pycache__/, *.pyc, wandb/",
142
+ });
143
+ if (p.isCancel(excludeRaw)) {
144
+ p.cancel("Setup cancelled.");
145
+ process.exit(0);
146
+ }
147
+ const exclude = excludeRaw.split(",").map(s => s.trim()).filter(Boolean);
148
+ const yaml = buildYaml({ name, gpuType, gpuCount, diskSize, storage: storageEnabled, exclude });
144
149
  writeFileSync("cassian.yaml", yaml);
145
- console.log();
146
- console.log(` ${green("✓")} Created cassian.yaml`);
147
- console.log();
148
- console.log(` Run ${green("cassian up")} to start your instance.`);
149
- console.log();
150
+ p.outro(`\x1b[32m✓\x1b[0m Created cassian.yaml — run \x1b[32mcassian up\x1b[0m to start`);
150
151
  }
@@ -58,10 +58,10 @@ export async function up() {
58
58
  info("Disk", config.disk);
59
59
  }
60
60
  else if (config.volumes?.length) {
61
- info("Storage", config.volumes.map((v) => `${v.size} at ${v.mount}`).join(", "));
61
+ info("Disk", config.volumes.map((v) => `${v.size} at ${v.mount}`).join(", "));
62
62
  }
63
- if (config.storage?.length) {
64
- info("Storage", config.storage.join(", "));
63
+ if (config.storage) {
64
+ info("Storage", "enabled (/workspace/storage)");
65
65
  }
66
66
  console.log();
67
67
  const vm = dev.vm;
@@ -125,7 +125,7 @@ export async function up() {
125
125
  },
126
126
  workspace: {
127
127
  no_sync: config.workspace?.no_sync || [],
128
- storage: config.storage || config.workspace?.storage || [],
128
+ storage: config.storage === true ? ["storage"] : (Array.isArray(config.storage) ? config.storage : config.workspace?.storage || []),
129
129
  exclude: config.workspace?.exclude || config.workspace?.syncignore || [],
130
130
  },
131
131
  });
package/dist/index.js CHANGED
@@ -88,14 +88,12 @@ program
88
88
  .option("--gpu <type>", "GPU type (e.g. h100-sxm, a100-sxm, rtx3090)")
89
89
  .option("--gpu-count <n>", "Number of GPUs")
90
90
  .option("--disk <size>", "Disk size (e.g. 50G, 200G)")
91
- .option("--storage <folders>", "Comma-separated storage folders (e.g. datasets/,models/)")
92
91
  .option("-y, --yes", "Skip all prompts, use defaults")
93
92
  .action((opts) => init({
94
93
  name: opts.name,
95
94
  gpu: opts.gpu,
96
95
  gpuCount: opts.gpuCount,
97
96
  disk: opts.disk,
98
- storage: opts.storage,
99
97
  yes: opts.yes,
100
98
  }));
101
99
  program.parse();
package/dist/types.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface CassianConfig {
12
12
  };
13
13
  image?: string;
14
14
  disk?: string;
15
- storage?: string[];
15
+ storage?: boolean | string[];
16
16
  volumes?: Array<{
17
17
  name: string;
18
18
  size: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassian-cli",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "The Cassian GPU cloud CLI — provision GPUs, sync files, and run workloads from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,6 +28,7 @@
28
28
  "node": ">=18"
29
29
  },
30
30
  "dependencies": {
31
+ "@clack/prompts": "^1.4.0",
31
32
  "@types/tar": "^6.1.13",
32
33
  "chalk": "^5.3.0",
33
34
  "chokidar": "^5.0.0",