@flowrunner/cli 0.1.19-dev.2 → 0.1.19-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/ai-docs/instructions/service-code-format/02-zod-types.md +6 -5
  2. package/ai-docs/instructions/service-code-format/17-client-certificates.md +4 -5
  3. package/dist/cli.js +96 -79
  4. package/dist/cli.js.map +3 -3
  5. package/dist/index.js +111 -91
  6. package/dist/index.js.map +3 -3
  7. package/dist/types/packages/cli/src/constants/testing.d.ts +13 -6
  8. package/dist/types/shared/src/constants/error-codes.d.ts +14 -0
  9. package/dist/types/shared/src/constants/flow-catalog.d.ts +54 -0
  10. package/dist/types/shared/src/constants/index.d.ts +1 -0
  11. package/dist/types/shared/src/errors/flow-catalog.d.ts +37 -0
  12. package/dist/types/shared/src/errors/index.d.ts +1 -0
  13. package/dist/types/shared/src/scheme/flow-catalog/analysis.d.ts +190 -0
  14. package/dist/types/shared/src/scheme/flow-catalog/index.d.ts +6 -0
  15. package/dist/types/shared/src/scheme/flow-catalog/pack.d.ts +144 -0
  16. package/dist/types/shared/src/scheme/flow-catalog/requests.d.ts +664 -0
  17. package/dist/types/shared/src/scheme/flow-catalog/summary.d.ts +69 -0
  18. package/dist/types/shared/src/scheme/flow-catalog/version.d.ts +132 -0
  19. package/dist/types/shared/src/scheme/flowrunner/java.dto.d.ts +76 -0
  20. package/dist/types/shared/src/scheme/index.d.ts +1 -0
  21. package/dist/types/shared/src/scheme/knowledge-base/dto.d.ts +12 -12
  22. package/dist/types/shared/src/scheme/properties/index.d.ts +1 -0
  23. package/dist/types/shared/src/scheme/properties/secret.d.ts +12 -0
  24. package/dist/types/shared/src/scheme/remote-mcp-server/dto.d.ts +0 -11
  25. package/dist/types/shared/src/scheme/shared-extensions/config.d.ts +20 -2
  26. package/dist/types/shared/src/scheme/shared-extensions/rest.d.ts +1 -0
  27. package/dist/types/shared/src/scheme/shared-extensions/usage-stats.d.ts +6 -6
  28. package/package.json +1 -4
  29. package/project-files/sandbox/nock-mock.js +61 -5
@@ -19,7 +19,7 @@ and behaviors.
19
19
  | `z.union([...])` | the **first** branch's widget — see below | | | | |
20
20
  | `z.filesUploadOptions([...])`, `z.filesListOptions([...])`, `z.filesGetOptions([...])`, `z.filesDeleteOptions([...])` | nested form — the platform's own file-storage options, one group per Files call (see [03-parameters.md](03-parameters.md)) | | | | |
21
21
  | | | | `.required()` | `z.unknown()` / `z.any()` field | required, any value — the open types are the only ones optional by default (see [Any value, but required](#any-value-but-required)) |
22
- | | | | `.secret()` | `z.string()` config field | Masks the input, with a reveal toggle. **Display only** — see below |
22
+ | | | | `.secret()` | `z.string()` config field | Masks the input, with a reveal toggle; once saved the value is write-only in the console — see below |
23
23
  | | | | `.dynamicProps({ dependsOn, execute })` | top-level **action** param: `z.looseObject()` or `z.array(z.looseObject())` | the object's inner fields are loaded at design time from other params (see [03-parameters.md](03-parameters.md)) |
24
24
 
25
25
  Notes:
@@ -37,10 +37,11 @@ Notes:
37
37
  installed as a *custom* extension has no shared tier at all — the customer fills in every item in one
38
38
  dialog. See `configItems` in [01-service-structure.md](01-service-structure.md) and the output mapping in
39
39
  [11-output-model.md](11-output-model.md).
40
- - `.secret()` marks a **`z.string()` config field** as sensitive: the console renders it masked, with a
41
- toggle to reveal it. It is **display only** — the value is stored, sent and validated exactly as it would
42
- be without it, so it hides a credential from someone looking over a shoulder rather than protecting it.
43
- It has no effect anywhere else: not on `z.text()`, which has no password mode, and not on an action or
40
+ - `.secret()` marks a **`z.string()` config field** as sensitive: the console renders it masked while it is
41
+ typed, with a toggle to reveal it. Once saved, the value is **write-only** in the console: it shows a hint
42
+ (the last characters) with **Replace** and **Clear** buttons and is never shown again, and the platform may
43
+ store it encrypted. Your handler still receives the plain value in `config`, validated exactly as it would
44
+ be without `.secret()`. It has no effect anywhere else: not on `z.text()`, which has no password mode, and not on an action or
44
45
  trigger param, whose value lives in the flow definition and is readable through the API — masking that
45
46
  input would suggest a protection that is not there. Put credentials in a `z.string()` config item.
46
47
  - `.dictionary(ref)` binds a param to a dictionary for dynamic options and auto-derives its `dependsOn` — the
@@ -62,8 +62,8 @@ See [01-service-structure.md](01-service-structure.md) for `configItems` and `in
62
62
 
63
63
  **`z.text()`, because a PEM block is multi-line** — it draws a textarea, where `z.string()` would put a
64
64
  27-line certificate through a one-line box. The cost is that the key is on screen in clear text:
65
- `.secret()` masks a `z.string()` config field only and is a no-op on `z.text()`
66
- ([02-zod-types.md](02-zod-types.md)). If that matters more than the textarea, ship the key as a file in the
65
+ `.secret()` (masked input, write-only once saved) applies to a `z.string()` config field only and is a no-op on
66
+ `z.text()` ([02-zod-types.md](02-zod-types.md)). If that matters more than the textarea, ship the key as a file in the
67
67
  service folder instead — the whole folder is deployed, so `require('fs').readFileSync(path.join(__dirname,
68
68
  '../certs/client.key'))` reads it in the pod.
69
69
 
@@ -74,9 +74,8 @@ service folder instead — the whole folder is deployed, so `require('fs').readF
74
74
  - **`ca` replaces the default trust store** for that request, the way `curl --cacert` does. Pass the whole
75
75
  chain needed to verify the server, not just the leaf.
76
76
  - **The private key is credential material.** Never inline it in the source and never put it in a URL —
77
- declare it as a config field or read it from a file in the service folder. Whichever way, the value is
78
- stored and transmitted in clear text; masking a config field with `.secret()` hides it from a passer-by,
79
- it does not protect it. The client keeps the key out of verbose output and off the request's enumerable
77
+ declare it as a config field or read it from a file in the service folder. Whichever way, a value that is not a `.secret()` config field is
78
+ stored and transmitted in clear text, and a `z.text()` field cannot be `.secret()`. The client keeps the key out of verbose output and off the request's enumerable
80
79
  properties, so `console.log(request)` and `JSON.stringify(request)` will not leak it — but your own logging
81
80
  still can, so redact there too ([04-http-requests.md](04-http-requests.md)).
82
81
 
package/dist/cli.js CHANGED
@@ -10048,7 +10048,7 @@ var require_form_data = __commonJS({
10048
10048
  var http2 = require("http");
10049
10049
  var https = require("https");
10050
10050
  var parseUrl = require("url").parse;
10051
- var fs19 = require("fs");
10051
+ var fs20 = require("fs");
10052
10052
  var crypto3 = require("crypto");
10053
10053
  var mime = require_mime_types();
10054
10054
  var asynckit = require_asynckit();
@@ -10118,7 +10118,7 @@ var require_form_data = __commonJS({
10118
10118
  if (value.end != null && value.end !== Infinity && value.start != null) {
10119
10119
  callback(null, value.end + 1 - (value.start ? value.start : 0));
10120
10120
  } else {
10121
- fs19.stat(value.path, function(err, stat) {
10121
+ fs20.stat(value.path, function(err, stat) {
10122
10122
  var fileSize;
10123
10123
  if (err) {
10124
10124
  callback(err);
@@ -12318,7 +12318,7 @@ var require_utils2 = __commonJS({
12318
12318
  var require_fattr = __commonJS({
12319
12319
  "node_modules/adm-zip/util/fattr.js"(exports2, module2) {
12320
12320
  var pth = require("path");
12321
- module2.exports = function(path22, { fs: fs19 }) {
12321
+ module2.exports = function(path22, { fs: fs20 }) {
12322
12322
  var _path = path22 || "", _obj = newAttr(), _stat = null;
12323
12323
  function newAttr() {
12324
12324
  return {
@@ -12330,8 +12330,8 @@ var require_fattr = __commonJS({
12330
12330
  atime: 0
12331
12331
  };
12332
12332
  }
12333
- if (_path && fs19.existsSync(_path)) {
12334
- _stat = fs19.statSync(_path);
12333
+ if (_path && fs20.existsSync(_path)) {
12334
+ _stat = fs20.statSync(_path);
12335
12335
  _obj.directory = _stat.isDirectory();
12336
12336
  _obj.mtime = _stat.mtime;
12337
12337
  _obj.atime = _stat.atime;
@@ -14508,7 +14508,7 @@ var require_package = __commonJS({
14508
14508
  "package.json"(exports2, module2) {
14509
14509
  module2.exports = {
14510
14510
  name: "@flowrunner/cli",
14511
- version: "0.1.19-dev.2",
14511
+ version: "0.1.19-dev.3",
14512
14512
  publishConfig: {
14513
14513
  access: "public"
14514
14514
  },
@@ -14543,7 +14543,6 @@ var require_package = __commonJS({
14543
14543
  dependencies: {
14544
14544
  "@types/node": "^20.0.0",
14545
14545
  "adm-zip": "^0.6.1",
14546
- archiver: "^7.0.0",
14547
14546
  commander: "^12.0.0",
14548
14547
  zod: "^4.6.2"
14549
14548
  },
@@ -14551,10 +14550,8 @@ var require_package = __commonJS({
14551
14550
  "@asteasolutions/zod-to-openapi": "^8.4.0",
14552
14551
  "@flowrunner/flow-extension-runner": "*",
14553
14552
  "@types/adm-zip": "^0.5.7",
14554
- "@types/archiver": "^6.0.0",
14555
14553
  esbuild: "^0.28.2",
14556
14554
  nock: "^14.0.17",
14557
- "query-string": "^7.1.3",
14558
14555
  "tsconfig-paths": "^4.2.0",
14559
14556
  tsx: "^4.0.0",
14560
14557
  typescript: "^5.4.0"
@@ -14624,8 +14621,10 @@ var TESTING_FILES = [
14624
14621
  ];
14625
14622
  var TEST_DEV_DEPENDENCIES = {
14626
14623
  jest: "^30.0.0",
14627
- nock: "^14.0.0",
14628
- "query-string": "^7.1.3"
14624
+ nock: "^14.0.0"
14625
+ };
14626
+ var TEST_OVERRIDES = {
14627
+ glob: "^13.0.7"
14629
14628
  };
14630
14629
  var TEST_SCRIPTS = {
14631
14630
  test: "jest",
@@ -15502,7 +15501,7 @@ async function downloadRemoteService(credentials, serviceId) {
15502
15501
  }
15503
15502
 
15504
15503
  // src/operations/deploy/index.ts
15505
- var import_fs11 = __toESM(require("fs"));
15504
+ var import_fs12 = __toESM(require("fs"));
15506
15505
  var import_path16 = __toESM(require("path"));
15507
15506
 
15508
15507
  // src/operations/deploy/discover-services.ts
@@ -20272,19 +20271,31 @@ function selectServices(available, selection = {}) {
20272
20271
  }
20273
20272
 
20274
20273
  // src/operations/deploy/zip.ts
20275
- var import_archiver = __toESM(require("archiver"));
20274
+ var import_adm_zip = __toESM(require_adm_zip());
20275
+ var import_fs11 = __toESM(require("fs"));
20276
20276
  var import_path15 = __toESM(require("path"));
20277
+ var S_IFLNK = 40960;
20277
20278
  async function createServiceZip(definition, projectRoot, serviceId) {
20278
- return new Promise((resolve, reject) => {
20279
- const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
20280
- const chunks = [];
20281
- archive.on("data", (chunk) => chunks.push(chunk));
20282
- archive.on("end", () => resolve(Buffer.concat(chunks)));
20283
- archive.on("error", reject);
20284
- archive.directory(`${import_path15.default.resolve(projectRoot, "services", serviceId)}/`, "package");
20285
- archive.append(JSON.stringify(definition, null, 2), { name: "definition.json" });
20286
- archive.finalize();
20287
- });
20279
+ const zip = new import_adm_zip.default();
20280
+ addDirectory(zip, import_path15.default.resolve(projectRoot, "services", serviceId), "package");
20281
+ zip.addFile("definition.json", Buffer.from(JSON.stringify(definition, null, 2)));
20282
+ return zip.toBuffer();
20283
+ }
20284
+ function addDirectory(zip, dir, zipDir) {
20285
+ for (const name of import_fs11.default.readdirSync(dir)) {
20286
+ const fullPath = import_path15.default.join(dir, name);
20287
+ const zipPath = `${zipDir}/${name}`;
20288
+ const stats = import_fs11.default.lstatSync(fullPath);
20289
+ if (stats.isDirectory()) {
20290
+ zip.addFile(`${zipPath}/`, Buffer.alloc(0), "", stats);
20291
+ addDirectory(zip, fullPath, zipPath);
20292
+ } else if (stats.isSymbolicLink()) {
20293
+ const entry = zip.addFile(zipPath, Buffer.from(import_fs11.default.readlinkSync(fullPath)), "", stats);
20294
+ entry.attr = (S_IFLNK | stats.mode & 4095) << 16 >>> 0;
20295
+ } else if (stats.isFile()) {
20296
+ zip.addFile(zipPath, import_fs11.default.readFileSync(fullPath), "", stats);
20297
+ }
20298
+ }
20288
20299
  }
20289
20300
 
20290
20301
  // src/operations/deploy/index.ts
@@ -20314,7 +20325,7 @@ async function deploy(options = {}) {
20314
20325
  const { serverUrl, workspaceId, workspaceName, deployToken } = await resolveAuth(projectRoot, options.onAuthRequired);
20315
20326
  const credentials = { serverUrl, workspaceId, deployToken };
20316
20327
  const workspace = { workspaceId, workspaceName };
20317
- if (!import_fs11.default.existsSync(import_path16.default.resolve(projectRoot, "services"))) {
20328
+ if (!import_fs12.default.existsSync(import_path16.default.resolve(projectRoot, "services"))) {
20318
20329
  throw new NoServicesDirectoryError();
20319
20330
  }
20320
20331
  emit({ type: "connecting", serverUrl, workspace });
@@ -21260,11 +21271,11 @@ var import_path21 = __toESM(require("path"));
21260
21271
 
21261
21272
  // src/operations/init/index.ts
21262
21273
  var import_child_process = require("child_process");
21263
- var import_fs13 = __toESM(require("fs"));
21274
+ var import_fs14 = __toESM(require("fs"));
21264
21275
  var import_path19 = __toESM(require("path"));
21265
21276
 
21266
21277
  // src/operations/init/testing.ts
21267
- var import_fs12 = __toESM(require("fs"));
21278
+ var import_fs13 = __toESM(require("fs"));
21268
21279
  var import_path18 = __toESM(require("path"));
21269
21280
  function testingFilesDirectory() {
21270
21281
  return import_path18.default.join(packageRoot(), PROJECT_FILES_DIRECTORY);
@@ -21275,13 +21286,13 @@ function writeTestingFiles(projectRoot) {
21275
21286
  const skipped = [];
21276
21287
  for (const file of TESTING_FILES) {
21277
21288
  const target = import_path18.default.join(projectRoot, file);
21278
- if (import_fs12.default.existsSync(target)) {
21289
+ if (import_fs13.default.existsSync(target)) {
21279
21290
  skipped.push(file);
21280
21291
  continue;
21281
21292
  }
21282
- const contents = import_fs12.default.readFileSync(import_path18.default.join(source, file));
21283
- import_fs12.default.mkdirSync(import_path18.default.dirname(target), { recursive: true });
21284
- import_fs12.default.writeFileSync(target, contents);
21293
+ const contents = import_fs13.default.readFileSync(import_path18.default.join(source, file));
21294
+ import_fs13.default.mkdirSync(import_path18.default.dirname(target), { recursive: true });
21295
+ import_fs13.default.writeFileSync(target, contents);
21285
21296
  created.push(file);
21286
21297
  }
21287
21298
  return { created, skipped };
@@ -21292,7 +21303,7 @@ var GITIGNORE_ENTRIES = ["node_modules/", `${TOKEN_DIR}/`, ...TEST_GITIGNORE_ENT
21292
21303
  var CLI_PACKAGE = "@flowrunner/cli";
21293
21304
  var CLI_PACKAGE_NAMES = [CLI_PACKAGE, "flowrunner-cli"];
21294
21305
  function cliVersion() {
21295
- return JSON.parse(import_fs13.default.readFileSync(import_path19.default.join(packageRoot(), "package.json"), "utf-8")).version;
21306
+ return JSON.parse(import_fs14.default.readFileSync(import_path19.default.join(packageRoot(), "package.json"), "utf-8")).version;
21296
21307
  }
21297
21308
  function packageNameFrom(directory) {
21298
21309
  const name = import_path19.default.basename(import_path19.default.resolve(directory)).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+|[-._]+$/g, "");
@@ -21313,46 +21324,52 @@ function writePackageJson(projectRoot, tests) {
21313
21324
  const version2 = cliVersion();
21314
21325
  const devDependencies = { [CLI_PACKAGE]: version2, ...tests ? TEST_DEV_DEPENDENCIES : {} };
21315
21326
  const scripts = { deploy: "flowrunner deploy --all", ...tests ? TEST_SCRIPTS : {} };
21316
- if (!import_fs13.default.existsSync(fullPath)) {
21327
+ const overrides = tests ? TEST_OVERRIDES : {};
21328
+ if (!import_fs14.default.existsSync(fullPath)) {
21317
21329
  const manifest2 = {
21318
21330
  name: packageNameFrom(projectRoot),
21319
21331
  version: "0.0.1",
21320
21332
  private: true,
21321
21333
  description: "FlowRunner custom extensions.",
21322
21334
  scripts,
21323
- devDependencies
21335
+ devDependencies,
21336
+ ...tests ? { overrides } : {}
21324
21337
  };
21325
- import_fs13.default.writeFileSync(fullPath, JSON.stringify(manifest2, null, 2) + "\n", "utf-8");
21338
+ import_fs14.default.writeFileSync(fullPath, JSON.stringify(manifest2, null, 2) + "\n", "utf-8");
21326
21339
  return "created";
21327
21340
  }
21328
- const manifest = JSON.parse(import_fs13.default.readFileSync(fullPath, "utf-8"));
21341
+ const manifest = JSON.parse(import_fs14.default.readFileSync(fullPath, "utf-8"));
21329
21342
  const alreadyDeclared = CLI_PACKAGE_NAMES.some((name) => manifest.dependencies?.[name] || manifest.devDependencies?.[name]);
21330
21343
  const additions = alreadyDeclared ? Object.fromEntries(Object.entries(devDependencies).filter(([name]) => name !== CLI_PACKAGE)) : devDependencies;
21331
21344
  manifest.devDependencies ??= {};
21332
21345
  manifest.scripts ??= {};
21346
+ if (tests) {
21347
+ manifest.overrides ??= {};
21348
+ }
21333
21349
  const changed = [
21334
21350
  addMissing(manifest.devDependencies, additions),
21335
- addMissing(manifest.scripts, tests ? TEST_SCRIPTS : {}, PLACEHOLDER_SCRIPTS)
21351
+ addMissing(manifest.scripts, tests ? TEST_SCRIPTS : {}, PLACEHOLDER_SCRIPTS),
21352
+ tests && addMissing(manifest.overrides, overrides)
21336
21353
  ].some(Boolean);
21337
21354
  if (!changed) {
21338
21355
  return "skipped";
21339
21356
  }
21340
- import_fs13.default.writeFileSync(fullPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
21357
+ import_fs14.default.writeFileSync(fullPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
21341
21358
  return "updated";
21342
21359
  }
21343
21360
  function writeGitignore(projectRoot) {
21344
21361
  const fullPath = import_path19.default.join(projectRoot, ".gitignore");
21345
- if (!import_fs13.default.existsSync(fullPath)) {
21346
- import_fs13.default.writeFileSync(fullPath, GITIGNORE_ENTRIES.join("\n") + "\n", "utf-8");
21362
+ if (!import_fs14.default.existsSync(fullPath)) {
21363
+ import_fs14.default.writeFileSync(fullPath, GITIGNORE_ENTRIES.join("\n") + "\n", "utf-8");
21347
21364
  return "created";
21348
21365
  }
21349
- const content = import_fs13.default.readFileSync(fullPath, "utf-8");
21366
+ const content = import_fs14.default.readFileSync(fullPath, "utf-8");
21350
21367
  const lines = content.split("\n").map((line) => line.trim());
21351
21368
  const missing = GITIGNORE_ENTRIES.filter((entry) => !lines.includes(entry) && !lines.includes(entry.replace(/\/$/, "")));
21352
21369
  if (missing.length === 0) {
21353
21370
  return "skipped";
21354
21371
  }
21355
- import_fs13.default.appendFileSync(fullPath, `${content.endsWith("\n") ? "" : "\n"}${missing.join("\n")}
21372
+ import_fs14.default.appendFileSync(fullPath, `${content.endsWith("\n") ? "" : "\n"}${missing.join("\n")}
21356
21373
  `);
21357
21374
  return "updated";
21358
21375
  }
@@ -21401,10 +21418,10 @@ The authoring reference the CLI ships lives in
21401
21418
  `;
21402
21419
  function writeReadme(projectRoot) {
21403
21420
  const fullPath = import_path19.default.join(projectRoot, "README.md");
21404
- if (import_fs13.default.existsSync(fullPath)) {
21421
+ if (import_fs14.default.existsSync(fullPath)) {
21405
21422
  return "skipped";
21406
21423
  }
21407
- import_fs13.default.writeFileSync(fullPath, README(packageNameFrom(projectRoot)), "utf-8");
21424
+ import_fs14.default.writeFileSync(fullPath, README(packageNameFrom(projectRoot)), "utf-8");
21408
21425
  return "created";
21409
21426
  }
21410
21427
  var JSCONFIG = {
@@ -21417,10 +21434,10 @@ var JSCONFIG = {
21417
21434
  };
21418
21435
  function writeJsconfig(projectRoot) {
21419
21436
  const fullPath = import_path19.default.join(projectRoot, "jsconfig.json");
21420
- if (import_fs13.default.existsSync(fullPath)) {
21437
+ if (import_fs14.default.existsSync(fullPath)) {
21421
21438
  return "skipped";
21422
21439
  }
21423
- import_fs13.default.writeFileSync(fullPath, JSON.stringify(JSCONFIG, null, 2) + "\n", "utf-8");
21440
+ import_fs14.default.writeFileSync(fullPath, JSON.stringify(JSCONFIG, null, 2) + "\n", "utf-8");
21424
21441
  return "created";
21425
21442
  }
21426
21443
  function git(projectRoot, args) {
@@ -21471,13 +21488,13 @@ function npmInstall(projectRoot, warn) {
21471
21488
  }
21472
21489
  }
21473
21490
  function describeTarget(projectRoot) {
21474
- if (!import_fs13.default.existsSync(projectRoot)) {
21491
+ if (!import_fs14.default.existsSync(projectRoot)) {
21475
21492
  return { projectRoot, lines: ["a new directory"], defaultYes: true };
21476
21493
  }
21477
- if (!import_fs13.default.statSync(projectRoot).isDirectory()) {
21494
+ if (!import_fs14.default.statSync(projectRoot).isDirectory()) {
21478
21495
  return { projectRoot, lines: ["not a directory"], defaultYes: false };
21479
21496
  }
21480
- const entries = import_fs13.default.readdirSync(projectRoot).filter((entry) => entry !== ".git");
21497
+ const entries = import_fs14.default.readdirSync(projectRoot).filter((entry) => entry !== ".git");
21481
21498
  if (entries.length === 0) {
21482
21499
  return { projectRoot, lines: ["an empty directory"], defaultYes: true };
21483
21500
  }
@@ -21521,10 +21538,10 @@ async function init(options = {}) {
21521
21538
  committed: false
21522
21539
  };
21523
21540
  }
21524
- if (!import_fs13.default.existsSync(projectRoot)) {
21525
- import_fs13.default.mkdirSync(projectRoot, { recursive: true });
21541
+ if (!import_fs14.default.existsSync(projectRoot)) {
21542
+ import_fs14.default.mkdirSync(projectRoot, { recursive: true });
21526
21543
  }
21527
- if (!import_fs13.default.statSync(projectRoot).isDirectory()) {
21544
+ if (!import_fs14.default.statSync(projectRoot).isDirectory()) {
21528
21545
  throw new PromptAbortedError(`${projectRoot} is not a directory.`);
21529
21546
  }
21530
21547
  const created = [];
@@ -21566,10 +21583,10 @@ async function init(options = {}) {
21566
21583
 
21567
21584
  // src/cli/offer-global-install.ts
21568
21585
  var import_child_process2 = require("child_process");
21569
- var import_fs14 = __toESM(require("fs"));
21586
+ var import_fs15 = __toESM(require("fs"));
21570
21587
  var import_path20 = __toESM(require("path"));
21571
21588
  function runningVersion() {
21572
- return JSON.parse(import_fs14.default.readFileSync(import_path20.default.join(packageRoot(), "package.json"), "utf-8")).version;
21589
+ return JSON.parse(import_fs15.default.readFileSync(import_path20.default.join(packageRoot(), "package.json"), "utf-8")).version;
21573
21590
  }
21574
21591
  async function offerGlobalInstall() {
21575
21592
  if (!process.stdin.isTTY || hasGlobalInstall()) {
@@ -21656,7 +21673,7 @@ async function initCommand(templateId, options = {}) {
21656
21673
  }
21657
21674
 
21658
21675
  // src/operations/init-claude/index.ts
21659
- var import_fs15 = __toESM(require("fs"));
21676
+ var import_fs16 = __toESM(require("fs"));
21660
21677
  var import_path22 = __toESM(require("path"));
21661
21678
 
21662
21679
  // src/operations/init-claude/segment.ts
@@ -21695,10 +21712,10 @@ function providerDirectory(provider = CLAUDE_PROVIDER) {
21695
21712
  return import_path22.default.join(packageRoot(), AI_PROVIDERS_DIRECTORY, provider);
21696
21713
  }
21697
21714
  function packedAgents(directory) {
21698
- if (!import_fs15.default.existsSync(directory)) {
21715
+ if (!import_fs16.default.existsSync(directory)) {
21699
21716
  return [];
21700
21717
  }
21701
- return import_fs15.default.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => entry.name).sort();
21718
+ return import_fs16.default.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => entry.name).sort();
21702
21719
  }
21703
21720
  function writeAgents(sourceDirectory, projectRoot, layout) {
21704
21721
  const directory = import_path22.default.join(projectRoot, layout.agentsDirectory);
@@ -21711,23 +21728,23 @@ function writeAgents(sourceDirectory, projectRoot, layout) {
21711
21728
  warnings.push(`The installed CLI ships no agent definitions in ${PROVIDER_AGENTS_DIRECTORY}/ \u2014 none were written.`);
21712
21729
  return { directory, created, updated, unchanged, warnings };
21713
21730
  }
21714
- import_fs15.default.mkdirSync(directory, { recursive: true });
21731
+ import_fs16.default.mkdirSync(directory, { recursive: true });
21715
21732
  for (const agent of agents) {
21716
- const contents = import_fs15.default.readFileSync(import_path22.default.join(sourceDirectory, agent), "utf-8");
21733
+ const contents = import_fs16.default.readFileSync(import_path22.default.join(sourceDirectory, agent), "utf-8");
21717
21734
  const target = import_path22.default.join(directory, agent);
21718
21735
  if (contents.length === 0) {
21719
21736
  warnings.push(`${agent} is empty in the installed CLI \u2014 written as an empty file.`);
21720
21737
  }
21721
- if (!import_fs15.default.existsSync(target)) {
21722
- import_fs15.default.writeFileSync(target, contents, "utf-8");
21738
+ if (!import_fs16.default.existsSync(target)) {
21739
+ import_fs16.default.writeFileSync(target, contents, "utf-8");
21723
21740
  created.push(agent);
21724
21741
  continue;
21725
21742
  }
21726
- if (import_fs15.default.readFileSync(target, "utf-8") === contents) {
21743
+ if (import_fs16.default.readFileSync(target, "utf-8") === contents) {
21727
21744
  unchanged.push(agent);
21728
21745
  continue;
21729
21746
  }
21730
- import_fs15.default.writeFileSync(target, contents, "utf-8");
21747
+ import_fs16.default.writeFileSync(target, contents, "utf-8");
21731
21748
  updated.push(agent);
21732
21749
  }
21733
21750
  return { directory, created, updated, unchanged, warnings };
@@ -21736,18 +21753,18 @@ function writeSegment(sourceDirectory, projectRoot, layout) {
21736
21753
  const file = import_path22.default.join(projectRoot, layout.instructionsFile);
21737
21754
  const source = import_path22.default.join(sourceDirectory, ORCHESTRATOR_SEGMENT_FILE);
21738
21755
  const warnings = [];
21739
- if (!import_fs15.default.existsSync(source)) {
21756
+ if (!import_fs16.default.existsSync(source)) {
21740
21757
  warnings.push(`The installed CLI ships no ${ORCHESTRATOR_SEGMENT_FILE} \u2014 ${layout.instructionsFile} was left alone.`);
21741
21758
  return { file, outcome: "unchanged", warnings };
21742
21759
  }
21743
- const segment = import_fs15.default.readFileSync(source, "utf-8");
21760
+ const segment = import_fs16.default.readFileSync(source, "utf-8");
21744
21761
  if (segment.trim().length === 0) {
21745
21762
  warnings.push(`${ORCHESTRATOR_SEGMENT_FILE} is empty in the installed CLI \u2014 the marked block is empty.`);
21746
21763
  }
21747
- const current = import_fs15.default.existsSync(file) ? import_fs15.default.readFileSync(file, "utf-8") : null;
21764
+ const current = import_fs16.default.existsSync(file) ? import_fs16.default.readFileSync(file, "utf-8") : null;
21748
21765
  const merged = mergeSegment(current, segment, layout.instructionsFile);
21749
21766
  if (merged.outcome !== "unchanged") {
21750
- import_fs15.default.writeFileSync(file, merged.contents, "utf-8");
21767
+ import_fs16.default.writeFileSync(file, merged.contents, "utf-8");
21751
21768
  }
21752
21769
  return { file, outcome: merged.outcome, warnings };
21753
21770
  }
@@ -21757,11 +21774,11 @@ async function initClaude(options = {}) {
21757
21774
  const warnAll = (messages) => messages.forEach((message) => emit({ type: "warning", message }));
21758
21775
  const layout = PROVIDERS[CLAUDE_PROVIDER];
21759
21776
  const sourceDirectory = providerDirectory(layout.id);
21760
- if (!import_fs15.default.existsSync(sourceDirectory)) {
21777
+ if (!import_fs16.default.existsSync(sourceDirectory)) {
21761
21778
  throw new AiDocsMissingError(import_path22.default.join(AI_PROVIDERS_DIRECTORY, CLAUDE_PROVIDER));
21762
21779
  }
21763
- if (!import_fs15.default.existsSync(projectRoot)) {
21764
- import_fs15.default.mkdirSync(projectRoot, { recursive: true });
21780
+ if (!import_fs16.default.existsSync(projectRoot)) {
21781
+ import_fs16.default.mkdirSync(projectRoot, { recursive: true });
21765
21782
  }
21766
21783
  const agents = writeAgents(import_path22.default.join(sourceDirectory, PROVIDER_AGENTS_DIRECTORY), projectRoot, layout);
21767
21784
  emit({
@@ -21836,12 +21853,12 @@ async function logoutCommand() {
21836
21853
  }
21837
21854
 
21838
21855
  // src/operations/pull/index.ts
21839
- var import_adm_zip = __toESM(require_adm_zip());
21840
- var import_fs17 = __toESM(require("fs"));
21856
+ var import_adm_zip2 = __toESM(require_adm_zip());
21857
+ var import_fs18 = __toESM(require("fs"));
21841
21858
  var import_path24 = __toESM(require("path"));
21842
21859
 
21843
21860
  // src/operations/pull/extract.ts
21844
- var import_fs16 = __toESM(require("fs"));
21861
+ var import_fs17 = __toESM(require("fs"));
21845
21862
  var import_path23 = __toESM(require("path"));
21846
21863
  var PACKAGE_PREFIX = "package/";
21847
21864
  var SAFE_SERVICE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -21865,8 +21882,8 @@ function extractService(archive, directory) {
21865
21882
  if (target !== directory && !target.startsWith(directory + import_path23.default.sep)) {
21866
21883
  continue;
21867
21884
  }
21868
- import_fs16.default.mkdirSync(import_path23.default.dirname(target), { recursive: true });
21869
- import_fs16.default.writeFileSync(target, entry.getData());
21885
+ import_fs17.default.mkdirSync(import_path23.default.dirname(target), { recursive: true });
21886
+ import_fs17.default.writeFileSync(target, entry.getData());
21870
21887
  written++;
21871
21888
  }
21872
21889
  return written;
@@ -21886,7 +21903,7 @@ function declaredDependencies(archive) {
21886
21903
 
21887
21904
  // src/operations/pull/index.ts
21888
21905
  async function localState(projectRoot, service) {
21889
- if (!import_fs17.default.existsSync(import_path24.default.resolve(projectRoot, "services", service.serviceId))) {
21906
+ if (!import_fs18.default.existsSync(import_path24.default.resolve(projectRoot, "services", service.serviceId))) {
21890
21907
  return "absent";
21891
21908
  }
21892
21909
  try {
@@ -21950,9 +21967,9 @@ async function pull(options = {}) {
21950
21967
  }
21951
21968
  const exists = state === "different";
21952
21969
  const zipBuffer = await guard(() => downloadRemoteService(credentials, service.serviceId));
21953
- const archive = new import_adm_zip.default(zipBuffer);
21970
+ const archive = new import_adm_zip2.default(zipBuffer);
21954
21971
  if (exists) {
21955
- import_fs17.default.rmSync(directory, { recursive: true, force: true });
21972
+ import_fs18.default.rmSync(directory, { recursive: true, force: true });
21956
21973
  }
21957
21974
  const files = extractService(archive, directory);
21958
21975
  const dependencies = declaredDependencies(archive);
@@ -22052,10 +22069,10 @@ async function pickServices2(available) {
22052
22069
  }
22053
22070
 
22054
22071
  // src/operations/use-server.ts
22055
- var import_fs18 = __toESM(require("fs"));
22072
+ var import_fs19 = __toESM(require("fs"));
22056
22073
  function useServer(target, options = {}) {
22057
22074
  const projectRoot = options.cwd ?? process.cwd();
22058
- if (!import_fs18.default.existsSync(configPath(projectRoot))) {
22075
+ if (!import_fs19.default.existsSync(configPath(projectRoot))) {
22059
22076
  throw new NotAProjectError();
22060
22077
  }
22061
22078
  const serverUrl = resolveServerTarget(target);