@backifydev/cli 0.3.15 → 0.3.17

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +74 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -317,7 +317,7 @@ You can start from an empty folder without a Git repository. `init` creates a mi
317
317
 
318
318
  See the [agent setup guide](https://agent.backify.dev/).
319
319
 
320
- Copy the application AI prompt in Backify to receive the application ID, organization ID, and an application-scoped, single-use pairing code; the agent guide supplies the connection and initialization commands. Codes expire after 15 minutes; redeemed sessions expire after seven days. Add `--clone` even when the current folder contains AI coding-tool scaffolding. Empty directories of any name are allowed. Hidden tool-metadata directories and files, Markdown instruction files, and default `work/` and `outputs/` directories may contain tool settings or artifacts. The CLI clones into a temporary directory, validates collisions, then merges without deleting or overwriting existing tool files. Existing Git metadata, root application source, and symlinked tool directories are rejected; file conflicts stop before repository files are installed. Credentials are stored in the user's home configuration, not the project. The default API is `https://api.backify.dev/api`; local development can override it with `BACKIFY_API_URL` or the connection command's `--api` option. HTTPS is required outside loopback.
320
+ Copy the application AI prompt in Backify to receive the application ID, organization ID, and an application-scoped, single-use pairing code; the agent guide supplies the connection and initialization commands. Codes expire after 15 minutes; redeemed sessions expire after seven days. Add `--clone` even when the current folder contains AI coding-tool scaffolding. Empty directories of any name are allowed. Hidden tool-metadata directories and files, Markdown instruction files, and default `work/` and `outputs/` directories may contain tool settings or artifacts. The CLI clones into a temporary directory, validates collisions, then merges without deleting or overwriting existing tool files. Existing Git metadata, root application source, and symlinked tool directories are rejected; file conflicts stop before repository files are installed. Credentials are stored in the user's home configuration, not the project. Running the setup prompt authorizes the CLI to save this application-scoped session with restricted filesystem permissions; no separate confirmation is needed solely for local credential storage. Prefer `connect --pair-stdin` and send the single-use code through the terminal tool's private stdin channel. Never embed it in shell commands, logs, environment variables, or temporary files. If private stdin is unavailable, omit pairing and use browser login. The legacy `--pair <code>` option remains compatible but exposes the code in process arguments. Actual sandbox restrictions still apply. The default API is `https://api.backify.dev/api`; local development can override it with `BACKIFY_API_URL` or the connection command's `--api` option. HTTPS is required outside loopback.
321
321
 
322
322
  `init` adds a persistent delivery guide linked from the existing agent instructions. For every user request associated with the application, including setup, questions, deployment, application work, and Backify platform troubleshooting, the agent sends only the user's own text through stdin to `backify prompt record --stdin --id <UUID> --type <build|deploy|fixing|other>`, optionally adding repeated `--filename <basename>` arguments. Reuse the UUID on retries. The command never reads attachments; their bodies, extracted text, full paths, and credentials must not be submitted. Setup/pairing requests are recorded with secrets replaced by [REDACTED], never excluded. The CLI and API redact recognized Backify session tokens and pairing codes; redact all other secrets before submission. History is displayed oldest-first under the application. This is an explicit agent workflow, not an automatic interceptor for every coding tool. Record the model, AI coding tool, and effective access for each request with --model, --ai-tool, and --access-level whenever known. Access is a short description of the tool’s actual filesystem, network, and approval permissions at the time of the request, not its Backify role. Use only exposed session information; never guess unknown values or inspect credentials to discover them. Omit unknown fields; older or incomplete records display “Not recorded”. These values are self-reported metadata, not verified authorization. Reuse the same metadata on retries. Model and tool names are limited to 200 characters each; access descriptions to 500. Never include secrets, tokens, full paths, or configuration file contents. Include the exposed model family and version, for example gpt-6-luna or gpt-6.1-sol, rather than only the tool name. Separate filesystem, network, and approval access descriptions with semicolons so each appears as a separate badge. The CLI automatically records the installed @backifydev/sdk version from the project or its hoisted node_modules, never the dependency range. Use --sdk-version to preserve the original installed version on retries or when auto-detection is unavailable; SDK versions are limited to 100 characters. Unknown SDK and model versions remain “Not recorded”; never guess them. Use build for application features and application bug fixes, deploy for shipping or launching, fixing only for Backify platform/SDK/CLI/connection/hosting troubleshooting (not application-code bugs), and other for setup, questions, or uncategorized requests. The API defaults new requests without a type to other; older untyped records remain visible as Not recorded. Record requests received before authentication in conversation order as soon as connected; never persist credentials to queue them. Types are classifications, not success/failure statuses.
323
323
 
package/dist/index.js CHANGED
@@ -35339,6 +35339,8 @@ function parseApplicationManifest(source) {
35339
35339
  throw new Error("Capabilities must be an explicit mapping");
35340
35340
  const capabilities = {};
35341
35341
  for (const [name2, settings] of Object.entries(value.capabilities)) {
35342
+ if (name2 === "audit")
35343
+ throw new Error("The audit capability was removed. Record application events with events.track and declare the events capability instead.");
35342
35344
  if (!Object.hasOwn(CAPABILITY_REGISTRY, name2))
35343
35345
  throw new Error("Unknown capability: " + name2);
35344
35346
  if (!object(settings))
@@ -35412,12 +35414,12 @@ function manifestDiagnostics(manifest, used, authentication) {
35412
35414
  // ../platform/dist/delivery.js
35413
35415
  var deliveryInstructions = `# Backify application delivery and prompt history
35414
35416
 
35415
- Instruction version: 10
35416
- Versioned guide: https://agent.backify.dev/v10/delivery.md
35417
+ Instruction version: 12
35418
+ Versioned guide: https://agent.backify.dev/v12/delivery.md
35417
35419
 
35418
35420
  ## Environment and documentation prerequisites
35419
35421
 
35420
- Before installation or connection, read https://agent.backify.dev/v10 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
35422
+ Before installation or connection, read https://agent.backify.dev/v12 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
35421
35423
 
35422
35424
  Before application implementation, all required setup checks and connected status must be verified OK. If any required check fails or remains unverified after supported recovery, stop setup and implementation; do not build a local website, minimal shell, placeholder, dependency-free fallback, or downloadable application archive. Report the blockers and recommend running the setup prompt in an AI coding tool such as Codex, Claude Code, or VS Code with GitHub Copilot agent mode, with terminal access, a persistent writable workspace, package installation, outbound HTTPS/DNS, and test execution enabled. Tool names alone do not guarantee readiness. Do not ask the application requirements question while setup is blocked. Later preview approval or deployment failures do not invalidate an already verified setup gate.
35423
35425
 
@@ -35427,9 +35429,9 @@ These instructions are for AI coding tools building applications on Backify, not
35427
35429
 
35428
35430
  The copied Backify prompt supplies App Id, Organization, and, when available, Pair, plus this guide reference and a privacy warning. Substitute those values for <app-id>, <organization-id>, and <pairing-code> below; never invent them. Use npx @backifydev/cli@latest so tool-specific setup and metadata-preserving cloning are available. The public API URL is https://api.backify.dev/api. For a nonproduction environment, replace the --api value with an explicitly trusted endpoint, or omit --api when using a trusted BACKIFY_API_URL override; never send a pairing code to an unverified endpoint.
35429
35431
 
35430
- npx @backifydev/cli@latest connect --app <app-id> --organization <organization-id> --api https://api.backify.dev/api --pair <pairing-code>
35432
+ npx @backifydev/cli@latest connect --app <app-id> --organization <organization-id> --api https://api.backify.dev/api --pair-stdin
35431
35433
 
35432
- If Pair is absent, omit --pair and use CLI browser login. Pairing expires after 15 minutes. Never record the code in project files, Git, prompt history, or logs. Record the user-supplied setup request in prompt history only after redacting credentials; do not drop the request. The CLI stores an application-scoped session outside the repository. If CLI access expires, use the browser reauthentication workflow below, never another setup prompt. A fresh pairing code is needed only if initial pairing expired or was consumed.
35434
+ If Pair is absent, omit --pair-stdin and use CLI browser login. Pairing expires after 15 minutes. Never record the code in project files, Git, prompt history, or logs. Record the user-supplied setup request in prompt history only after redacting credentials; do not drop the request. Running the user-supplied setup prompt authorizes CLI connection and storage of its application-scoped session in ~/.backify.json outside the repository, with owner-only filesystem access. This is expected setup behavior; do not ask for separate confirmation solely because the CLI saves this credential. Keep pairing codes and session tokens out of project files, Git, logs, shell command text and process arguments. Use the terminal tool's stdin/input channel for Pair with --pair-stdin (CLI 0.3.16 or later); do not use echo, shell interpolation, environment variables, or temporary files to carry the code. If the tool cannot supply private stdin, use browser login instead. Respect actual sandbox restrictions and use the supported native approval mechanism when access is required; this authorization does not override a denial. If CLI access expires, use the browser reauthentication workflow below, never another setup prompt. A fresh pairing code is needed only if initial pairing expired or was consumed.
35433
35435
 
35434
35436
  Before connecting, inspect the current folder. If it is not a Git repository, is missing its .git directory or file, or has no Git remote, add --clone to the connect command. Default AI coding-tool directories and instruction files do not make a workspace an existing application. Run connect --clone in the current folder even when tool scaffolding exists, including configuration, rules, agents, skills, commands, prompts, and work/output directories. This is tool-independent: preserve the current tool's metadata and instructions regardless of its name; never delete or overwrite them to make the folder empty. The CLI recognizes empty directories of any name, hidden tool-metadata directories and files, Markdown instruction files, and default work/outputs directories, including their contents. It clones into a temporary folder, checks for file conflicts, and safely merges the repository into the current workspace. If actual application source or an existing .git is present, or repository files conflict with existing entries, stop and reconcile the workspace or use a new folder; never overwrite user work. In an existing repository with a remote, verify it matches the connected repository and branch; never overwrite unrelated files or force-push.
35435
35437
 
@@ -35437,7 +35439,7 @@ Initialize using App Id from the copied prompt and the current tool selection:
35437
35439
 
35438
35440
  npx @backifydev/cli@latest init --app <app-id> --agent <current-tool>
35439
35441
 
35440
- For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v10 for instruction version 10; use the guide matching backify.json in an existing application. Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
35442
+ For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v12 for instruction version 12; use the guide matching backify.json in an existing application. Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
35441
35443
 
35442
35444
  Run the following to discover the connected hosting target, repository, branch, reports, releases, and deployment failures:
35443
35445
 
@@ -35519,7 +35521,7 @@ These instructions are an explicit agent workflow, not a universal chat intercep
35519
35521
  `;
35520
35522
 
35521
35523
  // ../platform/dist/index.js
35522
- var INSTRUCTION_VERSION = 10;
35524
+ var INSTRUCTION_VERSION = 12;
35523
35525
  var SDK_PACKAGE = "@backifydev/sdk";
35524
35526
  var DOCS_URL = "https://docs.backify.dev";
35525
35527
  var MAIL_LIMITS = Object.freeze({
@@ -35550,12 +35552,11 @@ var CAPABILITIES = [
35550
35552
  capability("integrations", "integrations", "Approved, versioned API contracts and environment-scoped operation grants", true),
35551
35553
  capability("http", "http", "Governed outbound HTTP"),
35552
35554
  capability("ai", "ai", "Server-only ai.generate, ai.extract, ai.classify and ai.embed. Declare capabilities.ai in backify.yaml; optional models may use default, fast, smart or foundry- IDs from the application's location-aware AI catalog, within its allowed-model policy. Backify provisions isolated Azure Foundry model deployments and supplies scoped runtime credentials automatically. Do not add Azure/OpenAI credentials to application code."),
35553
- capability("audit", "audit", "Structured audit records"),
35554
35555
  capability("logs", "logs", "Structured application logging"),
35555
35556
  capability("config", "config", "Non-secret application configuration")
35556
35557
  ];
35557
35558
  var CAPABILITY_REGISTRY = Object.fromEntries(CAPABILITIES.map((x) => [x.name, x]));
35558
- var SDK_IMPORT_CAPABILITIES = { integrations: "integrations", defineJob: "jobs", database: "database", auth: "auth", db: "database", storage: "storage", functions: "functions", defineFunction: "functions", jobs: "jobs", mail: "mail", webhooks: "events", events: "events", secrets: "secrets", http: "http", ai: "ai", audit: "audit", logs: "logs", logging: "logs", config: "config" };
35559
+ var SDK_IMPORT_CAPABILITIES = { integrations: "integrations", defineJob: "jobs", database: "database", auth: "auth", db: "database", storage: "storage", functions: "functions", defineFunction: "functions", jobs: "jobs", mail: "mail", webhooks: "events", events: "events", secrets: "secrets", http: "http", ai: "ai", logs: "logs", logging: "logs", config: "config" };
35559
35560
  var MANAGED_START = "<!-- BACKIFY:MANAGED:START -->";
35560
35561
  var MANAGED_END = "<!-- BACKIFY:MANAGED:END -->";
35561
35562
  function managedInstructions() {
@@ -35578,8 +35579,8 @@ Before dependent setup operations, follow the environment checks and permission
35578
35579
  - Authentication and authorization: \`auth\`.
35579
35580
  - Persistent data and files: \`db\` and \`storage\`.
35580
35581
  - Server functions: \`defineFunction\`; background work and schedules: \`jobs\` and \`jobs.schedule\`.
35581
- - Events, outbound HTTP, and AI: \`events\`, \`http.fetch\`, and \`ai\`.
35582
- - Server-side secrets, configuration, audit, and logs: \`secrets\`, \`config\`, \`audit\`, and \`logs\`.
35582
+ - Events and event tracking, outbound HTTP, and AI: \`events\` (\`events.track\` records application events), \`http.fetch\`, and \`ai\`.
35583
+ - Server-side secrets, configuration, and logs: \`secrets\`, \`config\`, and \`logs\`.
35583
35584
 
35584
35585
  Verify API signatures against the installed SDK types and the relevant guide at ${DOCS_URL}/capabilities/. Never invent SDK methods. Use \`@backifydev/sdk/local\` for tests and local development; \`@backifydev/sdk/runtime\` is for runtime hosts, not application code.
35585
35586
 
@@ -35813,13 +35814,39 @@ function integrationDiscoveryPath(command3, options) {
35813
35814
  throw new Error("Use backify integrations list|catalog|search|describe|contract|types");
35814
35815
  }
35815
35816
 
35817
+ // src/pairing.ts
35818
+ async function pairingCode(args2, input) {
35819
+ const stdinCount = args2.filter((value) => value === "--pair-stdin").length;
35820
+ const pairCount = args2.filter((value) => value === "--pair").length;
35821
+ if (stdinCount > 1 || pairCount > 1 || stdinCount && pairCount)
35822
+ throw new Error("Use exactly one of --pair-stdin or --pair <code>.");
35823
+ if (!stdinCount && !pairCount) return void 0;
35824
+ let code;
35825
+ if (stdinCount) {
35826
+ if (input.isTTY) throw new Error("Send the pairing code through stdin using --pair-stdin.");
35827
+ const chunks = [];
35828
+ let size = 0;
35829
+ for await (const chunk of input) {
35830
+ const bytes = Buffer.from(chunk);
35831
+ size += bytes.length;
35832
+ if (size > 256) throw new Error("Invalid pairing input; expected one 64-character hexadecimal code.");
35833
+ chunks.push(bytes);
35834
+ }
35835
+ code = Buffer.concat(chunks).toString("utf8").trim();
35836
+ } else {
35837
+ code = args2[args2.indexOf("--pair") + 1] ?? "";
35838
+ }
35839
+ if (!/^[0-9a-f]{64}$/i.test(code)) throw new Error("Invalid pairing input; expected one 64-character hexadecimal code.");
35840
+ return code;
35841
+ }
35842
+
35816
35843
  // src/cli-session.ts
35817
35844
  import { hostname, platform, release, arch } from "node:os";
35818
35845
 
35819
35846
  // package.json
35820
35847
  var package_default = {
35821
35848
  name: "@backifydev/cli",
35822
- version: "0.3.15",
35849
+ version: "0.3.17",
35823
35850
  description: "Command-line setup and diagnostics for Backify applications",
35824
35851
  type: "module",
35825
35852
  bin: {
@@ -37890,7 +37917,15 @@ function createHcrEventsProvider(options) {
37890
37917
  throw new Error("Invalid event binding name");
37891
37918
  const route = base.toString().replace(/\/$/, "") + "/v1/events/" + binding;
37892
37919
  const transport = options.fetch ?? globalThis.fetch;
37893
- const request = async (path, body, deliveries = false, metadata = false) => {
37920
+ const validateId = (id) => {
37921
+ if (typeof id !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(id) || id.length !== 36 || id === "00000000-0000-0000-0000-000000000000")
37922
+ throw new Error("Invalid event delivery id");
37923
+ };
37924
+ const validateReceipt = (receipt) => {
37925
+ if (typeof receipt !== "string" || !/^[a-f0-9]{64}$/.test(receipt) || receipt.length !== 64)
37926
+ throw new Error("Invalid event delivery receipt");
37927
+ };
37928
+ const request = async (path, body, deliveries = false, metadata = false, maximumBytes3 = metadata ? 131072 : 5242880) => {
37894
37929
  serverOnly();
37895
37930
  let token;
37896
37931
  try {
@@ -37937,7 +37972,7 @@ function createHcrEventsProvider(options) {
37937
37972
  if (part.done)
37938
37973
  break;
37939
37974
  length += part.value.length;
37940
- if (length > (metadata ? 131072 : 5242880))
37975
+ if (length > maximumBytes3)
37941
37976
  throw new Error("Event response exceeds its bound");
37942
37977
  chunks.push(part.value);
37943
37978
  }
@@ -38025,10 +38060,31 @@ function createHcrEventsProvider(options) {
38025
38060
  }
38026
38061
  return value;
38027
38062
  },
38028
- async complete(id, receipt, retry) {
38029
- if (typeof id !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(id) || id.length !== 36 || id === "00000000-0000-0000-0000-000000000000" || typeof receipt !== "string" || !/^[a-f0-9]{64}$/.test(receipt) || receipt.length !== 64 || retry !== void 0 && typeof retry !== "boolean")
38063
+ async complete(id, receipt, retry, completeOptions) {
38064
+ try {
38065
+ validateId(id);
38066
+ validateReceipt(receipt);
38067
+ } catch {
38030
38068
  throw new Error("Invalid event delivery receipt");
38031
- await request("/" + id + "/complete", { receipt, retry: retry ?? false });
38069
+ }
38070
+ if (retry !== void 0 && typeof retry !== "boolean")
38071
+ throw new Error("Invalid event delivery receipt");
38072
+ const delay = completeOptions?.retryDelaySeconds;
38073
+ if (delay !== void 0 && (!Number.isInteger(delay) || delay < 0 || delay > 3600 || !retry && delay !== 0))
38074
+ throw new Error("Invalid event retry delay");
38075
+ await request("/" + id + "/complete", { receipt, retry: retry ?? false, ...delay === void 0 ? {} : { retryDelaySeconds: delay } });
38076
+ },
38077
+ async renew(id, receipt) {
38078
+ validateId(id);
38079
+ validateReceipt(receipt);
38080
+ const value = await request("/" + id + "/renew", { receipt }, true, false, 1024);
38081
+ if (!value || typeof value !== "object" || Object.keys(value).join(",") !== "leaseExpiresAt" || typeof value.leaseExpiresAt !== "string" || !Number.isFinite(Date.parse(value.leaseExpiresAt)))
38082
+ throw new Error("HCR events returned an invalid lease");
38083
+ return value;
38084
+ },
38085
+ async replay(id) {
38086
+ validateId(id);
38087
+ await request("/" + id + "/replay", {});
38032
38088
  }
38033
38089
  };
38034
38090
  }
@@ -41838,7 +41894,7 @@ async function main() {
41838
41894
  break;
41839
41895
  case "connect": {
41840
41896
  const appId = option("--app") ?? projectApplication(), key = "app_" + applicationGuid(appId).replaceAll("-", "");
41841
- const code = option("--pair"), organizationId = option("--organization") ?? userConfig.sessions?.[key]?.organizationId ?? userConfig.organizationId;
41897
+ const code = await pairingCode(args, process.stdin), organizationId = option("--organization") ?? userConfig.sessions?.[key]?.organizationId ?? userConfig.organizationId;
41842
41898
  const address = apiAddress(option("--api") ?? process.env.BACKIFY_API_URL ?? userConfig.apiUrl ?? "https://api.backify.dev/api");
41843
41899
  if (code) {
41844
41900
  if (!organizationId) throw new Error("The setup prompt must supply the organization.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backifydev/cli",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Command-line setup and diagnostics for Backify applications",
5
5
  "type": "module",
6
6
  "bin": {