@cargo-ai/cli 1.0.21 → 1.0.23

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.
@@ -1,4 +1,4 @@
1
- import { promises as fs } from "node:fs";
1
+ import { existsSync, promises as fs } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -166,25 +166,32 @@ const TEMPLATE_DESCRIPTIONS = {
166
166
  };
167
167
  const findTemplatesRoot = () => {
168
168
  // The CLI is published as `@cargo-ai/cli`. Templates live in
169
- // `@cargo-ai/app-sdk/templates`. Resolve via require so we work whether the
170
- // user installed both packages globally or both came from the monorepo.
169
+ // `@cargo-ai/app-sdk/templates`. The package only exports its main entry (no
170
+ // `./package.json` subpath), so resolve the entry and walk up to the package
171
+ // root that contains `templates/`. This works whether both packages were
172
+ // installed globally or both came from the monorepo.
171
173
  try {
172
- const appSdkPackageJson = require.resolve("@cargo-ai/app-sdk/package.json");
173
- return path.join(path.dirname(appSdkPackageJson), "templates");
174
- }
175
- catch {
176
- const here = fileURLToPath(import.meta.url);
177
- let cursor = path.dirname(here);
174
+ const entry = require.resolve("@cargo-ai/app-sdk");
175
+ let cursor = path.dirname(entry);
178
176
  for (let i = 0; i < 6; i += 1) {
179
- const candidate = path.join(cursor, "packages/app-sdk/templates");
180
- try {
181
- require("node:fs").accessSync(candidate);
177
+ const candidate = path.join(cursor, "templates");
178
+ if (existsSync(candidate)) {
182
179
  return candidate;
183
180
  }
184
- catch {
185
- cursor = path.dirname(cursor);
186
- }
181
+ cursor = path.dirname(cursor);
182
+ }
183
+ }
184
+ catch {
185
+ // Fall through to the monorepo-relative lookup below.
186
+ }
187
+ const here = fileURLToPath(import.meta.url);
188
+ let cursor = path.dirname(here);
189
+ for (let i = 0; i < 6; i += 1) {
190
+ const candidate = path.join(cursor, "packages/app-sdk/templates");
191
+ if (existsSync(candidate)) {
192
+ return candidate;
187
193
  }
188
- throw new Error("Could not locate @cargo-ai/app-sdk templates. Make sure @cargo-ai/app-sdk is installed alongside @cargo-ai/cli.");
194
+ cursor = path.dirname(cursor);
189
195
  }
196
+ throw new Error("Could not locate @cargo-ai/app-sdk templates. Make sure @cargo-ai/app-sdk is installed alongside @cargo-ai/cli.");
190
197
  };
@@ -1,4 +1,4 @@
1
- import { promises as fs } from "node:fs";
1
+ import { existsSync, promises as fs } from "node:fs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -149,26 +149,32 @@ const WORKER_TEMPLATE_DESCRIPTIONS = {
149
149
  "custom-integration": "Cargo Custom Integration worker built on @cargo-ai/worker-sdk — manifest / actions / extractors / autocompletes / dynamic schemas with automatic /openapi.json.",
150
150
  };
151
151
  const findWorkerTemplatesRoot = () => {
152
- // Worker templates live in `@cargo-ai/worker-sdk/templates`. Resolve via
153
- // require so we work whether the user installed both packages globally or
154
- // both came from the monorepo.
152
+ // Worker templates live in `@cargo-ai/worker-sdk/templates`. The package only
153
+ // exports its main entry (no `./package.json` subpath), so resolve the entry
154
+ // and walk up to the package root that contains `templates/`. This works
155
+ // whether both packages were installed globally or came from the monorepo.
155
156
  try {
156
- const workerSdkPackageJson = require.resolve("@cargo-ai/worker-sdk/package.json");
157
- return path.join(path.dirname(workerSdkPackageJson), "templates");
158
- }
159
- catch {
160
- const here = fileURLToPath(import.meta.url);
161
- let cursor = path.dirname(here);
157
+ const entry = require.resolve("@cargo-ai/worker-sdk");
158
+ let cursor = path.dirname(entry);
162
159
  for (let i = 0; i < 6; i += 1) {
163
- const candidate = path.join(cursor, "packages/worker-sdk/templates");
164
- try {
165
- require("node:fs").accessSync(candidate);
160
+ const candidate = path.join(cursor, "templates");
161
+ if (existsSync(candidate)) {
166
162
  return candidate;
167
163
  }
168
- catch {
169
- cursor = path.dirname(cursor);
170
- }
164
+ cursor = path.dirname(cursor);
165
+ }
166
+ }
167
+ catch {
168
+ // Fall through to the monorepo-relative lookup below.
169
+ }
170
+ const here = fileURLToPath(import.meta.url);
171
+ let cursor = path.dirname(here);
172
+ for (let i = 0; i < 6; i += 1) {
173
+ const candidate = path.join(cursor, "packages/worker-sdk/templates");
174
+ if (existsSync(candidate)) {
175
+ return candidate;
171
176
  }
172
- throw new Error("Could not locate @cargo-ai/worker-sdk templates. Make sure @cargo-ai/worker-sdk is installed alongside @cargo-ai/cli.");
177
+ cursor = path.dirname(cursor);
173
178
  }
179
+ throw new Error("Could not locate @cargo-ai/worker-sdk templates. Make sure @cargo-ai/worker-sdk is installed alongside @cargo-ai/cli.");
174
180
  };
@@ -171,7 +171,7 @@ function describeApiError(status, body) {
171
171
  }
172
172
  if (status !== undefined && status >= 500) {
173
173
  return {
174
- message: `Server error (${String(status)})${detailSuffix}. Retry shortly or check status.cargo.io.`,
174
+ message: `Server error (${String(status)})${detailSuffix}. Retry shortly or check status.getcargo.io.`,
175
175
  code: ExitCodes.GenericError,
176
176
  };
177
177
  }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cargo-ai/cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "private": false,
5
+ "license": "UNLICENSED",
5
6
  "description": "Command-line interface for the Cargo API",
6
7
  "engines": {
7
8
  "node": ">=22"
@@ -28,8 +29,8 @@
28
29
  "format:check": "prettier --check ."
29
30
  },
30
31
  "dependencies": {
31
- "@cargo-ai/api": "^1.0.27",
32
- "@cargo-ai/app-sdk": "^1.0.0",
32
+ "@cargo-ai/api": "^1.0.28",
33
+ "@cargo-ai/app-sdk": "^1.0.2",
33
34
  "@cargo-ai/worker-sdk": "^1.0.2",
34
35
  "commander": "^12.1.0",
35
36
  "tsx": "^4.19.2"