gipity 1.1.22 → 1.1.24
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/README.md +33 -15
- package/dist/adopt-cwd.js +2 -2
- package/dist/commands/brand.js +1 -1
- package/dist/commands/deploy.js +57 -16
- package/dist/commands/env.js +168 -0
- package/dist/commands/file.js +6 -2
- package/dist/commands/fn.js +1 -1
- package/dist/commands/init.js +66 -24
- package/dist/commands/job.js +18 -2
- package/dist/commands/login.js +31 -14
- package/dist/commands/logout.js +7 -6
- package/dist/commands/push.js +11 -3
- package/dist/commands/rbac.js +2 -1
- package/dist/commands/realtime.js +6 -0
- package/dist/commands/records.js +22 -4
- package/dist/commands/service.js +2 -2
- package/dist/commands/status.js +3 -0
- package/dist/commands/test.js +6 -6
- package/dist/commands/uninstall.js +53 -30
- package/dist/commands/update.js +17 -2
- package/dist/config.js +34 -3
- package/dist/helpers/sync.js +4 -1
- package/dist/index.js +593 -169
- package/dist/knowledge.js +19 -15
- package/dist/login-flow.js +9 -7
- package/dist/prompts.js +2 -2
- package/dist/provider-docs.js +1 -1
- package/dist/setup.js +52 -7
- package/dist/sync.js +72 -10
- package/dist/template-vars.js +1 -1
- package/dist/utils.js +5 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3974,11 +3974,11 @@ function decodeJwtExp(token) {
|
|
|
3974
3974
|
return null;
|
|
3975
3975
|
}
|
|
3976
3976
|
}
|
|
3977
|
-
function prompt(question) {
|
|
3977
|
+
function prompt(question, output = process.stdout) {
|
|
3978
3978
|
if (!process.stdin.isTTY) {
|
|
3979
3979
|
return Promise.reject(new Error(`prompt() called without a TTY: ${question.trim()}`));
|
|
3980
3980
|
}
|
|
3981
|
-
const rl2 = createInterface({ input: process.stdin, output
|
|
3981
|
+
const rl2 = createInterface({ input: process.stdin, output });
|
|
3982
3982
|
return new Promise((resolve19) => {
|
|
3983
3983
|
rl2.question(question, (answer) => {
|
|
3984
3984
|
rl2.close();
|
|
@@ -6965,7 +6965,7 @@ Templates:
|
|
|
6965
6965
|
- \`karaoke-captions\` - Forced-alignment app - karaoke captions, subtitle timing, language learning, dubbing alignment
|
|
6966
6966
|
- \`paid-app\` - App that charges users money - SaaS subscription, paid membership, digital product store, "Pro" upgrade, paywalled content (Stripe one-time + subscriptions)
|
|
6967
6967
|
- \`notify-demo\` - App that sends push notifications / alerts / reminders to users' phones or desktops - web push, PWA notifications, "notify me when..." features
|
|
6968
|
-
When unsure, default to \`web-simple\`. After adding the template, edit the generated files, then \`gipity deploy
|
|
6968
|
+
When unsure, default to \`web-simple\`. After adding the template, edit the generated files, then \`gipity deploy\`.
|
|
6969
6969
|
Only skip this on a build request if the user explicitly says not to.
|
|
6970
6970
|
|
|
6971
6971
|
Hidden types (do NOT suggest unsolicited - use only when the user explicitly asks for that domain):
|
|
@@ -6991,11 +6991,11 @@ Gipity is the cloud platform your project runs on - hosting, databases, deployme
|
|
|
6991
6991
|
|
|
6992
6992
|
Prefer the cheapest option that works - CLI and sandbox are instant and free, app services are runtime HTTP calls, and a model call (\`gipity ask\`) costs tokens:
|
|
6993
6993
|
|
|
6994
|
-
1. CLI commands (fast, no agent overhead). The \`gipity\` CLI covers add, deploy, db, fn, logs, page, sync, memory, skill, email, and more. All commands support \`--json
|
|
6994
|
+
1. CLI commands (fast, no agent overhead). The \`gipity\` CLI covers add, deploy, db, fn, logs, page, sync, memory, skill, email, and more. All commands support \`--json\` (except \`gipity build\`, which hands the terminal to your coding agent).
|
|
6995
6995
|
2. Cloud sandbox via \`gipity sandbox run\` - Docker container with pre-installed tools for media (ffmpeg, ImageMagick, sox), documents (pandoc, LibreOffice), and data (pandas, matplotlib, sqlite3). Run \`gipity skill read sandbox-tools\` for the full toolkit. No network from inside the sandbox - fetch what you need before sending it in.
|
|
6996
|
-
3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime, location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
|
|
6996
|
+
3. App services - runtime HTTP endpoints your deployed app calls directly at \`https://a.gipity.ai/api/<PROJECT_GUID>/services/*\`. Available: LLM, TTS, image, sound, music, transcribe, video, file upload, realtime (a function can push into a room with the injected \`realtime.publish()\`, so a page listens instead of polling; see \`app-realtime\`), location, push notifications (Gipity Notify - \`gipity add notify\`, send from a function with the injected \`notify()\`; see \`app-notify\`). Load the matching skill (\`app-llm\`, \`app-tts\`, etc.) before writing service code - they have the schemas, auth pattern, and common-mistake guards. For one-off generation during development, prefer \`gipity generate <image|video|speech|sound|music>\` - direct generation always bills you (the owner), regardless of any service \`billing_mode\` (that setting only governs the deployed app's runtime calls; never flip it just to create assets). \`gipity generate\` saves to a generic file in the current directory by default (e.g. \`./generated.png\`) - pass \`-o <path>\` to write it straight into your source tree so it deploys (e.g. \`gipity generate image "hero banner" -o src/assets/images/hero.png\`) instead of generating at cwd and moving it. For a quick model answer while you work - summarize a log, extract fields, describe a screenshot, a second opinion from a different model - use \`gipity ask "<question>"\`: one call, no history or tools, any model (\`--model sonnet\`, \`--model openai\`), text files with \`--file <path>\` (\`--file -\` for stdin), images with \`--image <path>\`, and a JSON answer with \`--schema '<json schema>'\`.
|
|
6997
6997
|
|
|
6998
|
-
You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Grok,
|
|
6998
|
+
You are the developer. Write files in this directory - Gipity's editor hooks (installed by \`gipity init\` into Claude Code, Codex, Grok, Antigravity, and opencode) auto-sync them to Gipity. Don't run \`npm install\`, \`npm start\`, \`node\`, or \`python\` locally; there is no local runtime. Code runs in the Gipity sandbox.
|
|
6999
6999
|
|
|
7000
7000
|
## Use first-party services before reaching outside
|
|
7001
7001
|
|
|
@@ -7027,15 +7027,17 @@ The other exception is app-level libraries the user imports into their own \`src
|
|
|
7027
7027
|
|
|
7028
7028
|
## Build loop
|
|
7029
7029
|
|
|
7030
|
-
Prefer a live Gipity URL over an ephemeral artifact. When you'd otherwise reach for a Claude Code Artifact (or any host's built-in page preview) to show the user something, build it as a Gipity app and \`gipity deploy
|
|
7030
|
+
Prefer a live Gipity URL over an ephemeral artifact. When you'd otherwise reach for a Claude Code Artifact (or any host's built-in page preview) to show the user something, build it as a Gipity app and \`gipity deploy\` it instead - the result is a real, shareable URL on their own project, not a throwaway.
|
|
7031
7031
|
|
|
7032
7032
|
The full "when to add a template" rule and the definition of done are spelled out in the two sections at the end of this document. In short: if the user wants something deployable (web app, game, API), \`gipity add <template>\` first (default \`web-simple\`); for a one-off task (analysis, PDFs, data work), use \`gipity sandbox run\` instead; to add a reusable building block to an existing app (e.g. multiplayer), \`gipity add <kit>\`.
|
|
7033
7033
|
|
|
7034
|
-
Build loop: \`gipity add\` \u2192 edit files \u2192 \`gipity deploy
|
|
7034
|
+
Build loop: \`gipity add\` \u2192 edit files \u2192 \`gipity deploy --inspect\` \u2192 fix any errors \u2192 repeat until the definition of done is met. \`deploy --inspect\` deploys and then runs the page-inspect report on the live URL in one command; use a standalone \`gipity page inspect <url>\` only when re-checking without deploying.
|
|
7035
|
+
|
|
7036
|
+
Where a deploy goes: a new app is just **prod**, and a bare \`gipity deploy\` deploys it (\`app.gipity.ai/<account>/<slug>/\`). An app can also have **environments** - isolated copies with their own database, functions and URL (\`gipity deploy dev\` creates \`dev\` at \`dev.gipity.ai/<account>/<slug>/\` on first use). Once an app has any, a bare \`gipity deploy\` is refused until you name one: iterate on \`dev\`, and deploy \`prod\` when the user wants it live. Every other command takes \`--env <name>\` to act on an environment (\`gipity db query "..." --env dev\`). If you're changing an app that real users already rely on and it has no environments yet, prefer \`gipity deploy dev\` over prod. Load the \`deploy\` skill for the details.
|
|
7035
7037
|
|
|
7036
7038
|
\`add\` writes real files to disk - Read a scaffolded file with the Read tool before your first Write/Edit to it, or the call fails \`"File has not been read yet"\` (viewing it with \`cat\`/\`head\` in Bash does not count - the harness only tracks the Read tool). Don't rewrite from memory of the template.
|
|
7037
7039
|
|
|
7038
|
-
Make your file changes and verify they landed, then run \`gipity deploy
|
|
7040
|
+
Make your file changes and verify they landed, then run \`gipity deploy\` once. \`0 uploaded, N unchanged\` means nothing changed on disk - fix the files, don't re-run deploy or probe the environment.
|
|
7039
7041
|
|
|
7040
7042
|
Before telling the user the app is online, verify the source tree is consistent: no files named like \`* (conflict from *)*\`, and every package directory has its expected canonical entry file. If a conflict artifact exists, resolve it (keep one copy), re-deploy, and re-inspect before reporting done.
|
|
7041
7043
|
|
|
@@ -7047,11 +7049,11 @@ If you're pointed at a project that already exists on Gipity but has no local co
|
|
|
7047
7049
|
mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <slug>
|
|
7048
7050
|
\`\`\`
|
|
7049
7051
|
|
|
7050
|
-
\`init\` matches the existing remote project by slug, links this directory to it, and syncs its files down (you'll see \`Found existing project ...\` and \`Synced N changes\`). There's no separate \`clone\`/\`pull\` - \`init\` against a matching slug *is* the pull. After it finishes, the files are in cwd; edit and \`gipity deploy
|
|
7052
|
+
\`init\` matches the existing remote project by slug, links this directory to it, and syncs its files down (you'll see \`Found existing project ...\` and \`Synced N changes\`). There's no separate \`clone\`/\`pull\` - \`init\` against a matching slug *is* the pull. After it finishes, the files are in cwd; edit and \`gipity deploy\` as usual. (Already linked to a different project in this dir? Switch and pull instead: \`gipity project <slug>\` then \`gipity sync\`. List your projects with \`gipity project --json\`.)
|
|
7051
7053
|
|
|
7052
7054
|
## CLI quick reference
|
|
7053
7055
|
|
|
7054
|
-
Key commands: \`gipity add <template|kit>\`, \`gipity brand set --emoji <e>|--color <hex>\` (regenerate the app's icons + social share card), \`gipity deploy
|
|
7056
|
+
Key commands: \`gipity add <template|kit>\`, \`gipity brand set --emoji <e>|--color <hex>\` (regenerate the app's icons + social share card), \`gipity deploy [prod|<env>]\`, \`gipity env\` (list/create/delete environments), \`gipity sandbox run\`, \`gipity page inspect <url>\`, \`gipity page screenshot <url>\`, \`gipity db query "SQL"\`, \`gipity fn call <name>\`, \`gipity logs fn <name>\`, \`gipity secrets set <NAME> <value> [--account]\` (store an API key/token encrypted; read in functions via \`secrets.get('NAME')\` - never hardcode keys), \`gipity skill read <name>\`.
|
|
7055
7057
|
Rename for findability: \`gipity project rename <name>\` renames the current project's display name (the slug and deployed URLs never change); it's the label users scan in Monitor and \`gipity project\`, so keep it SHORT: 2-4 words, at most 40 characters, no trailing punctuation (e.g. "Stripe checkout", "Tetris game").
|
|
7056
7058
|
Pull an existing remote project local (given its URL/slug): \`mkdir -p ~/GipityProjects/<slug> && cd ~/GipityProjects/<slug> && gipity init <slug>\` (adopts the matching project and syncs files down - this is the "clone").
|
|
7057
7059
|
Move whole apps in/out: \`gipity save\` (export this project as a portable \`.gip\` bundle), \`gipity load <file.gip | github:owner/repo>\` (import as a NEW project; \`--inspect\` to preview), \`gipity github connect\` (1-2 click GitHub access for imports). Porting a Vercel/Replit/Lovable app? Load the \`app-import\` skill first.
|
|
@@ -7061,7 +7063,7 @@ Run \`gipity --help\` for the full list. Use \`--help\` on any command for detai
|
|
|
7061
7063
|
|
|
7062
7064
|
Function return shape: \`gipity fn call\`, the in-test \`ctx.fn.call\`/\`callAs\`, and the client \`Gipity.fn\` all return your function's value **unwrapped** - read/assert \`result.field\`. Only raw HTTP/\`curl\` wraps it as \`{ data: ... }\`; never write \`result.data.field\` in a test.
|
|
7063
7065
|
|
|
7064
|
-
Tests are isolated, not run against your live DB: \`gipity test\` points \`ctx.fn.call\`/\`callAs\` at a throwaway copy of your database (your
|
|
7066
|
+
Tests are isolated, not run against your live DB: \`gipity test\` points \`ctx.fn.call\`/\`callAs\` at a throwaway copy of your database (your migrations plus the seed files named by the sql phase's \`seed:\` key in \`gipity.yaml\`), one per test FILE, reset (truncate + reseed) before the file runs - so files can't interfere, test rows never reach the deployed app, and you don't write teardown. Functions see \`ctx.isTest === true\` during a run (use it to skip your own rate limiting); the platform also suppresses \`notify()\` push so a suite can't spam subscribers. Reference data tests need goes in those seed files; a runtime-written settings table that isn't seeded goes under \`test.preserve\` in \`gipity.yaml\`. Build per-file fixtures in \`setup(fn)\` \u2192 \`ctx.fixtures\`.
|
|
7065
7067
|
|
|
7066
7068
|
## Hit friction on the platform? Report it in real time
|
|
7067
7069
|
|
|
@@ -7089,7 +7091,9 @@ Every tool call returns its full output with that call. There is no output buffe
|
|
|
7089
7091
|
|
|
7090
7092
|
This directory is the app root - it holds \`.gipity.json\` (and \`gipity.yaml\` for backends) and is already your cwd, so run app commands here. Don't \`cd\` to a git root (\`git rev-parse --show-toplevel\`): when the app is nested in a larger repo that resolves outside the app.
|
|
7091
7093
|
|
|
7092
|
-
Write files locally - Gipity's editor hooks (installed into Claude Code, Grok,
|
|
7094
|
+
Write files locally - Gipity's editor hooks (installed into Claude Code, Codex, Grok, Antigravity, and opencode by \`gipity init\`) auto-push every save to Gipity and auto-pull remote changes (sandbox outputs, restored versions) before each turn. Use \`gipity sync\` if things get out of sync (or if the hooks aren't installed - \`gipity status --repair-hooks\` re-enables them). Deletes are safe - \`gipity file rollback <datetime>\` undoes a tree, \`gipity file restore <path> <version>\` a single file.
|
|
7095
|
+
|
|
7096
|
+
Files your deployed app stores at runtime through the app uploads API (users' uploads, \`gipity upload\`, or an external service using a project API key; under \`uploads/\` or any custom path) are user content, not source: they stay in Gipity Storage and never sync into this directory, and sync never deletes them. List them with \`gipity file tree\`, read one with \`gipity file cat <path>\`.
|
|
7093
7097
|
|
|
7094
7098
|
To keep local-only material (research clones, scratch data, vendored references) in the project directory without syncing or deploying it, list it in a \`.gipityignore\` at the project root - gitignore-style, one pattern per line, \`#\` comments. Ignored paths are invisible to sync in both directions; anything that already synced before being ignored stays on the server until you delete it.
|
|
7095
7099
|
|
|
@@ -7097,7 +7101,7 @@ To keep local-only material (research clones, scratch data, vendored references)
|
|
|
7097
7101
|
|
|
7098
7102
|
### Where files go: deploy only ships \`src/\`
|
|
7099
7103
|
|
|
7100
|
-
Deploy is opt-in, not opt-out: the \`files\` phase uploads **only** what's under \`src/\` (plus \`functions/\` and \`migrations/\` as backend, not CDN files). Anything else at the project root is kept but never deployed. Put each kind of file in the right bucket so scratch and reference material can't bloat a deploy:
|
|
7104
|
+
Deploy is opt-in, not opt-out: the \`files\` phase uploads **only** what's under \`src/\` (plus \`functions/\` and \`migrations/\` as backend, not CDN files). Anything else at the project root is kept but never deployed. (A project with no \`src/\` fails the files deploy with \`no src/ directory\`; every template creates it.) Put each kind of file in the right bucket so scratch and reference material can't bloat a deploy:
|
|
7101
7105
|
|
|
7102
7106
|
- **\`src/\`** - the app itself. Synced **and** deployed to the CDN. Only app code, assets, and pages belong here.
|
|
7103
7107
|
- **\`tmp/\`** - ephemeral scratch: file conversions, intermediate outputs, design staging. **Already ignored** (never synced, never deployed) - the one place to do throwaway work. Use this single root. Leave scratch files where they are when you're done; there's nothing to clean up (no \`rm\` turn) - they're invisible to sync and deploy. (\`*_tmp/\` dirs and \`.gipityscratch/\` are auto-ignored too, as a safety net, so legacy scattered scratch like \`_vsd_tmp/\` can't leak - but write new scratch to \`tmp/\`, not scattered dirs.) Because it never syncs, \`tmp/\` is also never mirrored into the sandbox: **don't stage \`gipity sandbox run\` inputs here** - the sandbox won't see them. Stage inputs under \`src/\`/\`docs/\` and delete them after.
|
|
@@ -7122,7 +7126,7 @@ App services skills (load before calling \`/services/*\` endpoints):
|
|
|
7122
7126
|
- \`app-notify\` - web push notifications for deployed apps (incl. iOS home-screen web apps) - notify kit + injected notify() service, platform owns the keys
|
|
7123
7127
|
- \`app-payments\` - charge end-users real money - Stripe one-time purchases & subscriptions, via the stripe kit (gipity add stripe)
|
|
7124
7128
|
- \`app-realtime\` - Gipity Realtime rooms, relay vs state
|
|
7125
|
-
- \`app-tts\` - voices,
|
|
7129
|
+
- \`app-tts\` - voices, models, dialogue, languages, word timestamps
|
|
7126
7130
|
- \`app-video\` - Gipity Video: models, aspect, resolution
|
|
7127
7131
|
|
|
7128
7132
|
App development skills:
|
|
@@ -7149,8 +7153,8 @@ Other key skills:
|
|
|
7149
7153
|
- \`email\` - sending email from a deployed app with the email() service or a workflow notify step (no setup/keys), gipity email test/log, HTML formatting, images
|
|
7150
7154
|
- \`sandbox-tools\` - cloud sandbox capabilities and pre-installed tools`;
|
|
7151
7155
|
DEFINITION_OF_DONE = `## Definition of done (build tasks)
|
|
7152
|
-
1. \`gipity deploy
|
|
7153
|
-
2. \`gipity page inspect <url>\` returns no console errors and the page loads (HTTP 200, no blank screen). (\`gipity deploy
|
|
7156
|
+
1. \`gipity deploy\` succeeds and you have a live URL.
|
|
7157
|
+
2. \`gipity page inspect <url>\` returns no console errors and the page loads (HTTP 200, no blank screen). (\`gipity deploy --inspect\` covers 1 and 2 in one command.)
|
|
7154
7158
|
3. For apps with functions: \`gipity test\` passes.
|
|
7155
7159
|
4. Non-rendered files the task called for (\`llms.txt\`, \`AGENTS.md\`, \`SKILL.md\`, \`robots.txt\`, served JSON, etc.): \`page inspect\` only sees rendered HTML, so verify them with \`gipity page fetch <url> <files...>\`. It flags any that 404 or come back as the static-host shell (a missing file is served as \`index.html\` with a 200, so a bare status check would pass) and checks each \`content-type\`.
|
|
7156
7160
|
5. You told the user the live URL.
|
|
@@ -7299,10 +7303,18 @@ var init_opencode_setup = __esm({
|
|
|
7299
7303
|
import { resolve, join as join6, dirname as dirname3 } from "path";
|
|
7300
7304
|
import { homedir as homedir4, tmpdir } from "os";
|
|
7301
7305
|
import { existsSync as existsSync5, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readFileSync as readFileSync4, mkdtempSync, rmSync, cpSync, readdirSync as readdirSync2 } from "fs";
|
|
7302
|
-
function
|
|
7306
|
+
function primerIgnorePatterns() {
|
|
7307
|
+
return [...new Set(Object.values(PRIMER_FILES))].map((p) => `/${p}`);
|
|
7308
|
+
}
|
|
7309
|
+
function anchorPrimerPatterns(patterns) {
|
|
7310
|
+
const primers = new Set(Object.values(PRIMER_FILES));
|
|
7311
|
+
return patterns.map((p) => primers.has(p) ? `/${p}` : p);
|
|
7312
|
+
}
|
|
7313
|
+
function isSyncIgnored(name, opts = {}) {
|
|
7303
7314
|
if (name.startsWith(".")) return true;
|
|
7304
7315
|
if (DEFAULT_SYNC_IGNORE.includes(name)) return true;
|
|
7305
7316
|
if (DEFAULT_SYNC_IGNORE.includes(`${name}/`)) return true;
|
|
7317
|
+
if (!opts.nested && DEFAULT_SYNC_IGNORE.includes(`/${name}`)) return true;
|
|
7306
7318
|
return false;
|
|
7307
7319
|
}
|
|
7308
7320
|
function isGipityManagedHookCommand(command) {
|
|
@@ -7729,6 +7741,21 @@ function writeSkillsFile(relPath, wrap) {
|
|
|
7729
7741
|
const next = wrap && existing === null ? wrap(baseNext) : baseNext;
|
|
7730
7742
|
if (next !== existing) writeFileSync3(path5, next);
|
|
7731
7743
|
}
|
|
7744
|
+
function refreshExistingPrimers(projectRoot) {
|
|
7745
|
+
const written = [];
|
|
7746
|
+
for (const rel2 of new Set(Object.values(PRIMER_FILES))) {
|
|
7747
|
+
const path5 = resolve(projectRoot, rel2);
|
|
7748
|
+
if (!existsSync5(path5)) continue;
|
|
7749
|
+
const existing = readFileSync4(path5, "utf-8");
|
|
7750
|
+
if (!existing.includes(GIPITY_BLOCK_BEGIN) && !existing.includes("# Gipity Integration")) continue;
|
|
7751
|
+
const next = applySkillsBlock(existing, resolveApiBase());
|
|
7752
|
+
if (next !== existing) {
|
|
7753
|
+
writeFileSync3(path5, next);
|
|
7754
|
+
written.push(rel2);
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7757
|
+
return written;
|
|
7758
|
+
}
|
|
7732
7759
|
function setupClaudeMd() {
|
|
7733
7760
|
writeSkillsFile(PRIMER_FILES.claude);
|
|
7734
7761
|
}
|
|
@@ -7886,7 +7913,7 @@ var init_setup = __esm({
|
|
|
7886
7913
|
".bash_history",
|
|
7887
7914
|
".bash_logout",
|
|
7888
7915
|
...SCRATCH_IGNORE,
|
|
7889
|
-
...
|
|
7916
|
+
...primerIgnorePatterns()
|
|
7890
7917
|
];
|
|
7891
7918
|
PERMISSIONS_SETTINGS = {
|
|
7892
7919
|
permissions: {
|
|
@@ -7896,7 +7923,8 @@ var init_setup = __esm({
|
|
|
7896
7923
|
"Bash(gipity push *)",
|
|
7897
7924
|
"Bash(gipity test *)",
|
|
7898
7925
|
"Bash(gipity add *)",
|
|
7899
|
-
"Bash(gipity deploy
|
|
7926
|
+
"Bash(gipity deploy *)",
|
|
7927
|
+
"Bash(gipity env list *)",
|
|
7900
7928
|
"Bash(gipity domain *)",
|
|
7901
7929
|
"Bash(gipity db query *)",
|
|
7902
7930
|
"Bash(gipity db list *)",
|
|
@@ -9408,11 +9436,14 @@ var init_api = __esm({
|
|
|
9408
9436
|
var config_exports = {};
|
|
9409
9437
|
__export(config_exports, {
|
|
9410
9438
|
DEFAULT_API_BASE: () => DEFAULT_API_BASE,
|
|
9439
|
+
PROD_ENV: () => PROD_ENV,
|
|
9440
|
+
applyEnvOverride: () => applyEnvOverride,
|
|
9411
9441
|
captureEnabled: () => captureEnabled,
|
|
9412
9442
|
clearConfigCache: () => clearConfigCache,
|
|
9413
9443
|
getApiBaseOverride: () => getApiBaseOverride,
|
|
9414
9444
|
getConfig: () => getConfig,
|
|
9415
9445
|
getConfigPath: () => getConfigPath,
|
|
9446
|
+
getEnvOption: () => getEnvOption,
|
|
9416
9447
|
getProjectRoot: () => getProjectRoot,
|
|
9417
9448
|
isAllowedApiHost: () => isAllowedApiHost,
|
|
9418
9449
|
liveUrl: () => liveUrl,
|
|
@@ -9422,10 +9453,22 @@ __export(config_exports, {
|
|
|
9422
9453
|
saveConfig: () => saveConfig2,
|
|
9423
9454
|
saveConfigAt: () => saveConfigAt,
|
|
9424
9455
|
setApiBaseOverride: () => setApiBaseOverride,
|
|
9456
|
+
setEnvOption: () => setEnvOption,
|
|
9425
9457
|
shouldIgnore: () => shouldIgnore
|
|
9426
9458
|
});
|
|
9427
9459
|
import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6 } from "fs";
|
|
9428
9460
|
import { dirname as dirname5, resolve as resolve3 } from "path";
|
|
9461
|
+
function setEnvOption(name) {
|
|
9462
|
+
envOption = name;
|
|
9463
|
+
}
|
|
9464
|
+
function getEnvOption() {
|
|
9465
|
+
return envOption;
|
|
9466
|
+
}
|
|
9467
|
+
function applyEnvOverride(env) {
|
|
9468
|
+
const base = getConfig();
|
|
9469
|
+
if (!base) throw new Error("--env needs a Gipity project directory");
|
|
9470
|
+
cached3 = { ...base, projectGuid: env.projectGuid, projectSlug: env.projectSlug, env: { name: env.name, appSlug: base.projectSlug } };
|
|
9471
|
+
}
|
|
9429
9472
|
function setApiBaseOverride(url) {
|
|
9430
9473
|
apiBaseOverride = url;
|
|
9431
9474
|
}
|
|
@@ -9552,15 +9595,20 @@ async function resolveProjectContext(opts) {
|
|
|
9552
9595
|
oneOff: true
|
|
9553
9596
|
};
|
|
9554
9597
|
}
|
|
9555
|
-
function liveUrl(config,
|
|
9556
|
-
const
|
|
9557
|
-
return `https
|
|
9598
|
+
function liveUrl(config, env = config.env?.name ?? PROD_ENV) {
|
|
9599
|
+
const appSlug = config.env?.appSlug ?? config.projectSlug;
|
|
9600
|
+
if (env === PROD_ENV) return `https://app.gipity.ai/${config.accountSlug}/${appSlug}/`;
|
|
9601
|
+
const segment = env === "dev" ? appSlug : `${appSlug}--${env}`;
|
|
9602
|
+
return `https://dev.gipity.ai/${config.accountSlug}/${segment}/`;
|
|
9558
9603
|
}
|
|
9559
9604
|
function clearConfigCache() {
|
|
9560
9605
|
cached3 = null;
|
|
9561
9606
|
cachedPath = null;
|
|
9562
9607
|
}
|
|
9563
9608
|
function saveConfig2(data) {
|
|
9609
|
+
if (cached3?.env || data.env) {
|
|
9610
|
+
throw new Error("Can't change the linked project while --env is set: run it without --env.");
|
|
9611
|
+
}
|
|
9564
9612
|
const path5 = getConfigPath();
|
|
9565
9613
|
if (!path5) {
|
|
9566
9614
|
throw new Error(
|
|
@@ -9595,12 +9643,13 @@ function shouldIgnore(filePath, ignorePatterns) {
|
|
|
9595
9643
|
if (!rel2 || rel2 === ".") return false;
|
|
9596
9644
|
return matcher.ignores(rel2);
|
|
9597
9645
|
}
|
|
9598
|
-
var import_ignore, CONFIG_FILE, DEFAULT_API_BASE, cached3, cachedPath, apiBaseOverride, warnedHosts, ignoreMatcherCache;
|
|
9646
|
+
var import_ignore, CONFIG_FILE, PROD_ENV, DEFAULT_API_BASE, cached3, cachedPath, envOption, apiBaseOverride, warnedHosts, ignoreMatcherCache;
|
|
9599
9647
|
var init_config = __esm({
|
|
9600
9648
|
"src/config.ts"() {
|
|
9601
9649
|
"use strict";
|
|
9602
9650
|
import_ignore = __toESM(require_ignore(), 1);
|
|
9603
9651
|
CONFIG_FILE = ".gipity.json";
|
|
9652
|
+
PROD_ENV = "prod";
|
|
9604
9653
|
DEFAULT_API_BASE = "https://a.gipity.ai";
|
|
9605
9654
|
cached3 = null;
|
|
9606
9655
|
cachedPath = null;
|
|
@@ -34313,6 +34362,7 @@ var {
|
|
|
34313
34362
|
|
|
34314
34363
|
// src/index.ts
|
|
34315
34364
|
init_config();
|
|
34365
|
+
init_setup();
|
|
34316
34366
|
init_utils();
|
|
34317
34367
|
import { readFileSync as readFileSync30 } from "fs";
|
|
34318
34368
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -34513,25 +34563,25 @@ init_colors();
|
|
|
34513
34563
|
function newAccountWouldBeUnexpected(email, priorAuth) {
|
|
34514
34564
|
return !!getConfig() || priorAuth?.email.toLowerCase() === email.toLowerCase().trim();
|
|
34515
34565
|
}
|
|
34516
|
-
function warnBeforeCodeIfUnexpectedNewAccount(isNewUser, email, indent = "") {
|
|
34566
|
+
function warnBeforeCodeIfUnexpectedNewAccount(isNewUser, email, indent = "", log3 = console.log) {
|
|
34517
34567
|
if (isNewUser !== true) return;
|
|
34518
34568
|
const priorAuth = getAuth();
|
|
34519
34569
|
if (!newAccountWouldBeUnexpected(email, priorAuth)) return;
|
|
34520
34570
|
const config = getConfig();
|
|
34521
|
-
|
|
34571
|
+
log3(`${indent}${warning(`No existing Gipity account for ${email}: entering the code will CREATE a new one.`)}`);
|
|
34522
34572
|
if (config) {
|
|
34523
|
-
|
|
34573
|
+
log3(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}). If you meant to log into that account, stop and re-check the email before entering the code.`)}`);
|
|
34524
34574
|
}
|
|
34525
34575
|
}
|
|
34526
|
-
function warnIfUnexpectedNewAccount(isNewUser, email, priorAuth, indent = "") {
|
|
34576
|
+
function warnIfUnexpectedNewAccount(isNewUser, email, priorAuth, indent = "", log3 = console.log) {
|
|
34527
34577
|
if (isNewUser !== true) return;
|
|
34528
34578
|
if (!newAccountWouldBeUnexpected(email, priorAuth)) return;
|
|
34529
34579
|
const config = getConfig();
|
|
34530
|
-
|
|
34580
|
+
log3(`${indent}${warning(`Logged into a NEW, empty account for ${email}: no prior account existed for this email.`)}`);
|
|
34531
34581
|
if (config) {
|
|
34532
|
-
|
|
34582
|
+
log3(`${indent}${muted(`This directory is linked to project ${config.projectSlug} (account ${config.accountSlug}), which the new account does not own: project / skill / sync commands will fail with "not found".`)}`);
|
|
34533
34583
|
}
|
|
34534
|
-
|
|
34584
|
+
log3(`${indent}${muted("If you expected an existing account, run gipity status, then gipity login again with the correct email.")}`);
|
|
34535
34585
|
}
|
|
34536
34586
|
async function interactiveLogin() {
|
|
34537
34587
|
const email = await prompt(" Email: ");
|
|
@@ -34569,41 +34619,49 @@ async function interactiveLogin() {
|
|
|
34569
34619
|
}
|
|
34570
34620
|
|
|
34571
34621
|
// src/commands/login.ts
|
|
34572
|
-
var loginCommand = new Command("login").description("Log in or sign up").option("--email <email>", "Email address").option("--code <code>", "Verification code").action(async (opts) => {
|
|
34622
|
+
var loginCommand = new Command("login").description("Log in or sign up").option("--email <email>", "Email address").option("--code <code>", "Verification code").option("--json", "Output as JSON (prompts and warnings go to stderr)").action(async (opts) => {
|
|
34623
|
+
const json = !!opts.json;
|
|
34624
|
+
const say = json ? (line) => console.error(line) : (line) => console.log(line);
|
|
34625
|
+
const promptOut = json ? process.stderr : process.stdout;
|
|
34573
34626
|
try {
|
|
34574
34627
|
let email = opts.email;
|
|
34575
34628
|
let code = opts.code;
|
|
34576
34629
|
if (email && code) {
|
|
34577
|
-
await verify(email, code);
|
|
34630
|
+
await verify(email, code, json, say);
|
|
34578
34631
|
return;
|
|
34579
34632
|
}
|
|
34580
34633
|
if (email && !code) {
|
|
34581
34634
|
const sendRes2 = await publicPost("/auth/login", { email });
|
|
34582
|
-
|
|
34583
|
-
|
|
34584
|
-
|
|
34635
|
+
const next = `gipity login --email ${email} --code <code>`;
|
|
34636
|
+
if (json) {
|
|
34637
|
+
console.log(JSON.stringify({ codeSent: true, email, newAccount: sendRes2.isNewUser === true, next }));
|
|
34638
|
+
} else {
|
|
34639
|
+
console.log("Check your email for a 6-digit code.");
|
|
34640
|
+
console.log(muted(`Then run: ${next}`));
|
|
34641
|
+
}
|
|
34642
|
+
warnBeforeCodeIfUnexpectedNewAccount(sendRes2.isNewUser, email, "", say);
|
|
34585
34643
|
return;
|
|
34586
34644
|
}
|
|
34587
|
-
|
|
34645
|
+
say("Enter your email to log in or create an account.");
|
|
34588
34646
|
const existing = getAuth();
|
|
34589
|
-
email = await prompt(existing ? `Email [${existing.email}]: ` : "Email: ");
|
|
34647
|
+
email = await prompt(existing ? `Email [${existing.email}]: ` : "Email: ", promptOut);
|
|
34590
34648
|
if (!email && existing) email = existing.email;
|
|
34591
34649
|
if (!email) {
|
|
34592
34650
|
console.error(error("Email required."));
|
|
34593
34651
|
process.exit(1);
|
|
34594
34652
|
}
|
|
34595
34653
|
const sendRes = await publicPost("/auth/login", { email });
|
|
34596
|
-
|
|
34597
|
-
|
|
34598
|
-
warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email);
|
|
34599
|
-
code = await prompt("Code: ");
|
|
34600
|
-
await verify(email, code);
|
|
34654
|
+
say("");
|
|
34655
|
+
say("Check your email for a 6-digit code.");
|
|
34656
|
+
warnBeforeCodeIfUnexpectedNewAccount(sendRes.isNewUser, email, "", say);
|
|
34657
|
+
code = await prompt("Code: ", promptOut);
|
|
34658
|
+
await verify(email, code, json, say);
|
|
34601
34659
|
} catch (err) {
|
|
34602
34660
|
console.error(error(`Login failed: ${err.message}`));
|
|
34603
34661
|
process.exit(1);
|
|
34604
34662
|
}
|
|
34605
34663
|
});
|
|
34606
|
-
async function verify(email, code) {
|
|
34664
|
+
async function verify(email, code, json, say) {
|
|
34607
34665
|
const priorAuth = getAuth();
|
|
34608
34666
|
const res = await publicPost("/auth/verify", { email, code });
|
|
34609
34667
|
const exp = decodeJwtExp(res.accessToken);
|
|
@@ -34618,9 +34676,13 @@ async function verify(email, code) {
|
|
|
34618
34676
|
email,
|
|
34619
34677
|
expiresAt
|
|
34620
34678
|
});
|
|
34621
|
-
console.log(success(`Logged in (${email}).`));
|
|
34622
|
-
warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth);
|
|
34679
|
+
if (!json) console.log(success(`Logged in (${email}).`));
|
|
34680
|
+
warnIfUnexpectedNewAccount(res.isNewUser, email, priorAuth, "", say);
|
|
34623
34681
|
const delivered = await flushBugQueue().catch(() => 0);
|
|
34682
|
+
if (json) {
|
|
34683
|
+
console.log(JSON.stringify({ loggedIn: true, email, newAccount: res.isNewUser === true, expiresAt, queuedBugReportsDelivered: delivered }));
|
|
34684
|
+
return;
|
|
34685
|
+
}
|
|
34624
34686
|
if (delivered > 0) {
|
|
34625
34687
|
console.log(muted(`Delivered ${delivered} queued bug report${delivered === 1 ? "" : "s"}.`));
|
|
34626
34688
|
}
|
|
@@ -34629,14 +34691,14 @@ async function verify(email, code) {
|
|
|
34629
34691
|
// src/commands/logout.ts
|
|
34630
34692
|
init_auth();
|
|
34631
34693
|
init_colors();
|
|
34632
|
-
var logoutCommand = new Command("logout").description("Log out").action(() => {
|
|
34694
|
+
var logoutCommand = new Command("logout").description("Log out").option("--json", "Output as JSON").action((opts) => {
|
|
34633
34695
|
const auth = getAuth();
|
|
34634
|
-
if (
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
console.log(success(`Logged out (${auth.email}).`));
|
|
34696
|
+
if (auth) clearAuth();
|
|
34697
|
+
if (opts.json) {
|
|
34698
|
+
console.log(JSON.stringify({ loggedOut: !!auth, email: auth?.email ?? null }));
|
|
34699
|
+
return;
|
|
34639
34700
|
}
|
|
34701
|
+
console.log(auth ? success(`Logged out (${auth.email}).`) : "Not logged in.");
|
|
34640
34702
|
});
|
|
34641
34703
|
|
|
34642
34704
|
// src/commands/token.ts
|
|
@@ -35013,7 +35075,8 @@ function readBaseline(projectGuid2) {
|
|
|
35013
35075
|
projectGuid: projectGuid2,
|
|
35014
35076
|
files: parsed.files ?? {},
|
|
35015
35077
|
lastFullSync: parsed.lastFullSync ?? null,
|
|
35016
|
-
...parsed.deletesSkippedStreak ? { deletesSkippedStreak: parsed.deletesSkippedStreak } : {}
|
|
35078
|
+
...parsed.deletesSkippedStreak ? { deletesSkippedStreak: parsed.deletesSkippedStreak } : {},
|
|
35079
|
+
...parsed.appUploads?.length ? { appUploads: parsed.appUploads } : {}
|
|
35017
35080
|
};
|
|
35018
35081
|
} catch {
|
|
35019
35082
|
return { projectGuid: projectGuid2, files: {}, lastFullSync: null };
|
|
@@ -35092,6 +35155,7 @@ function resolveInRoot(root, relPath) {
|
|
|
35092
35155
|
async function fetchRemote(projectGuid2) {
|
|
35093
35156
|
const res = await get(`/projects/${projectGuid2}/files/tree`);
|
|
35094
35157
|
const out = /* @__PURE__ */ new Map();
|
|
35158
|
+
const appUploads = new Set((res.appUploads ?? []).map(normalizeTreePath));
|
|
35095
35159
|
for (const f of res.data) {
|
|
35096
35160
|
if (f.type !== "file") continue;
|
|
35097
35161
|
const path5 = normalizeTreePath(f.path);
|
|
@@ -35103,7 +35167,7 @@ async function fetchRemote(projectGuid2) {
|
|
|
35103
35167
|
modified: f.modified
|
|
35104
35168
|
});
|
|
35105
35169
|
}
|
|
35106
|
-
return out;
|
|
35170
|
+
return { files: out, appUploads };
|
|
35107
35171
|
}
|
|
35108
35172
|
function extractTarToMap(stream, idleMs, onBytes, keep) {
|
|
35109
35173
|
const extract3 = tar2.extract();
|
|
@@ -35350,6 +35414,18 @@ function formatPlan(p) {
|
|
|
35350
35414
|
for (const a of p.actions) lines.push(formatAction(a));
|
|
35351
35415
|
return lines.join("\n");
|
|
35352
35416
|
}
|
|
35417
|
+
function appUploadNote(leftLocal) {
|
|
35418
|
+
const n = leftLocal.length;
|
|
35419
|
+
if (!n) return "";
|
|
35420
|
+
const first = leftLocal[0];
|
|
35421
|
+
const where = first.includes("/") ? `${first.split("/")[0]}/` : first;
|
|
35422
|
+
return `${n} app upload${n === 1 ? "" : "s"} (files your app stored at runtime, e.g. in ${where}) ${n === 1 ? "is" : "are"} no longer synced: ${n === 1 ? "it stays" : "they stay"} in Gipity Storage. The local ${n === 1 ? "copy was" : "copies were"} left in place and ${n === 1 ? "is" : "are"} safe to delete.`;
|
|
35423
|
+
}
|
|
35424
|
+
function withAppUploadNote(summary, leftLocal) {
|
|
35425
|
+
const note = appUploadNote(leftLocal);
|
|
35426
|
+
return note ? `${summary}
|
|
35427
|
+
${note}` : summary;
|
|
35428
|
+
}
|
|
35353
35429
|
async function bulkDeleteGuard(p, knownFiles, opts) {
|
|
35354
35430
|
const totalDeletes = p.deletesLocal + p.deletesRemote;
|
|
35355
35431
|
if (totalDeletes === 0) return true;
|
|
@@ -35373,7 +35449,7 @@ function readGipityIgnore(root) {
|
|
|
35373
35449
|
return readFileSync8(path5, "utf8").split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/^\.\//, "").replace(/^\//, ""));
|
|
35374
35450
|
}
|
|
35375
35451
|
function effectiveIgnore(root, configIgnore) {
|
|
35376
|
-
const base = configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE;
|
|
35452
|
+
const base = anchorPrimerPatterns(configIgnore && configIgnore.length ? configIgnore : DEFAULT_SYNC_IGNORE);
|
|
35377
35453
|
const merged = [...base, GIPITY_IGNORE_FILE, ...readGipityIgnore(root)];
|
|
35378
35454
|
return [...merged, ...SCRATCH_IGNORE.filter((p) => !merged.includes(p))];
|
|
35379
35455
|
}
|
|
@@ -35384,6 +35460,7 @@ function isLocalTreeClean() {
|
|
|
35384
35460
|
const baseline = readBaseline(config.projectGuid);
|
|
35385
35461
|
if (!baseline.lastFullSync) return false;
|
|
35386
35462
|
const local = walkLocal(root, effectiveIgnore(root, config.ignore), baseline.files);
|
|
35463
|
+
for (const path5 of baseline.appUploads ?? []) local.delete(path5);
|
|
35387
35464
|
const baselineFiles = baseline.files;
|
|
35388
35465
|
if (local.size !== Object.keys(baselineFiles).length) return false;
|
|
35389
35466
|
for (const [path5, info2] of local) {
|
|
@@ -35414,7 +35491,18 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35414
35491
|
p?.phase("Scanning local files...");
|
|
35415
35492
|
const local = walkLocal(root, ignore2, baseline.files);
|
|
35416
35493
|
p?.phase("Checking Gipity for changes...");
|
|
35417
|
-
const remote = await fetchRemote(projectGuid2);
|
|
35494
|
+
const { files: remote, appUploads } = await fetchRemote(projectGuid2);
|
|
35495
|
+
const appUploadsLeftLocal = [];
|
|
35496
|
+
const knownUploads = /* @__PURE__ */ new Set([...appUploads, ...(baseline.appUploads ?? []).filter((p7) => local.has(p7))]);
|
|
35497
|
+
for (const path5 of knownUploads) {
|
|
35498
|
+
if (baseline.files[path5]) {
|
|
35499
|
+
if (local.has(path5)) appUploadsLeftLocal.push(path5);
|
|
35500
|
+
delete baseline.files[path5];
|
|
35501
|
+
}
|
|
35502
|
+
local.delete(path5);
|
|
35503
|
+
}
|
|
35504
|
+
if (knownUploads.size) baseline.appUploads = [...knownUploads].sort();
|
|
35505
|
+
else delete baseline.appUploads;
|
|
35418
35506
|
for (const path5 of [...remote.keys()]) {
|
|
35419
35507
|
if (shouldIgnore(path5, ignore2)) remote.delete(path5);
|
|
35420
35508
|
}
|
|
@@ -35433,8 +35521,9 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35433
35521
|
applied: 0,
|
|
35434
35522
|
skipped: 0,
|
|
35435
35523
|
errors: [],
|
|
35436
|
-
summary: formatPlan(planned),
|
|
35437
|
-
deferredDeletes: 0
|
|
35524
|
+
summary: withAppUploadNote(formatPlan(planned), appUploadsLeftLocal),
|
|
35525
|
+
deferredDeletes: 0,
|
|
35526
|
+
appUploadsLeftLocal
|
|
35438
35527
|
};
|
|
35439
35528
|
}
|
|
35440
35529
|
if (opts.confirmMerge && remote.size > 0 && // project already has files - a real merge target
|
|
@@ -35456,7 +35545,8 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35456
35545
|
`Re-run with --yes to merge, or sync into an empty folder.`
|
|
35457
35546
|
].join("\n"),
|
|
35458
35547
|
deferredDeletes: 0,
|
|
35459
|
-
aborted: true
|
|
35548
|
+
aborted: true,
|
|
35549
|
+
appUploadsLeftLocal: []
|
|
35460
35550
|
});
|
|
35461
35551
|
if (getAutoConfirm()) {
|
|
35462
35552
|
} else if (interactive) {
|
|
@@ -35896,8 +35986,9 @@ async function syncInner(projectGuid2, root, ignore2, opts, interactive) {
|
|
|
35896
35986
|
applied,
|
|
35897
35987
|
skipped: skippedByGuard,
|
|
35898
35988
|
errors,
|
|
35899
|
-
summary: formatPlan(planned),
|
|
35900
|
-
deferredDeletes: skippedByGuard
|
|
35989
|
+
summary: withAppUploadNote(formatPlan(planned), appUploadsLeftLocal),
|
|
35990
|
+
deferredDeletes: skippedByGuard,
|
|
35991
|
+
appUploadsLeftLocal
|
|
35901
35992
|
};
|
|
35902
35993
|
}
|
|
35903
35994
|
function cleanupEmptyDirs(root, emptiedDirs) {
|
|
@@ -35925,15 +36016,16 @@ async function pushFile(filePath) {
|
|
|
35925
36016
|
const config = requireConfig2();
|
|
35926
36017
|
const root = projectDir();
|
|
35927
36018
|
const rel2 = relative(root, filePath).replace(/\\/g, "/");
|
|
35928
|
-
if (shouldIgnore(rel2, effectiveIgnore(root, config.ignore))) return;
|
|
36019
|
+
if (shouldIgnore(rel2, effectiveIgnore(root, config.ignore))) return false;
|
|
35929
36020
|
try {
|
|
35930
|
-
if (lstatSync(filePath).isSymbolicLink()) return;
|
|
36021
|
+
if (lstatSync(filePath).isSymbolicLink()) return false;
|
|
35931
36022
|
} catch {
|
|
35932
|
-
return;
|
|
36023
|
+
return false;
|
|
35933
36024
|
}
|
|
35934
36025
|
const releaseLock = await acquireLock();
|
|
35935
36026
|
try {
|
|
35936
36027
|
const baseline = readBaseline(config.projectGuid);
|
|
36028
|
+
if (baseline.appUploads?.includes(rel2)) return false;
|
|
35937
36029
|
const baseEntry = baseline.files[rel2];
|
|
35938
36030
|
const result = await uploadOneFile(config.projectGuid, filePath, rel2, {
|
|
35939
36031
|
expectedServerVersion: baseEntry ? baseEntry.serverVersion : null
|
|
@@ -35947,6 +36039,7 @@ async function pushFile(filePath) {
|
|
|
35947
36039
|
serverVersion: result.serverVersion
|
|
35948
36040
|
};
|
|
35949
36041
|
writeBaseline(baseline);
|
|
36042
|
+
return true;
|
|
35950
36043
|
} catch (err) {
|
|
35951
36044
|
if (err instanceof UploadConflictError) {
|
|
35952
36045
|
throw new Error(
|
|
@@ -36125,6 +36218,8 @@ async function syncBeforeAction(opts) {
|
|
|
36125
36218
|
if (result.applied > 0 && !opts.json) {
|
|
36126
36219
|
console.log(muted(`Synced ${result.applied} change${result.applied > 1 ? "s" : ""}`));
|
|
36127
36220
|
}
|
|
36221
|
+
const note = appUploadNote(result.appUploadsLeftLocal);
|
|
36222
|
+
if (note && !opts.json) console.log(muted(note));
|
|
36128
36223
|
if (result.errors.length > 0 && !opts.json) {
|
|
36129
36224
|
for (const e of result.errors) console.error(error(`[sync] ${e}`));
|
|
36130
36225
|
}
|
|
@@ -36531,7 +36626,7 @@ function* walkTextFiles(root) {
|
|
|
36531
36626
|
continue;
|
|
36532
36627
|
}
|
|
36533
36628
|
for (const entry of entries) {
|
|
36534
|
-
if (isSyncIgnored(entry.name)) continue;
|
|
36629
|
+
if (isSyncIgnored(entry.name, { nested: dir !== root })) continue;
|
|
36535
36630
|
const full = join11(dir, entry.name);
|
|
36536
36631
|
if (entry.isDirectory()) {
|
|
36537
36632
|
stack.push(full);
|
|
@@ -36659,7 +36754,7 @@ function scanForAdoption(cwd) {
|
|
|
36659
36754
|
}
|
|
36660
36755
|
for (const name of entries) {
|
|
36661
36756
|
if (truncated) return;
|
|
36662
|
-
if (isSyncIgnored(name)) continue;
|
|
36757
|
+
if (isSyncIgnored(name, { nested: dir !== cwd })) continue;
|
|
36663
36758
|
const full = join13(dir, name);
|
|
36664
36759
|
let st2;
|
|
36665
36760
|
try {
|
|
@@ -36693,7 +36788,7 @@ function isLikelyEmpty(cwd) {
|
|
|
36693
36788
|
} catch {
|
|
36694
36789
|
return true;
|
|
36695
36790
|
}
|
|
36696
|
-
return entries.every(isSyncIgnored);
|
|
36791
|
+
return entries.every((name) => isSyncIgnored(name));
|
|
36697
36792
|
}
|
|
36698
36793
|
function canAdoptCwd(cwd) {
|
|
36699
36794
|
const norm = resolve6(cwd);
|
|
@@ -37303,18 +37398,18 @@ function resolveTools(forFlag) {
|
|
|
37303
37398
|
(t) => requested.includes(t.key) || !t.optIn && requested.includes("all")
|
|
37304
37399
|
);
|
|
37305
37400
|
}
|
|
37306
|
-
async function pairForCapture() {
|
|
37401
|
+
async function pairForCapture(log3) {
|
|
37307
37402
|
try {
|
|
37308
37403
|
await ensureDevicePaired();
|
|
37309
37404
|
} catch (err) {
|
|
37310
|
-
|
|
37405
|
+
log3(warning(`Couldn't register this machine for session recording (${err.message}); run \`gipity init --capture\` again to retry.`));
|
|
37311
37406
|
}
|
|
37312
37407
|
}
|
|
37313
37408
|
var initCommand = new Command("init").description("Link this directory to a project").addHelpText("after", `
|
|
37314
37409
|
Writes CLAUDE.md/AGENTS.md primer files so your AI coding tool understands Gipity, and installs the Gipity skills + file-sync hooks. By default it only sets up the tools actually installed here (${AGENT_ADAPTERS.map((a) => a.displayName).join(", ")}, ...) - use --for to choose explicitly.`).argument("[name]", "Project name/slug (defaults to current directory name)").option("--capture", "Record Claude Code sessions in this directory to your Gipity project (sets captureHooks: true in .gipity.json; new projects start with it off)").option("--no-capture", "Stop recording sessions in this directory (sets captureHooks: false in .gipity.json)").option(
|
|
37315
37410
|
"--for <tools>",
|
|
37316
37411
|
`Which AI tool primer files to write (comma-separated). Default: the tools detected on this machine. An explicit --for is remembered in .gipity.json, so later commands don't re-add the others. Choices: ${TOOL_KEYS.join(", ")}, all`
|
|
37317
|
-
).addHelpText("after", `
|
|
37412
|
+
).option("--json", "Output a structured result as JSON (confirmations need -y; notes go to stderr)").addHelpText("after", `
|
|
37318
37413
|
Examples:
|
|
37319
37414
|
$ gipity init Link cwd as a new project (slug = dir name);
|
|
37320
37415
|
sets up the tools installed on this machine.
|
|
@@ -37336,6 +37431,21 @@ Working with an existing Gipity project:
|
|
|
37336
37431
|
$ gipity project <slug> Switch this dir's linked project.
|
|
37337
37432
|
$ gipity sync Pull the project's files down.
|
|
37338
37433
|
`).action(async (name, opts) => {
|
|
37434
|
+
const json = !!opts.json;
|
|
37435
|
+
const say = (line) => {
|
|
37436
|
+
if (!json) console.log(line);
|
|
37437
|
+
};
|
|
37438
|
+
const note = (line) => {
|
|
37439
|
+
(json ? console.error : console.log)(line);
|
|
37440
|
+
};
|
|
37441
|
+
const ask = async (question, def) => {
|
|
37442
|
+
if (!json) return confirm(question, { default: def });
|
|
37443
|
+
if (getAutoConfirm()) return true;
|
|
37444
|
+
console.error(error(`Confirmation required in --json mode: ${question}`));
|
|
37445
|
+
console.error(`Re-run with --yes:
|
|
37446
|
+
${rerunWithYes()}`);
|
|
37447
|
+
process.exit(1);
|
|
37448
|
+
};
|
|
37339
37449
|
let tools;
|
|
37340
37450
|
try {
|
|
37341
37451
|
tools = resolveTools(opts.for);
|
|
@@ -37356,7 +37466,7 @@ Working with an existing Gipity project:
|
|
|
37356
37466
|
const cwd = process.cwd();
|
|
37357
37467
|
if (existsSync11(resolve8(cwd, ".gipity.json"))) {
|
|
37358
37468
|
const existing = getConfig();
|
|
37359
|
-
|
|
37469
|
+
say(`Already linked to ${info(`"${existing?.projectSlug ?? ""}"`)} ${muted(`(${existing?.projectGuid ?? ""})`)}`);
|
|
37360
37470
|
setupProjectTools(tools);
|
|
37361
37471
|
if (existing) {
|
|
37362
37472
|
let changed = false;
|
|
@@ -37377,11 +37487,26 @@ Working with an existing Gipity project:
|
|
|
37377
37487
|
}
|
|
37378
37488
|
if (changed) saveConfigAt(cwd, existing);
|
|
37379
37489
|
}
|
|
37380
|
-
|
|
37381
|
-
|
|
37490
|
+
if (json) {
|
|
37491
|
+
if (opts.capture) await pairForCapture(note);
|
|
37492
|
+
console.log(JSON.stringify({
|
|
37493
|
+
linked: true,
|
|
37494
|
+
alreadyLinked: true,
|
|
37495
|
+
created: false,
|
|
37496
|
+
project: { guid: existing?.projectGuid ?? null, slug: existing?.projectSlug ?? null },
|
|
37497
|
+
dir: cwd,
|
|
37498
|
+
synced: 0,
|
|
37499
|
+
primers: tools.map((t) => t.key),
|
|
37500
|
+
skippedTools: skipped.map((t) => t.key),
|
|
37501
|
+
captureHooks: captureEnabled(existing ?? null)
|
|
37502
|
+
}));
|
|
37503
|
+
return;
|
|
37504
|
+
}
|
|
37505
|
+
say(success(`Refreshed primer files: ${primerSummary}.`));
|
|
37506
|
+
if (skippedNote) say(skippedNote);
|
|
37382
37507
|
if (opts.capture !== void 0) {
|
|
37383
|
-
if (opts.capture) await pairForCapture();
|
|
37384
|
-
|
|
37508
|
+
if (opts.capture) await pairForCapture(note);
|
|
37509
|
+
say(success(`Session recording ${opts.capture ? "enabled" : "disabled"} for this project (captureHooks: ${opts.capture} in .gipity.json).`));
|
|
37385
37510
|
}
|
|
37386
37511
|
return;
|
|
37387
37512
|
}
|
|
@@ -37392,13 +37517,10 @@ Working with an existing Gipity project:
|
|
|
37392
37517
|
}
|
|
37393
37518
|
const ancestorConfigPath = getConfigPath();
|
|
37394
37519
|
if (ancestorConfigPath) {
|
|
37395
|
-
|
|
37396
|
-
const ok = await
|
|
37397
|
-
`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`,
|
|
37398
|
-
{ default: "no" }
|
|
37399
|
-
);
|
|
37520
|
+
note(muted(`Note: ${formatCwdLabel(dirname8(ancestorConfigPath))} is already a Gipity project.`));
|
|
37521
|
+
const ok = await ask(`Create a separate nested project at ${bold(formatCwdLabel(cwd))}?`, "no");
|
|
37400
37522
|
if (!ok) {
|
|
37401
|
-
|
|
37523
|
+
say(muted("Aborted."));
|
|
37402
37524
|
process.exit(1);
|
|
37403
37525
|
}
|
|
37404
37526
|
}
|
|
@@ -37417,12 +37539,9 @@ Working with an existing Gipity project:
|
|
|
37417
37539
|
process.exit(1);
|
|
37418
37540
|
}
|
|
37419
37541
|
if (scan.tier === "moderate") {
|
|
37420
|
-
const ok = await
|
|
37421
|
-
`About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`,
|
|
37422
|
-
{ default: "yes" }
|
|
37423
|
-
);
|
|
37542
|
+
const ok = await ask(`About to adopt ${bold(String(scan.files))} files (${bold(formatBytes(scan.bytes))}) at ${bold(formatCwdLabel(process.cwd()))}. Continue?`, "yes");
|
|
37424
37543
|
if (!ok) {
|
|
37425
|
-
|
|
37544
|
+
say(muted("Aborted."));
|
|
37426
37545
|
process.exit(1);
|
|
37427
37546
|
}
|
|
37428
37547
|
}
|
|
@@ -37432,15 +37551,17 @@ Working with an existing Gipity project:
|
|
|
37432
37551
|
projectName,
|
|
37433
37552
|
projectSlug,
|
|
37434
37553
|
accountSlug,
|
|
37435
|
-
|
|
37554
|
+
// No y/N on stdout in JSON mode: a non-interactive sync fails safe
|
|
37555
|
+
// (aborts rather than deleting) instead of asking.
|
|
37556
|
+
confirmDeletions: !json,
|
|
37436
37557
|
tools
|
|
37437
37558
|
});
|
|
37438
37559
|
if (adopted.isNew) {
|
|
37439
|
-
|
|
37560
|
+
say(success(`Created project "${adopted.project.name}" (${adopted.project.slug})`));
|
|
37440
37561
|
} else {
|
|
37441
|
-
|
|
37562
|
+
say(`Found existing project ${info(`"${adopted.project.name}"`)} ${muted(`(${adopted.project.slug})`)}`);
|
|
37442
37563
|
}
|
|
37443
|
-
if (adopted.applied > 0)
|
|
37564
|
+
if (adopted.applied > 0) say(`Synced ${adopted.applied} change${adopted.applied > 1 ? "s" : ""} with Gipity.`);
|
|
37444
37565
|
const pinnedFresh = pinnedToolKeys(opts.for, tools);
|
|
37445
37566
|
if (opts.capture !== void 0 || pinnedFresh) {
|
|
37446
37567
|
try {
|
|
@@ -37451,15 +37572,30 @@ Working with an existing Gipity project:
|
|
|
37451
37572
|
} catch {
|
|
37452
37573
|
}
|
|
37453
37574
|
}
|
|
37454
|
-
if (opts.capture) await pairForCapture();
|
|
37455
|
-
|
|
37456
|
-
|
|
37575
|
+
if (opts.capture) await pairForCapture(note);
|
|
37576
|
+
if (json) {
|
|
37577
|
+
const cfg = JSON.parse(readFileSync13(resolve8(cwd, ".gipity.json"), "utf-8"));
|
|
37578
|
+
console.log(JSON.stringify({
|
|
37579
|
+
linked: true,
|
|
37580
|
+
alreadyLinked: false,
|
|
37581
|
+
created: adopted.isNew,
|
|
37582
|
+
project: { guid: adopted.project.short_guid, slug: adopted.project.slug, name: adopted.project.name },
|
|
37583
|
+
dir: cwd,
|
|
37584
|
+
synced: adopted.applied,
|
|
37585
|
+
primers: tools.map((t) => t.key),
|
|
37586
|
+
skippedTools: skipped.map((t) => t.key),
|
|
37587
|
+
captureHooks: captureEnabled(cfg)
|
|
37588
|
+
}));
|
|
37589
|
+
return;
|
|
37590
|
+
}
|
|
37591
|
+
say(success(`Wrote primer files: ${primerSummary}.`));
|
|
37592
|
+
if (skippedNote) say(skippedNote);
|
|
37457
37593
|
if (wantsClaude) {
|
|
37458
|
-
|
|
37594
|
+
say(success(`Ready! Run your coding agent here (${AGENT_ADAPTERS.map((a) => a.key).join(", ")}), or \`gipity build\` to launch one with a picker.`));
|
|
37459
37595
|
const recording = JSON.parse(readFileSync13(resolve8(cwd, ".gipity.json"), "utf-8")).captureHooks !== false;
|
|
37460
|
-
|
|
37596
|
+
say(muted(recording ? "Claude Code sessions here are recorded to your Gipity project (Chats in your Gipity dashboard). Turn off: gipity init --no-capture." : "Claude Code sessions here are not recorded. To keep them in your Gipity project (Chats in your dashboard): gipity init --capture."));
|
|
37461
37597
|
} else {
|
|
37462
|
-
|
|
37598
|
+
say(success("Ready! Open this directory in your AI coding tool."));
|
|
37463
37599
|
}
|
|
37464
37600
|
} catch (err) {
|
|
37465
37601
|
const msg = err?.message ?? String(err);
|
|
@@ -37529,7 +37665,8 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
|
|
|
37529
37665
|
account: config.accountSlug,
|
|
37530
37666
|
apiBase: config.apiBase,
|
|
37531
37667
|
apiBaseInUse,
|
|
37532
|
-
url: liveUrl(config)
|
|
37668
|
+
url: liveUrl(config),
|
|
37669
|
+
...config.env ? { env: config.env.name } : {}
|
|
37533
37670
|
} : null,
|
|
37534
37671
|
// `valid` reflects the refresh token (the real session) - access
|
|
37535
37672
|
// tokens auto-renew, so their expiry must not read as "invalid".
|
|
@@ -37553,6 +37690,7 @@ var statusCommand = new Command("status").alias("whoami").description("Show proj
|
|
|
37553
37690
|
} else {
|
|
37554
37691
|
console.log(`${muted("Project:")} ${brand(config.projectSlug)} ${muted(`(${config.projectGuid})`)}`);
|
|
37555
37692
|
console.log(`${muted("Account:")} ${config.accountSlug}`);
|
|
37693
|
+
if (config.env) console.log(`${muted("Env:")} ${config.env.name}`);
|
|
37556
37694
|
console.log(`${muted("Live:")} ${liveUrl(config)}`);
|
|
37557
37695
|
console.log(`${muted("API:")} ${config.apiBase}`);
|
|
37558
37696
|
if (apiBaseInUse !== config.apiBase) {
|
|
@@ -37647,7 +37785,7 @@ ${result.deferredDeletes} file${result.deferredDeletes > 1 ? "s" : ""} on Gipity
|
|
|
37647
37785
|
// src/commands/push.ts
|
|
37648
37786
|
import { resolve as resolve10 } from "path";
|
|
37649
37787
|
init_colors();
|
|
37650
|
-
var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").action(async (files, opts) => {
|
|
37788
|
+
var pushCommand = new Command("push").description("Push one or more files").argument("<files...>", "File path(s) to push").option("--quiet", "Suppress output").option("--background", "Fork and exit immediately").option("--json", "Output as JSON").action(async (files, opts) => {
|
|
37651
37789
|
try {
|
|
37652
37790
|
const fullPaths = files.map((f) => resolve10(f));
|
|
37653
37791
|
if (opts.background) {
|
|
@@ -37657,12 +37795,17 @@ var pushCommand = new Command("push").description("Push one or more files").argu
|
|
|
37657
37795
|
stdio: "ignore"
|
|
37658
37796
|
});
|
|
37659
37797
|
child.unref();
|
|
37798
|
+
if (opts.json) console.log(JSON.stringify({ background: true, files }));
|
|
37660
37799
|
return;
|
|
37661
37800
|
}
|
|
37662
|
-
|
|
37663
|
-
|
|
37801
|
+
const pushed = [];
|
|
37802
|
+
const skipped = [];
|
|
37803
|
+
for (let i = 0; i < fullPaths.length; i++) {
|
|
37804
|
+
(await pushFile(fullPaths[i]) ? pushed : skipped).push(files[i]);
|
|
37664
37805
|
}
|
|
37665
|
-
if (
|
|
37806
|
+
if (opts.json) {
|
|
37807
|
+
console.log(JSON.stringify({ pushed, skipped }));
|
|
37808
|
+
} else if (!opts.quiet) {
|
|
37666
37809
|
console.log(success(files.length === 1 ? `Pushed ${files[0]}` : `Pushed ${files.length} files`));
|
|
37667
37810
|
}
|
|
37668
37811
|
} catch (err) {
|
|
@@ -38982,10 +39125,35 @@ function statusIcon(status) {
|
|
|
38982
39125
|
if (status === "warning") return warning("\u26A0");
|
|
38983
39126
|
return muted("\u2192");
|
|
38984
39127
|
}
|
|
38985
|
-
|
|
38986
|
-
|
|
38987
|
-
|
|
38988
|
-
|
|
39128
|
+
async function printPlan(appGuid2, env, json) {
|
|
39129
|
+
const res = await get(`/projects/${appGuid2}/envs/${encodeURIComponent(env)}/plan`);
|
|
39130
|
+
const p = res.data;
|
|
39131
|
+
if (json) {
|
|
39132
|
+
console.log(JSON.stringify(p));
|
|
39133
|
+
return;
|
|
39134
|
+
}
|
|
39135
|
+
console.log(brand(bold(`Deploy plan for ${p.env}`)));
|
|
39136
|
+
console.log(muted("\u2500".repeat(40)));
|
|
39137
|
+
if (p.pending.length === 0) {
|
|
39138
|
+
console.log(success(`\u2713 No pending migrations: ${p.env}'s database is up to date.`));
|
|
39139
|
+
return;
|
|
39140
|
+
}
|
|
39141
|
+
for (const m of p.pending) {
|
|
39142
|
+
const where = m.ranOn.length ? muted(`ran on ${m.ranOn.map((r) => `${r.env} ${new Date(r.appliedAt).toLocaleDateString()}`).join(", ")}`) : warning("has not run anywhere yet");
|
|
39143
|
+
const edited = p.changed.includes(m.file) ? muted(" (edited since it ran here; runs again)") : "";
|
|
39144
|
+
console.log(`${m.destructive.length ? error("!") : muted("\u2192")} ${bold(m.file)} ${where}${edited}`);
|
|
39145
|
+
for (const d of m.destructive) console.log(` ${error(d)}`);
|
|
39146
|
+
}
|
|
39147
|
+
if (p.env === "prod" && p.pending.some((m) => m.destructive.length)) {
|
|
39148
|
+
console.log("");
|
|
39149
|
+
console.log(warning("A prod deploy stops on the destructive statements above until you pass --yes-destructive."));
|
|
39150
|
+
}
|
|
39151
|
+
}
|
|
39152
|
+
var deployCommand = new Command("deploy").description("Deploy the app to prod, or to an environment (created on first deploy)").argument("[env]", "prod, or an environment name (dev, staging, ...). Omitted: prod while the app has no environments; once it has any, name one").option("--yes-destructive", "Allow pending prod migrations that destroy data (DROP TABLE/COLUMN, TRUNCATE, DELETE without WHERE, column type changes)").option("--plan", "Show the pending migrations this deploy would run (and where each already ran), without deploying").option("--source-dir <dir>", "Source directory to deploy from").option("--only <phases>", "Run only specific phases, comma-separated, matched by gipity.yaml phase name or type: files/static, database/sql, functions, workflows, services, jobs, records, realtime, env, auth_branding").option("--force", "Re-run all phases (ignore checksums) and bypass the sync bulk-deletion guard").option("--no-sync", "Skip sync-up before deploy").option("--optimize", "Force Vite build optimization on (default for prod; use this to optimize a dev deploy too)").option("--no-optimize", 'Skip build optimization and upload files as-is - the escape hatch for plain-HTML apps whose <script src> tags are not type="module"').option("--json", "Output as JSON").option("--inspect [path]", "After a successful deploy, run `page inspect` on the deployed URL (or URL + path) in the same command - one build-loop step instead of two. With --json, emits two JSON lines: deploy, then inspect.").option("--wait <ms>", "With --inspect: sleep this many ms before capturing (max 30000)").option("--wait-for <selector>", "With --inspect: wait until this CSS selector appears before capturing (deterministic; the app's own ready signal)").option("--wait-timeout <ms>", "With --inspect: max ms to wait for --wait-for before giving up", "5000").action((envArg, opts) => run("Deploy", async () => {
|
|
39153
|
+
const env = envArg ?? getEnvOption();
|
|
39154
|
+
if (opts.plan) {
|
|
39155
|
+
await printPlan(requireConfig2().projectGuid, env ?? "prod", !!opts.json);
|
|
39156
|
+
return;
|
|
38989
39157
|
}
|
|
38990
39158
|
if (!opts.inspect && (opts.waitFor || deployCommand.getOptionValueSource("wait") !== void 0)) {
|
|
38991
39159
|
opts.inspect = true;
|
|
@@ -38993,14 +39161,16 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
|
|
|
38993
39161
|
const config = requireConfig2();
|
|
38994
39162
|
await syncBeforeAction(opts);
|
|
38995
39163
|
const doDeploy = () => post(`/projects/${config.projectGuid}/deploy`, {
|
|
38996
|
-
|
|
39164
|
+
...env ? { env } : {},
|
|
39165
|
+
...opts.yesDestructive ? { yesDestructive: true } : {},
|
|
38997
39166
|
sourceDir: opts.sourceDir,
|
|
38998
39167
|
optimize: opts.optimize,
|
|
38999
39168
|
force: opts.force,
|
|
39000
39169
|
only: opts.only?.split(",").map((s) => s.trim())
|
|
39001
39170
|
});
|
|
39002
|
-
const res = opts.json ? await doDeploy() : await withSpinner(`Deploying to ${
|
|
39171
|
+
const res = opts.json ? await doDeploy() : await withSpinner(env ? `Deploying to ${env}...` : "Deploying...", doDeploy, { done: null });
|
|
39003
39172
|
const d = res.data;
|
|
39173
|
+
const where = d.env ?? d.target;
|
|
39004
39174
|
const inspectAfter = async () => {
|
|
39005
39175
|
if (!opts.inspect) return;
|
|
39006
39176
|
if (!d.url) {
|
|
@@ -39023,11 +39193,12 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
|
|
|
39023
39193
|
if (opts.json) {
|
|
39024
39194
|
console.log(JSON.stringify(d));
|
|
39025
39195
|
const failedJson = d.phases?.some((p) => p.status === "failed");
|
|
39026
|
-
if (
|
|
39196
|
+
if (failedJson) process.exit(1);
|
|
39197
|
+
await inspectAfter();
|
|
39027
39198
|
return;
|
|
39028
39199
|
}
|
|
39029
39200
|
const batchLabel = d.batch ? muted(` (batch ${d.batch})`) : "";
|
|
39030
|
-
console.log(brand(bold(`Deploy to ${
|
|
39201
|
+
console.log(brand(bold(`Deploy to ${where}`)) + batchLabel + (d.created ? muted(" (new environment)") : ""));
|
|
39031
39202
|
console.log(muted("\u2500".repeat(40)));
|
|
39032
39203
|
if (d.phases && d.phases.length > 0) {
|
|
39033
39204
|
for (const phase of d.phases) {
|
|
@@ -39063,16 +39234,157 @@ var deployCommand = new Command("deploy").description("Deploy to dev or prod").a
|
|
|
39063
39234
|
console.log(error(`Deploy failed`) + muted(` (${d.elapsedMs}ms)`));
|
|
39064
39235
|
process.exit(1);
|
|
39065
39236
|
} else {
|
|
39066
|
-
console.log(success(`\u2713 Deployed to ${
|
|
39237
|
+
console.log(success(`\u2713 Deployed to ${where}`) + muted(` (${d.elapsedMs}ms)`));
|
|
39067
39238
|
if (d.url) console.log(`${muted("Live:")} ${brand(d.url)}`);
|
|
39068
39239
|
if (d.phases?.some((p) => p.name === "functions")) {
|
|
39069
|
-
console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${config.projectGuid}/fn/<name>`)}`);
|
|
39070
|
-
|
|
39240
|
+
console.log(`${muted("Functions:")} POST ${brand(`${resolveApiBase()}/api/${d.appGuid ?? config.projectGuid}/fn/<name>`)}`);
|
|
39241
|
+
const envFlag = d.env && d.env !== "prod" ? ` --env ${d.env}` : "";
|
|
39242
|
+
console.log(muted(` (names: gipity fn list${envFlag}; verify the public path: gipity fn call <name>${envFlag} --anon)`));
|
|
39071
39243
|
}
|
|
39244
|
+
for (const hint of d.hints ?? []) console.log(muted(hint));
|
|
39072
39245
|
await inspectAfter();
|
|
39073
39246
|
}
|
|
39074
39247
|
}));
|
|
39075
39248
|
|
|
39249
|
+
// src/commands/env.ts
|
|
39250
|
+
init_api();
|
|
39251
|
+
init_config();
|
|
39252
|
+
init_utils();
|
|
39253
|
+
init_colors();
|
|
39254
|
+
init_utils();
|
|
39255
|
+
function appGuid() {
|
|
39256
|
+
return requireConfig2().projectGuid;
|
|
39257
|
+
}
|
|
39258
|
+
var envCommand = new Command("env").description("App environments: prod plus any number of isolated copies (dev, staging, ...), each with its own database, functions and URL").addHelpText("after", `
|
|
39259
|
+
An environment is created the first time you deploy to it:
|
|
39260
|
+
gipity deploy dev # creates "dev" (own DB from migrations, own functions), deploys
|
|
39261
|
+
gipity deploy prod # the live app
|
|
39262
|
+
|
|
39263
|
+
Run any project command against one with --env:
|
|
39264
|
+
gipity db query "SELECT count(*) FROM orders" --env dev
|
|
39265
|
+
gipity fn call checkout --env staging
|
|
39266
|
+
gipity logs fn checkout --env dev
|
|
39267
|
+
|
|
39268
|
+
Envs share the app's secrets (an env can override one: gipity secrets set NAME value --env staging),
|
|
39269
|
+
members and players. Cron workflows are off in an env until: gipity env set <name> --schedules on.
|
|
39270
|
+
Email from an env reaches only the app owner and members; payments run in prod only.`);
|
|
39271
|
+
envCommand.command("list", { isDefault: true }).description("List the app's environments").option("--json", "Output as JSON").action((opts) => run("Env", async () => {
|
|
39272
|
+
const res = await get(`/projects/${appGuid()}/envs`);
|
|
39273
|
+
const d = res.data;
|
|
39274
|
+
if (opts.json) {
|
|
39275
|
+
console.log(JSON.stringify(d));
|
|
39276
|
+
return;
|
|
39277
|
+
}
|
|
39278
|
+
console.log(`${bold("prod")} ${brand(d.prod.url)}`);
|
|
39279
|
+
if (d.envs.length === 0) {
|
|
39280
|
+
console.log(muted("No environments yet. `gipity deploy dev` creates one."));
|
|
39281
|
+
return;
|
|
39282
|
+
}
|
|
39283
|
+
for (const e of d.envs) {
|
|
39284
|
+
const deployed = e.lastDeploy ? `deployed ${new Date(e.lastDeploy).toLocaleString()}` : "never deployed";
|
|
39285
|
+
const parts = [deployed, `DB ${formatSize(e.dbBytes)}`, e.schedules ? "schedules on" : "schedules off"];
|
|
39286
|
+
if (e.customDomains.length) parts.push(e.customDomains.join(", "));
|
|
39287
|
+
console.log(`${bold(e.name)} ${brand(e.url)} ${muted(parts.join(" \xB7 "))}`);
|
|
39288
|
+
}
|
|
39289
|
+
}));
|
|
39290
|
+
function printCopy(copy) {
|
|
39291
|
+
if (!copy) return;
|
|
39292
|
+
for (const d of copy.databases) {
|
|
39293
|
+
console.log(muted(`Copied ${d.rows} rows (${d.tables} tables) from ${copy.from}'s ${d.database} database`));
|
|
39294
|
+
}
|
|
39295
|
+
}
|
|
39296
|
+
envCommand.command("create <name>").description("Create an environment and deploy the app to it (`gipity deploy <name>` does the same, without --data)").option("--data", "Copy the rows of prod (or --from) into it, to try a change against real data").option("--from <env>", "With --data: the environment to copy from (default prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
|
|
39297
|
+
if (name === PROD_ENV) {
|
|
39298
|
+
console.error(error("prod is the app itself. Deploy it with: gipity deploy prod"));
|
|
39299
|
+
process.exit(1);
|
|
39300
|
+
}
|
|
39301
|
+
if (opts.from && !opts.data) {
|
|
39302
|
+
console.error(error("--from goes with --data"));
|
|
39303
|
+
process.exit(1);
|
|
39304
|
+
}
|
|
39305
|
+
const create = () => post(
|
|
39306
|
+
`/projects/${appGuid()}/envs`,
|
|
39307
|
+
{ name, ...opts.data ? { data: true } : {}, ...opts.from ? { from: opts.from } : {} }
|
|
39308
|
+
);
|
|
39309
|
+
const res = opts.json ? await create() : await withSpinner(`Creating ${name}...`, create, { done: null });
|
|
39310
|
+
if (opts.json) {
|
|
39311
|
+
console.log(JSON.stringify(res.data));
|
|
39312
|
+
return;
|
|
39313
|
+
}
|
|
39314
|
+
const failed = res.data.phases.filter((p) => p.status === "failed");
|
|
39315
|
+
for (const p of failed) console.log(`${error("\u2717")} ${bold(p.name)}: ${p.summary}`);
|
|
39316
|
+
if (failed.length > 0) {
|
|
39317
|
+
console.log(error(`Created ${name}, but its first deploy failed. Fix it and run: gipity deploy ${name}`));
|
|
39318
|
+
process.exit(1);
|
|
39319
|
+
}
|
|
39320
|
+
console.log(success(`\u2713 Created ${name}`));
|
|
39321
|
+
printCopy(res.data.data);
|
|
39322
|
+
console.log(`${muted("Live:")} ${brand(res.data.url)}`);
|
|
39323
|
+
}));
|
|
39324
|
+
envCommand.command("reset <name>").description("Start an environment over: drop its database, rerun every migration from zero, redeploy").option("--data", "Then copy the rows of prod (or --from) into it").option("--from <env>", "With --data: the environment to copy from (default prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
|
|
39325
|
+
if (name === PROD_ENV) {
|
|
39326
|
+
console.error(error("prod can't be reset."));
|
|
39327
|
+
process.exit(1);
|
|
39328
|
+
}
|
|
39329
|
+
if (opts.from && !opts.data) {
|
|
39330
|
+
console.error(error("--from goes with --data"));
|
|
39331
|
+
process.exit(1);
|
|
39332
|
+
}
|
|
39333
|
+
const ok = await confirm(`Reset ${bold(name)}? Its database is dropped and rebuilt${opts.data ? ` from ${opts.from ?? "prod"}'s data` : " empty"}.`, { default: "no" });
|
|
39334
|
+
if (!ok) {
|
|
39335
|
+
console.log(muted("Aborted."));
|
|
39336
|
+
process.exit(1);
|
|
39337
|
+
}
|
|
39338
|
+
const reset = () => post(
|
|
39339
|
+
`/projects/${appGuid()}/envs/${encodeURIComponent(name)}/reset`,
|
|
39340
|
+
{ ...opts.data ? { data: true } : {}, ...opts.from ? { from: opts.from } : {} }
|
|
39341
|
+
);
|
|
39342
|
+
const res = opts.json ? await reset() : await withSpinner(`Resetting ${name}...`, reset, { done: null });
|
|
39343
|
+
if (opts.json) {
|
|
39344
|
+
console.log(JSON.stringify(res.data));
|
|
39345
|
+
return;
|
|
39346
|
+
}
|
|
39347
|
+
const failed = res.data.phases.filter((p) => p.status === "failed");
|
|
39348
|
+
for (const p of failed) console.log(`${error("\u2717")} ${bold(p.name)}: ${p.summary}`);
|
|
39349
|
+
if (failed.length > 0) {
|
|
39350
|
+
console.log(error(`Reset ${name}, but its deploy failed.`));
|
|
39351
|
+
process.exit(1);
|
|
39352
|
+
}
|
|
39353
|
+
console.log(success(`\u2713 Reset ${name}`));
|
|
39354
|
+
printCopy(res.data.data);
|
|
39355
|
+
if (res.data.url) console.log(`${muted("Live:")} ${brand(res.data.url)}`);
|
|
39356
|
+
}));
|
|
39357
|
+
envCommand.command("set <name>").description("Change an environment's settings").requiredOption("--schedules <on|off>", "Turn the environment's cron workflows on or off").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
|
|
39358
|
+
const value = String(opts.schedules).toLowerCase();
|
|
39359
|
+
if (value !== "on" && value !== "off") {
|
|
39360
|
+
console.error(error("--schedules takes on or off"));
|
|
39361
|
+
process.exit(1);
|
|
39362
|
+
}
|
|
39363
|
+
const res = await patch(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`, { schedules: value === "on" });
|
|
39364
|
+
if (opts.json) {
|
|
39365
|
+
console.log(JSON.stringify(res.data));
|
|
39366
|
+
return;
|
|
39367
|
+
}
|
|
39368
|
+
console.log(success(`\u2713 Schedules ${value} in ${name}`));
|
|
39369
|
+
}));
|
|
39370
|
+
envCommand.command("delete <name>").description("Delete an environment: its database, functions, files and custom domains (never prod)").option("--json", "Output as JSON").action((name, opts) => run("Env", async () => {
|
|
39371
|
+
if (name === PROD_ENV) {
|
|
39372
|
+
console.error(error("prod is the app itself and can't be deleted as an environment."));
|
|
39373
|
+
process.exit(1);
|
|
39374
|
+
}
|
|
39375
|
+
const ok = await confirm(`Delete the ${bold(name)} environment and its database?`, { default: "no" });
|
|
39376
|
+
if (!ok) {
|
|
39377
|
+
console.log(muted("Aborted."));
|
|
39378
|
+
process.exit(1);
|
|
39379
|
+
}
|
|
39380
|
+
const res = await del(`/projects/${appGuid()}/envs/${encodeURIComponent(name)}`);
|
|
39381
|
+
if (opts.json) {
|
|
39382
|
+
console.log(JSON.stringify(res.data));
|
|
39383
|
+
return;
|
|
39384
|
+
}
|
|
39385
|
+
console.log(success(`\u2713 Deleted ${name}`));
|
|
39386
|
+
}));
|
|
39387
|
+
|
|
39076
39388
|
// src/commands/db.ts
|
|
39077
39389
|
init_api();
|
|
39078
39390
|
init_config();
|
|
@@ -40435,9 +40747,10 @@ syncs; ideal for throwaway test fixtures (delete the file to revoke the link).
|
|
|
40435
40747
|
}));
|
|
40436
40748
|
fileCommand.command("tree [path]").description("Show the file tree").option("--json", "Output as JSON").action((path5, opts) => run("Tree", async () => {
|
|
40437
40749
|
const { config } = await resolveProjectContext();
|
|
40438
|
-
const
|
|
40750
|
+
const qs = new URLSearchParams({ include: "app_uploads" });
|
|
40751
|
+
if (path5) qs.set("path", path5);
|
|
40439
40752
|
const res = await get(
|
|
40440
|
-
`/projects/${config.projectGuid}/files/tree
|
|
40753
|
+
`/projects/${config.projectGuid}/files/tree?${qs.toString()}`
|
|
40441
40754
|
);
|
|
40442
40755
|
printList(res.data, opts, "(empty)", (f) => {
|
|
40443
40756
|
const size = f.type === "dir" ? "" : ` (${formatSize(Number(f.size))})`;
|
|
@@ -40626,7 +40939,7 @@ function humanBytes(n) {
|
|
|
40626
40939
|
return `${(n / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
40627
40940
|
}
|
|
40628
40941
|
function buildHeader(opts) {
|
|
40629
|
-
const deployUrl = opts.accountSlug ? `https://
|
|
40942
|
+
const deployUrl = opts.accountSlug ? `https://app.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
|
|
40630
40943
|
const filesLine = opts.fileCount === 0 ? `- Files: empty (no files yet)` : `- Files: ${opts.fileCount} file${opts.fileCount === 1 ? "" : "s"} in ${opts.folderCount} folder${opts.folderCount === 1 ? "" : "s"} (${humanBytes(opts.totalBytes)}) - ${opts.topLevel}`;
|
|
40631
40944
|
return [
|
|
40632
40945
|
`## Gipity project`,
|
|
@@ -40678,7 +40991,7 @@ var USER_MSG_OPEN = "<gipity-user-message>";
|
|
|
40678
40991
|
var USER_MSG_CLOSE = "</gipity-user-message>";
|
|
40679
40992
|
var RESPONSE_DIRECTIVE = `Respond to the user message below. Don't greet or reintroduce yourself.`;
|
|
40680
40993
|
function buildResumeWrap(opts, userMsg) {
|
|
40681
|
-
const deployUrl = opts.accountSlug ? `https://
|
|
40994
|
+
const deployUrl = opts.accountSlug ? `https://app.gipity.ai/${opts.accountSlug}/${opts.projectSlug}/` : "(not yet deployed)";
|
|
40682
40995
|
return [
|
|
40683
40996
|
`Project: ${opts.projectName} (\`${opts.projectGuid}\`) - ${deployUrl}`,
|
|
40684
40997
|
PLATFORM_REMINDER,
|
|
@@ -42226,7 +42539,7 @@ function printBrand(d) {
|
|
|
42226
42539
|
if (d.branding.app_name) console.log(`${bold("Name:")} ${d.branding.app_name}`);
|
|
42227
42540
|
if (d.branding.tagline) console.log(`${bold("Tagline:")} ${d.branding.tagline}`);
|
|
42228
42541
|
}
|
|
42229
|
-
var DEPLOY_HINT = "Deploy to publish the new assets: gipity deploy
|
|
42542
|
+
var DEPLOY_HINT = "Deploy to publish the new assets: gipity deploy";
|
|
42230
42543
|
var brandCommand = new Command("brand").description("The app's generated icons + share card (favicons, iOS icon, og-image)").addHelpText("after", `
|
|
42231
42544
|
Examples:
|
|
42232
42545
|
gipity brand Show the current brand
|
|
@@ -43217,10 +43530,10 @@ recordsCommand.command("list").description("List record tables").option("--json"
|
|
|
43217
43530
|
(t) => `${bold(t.table_name)} ${muted(t.auth_level)} ${muted(`pk=${t.primary_key_column}`)} ${muted(`db=${t.database_name}`)}`
|
|
43218
43531
|
);
|
|
43219
43532
|
}));
|
|
43220
|
-
recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, etc.)").addOption(new Option("--auth <level>", "Auth level: public (anonymous writes),
|
|
43533
|
+
recordsCommand.command("config <table>").description("Show or set a table's Records API config (auth level, search, auto-numbering, etc.)").addOption(new Option("--auth <level>", "Auth level: public (anonymous writes), user (any signed-in caller), or member (owner and project members only)").choices(["public", "member", "user"])).option("--searchable <bool>", "Enable full-text search (true/false)").option("--primary-key <col>", "Primary key column (default: id)").option("--soft-delete <col>", 'Soft-delete column (pass "none" to clear)').option("--auto-number <prefix>", 'Number new records automatically, e.g. INC -> INC0001001 (pass "none" to turn off). Same as auto_number in gipity.yaml').option("--auto-number-pad <n>", "Zero-pad width of the auto-number (default 7)").option("--auto-number-column <col>", "Column the auto-number is written to (default: number)").option("--json", "Output as JSON").action((table, opts) => run("Config", async () => {
|
|
43221
43534
|
const config = requireConfig2();
|
|
43222
43535
|
const base = `/api/${config.projectGuid}/records/${table}/config`;
|
|
43223
|
-
const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete;
|
|
43536
|
+
const setting = opts.auth || opts.searchable !== void 0 || opts.primaryKey || opts.softDelete || opts.autoNumber || opts.autoNumberPad || opts.autoNumberColumn;
|
|
43224
43537
|
if (!setting) {
|
|
43225
43538
|
const res2 = await get(base);
|
|
43226
43539
|
printResult(JSON.stringify(res2.data, null, 2), opts, res2.data);
|
|
@@ -43231,11 +43544,20 @@ recordsCommand.command("config <table>").description("Show or set a table's Reco
|
|
|
43231
43544
|
if (opts.searchable !== void 0) body.searchable = /^(true|1|on|yes)$/i.test(String(opts.searchable));
|
|
43232
43545
|
if (opts.primaryKey) body.primary_key_column = opts.primaryKey;
|
|
43233
43546
|
if (opts.softDelete) body.soft_delete_column = opts.softDelete === "none" ? null : opts.softDelete;
|
|
43547
|
+
if (opts.autoNumber) body.auto_number_prefix = opts.autoNumber === "none" ? null : opts.autoNumber;
|
|
43548
|
+
if (opts.autoNumberPad) {
|
|
43549
|
+
const pad = Number(opts.autoNumberPad);
|
|
43550
|
+
if (!Number.isInteger(pad)) throw new Error(`--auto-number-pad must be a whole number (got '${opts.autoNumberPad}')`);
|
|
43551
|
+
body.auto_number_pad = pad;
|
|
43552
|
+
}
|
|
43553
|
+
if (opts.autoNumberColumn) body.auto_number_column = opts.autoNumberColumn;
|
|
43234
43554
|
const res = await patch(base, body);
|
|
43555
|
+
const d = res.data;
|
|
43556
|
+
const autoNumber = d.auto_number_prefix ? `${d.auto_number_prefix} (pad ${d.auto_number_pad}, column ${d.auto_number_column})` : "off";
|
|
43235
43557
|
printResult(
|
|
43236
|
-
`Configured "${table}": auth=${
|
|
43558
|
+
`Configured "${table}": auth=${d.auth_level}, searchable=${d.searchable}, pk=${d.primary_key_column}, auto-number=${autoNumber}`,
|
|
43237
43559
|
opts,
|
|
43238
|
-
|
|
43560
|
+
d
|
|
43239
43561
|
);
|
|
43240
43562
|
}));
|
|
43241
43563
|
recordsCommand.command("query <table>").description("List records (full-text search, filter, sort, recycle bin)").option("-q, --q <text>", "Full-text search across the table's text columns (needs `--searchable true` on the table)").option("--filter <filter>", 'AND filter string, "col:op:value" comma-joined. Ops: eq, neq, gt, gte, lt, lte, like, ilike, in (pipe-separated values), is_null, not_null. Full grammar: gipity skill read app-records').option("--any <filter>", 'OR filter group, same grammar and ops as --filter (e.g., "owner:eq:me,shared:eq:true")').option("--sort <sort>", 'Sort string (e.g., "created_at:desc")').option("--limit <n>", "Max rows", "20").option("--offset <n>", "Offset", "0").option("--fields <fields>", "Comma-separated column names").option("--include-deleted", "Include soft-deleted rows (owner/editor)").option("--only-deleted", "Only soft-deleted rows - the recycle bin (owner/editor)").option(ANON_FLAG, ANON_HELP).option("--json", "Output as JSON").action((table, opts) => run("Query", async () => {
|
|
@@ -43326,7 +43648,7 @@ fnCommand.command("list").description("List functions").option("--json", "Output
|
|
|
43326
43648
|
${muted(f.description)}` : line;
|
|
43327
43649
|
});
|
|
43328
43650
|
if (!opts.json && res.data.length > 0) {
|
|
43329
|
-
console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (
|
|
43651
|
+
console.log(muted(`Endpoint: POST ${resolveApiBase()}/api/${config.projectGuid}/fn/<name> (this is ${config.env ? `the ${config.env.name} environment` : "prod"}; each environment has its own address, see --env; public path: gipity fn call <name> --anon)`));
|
|
43330
43652
|
}
|
|
43331
43653
|
}));
|
|
43332
43654
|
fnCommand.command("logs <name>").description("Show recent logs").option("--limit <n>", "Max entries", "20").option("--json", "Output as JSON").action((name, opts) => run("Logs", async () => {
|
|
@@ -43439,7 +43761,7 @@ function anonBillingHint(name, err) {
|
|
|
43439
43761
|
service_definitions:
|
|
43440
43762
|
- service: ${service}
|
|
43441
43763
|
billing_mode: owner_pays
|
|
43442
|
-
gipity deploy
|
|
43764
|
+
gipity deploy --only services`;
|
|
43443
43765
|
}
|
|
43444
43766
|
serviceCommand.command("call <name> [body]").description("Call an app service by name (e.g. llm, image, music). Uses your logged-in session - no token wrangling; --anon calls it as a signed-out visitor instead.").option("-d, --data <json>", "JSON request body: inline JSON, @file to read a file, or @- / - for stdin (alternative to the positional [body])").option("--file <field=@path>", "Attach a file as { data, media_type } under <field> in the JSON body (the shape image/vision services expect), repeatable, e.g. --file image=@receipt.png", (v7, acc) => (acc || []).concat(v7)).option("--form <field=value>", "Send multipart/form-data instead of JSON, curl -F style: field=@path attaches a file, field=value a text field. Repeatable. For upload endpoints like transcribe: --form audio=@talk.mp3 --form language=en", (v7, acc) => (acc || []).concat(v7)).option("--anon", "Call as an anonymous visitor (the public path a signed-out user of your deployed app hits) instead of as your signed-in account").option("--get", "Issue a GET (for listing endpoints like llm/models, tts/voices)").option("--field <path>", "Print only this field of the result (dot path, e.g. choices.0.message.content)").option("--json", "Output compact JSON").action((name, bodyArg, opts) => run("Call", async () => {
|
|
43445
43767
|
const config = requireConfig2();
|
|
@@ -43462,7 +43784,7 @@ serviceCommand.command("call <name> [body]").description("Call an app service by
|
|
|
43462
43784
|
const headers = await mintAppToken(config.projectGuid);
|
|
43463
43785
|
if (!headers) {
|
|
43464
43786
|
throw new Error(
|
|
43465
|
-
`Could not mint a visitor token for this project, so there is no anonymous path to call. That means the app is not deployed on this API base yet: run \`gipity deploy
|
|
43787
|
+
`Could not mint a visitor token for this project, so there is no anonymous path to call. That means the app is not deployed on this API base yet: run \`gipity deploy\` first, then re-run this command.`
|
|
43466
43788
|
);
|
|
43467
43789
|
}
|
|
43468
43790
|
res = await publicRequest(opts.get ? "GET" : "POST", url, opts.get ? void 0 : body, headers, LONG_REQUEST_TIMEOUT_MS);
|
|
@@ -43991,7 +44313,7 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
|
|
|
43991
44313
|
console.log(`${success("cancelled")} ${muted(runGuid)}`);
|
|
43992
44314
|
}
|
|
43993
44315
|
}));
|
|
43994
|
-
jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").action(async (name, opts) => {
|
|
44316
|
+
jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").option("--json", "Capture the job's output and print one JSON result (exitCode, stdout, stderr) instead of streaming it").action(async (name, opts) => {
|
|
43995
44317
|
const { existsSync: existsSync27, statSync: statSync12 } = await import("node:fs");
|
|
43996
44318
|
const { resolve: resolve19, join: join32 } = await import("node:path");
|
|
43997
44319
|
const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
@@ -44052,12 +44374,34 @@ jobCommand.command("run-local <name>").description("Run the job in a local Docke
|
|
|
44052
44374
|
shellCmd = `echo '[run-local] running ${handlerCmd} (${picked.runtime})' >&2 && exec ${handlerCmd}`;
|
|
44053
44375
|
}
|
|
44054
44376
|
const runArgs = ["run", ...sharedArgs, "--entrypoint", "sh", opts.image, "-c", shellCmd];
|
|
44055
|
-
const
|
|
44377
|
+
const startedAt = Date.now();
|
|
44378
|
+
const child = spawnCommand2("docker", runArgs, { stdio: opts.json ? ["ignore", "pipe", "pipe"] : "inherit" });
|
|
44379
|
+
const captured = { stdout: "", stderr: "" };
|
|
44380
|
+
if (opts.json) {
|
|
44381
|
+
child.stdout?.on("data", (d) => {
|
|
44382
|
+
captured.stdout += d.toString();
|
|
44383
|
+
});
|
|
44384
|
+
child.stderr?.on("data", (d) => {
|
|
44385
|
+
captured.stderr += d.toString();
|
|
44386
|
+
});
|
|
44387
|
+
}
|
|
44056
44388
|
child.on("error", (err) => {
|
|
44057
44389
|
console.error(error(err.code === "ENOENT" ? "Docker not found. Install Docker to use `gipity job run-local`." : `Failed to launch docker: ${err.message}`));
|
|
44058
44390
|
process.exit(1);
|
|
44059
44391
|
});
|
|
44060
|
-
child.on("
|
|
44392
|
+
child.on("close", (code) => {
|
|
44393
|
+
if (opts.json) {
|
|
44394
|
+
console.log(JSON.stringify({
|
|
44395
|
+
name,
|
|
44396
|
+
runtime: picked.runtime,
|
|
44397
|
+
image: opts.image,
|
|
44398
|
+
exitCode: code,
|
|
44399
|
+
durationMs: Date.now() - startedAt,
|
|
44400
|
+
stdout: captured.stdout,
|
|
44401
|
+
stderr: captured.stderr
|
|
44402
|
+
}));
|
|
44403
|
+
process.exit(code ?? 1);
|
|
44404
|
+
}
|
|
44061
44405
|
if (code === 0) console.error(muted(`[run-local] ${success("done")}`));
|
|
44062
44406
|
else console.error(muted(`[run-local] ${error("failed")} (exit ${code})`));
|
|
44063
44407
|
process.exit(code ?? 1);
|
|
@@ -44093,7 +44437,7 @@ rbacCommand.command("create <table>").description("Create or update a policy").r
|
|
|
44093
44437
|
const res = await post(`/projects/${config.projectGuid}/rbac`, body);
|
|
44094
44438
|
printResult("Policy created.", opts, res.data);
|
|
44095
44439
|
}));
|
|
44096
|
-
rbacCommand.command("delete <table>").description("Delete a policy").requiredOption("--role <role>", "Role").requiredOption("--op <operation>", "Operation").action((table, opts) => run("Delete", async () => {
|
|
44440
|
+
rbacCommand.command("delete <table>").description("Delete a policy").requiredOption("--role <role>", "Role").requiredOption("--op <operation>", "Operation").option("--json", "Output as JSON").action((table, opts) => run("Delete", async () => {
|
|
44097
44441
|
if (!await confirm(`Delete RBAC policy for "${table}"?`)) {
|
|
44098
44442
|
console.log("Cancelled.");
|
|
44099
44443
|
return;
|
|
@@ -44104,7 +44448,7 @@ rbacCommand.command("delete <table>").description("Delete a policy").requiredOpt
|
|
|
44104
44448
|
role: opts.role,
|
|
44105
44449
|
operation: opts.op
|
|
44106
44450
|
});
|
|
44107
|
-
printResult("Policy deleted.", {
|
|
44451
|
+
printResult("Policy deleted.", opts, { success: true, table, role: opts.role, operation: opts.op });
|
|
44108
44452
|
}));
|
|
44109
44453
|
|
|
44110
44454
|
// src/commands/audit.ts
|
|
@@ -44240,7 +44584,7 @@ var IMAGE_TIER_ALIAS_IDS = [
|
|
|
44240
44584
|
var TTS_PROVIDER_DESCRIPTIONS = {
|
|
44241
44585
|
"elevenlabs": `ElevenLabs (many premium voices)`,
|
|
44242
44586
|
"openai": `OpenAI (alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse)`,
|
|
44243
|
-
"gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more).
|
|
44587
|
+
"gemini": `Gemini (30 voices: Kore, Puck, Zephyr, Charon, Fenrir, Leda, Orus, Aoede, and 22 more). Two-voice dialogue (speakers) and an explicit language`
|
|
44244
44588
|
};
|
|
44245
44589
|
var TTS_PROVIDER_IDS = [
|
|
44246
44590
|
"elevenlabs",
|
|
@@ -45011,7 +45355,7 @@ function hasDeployManifest() {
|
|
|
45011
45355
|
if (!cfgPath) return false;
|
|
45012
45356
|
return existsSync19(resolve14(dirname14(cfgPath), "gipity.yaml"));
|
|
45013
45357
|
}
|
|
45014
|
-
var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").addOption(new Option("--type <type>", "Room type for create").choices(["state", "relay"]).default("state")).addOption(new Option("--auth <level>", "Auth level for create").choices(["public", "user"]).default("public")).option("--max-clients <n>", "max clients for create (1-200)").option("--seat-hold <seconds>", "create: how long a dropped client keeps its seat (0-300, default 30)").option("--host-hold <seconds>", "create: how long the host role waits for a dropped or reloading host (0-600, default 60)").option("--host-handoff", "create: move the host role to another player when the host is gone").option("--host-grace <seconds>", "create: with handoff, how long the host may be unreachable before the role moves (1-60, default 5)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
|
|
45358
|
+
var roomCommand = new Command("room").description("Manage realtime rooms").argument("[action]", "list | create | delete | info", "list").argument("[name]", "room name (for create | delete | info)").addOption(new Option("--type <type>", "Room type for create").choices(["state", "relay"]).default("state")).addOption(new Option("--auth <level>", "Auth level for create").choices(["public", "user"]).default("public")).option("--max-clients <n>", "max clients for create (1-200)").option("--seat-hold <seconds>", "create: how long a dropped client keeps its seat (0-300, default 30)").option("--host-hold <seconds>", "create: how long the host role waits for a dropped or reloading host (0-600, default 60)").option("--host-handoff", "create: move the host role to another player when the host is gone").option("--host-grace <seconds>", "create: with handoff, how long the host may be unreachable before the role moves (1-60, default 5)").option("--server-channels <names>", "create: comma-separated channels only the app's functions may publish on (realtime.publish)").option("--json", "Output as JSON").action((action, name, opts) => run("Realtime room", async () => {
|
|
45015
45359
|
const config = requireConfig2();
|
|
45016
45360
|
const base = `/projects/${config.projectGuid}/realtime-rooms`;
|
|
45017
45361
|
const sub = (action || "list").toLowerCase();
|
|
@@ -45037,6 +45381,9 @@ var roomCommand = new Command("room").description("Manage realtime rooms").argum
|
|
|
45037
45381
|
if (opts.hostHold !== void 0) body.host_hold_seconds = Number(opts.hostHold);
|
|
45038
45382
|
if (opts.hostHandoff) body.host_handoff = true;
|
|
45039
45383
|
if (opts.hostGrace !== void 0) body.host_grace_seconds = Number(opts.hostGrace);
|
|
45384
|
+
if (opts.serverChannels !== void 0) {
|
|
45385
|
+
body.server_channels = String(opts.serverChannels).split(",").map((c) => c.trim()).filter(Boolean);
|
|
45386
|
+
}
|
|
45040
45387
|
const res = await post(base, body);
|
|
45041
45388
|
if (opts.json) {
|
|
45042
45389
|
console.log(JSON.stringify(res.data));
|
|
@@ -45082,6 +45429,8 @@ var roomCommand = new Command("room").description("Manage realtime rooms").argum
|
|
|
45082
45429
|
console.log(`Max clients: ${room.max_clients}`);
|
|
45083
45430
|
console.log(`Seat hold: ${room.config?.seat_hold_seconds ?? 30}s (host ${room.config?.host_hold_seconds ?? 60}s)`);
|
|
45084
45431
|
console.log(`Handoff: ${room.config?.host_handoff ? `on, after ${room.config?.host_grace_seconds ?? 5}s` : "off"}`);
|
|
45432
|
+
const serverChannels = Array.isArray(room.config?.server_channels) ? room.config.server_channels : [];
|
|
45433
|
+
console.log(`Server-only: ${serverChannels.length ? serverChannels.join(", ") : "none"}`);
|
|
45085
45434
|
console.log(`Live: ${live ? `${live.instances} instance(s), ${live.clients} client(s)` : muted("Gipity Realtime unreachable")}`);
|
|
45086
45435
|
}
|
|
45087
45436
|
break;
|
|
@@ -45325,9 +45674,9 @@ var testCommand = new Command("test").description("Run tests").argument("[path]"
|
|
|
45325
45674
|
if (undeployed.length > 0) {
|
|
45326
45675
|
const list = undeployed.map((n) => `'${n}'`).join(", ");
|
|
45327
45676
|
console.log(warning(
|
|
45328
|
-
`${undeployed.length === 1 ? "Function" : "Functions"} ${list} 404'd:
|
|
45677
|
+
`${undeployed.length === 1 ? "Function" : "Functions"} ${list} 404'd: \`gipity test\` registers every file in functions/ before the run, so ${undeployed.length === 1 ? "that name has" : "those names have"} no function file, or failed to register.`
|
|
45329
45678
|
));
|
|
45330
|
-
console.log(muted("
|
|
45679
|
+
console.log(muted("Check the name against functions/<name>.js (or functions/<name>/index.js) and gipity.yaml."));
|
|
45331
45680
|
console.log("");
|
|
45332
45681
|
}
|
|
45333
45682
|
const parts = [];
|
|
@@ -45850,9 +46199,20 @@ if (isDirect) {
|
|
|
45850
46199
|
|
|
45851
46200
|
// src/commands/update.ts
|
|
45852
46201
|
init_colors();
|
|
45853
|
-
var updateCommand = new Command("update").description("Update the CLI").action(async () => {
|
|
45854
|
-
console.log(info("Checking for updates..."));
|
|
46202
|
+
var updateCommand = new Command("update").description("Update the CLI").option("--json", "Output as JSON").action(async (opts) => {
|
|
46203
|
+
if (!opts.json) console.log(info("Checking for updates..."));
|
|
45855
46204
|
const result = await runCheck({ force: true, verbose: true });
|
|
46205
|
+
if (opts.json) {
|
|
46206
|
+
console.log(JSON.stringify({
|
|
46207
|
+
updated: result.updated,
|
|
46208
|
+
upToDate: result.reason === "up-to-date",
|
|
46209
|
+
from: result.from ?? null,
|
|
46210
|
+
to: result.to ?? null,
|
|
46211
|
+
reason: result.updated || result.reason === "up-to-date" ? null : result.reason ?? null
|
|
46212
|
+
}));
|
|
46213
|
+
if (!result.updated && result.reason !== "up-to-date") process.exitCode = 1;
|
|
46214
|
+
return;
|
|
46215
|
+
}
|
|
45856
46216
|
console.log("");
|
|
45857
46217
|
if (result.updated) {
|
|
45858
46218
|
console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
|
|
@@ -49222,73 +49582,94 @@ async function revokeDeviceBestEffort() {
|
|
|
49222
49582
|
} catch {
|
|
49223
49583
|
}
|
|
49224
49584
|
}
|
|
49225
|
-
var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").action(async (opts) => {
|
|
49585
|
+
var uninstallCommand = new Command("uninstall").description("Uninstall Gipity").option("--yes", "Skip confirmation prompts").option("--json", "Output a structured result as JSON (requires --yes)").action(async (opts) => {
|
|
49226
49586
|
const autoYes = opts.yes || getAutoConfirm();
|
|
49587
|
+
if (opts.json && !autoYes) {
|
|
49588
|
+
console.error(error("uninstall --json needs --yes (there is no prompt in JSON mode)."));
|
|
49589
|
+
process.exit(1);
|
|
49590
|
+
}
|
|
49591
|
+
const say = (line) => {
|
|
49592
|
+
if (!opts.json) console.log(line);
|
|
49593
|
+
};
|
|
49227
49594
|
const gipityDir = join30(homedir20(), ".gipity");
|
|
49228
49595
|
const launcherBin = join30(gipityDir, "launcher", "bin", "gipity");
|
|
49229
49596
|
const installedViaLauncher = existsSync26(launcherBin);
|
|
49230
|
-
|
|
49231
|
-
|
|
49232
|
-
|
|
49233
|
-
|
|
49234
|
-
|
|
49235
|
-
|
|
49236
|
-
if (installedViaLauncher)
|
|
49237
|
-
|
|
49597
|
+
say(`${bold("Gipity uninstall")} - this will:`);
|
|
49598
|
+
say(`\u2022 Stop the running relay daemon (if any)`);
|
|
49599
|
+
say(`\u2022 Remove the OS autostart service (launchd / systemd / Task Scheduler)`);
|
|
49600
|
+
say(`\u2022 Revoke this device on the server (best-effort)`);
|
|
49601
|
+
say(`\u2022 Remove the Gipity Claude Code plugin enablement (all Gipity hooks)`);
|
|
49602
|
+
say(`\u2022 Delete ${gipityDir}/${installedViaLauncher ? dim(" (includes the gipity launcher binary itself)") : ""}`);
|
|
49603
|
+
if (installedViaLauncher) say(`\u2022 Remove the launcher PATH line from your shell startup files`);
|
|
49604
|
+
say("");
|
|
49238
49605
|
if (installedViaLauncher) {
|
|
49239
|
-
|
|
49606
|
+
say(`${dim("The `gipity` launcher lives under ~/.gipity, so this removes the binary too - no separate `npm uninstall` needed.")}`);
|
|
49240
49607
|
} else {
|
|
49241
|
-
|
|
49608
|
+
say(`${dim("It will NOT remove the `gipity` binary. Run `npm uninstall -g gipity` afterward if you want that too.")}`);
|
|
49242
49609
|
}
|
|
49243
|
-
|
|
49610
|
+
say("");
|
|
49244
49611
|
if (!autoYes) {
|
|
49245
49612
|
const ok = await confirm("Proceed?");
|
|
49246
49613
|
if (!ok) {
|
|
49247
|
-
|
|
49614
|
+
say(`${muted("Cancelled.")}`);
|
|
49248
49615
|
return;
|
|
49249
49616
|
}
|
|
49250
49617
|
}
|
|
49251
49618
|
await stopDaemon();
|
|
49252
|
-
|
|
49619
|
+
say(`${success("Daemon stopped.")}`);
|
|
49253
49620
|
const svc = removeServiceUnit();
|
|
49254
|
-
if (svc.ran && svc.ok)
|
|
49255
|
-
else if (svc.ran)
|
|
49256
|
-
else
|
|
49621
|
+
if (svc.ran && svc.ok) say(`${success("Autostart service removed.")} ${svc.note ? dim(`(${svc.note})`) : ""}`);
|
|
49622
|
+
else if (svc.ran) say(`${muted("Autostart service not installed or already gone.")}`);
|
|
49623
|
+
else say(`${muted(svc.note ?? "Autostart skipped.")}`);
|
|
49257
49624
|
await revokeDeviceBestEffort();
|
|
49258
|
-
|
|
49259
|
-
|
|
49625
|
+
say(`${success("Device revoked on server (or was already revoked).")}`);
|
|
49626
|
+
const agentNotes = [];
|
|
49260
49627
|
for (const agent of AGENT_ADAPTERS) {
|
|
49261
49628
|
const note = agent.setup?.uninstall();
|
|
49262
49629
|
if (note) {
|
|
49263
|
-
|
|
49264
|
-
|
|
49630
|
+
say(`${success(note)}`);
|
|
49631
|
+
agentNotes.push(note);
|
|
49265
49632
|
}
|
|
49266
49633
|
}
|
|
49267
|
-
if (!
|
|
49268
|
-
|
|
49634
|
+
if (!agentNotes.length) {
|
|
49635
|
+
say(`${muted("No Gipity entries in any detected coding agent.")}`);
|
|
49269
49636
|
}
|
|
49637
|
+
let gipityDirRemoved = false;
|
|
49270
49638
|
if (existsSync26(gipityDir)) {
|
|
49271
49639
|
try {
|
|
49272
49640
|
rmSync4(gipityDir, { recursive: true, force: true });
|
|
49273
|
-
|
|
49641
|
+
gipityDirRemoved = true;
|
|
49642
|
+
say(`${success(`Removed ${gipityDir}/`)}`);
|
|
49274
49643
|
} catch (err) {
|
|
49275
49644
|
console.error(`${error(`Could not remove ${gipityDir}: ${err?.message || err}`)}`);
|
|
49276
49645
|
}
|
|
49277
49646
|
} else {
|
|
49278
|
-
|
|
49647
|
+
say(`${muted(`${gipityDir}/ already gone.`)}`);
|
|
49279
49648
|
}
|
|
49280
49649
|
const touchedRc = removeInstallerPathLines();
|
|
49650
|
+
if (opts.json) {
|
|
49651
|
+
console.log(JSON.stringify({
|
|
49652
|
+
success: true,
|
|
49653
|
+
autostartService: svc.ran ? svc.ok ? "removed" : "not_installed" : "skipped",
|
|
49654
|
+
agentIntegrationsRemoved: agentNotes,
|
|
49655
|
+
gipityDir,
|
|
49656
|
+
gipityDirRemoved,
|
|
49657
|
+
shellRcFilesUpdated: touchedRc,
|
|
49658
|
+
binaryRemoved: installedViaLauncher
|
|
49659
|
+
}));
|
|
49660
|
+
return;
|
|
49661
|
+
}
|
|
49281
49662
|
if (touchedRc.length) {
|
|
49282
|
-
|
|
49663
|
+
say(`${success("Removed the launcher PATH line from")} ${dim(touchedRc.map(tildify2).join(", "))}`);
|
|
49283
49664
|
}
|
|
49284
|
-
|
|
49285
|
-
|
|
49665
|
+
say("");
|
|
49666
|
+
say(`${success("Uninstall complete.")}`);
|
|
49286
49667
|
if (installedViaLauncher) {
|
|
49287
|
-
|
|
49668
|
+
say(`${dim("The launcher binary was under ~/.gipity and is now gone - nothing left to remove.")}`);
|
|
49288
49669
|
} else {
|
|
49289
|
-
|
|
49670
|
+
say(`${dim("Run")} ${brand("npm uninstall -g gipity")} ${dim("to remove the `gipity` binary too.")}`);
|
|
49290
49671
|
}
|
|
49291
|
-
|
|
49672
|
+
say(`${dim("Open a new terminal - or run")} ${brand("hash -r")} ${dim("in this one - so your shell forgets the removed binary\u2019s path.")}`);
|
|
49292
49673
|
});
|
|
49293
49674
|
|
|
49294
49675
|
// src/commands/approval.ts
|
|
@@ -49924,7 +50305,7 @@ function configureHelp(cmd) {
|
|
|
49924
50305
|
var program2 = new Command();
|
|
49925
50306
|
program2.enablePositionalOptions();
|
|
49926
50307
|
var startGroup = [statusCommand, initCommand, skillCommand, projectCommand];
|
|
49927
|
-
var buildGroup = [addCommand, removeCommand, brandCommand, saveCommand, loadCommand, deployCommand, pageCommand, testCommand];
|
|
50308
|
+
var buildGroup = [addCommand, removeCommand, brandCommand, saveCommand, loadCommand, deployCommand, envCommand, pageCommand, testCommand];
|
|
49928
50309
|
var backendGroup = [dbCommand, fnCommand, secretsCommand, keyCommand, logsCommand, jobCommand, workflowCommand, approvalCommand, memoryCommand];
|
|
49929
50310
|
var servicesGroup = [serviceCommand, generateCommand, askCommand, notifyCommand, paymentsCommand, realtimeCommand, recordsCommand, rbacCommand, auditCommand, domainCommand, tokenCommand];
|
|
49930
50311
|
var filesGroup = [syncCommand, fileCommand, pushCommand, uploadCommand, storageCommand];
|
|
@@ -49965,13 +50346,46 @@ var SKILL_DOCS = {
|
|
|
49965
50346
|
};
|
|
49966
50347
|
program2.name("gipity").description(`${brand(bold("Gipity CLI"))} ${dim("-")} ${GIPITY_TAGLINE.replace(/\.$/, "")}
|
|
49967
50348
|
|
|
49968
|
-
${dim("Hosting, databases, deploys, workflows, code execution, and monitoring - one place, agent-tuned. Pair with Claude Code or use standalone.")}`).version(pkg.version, "-v, --version").addOption(new Option("--api-base <url>", "API base URL").hideHelp()).option("-y, --yes", "Skip confirmation prompts");
|
|
49969
|
-
|
|
50349
|
+
${dim("Hosting, databases, deploys, workflows, code execution, and monitoring - one place, agent-tuned. Pair with Claude Code or use standalone.")}`).version(pkg.version, "-v, --version").addOption(new Option("--api-base <url>", "API base URL").hideHelp()).option("-y, --yes", "Skip confirmation prompts").option("--env <name>", "Act on an app environment (dev, staging, ...) instead of prod");
|
|
50350
|
+
var SELF_ENV_COMMANDS = /* @__PURE__ */ new Set(["deploy", "env"]);
|
|
50351
|
+
program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
49970
50352
|
const globalOpts = program2.opts();
|
|
49971
50353
|
if (globalOpts.apiBase) setApiBaseOverride(globalOpts.apiBase);
|
|
50354
|
+
const envName = actionCommand.opts().env ?? globalOpts.env;
|
|
50355
|
+
setEnvOption(envName);
|
|
50356
|
+
let top = actionCommand;
|
|
50357
|
+
while (top.parent && top.parent !== program2) top = top.parent;
|
|
50358
|
+
if (envName && !SELF_ENV_COMMANDS.has(top.name())) await resolveEnvOverride(envName);
|
|
50359
|
+
refreshPrimersQuietly();
|
|
49972
50360
|
if (globalOpts.yes || actionCommand.opts().yes) setAutoConfirm(true);
|
|
49973
50361
|
rejectBlankIdArgs(actionCommand);
|
|
49974
50362
|
});
|
|
50363
|
+
function refreshPrimersQuietly() {
|
|
50364
|
+
const root = getProjectRoot();
|
|
50365
|
+
if (!root) return;
|
|
50366
|
+
try {
|
|
50367
|
+
refreshExistingPrimers(root);
|
|
50368
|
+
} catch (err) {
|
|
50369
|
+
console.error(`Could not refresh this project's Gipity docs block: ${err.message}`);
|
|
50370
|
+
}
|
|
50371
|
+
}
|
|
50372
|
+
async function resolveEnvOverride(name) {
|
|
50373
|
+
const config = getConfig();
|
|
50374
|
+
if (!config) {
|
|
50375
|
+
console.error("--env needs a Gipity project directory (run it where .gipity.json is).");
|
|
50376
|
+
process.exit(1);
|
|
50377
|
+
}
|
|
50378
|
+
const { get: get3 } = await Promise.resolve().then(() => (init_api(), api_exports));
|
|
50379
|
+
try {
|
|
50380
|
+
const res = await get3(
|
|
50381
|
+
`/projects/${config.projectGuid}/envs/${encodeURIComponent(name)}`
|
|
50382
|
+
);
|
|
50383
|
+
applyEnvOverride({ name, projectGuid: res.data.guid, projectSlug: res.data.slug });
|
|
50384
|
+
} catch (err) {
|
|
50385
|
+
console.error(err.message);
|
|
50386
|
+
process.exit(1);
|
|
50387
|
+
}
|
|
50388
|
+
}
|
|
49975
50389
|
var ID_ARG = /(guid|id)$/i;
|
|
49976
50390
|
function rejectBlankIdArgs(cmd) {
|
|
49977
50391
|
cmd.registeredArguments.forEach((arg, i) => {
|
|
@@ -50145,6 +50559,16 @@ function enableYesEverywhere(cmd) {
|
|
|
50145
50559
|
if (!hasYes) cmd.addOption(new Option("-y, --yes", "Skip confirmation prompts").hideHelp());
|
|
50146
50560
|
}
|
|
50147
50561
|
enableYesEverywhere(program2);
|
|
50562
|
+
function enableEnvEverywhere(cmd) {
|
|
50563
|
+
if (cmd.commands.length > 0) {
|
|
50564
|
+
for (const sub of cmd.commands) enableEnvEverywhere(sub);
|
|
50565
|
+
return;
|
|
50566
|
+
}
|
|
50567
|
+
if (!cmd.options.some((o) => o.long === "--env")) {
|
|
50568
|
+
cmd.addOption(new Option("--env <name>", "Act on an app environment (dev, staging, ...) instead of prod").hideHelp());
|
|
50569
|
+
}
|
|
50570
|
+
}
|
|
50571
|
+
enableEnvEverywhere(program2);
|
|
50148
50572
|
{
|
|
50149
50573
|
const target = resolveTarget(process.argv, program2);
|
|
50150
50574
|
const helpAsked = process.argv.slice(2).some((a) => a === "--help" || a === "-h");
|