cassian-cli 0.3.6 → 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.
Files changed (2) hide show
  1. package/dist/commands/init.js +101 -97
  2. package/package.json +2 -1
@@ -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,40 +28,6 @@ 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
32
  const storageLine = opts.storage ? "\nstorage: true\n" : "";
68
33
  const excludeLines = opts.exclude.length
@@ -78,11 +43,11 @@ ${storageLine}${excludeLines}`;
78
43
  }
79
44
  export async function init(options = {}) {
80
45
  if (existsSync("cassian.yaml")) {
81
- fatal("cassian.yaml already exists in this directory.");
46
+ p.log.error("cassian.yaml already exists in this directory.");
47
+ process.exit(1);
82
48
  }
83
49
  const dirName = process.cwd().split("/").pop().toLowerCase().replace(/[^a-z0-9-]/g, "-");
84
- const skipPrompts = options.yes ?? false;
85
- if (skipPrompts) {
50
+ if (options.yes) {
86
51
  const yaml = buildYaml({
87
52
  name: options.name || dirName,
88
53
  gpuType: options.gpu || "rtx3090",
@@ -92,56 +57,95 @@ export async function init(options = {}) {
92
57
  exclude: ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"],
93
58
  });
94
59
  writeFileSync("cassian.yaml", yaml);
95
- console.log();
96
- console.log(` ${green("✓")} Created cassian.yaml`);
97
- console.log();
98
- console.log(` Run ${green("cassian up")} to start your instance.`);
99
- console.log();
60
+ p.log.success("Created cassian.yaml");
61
+ p.log.info("Run \x1b[32mcassian up\x1b[0m to start your instance.");
100
62
  return;
101
63
  }
102
- // Interactive wizard
103
- const rl = createInterface({ input: process.stdin, output: process.stdout });
104
- console.log();
105
- console.log(bold(" Let's set up your Cassian project."));
106
- console.log(dim(" Press enter to accept defaults.\n"));
107
- const name = options.name || await prompt(rl, ` Instance name ${dim(`[${dirName}]`)}: `, dirName);
108
- 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
+ }
109
78
  const availability = await fetchAvailability();
110
- const gpuOptions = buildGpuOptions(availability);
111
- const availableTypes = Object.keys(availability).filter(k => availability[k] > 0);
112
- const defaultGpu = availableTypes[0] || "rtx3090";
113
- const gpuType = options.gpu || await promptChoice(rl, " GPU type:", gpuOptions, defaultGpu);
114
- console.log();
115
- const gpuCountStr = options.gpuCount || await promptChoice(rl, " Number of GPUs:", [
116
- { label: "1", value: "1" }, { label: "2", value: "2" },
117
- { label: "4", value: "4" }, { label: "8", value: "8" },
118
- ], "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
+ }
119
114
  const gpuCount = parseInt(gpuCountStr);
120
- console.log();
121
- const diskSize = options.disk || await promptChoice(rl, " Disk size (fast storage for code + training):", [
122
- { label: "20 GB", value: "20G" },
123
- { label: "50 GB", value: "50G", hint: "recommended" },
124
- { label: "100 GB", value: "100G" },
125
- { label: "200 GB", value: "200G" },
126
- { label: "500 GB", value: "500G" },
127
- ], "50G");
128
- console.log();
129
- console.log(dim(" Cloud storage gives you unlimited persistent space at /workspace/storage"));
130
- console.log(dim(" Great for datasets, model weights, and large files"));
131
- const storageAnswer = await prompt(rl, ` Enable cloud storage? ${dim("[Y/n]")}: `, "Y");
132
- const storage = storageAnswer.toLowerCase() !== "n";
133
- console.log();
134
- console.log(dim(" Folders to exclude (build artifacts, can be recreated)"));
135
- const excludeRaw = await prompt(rl, ` Exclude ${dim("[node_modules/, .venv/, __pycache__/, *.pyc, wandb/]")}: `, "");
136
- const exclude = excludeRaw
137
- ? excludeRaw.split(",").map(s => s.trim()).filter(Boolean)
138
- : ["node_modules/", ".venv/", "__pycache__/", "*.pyc", "wandb/"];
139
- rl.close();
140
- 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 });
141
149
  writeFileSync("cassian.yaml", yaml);
142
- console.log();
143
- console.log(` ${green("✓")} Created cassian.yaml`);
144
- console.log();
145
- console.log(` Run ${green("cassian up")} to start your instance.`);
146
- console.log();
150
+ p.outro(`\x1b[32m✓\x1b[0m Created cassian.yaml — run \x1b[32mcassian up\x1b[0m to start`);
147
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cassian-cli",
3
- "version": "0.3.6",
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",