sagacloud 0.1.1 → 0.2.0

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,13 @@
1
+ {
2
+ "name": "sagacloud",
3
+ "version": "0.2.0",
4
+ "description": "Deploy and manage Static, SPA, and Node.js apps on SagaCloud via the sagacloud CLI.",
5
+ "author": {
6
+ "name": "SagaSoft",
7
+ "url": "https://app.sagasoft.xyz"
8
+ },
9
+ "homepage": "https://app.sagasoft.xyz",
10
+ "repository": "https://gitlab.com/sagasoft/sagacloud-cli",
11
+ "license": "MIT",
12
+ "skills": "./skills/"
13
+ }
package/README.md CHANGED
@@ -65,6 +65,7 @@ For CI/CD pipelines (GitHub Actions / GitLab CI), set `SAGACLOUD_TOKEN` as a sec
65
65
  | `sagacloud cancel` | Cancel active queued/running deployment |
66
66
  | `sagacloud delete` | Delete a hosted site and unlink local project |
67
67
  | `sagacloud ci init` | Generate `.github/workflows/sagacloud.yml` |
68
+ | `sagacloud skills install` | Install the SagaCloud Agent Skill (`SKILL.md`) for Antigravity, Claude Code, Codex, and Cursor |
68
69
 
69
70
  ## Example `sagacloud.jsonc`
70
71
 
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { Command } from "commander";
5
- import pc7 from "picocolors";
5
+ import pc8 from "picocolors";
6
6
 
7
7
  // src/commands/auth.ts
8
8
  import crypto from "crypto";
@@ -1502,16 +1502,124 @@ function registerProjectCommands(program2) {
1502
1502
  });
1503
1503
  }
1504
1504
 
1505
+ // src/commands/skill.ts
1506
+ import fs8 from "fs";
1507
+ import os3 from "os";
1508
+ import path8 from "path";
1509
+ import { fileURLToPath } from "url";
1510
+ import pc7 from "picocolors";
1511
+ function resolveBundledSkillDir() {
1512
+ const here = path8.dirname(fileURLToPath(import.meta.url));
1513
+ const candidates = [
1514
+ path8.resolve(here, "..", "skills", "sagacloud"),
1515
+ path8.resolve(here, "..", "..", "skills", "sagacloud")
1516
+ ];
1517
+ for (const dir of candidates) {
1518
+ if (fs8.existsSync(path8.join(dir, "SKILL.md"))) {
1519
+ return dir;
1520
+ }
1521
+ }
1522
+ throw new Error("Bundled SagaCloud skill files were not found in package.");
1523
+ }
1524
+ function getTargetPaths(target, opts) {
1525
+ const cwd = opts.cwd || process.cwd();
1526
+ const home = os3.homedir();
1527
+ const normalized = (target || "all").toLowerCase();
1528
+ const map = opts.project ? {
1529
+ antigravity: {
1530
+ label: "Antigravity / Universal (.agents/skills)",
1531
+ destDir: path8.join(cwd, ".agents", "skills", "sagacloud")
1532
+ },
1533
+ claude: {
1534
+ label: "Claude Code (.claude/skills)",
1535
+ destDir: path8.join(cwd, ".claude", "skills", "sagacloud")
1536
+ },
1537
+ agents: {
1538
+ label: "Agent Skills (.agents/skills)",
1539
+ destDir: path8.join(cwd, ".agents", "skills", "sagacloud")
1540
+ }
1541
+ } : {
1542
+ antigravity: {
1543
+ label: "Antigravity (~/.gemini/config/skills)",
1544
+ destDir: path8.join(home, ".gemini", "config", "skills", "sagacloud")
1545
+ },
1546
+ claude: {
1547
+ label: "Claude Code (~/.claude/skills)",
1548
+ destDir: path8.join(home, ".claude", "skills", "sagacloud")
1549
+ },
1550
+ agents: {
1551
+ label: "Codex / Open Agents (~/.agents/skills)",
1552
+ destDir: path8.join(home, ".agents", "skills", "sagacloud")
1553
+ }
1554
+ };
1555
+ const keys = normalized === "all" ? ["antigravity", "claude", "agents"] : normalized in map ? [normalized] : (() => {
1556
+ throw new Error(`Unknown target '${target}'. Use: all, antigravity, claude, or agents.`);
1557
+ })();
1558
+ const seen = /* @__PURE__ */ new Set();
1559
+ const out = [];
1560
+ for (const k of keys) {
1561
+ const entry = map[k];
1562
+ if (!seen.has(entry.destDir)) {
1563
+ seen.add(entry.destDir);
1564
+ out.push(entry);
1565
+ }
1566
+ }
1567
+ return out;
1568
+ }
1569
+ function copyDirRecursive(src, dest) {
1570
+ fs8.mkdirSync(dest, { recursive: true });
1571
+ for (const entry of fs8.readdirSync(src, { withFileTypes: true })) {
1572
+ const srcPath = path8.join(src, entry.name);
1573
+ const destPath = path8.join(dest, entry.name);
1574
+ if (entry.isDirectory()) {
1575
+ copyDirRecursive(srcPath, destPath);
1576
+ } else if (entry.isFile()) {
1577
+ fs8.copyFileSync(srcPath, destPath);
1578
+ }
1579
+ }
1580
+ }
1581
+ function registerSkillCommands(program2) {
1582
+ const skills = program2.command("skills").alias("skill").description("Install or inspect the SagaCloud skill for AI coding agents");
1583
+ skills.command("install").description("Install SagaCloud SKILL.md for Antigravity, Claude Code, Codex, and Cursor").option("--project", "Install into current project (.agents/skills & .claude/skills) instead of user home", false).option("--target <agent>", "Target agent: all, antigravity, claude, agents", "all").action((opts) => {
1584
+ const srcDir = resolveBundledSkillDir();
1585
+ const destinations = getTargetPaths(opts.target, { project: opts.project });
1586
+ for (const item of destinations) {
1587
+ copyDirRecursive(srcDir, item.destDir);
1588
+ console.log(`${pc7.green("\u2713")} ${item.label} -> ${pc7.cyan(item.destDir)}`);
1589
+ }
1590
+ console.log(pc7.dim("\nYour coding agent can now load the 'sagacloud' skill automatically."));
1591
+ });
1592
+ skills.command("status").description("Show where the SagaCloud agent skill is installed").option("--project", "Check current project directories", false).action((opts) => {
1593
+ const destinations = getTargetPaths("all", { project: opts.project });
1594
+ for (const item of destinations) {
1595
+ const installed = fs8.existsSync(path8.join(item.destDir, "SKILL.md"));
1596
+ console.log(`${installed ? pc7.green("installed") : pc7.dim("not found")} ${item.destDir}`);
1597
+ }
1598
+ });
1599
+ skills.command("uninstall").description("Remove installed SagaCloud agent skill files").option("--project", "Remove from current project instead of user home", false).option("--target <agent>", "Target agent: all, antigravity, claude, agents", "all").action((opts) => {
1600
+ const destinations = getTargetPaths(opts.target, { project: opts.project });
1601
+ for (const item of destinations) {
1602
+ if (fs8.existsSync(item.destDir)) {
1603
+ fs8.rmSync(item.destDir, { recursive: true, force: true });
1604
+ console.log(`${pc7.yellow("-")} Removed ${item.destDir}`);
1605
+ } else {
1606
+ console.log(`${pc7.dim("\u2022")} Not installed at ${item.destDir}`);
1607
+ }
1608
+ }
1609
+ });
1610
+ }
1611
+
1505
1612
  // src/index.ts
1506
1613
  var program = new Command();
1507
- program.name("sagacloud").description("SagaCloud CLI \u2014 deploy Static, SPA, Express & Node.js apps cleanly").version("0.1.1");
1614
+ program.name("sagacloud").description("SagaCloud CLI \u2014 deploy Static, SPA, Express & Node.js apps cleanly").version("0.2.0");
1508
1615
  registerAuthCommands(program);
1509
1616
  registerProjectCommands(program);
1510
1617
  registerDeployCommands(program);
1511
1618
  registerEnvCommands(program);
1512
1619
  registerOpsCommands(program);
1620
+ registerSkillCommands(program);
1513
1621
  program.parseAsync(process.argv).catch((err) => {
1514
1622
  const msg = err instanceof Error ? err.message : String(err);
1515
- console.error(pc7.red(`Error: ${msg}`));
1623
+ console.error(pc8.red(`Error: ${msg}`));
1516
1624
  process.exit(1);
1517
1625
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sagacloud",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Official CLI for SagaCloud Web & App Hosting",
5
5
  "license": "MIT",
6
6
  "author": "SagaSoft",
@@ -28,6 +28,9 @@
28
28
  },
29
29
  "files": [
30
30
  "dist",
31
+ "skills",
32
+ "plugin.json",
33
+ ".claude-plugin",
31
34
  "README.md",
32
35
  "LICENSE"
33
36
  ],
package/plugin.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "sagacloud",
3
+ "description": "Deploy and manage Static, SPA, and Node.js apps on SagaCloud via the sagacloud CLI.",
4
+ "author": "SagaSoft",
5
+ "homepage": "https://app.sagasoft.xyz",
6
+ "repository": "https://gitlab.com/sagasoft/sagacloud-cli"
7
+ }
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: sagacloud
3
+ description: >-
4
+ Deploy, configure, inspect, and troubleshoot websites and Node.js apps on
5
+ SagaCloud using the `sagacloud` CLI. Use when the user asks to deploy a
6
+ static site, React/Vite/Angular/Next.js SPA, or Express/Node.js server to
7
+ SagaCloud, sync environment variables, inspect build or runtime logs, manage
8
+ custom domains and Edge SSL, roll back deployments, or set up GitHub Actions
9
+ CI/CD (`sagacloud.jsonc`).
10
+ ---
11
+
12
+ # SagaCloud Hosting Skill (`sagacloud` CLI)
13
+
14
+ Use the `sagacloud` CLI to deploy and operate applications on **SagaCloud** (`https://app.sagasoft.xyz`).
15
+
16
+ ## Safety & Rules
17
+ - **Never read, print, or invent secrets:** Do not print `~/.config/sagacloud/auth.json`, `$SAGACLOUD_TOKEN`, or `.env*` secrets into chat.
18
+ - **Check auth before mutating:** Always verify auth with `sagacloud whoami`. If unauthenticated, ask the user to run `sagacloud login` interactively (browser approval) or export `SAGACLOUD_TOKEN`.
19
+ - **Use `--yes` for non-interactive commands:** Agents cannot reliably drive interactive prompts; pass `--yes` (`init`, `deploy`, `delete`) and explicit flags (`--site`, `--name`, `--dir`, `--static`, `--spa`, `--node`).
20
+ - **Prefer local builds for static SPAs:** React, Vite, Vue, Angular, Astro, and Next.js static export build locally (`npm run build`) and upload only the static output directory (`dist/`, `build/`, `out/`) unless the site uses remote Git deploy (`--git`).
21
+ - **Environment variables on static builds:** Variables injected for static SPAs must be present **before** building (`--build-time` on `env set` or `--with-env .env.production` on `deploy`), whereas Node.js/Express apps distinguish build-time (`VITE_*`, `NEXT_PUBLIC_*`) from runtime secrets.
22
+
23
+ ## Step 1: Verify CLI & Authentication
24
+
25
+ ```bash
26
+ sagacloud --version
27
+ sagacloud whoami
28
+ ```
29
+
30
+ If `sagacloud` is missing, tell the user to install it or invoke via `npx sagacloud`:
31
+ ```bash
32
+ npm install -g sagacloud # Node >= 20 required
33
+ ```
34
+
35
+ If `sagacloud whoami` fails (`Not authenticated`), stop and instruct the user to run:
36
+ ```bash
37
+ sagacloud login
38
+ ```
39
+ (In headless/CI environments, use `SAGACLOUD_TOKEN=sc_live_...` or `sagacloud login --token <token>`.)
40
+
41
+ ## Step 2: Detect Project Type & Link/Configure
42
+
43
+ Inspect `package.json`, `angular.json`, `next.config.*`, or existing `sagacloud.jsonc` / `.sagacloud/project.json`. See [sagacloud.jsonc reference](./references/sagacloud-jsonc.md) for all supported fields.
44
+
45
+ - Generate default `sagacloud.jsonc`:
46
+ ```bash
47
+ sagacloud init --yes
48
+ ```
49
+ - Link to an existing remote site instead of creating a new one:
50
+ ```bash
51
+ sagacloud list
52
+ sagacloud link --site <site_id>
53
+ ```
54
+
55
+ ## Step 3: Deploy by Project Type
56
+
57
+ ### Static HTML / PHP / Pre-built SPA (`dist/`, `build/`, `out/`)
58
+ ```bash
59
+ # Build locally and deploy auto-detected output dir:
60
+ sagacloud deploy --spa --yes --name <site-name>
61
+
62
+ # Or skip local build when output directory is already built:
63
+ sagacloud deploy --dir ./dist --spa --no-build --yes --name <site-name>
64
+
65
+ # Plain static HTML/PHP without SPA index.html fallback:
66
+ sagacloud deploy --dir ./public --static --no-build --yes --name <site-name>
67
+ ```
68
+
69
+ ### Express / Fastify / NestJS / Hono / Next.js SSR (`node`)
70
+ ```bash
71
+ sagacloud deploy --node --port 3000 --start "npm start" --yes --name <site-name>
72
+ ```
73
+ *(Uploads source archive excluding `node_modules/`, `.git/`, `.env*`; builds and runs on SagaCloud Node runtime.)*
74
+
75
+ ### Git-Connected Site
76
+ ```bash
77
+ sagacloud deploy --git --site <site_id>
78
+ # Force clean rebuild bypassing cache:
79
+ sagacloud deploy --git --force --site <site_id>
80
+ ```
81
+
82
+ ## Step 4: Verify, Debug & Operate
83
+
84
+ - **Check live URL & Edge status:** `sagacloud status`
85
+ - **Build logs (latest or specific deployment):** `sagacloud logs [deploymentUuid]`
86
+ - **Runtime container logs (Node apps):** `sagacloud logs --runtime -n 200` (or `-f` to stream)
87
+ - **Sync environment variables:**
88
+ - `sagacloud env ls`
89
+ - `sagacloud env set API_URL=https://api.example.com` (add `--build-time` for frontend bundle vars)
90
+ - `sagacloud env push .env.production` (always run `sagacloud deploy` afterward to apply changes)
91
+ - `sagacloud env pull .env.local`
92
+ - **Rollback instant or source version:** `sagacloud deployments` → `sagacloud rollback v2`
93
+ - **Custom domains & Edge SSL:** `sagacloud domains add app.example.com` → instruct user to set CNAME target → `sagacloud domains verify app.example.com`
94
+ - **Purge Edge CDN cache:** `sagacloud purge`
95
+ - **Container power control:** `sagacloud start | stop | restart`
96
+ - **Generate GitHub Actions workflow:** `sagacloud ci init` (creates `.github/workflows/sagacloud.yml` expecting `secrets.SAGACLOUD_TOKEN`)
@@ -0,0 +1,52 @@
1
+ # `sagacloud.jsonc` Schema & Framework Reference
2
+
3
+ Place `sagacloud.jsonc` (or `sagacloud.json`) in the root of your repository. Trailing commas and `//` / `/* */` comments are supported.
4
+
5
+ ## Fields
6
+
7
+ | Field | Type | Description |
8
+ | --- | --- | --- |
9
+ | `name` | `string` | Default site slug/name when creating a new site |
10
+ | `site_id` | `string` | Explicit target Site ID (`site_...`) if not using `.sagacloud/project.json` |
11
+ | `type` | `"static" \| "spa" \| "php" \| "node" \| "nextjs"` | Runtime mode override |
12
+ | `base_directory` | `string` | Optional monorepo subdirectory |
13
+ | `install_command` | `string` | Custom install command for remote Node/SSR builds |
14
+ | `build_command` | `string` | Local build command for static/SPA (e.g. `npm run build`) or remote build for Node |
15
+ | `output_dir` | `string` | Built static output directory (e.g. `dist`, `build`, `out`, `dist/my-app/browser`) |
16
+ | `start_command` | `string` | Start command for Node/SSR runtime (e.g. `npm start`, `node server.js`) |
17
+ | `port` | `number \| string` | Listening HTTP port inside Node container (default `3000`) |
18
+ | `spa_fallback` | `boolean` | When `true`, unknown routes rewrite to `/index.html` (`type: "spa"`) |
19
+ | `domains` | `string[]` | Custom domains reference list |
20
+ | `ignore` | `string[]` | Extra glob patterns excluded from upload archive (`node_modules`, `.git`, `.env*`, `.sagacloud`, `sagacloud.json*` are always excluded) |
21
+ | `vars` | `Record<string, string \| number \| boolean>` | Non-secret environment variables pushed automatically on `sagacloud deploy` |
22
+
23
+ ## Auto-Detection Defaults
24
+
25
+ | Framework | Detected Type | Output Dir / Start Cmd |
26
+ | --- | --- | --- |
27
+ | Static HTML | `static` / `html` | `.` |
28
+ | PHP (`index.php`) | `static` / `php` | `.` |
29
+ | Vite / React / Vue | `static` / `spa` | `dist` |
30
+ | Create React App | `static` / `spa` | `build` |
31
+ | Angular (`angular.json`) | `static` / `spa` | `outputPath` (+ `/browser` if present) or `dist` |
32
+ | Astro | `static` / `spa` | `dist` |
33
+ | Next.js (`output: 'export'`) | `static` / `spa` | `out` |
34
+ | Next.js SSR | `node` / `nextjs` | `npm start` (port `3000`) |
35
+ | Express / Fastify / NestJS / Hono / Koa | `node` / `node` | `npm start` (port `3000`) |
36
+
37
+ ## Example
38
+
39
+ ```jsonc
40
+ {
41
+ // Vite + React SPA on SagaCloud
42
+ "name": "billing-portal",
43
+ "type": "spa",
44
+ "build_command": "npm run build",
45
+ "output_dir": "dist",
46
+ "spa_fallback": true,
47
+ "ignore": ["node_modules", ".git", ".env*", "coverage"],
48
+ "vars": {
49
+ "VITE_APP_NAME": "Billing Portal"
50
+ }
51
+ }
52
+ ```