npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gtm-agents/cli

v0.3.0

Published

The gtm command: init, setup, doctor, migrate, brain, flags and deploy.

Readme

@gtm-agents/cli

The gtm command, for setting up and operating a deployment. This page is for deployers looking up a command's options and for contributors changing the CLI; docs/DEPLOYING.md walks through a first deployment in order.

Create a deployment from a published release with npx @gtm-agents/cli@<version> init <dir>; the new project lists @gtm-agents/cli as a dev dependency, so inside it the command is npx gtm. From a checkout of this repository, run npx gtm init <dir> --local <checkout> instead.

| Command | What it does | |---|---| | gtm init <dir> | Creates a new deployment from the worker template | | gtm setup | Creates the Cloudflare resources, reusing any that exist, fills their ids into wrangler.jsonc, and lists the missing secrets | | gtm migrate | Checks the migration order, then applies the D1 migrations | | gtm brain init | A short interview that writes a draft brain and prints the matching gtm.config.ts lines | | gtm brain validate \| upload \| diff | Validates the brain and templates, uploads them to KV with their locks, and shows what differs from KV | | gtm flags list \| get \| set \| unset | Reads and writes feature flags in KV, checked against the flag registry | | gtm doctor | Checks bindings, the cron trigger, configuration, adapters, secrets, webhooks, the kill switch and flags | | gtm deploy | Runs doctor and the migrations, warns on a brain diff, then deploys |

Every command that talks to Cloudflare runs the deployment's installed Wrangler (npx --no-install wrangler ...) in the deployment's directory, with your Wrangler login, and takes --config <dir> (default: the current directory) and --env staging|production (default: production, the top level of wrangler.jsonc). Commands that write to production (migrate, brain upload, flags set|unset, deploy) ask first and take --yes to skip the question; without a terminal, --yes is required. Staging writes without asking. Wrangler itself runs without a terminal, so its own prompts auto-confirm. Exit codes: 0 success, 1 a check or a Wrangler call failed, 2 a usage error. The CLI runs on macOS and Linux; on Windows, use WSL.

Commands

gtm init <dir> [--name <worker-name>] [--local <checkout>] copies the worker template into a new, empty directory. It sets the Worker and bucket names, points migrations at the installed core package (node_modules/@gtm-agents/core/migrations), copies the built dashboard into public/admin (or a placeholder page when the dashboard has not been built), and writes package.json, tsconfig.json and .gitignore.

  • By default (npm mode) the template is the copy bundled in the CLI package, and package.json depends on @gtm-agents/core, @gtm-agents/adapters and @gtm-agents/cli at exactly the CLI's own version, so npm install fetches one matching release.
  • With --local <checkout>, the template is the checkout's apps/worker and the packages are file: links into the checkout's packages/. The path must be the checkout's root.
  • Both modes produce the same wrangler.jsonc. Run from a checkout without --local, init uses the checkout's template, pins the checkout's version, and says that version may not be on npm.

gtm setup [--env] [--yes] [--reuse-existing] [--base-url <https-origin>] [--vector-dimensions <n>] [--vector-metric <metric>]

  • Reads wrangler.jsonc and plans a resource for every binding that still holds a ${...} placeholder, plus the R2 bucket and any queue that does not exist yet: the D1 database, KV namespace, R2 bucket, Vectorize index and queues, named after the Worker and the binding (my-agent-db, my-agent-kv, my-agent-memory, my-agent-events, my-agent-events-dlq, my-agent-chat, my-agent-jobs, my-agent-jobs-dlq).
  • Looks each name up first (d1 list, kv namespace list, r2 bucket info, vectorize list, queues info). If a lookup fails, it creates nothing. A resource wrangler.jsonc already names is reused; one that exists under a derived name the file does not hold yet is adopted only with --reuse-existing, since it may belong to another deployment with the same Worker name. An existing Vectorize index with other dimensions or metric is refused.
  • Prints the plan and asks before acting; --yes skips the question, and without a terminal it is required.
  • Creates with --update-config=false, so Wrangler never edits the file itself, then replaces only the placeholder strings in wrangler.jsonc, keeping comments and formatting. It does not write if the file changed while it ran.
  • --base-url fills AGENT_BASE_URL. The Vectorize index defaults to 1536 dimensions and cosine distance, which cannot change after it is created.
  • A second run plans nothing. It ends with the chat queue's name and the jobs queue and its dead-letter queue, to list in agent.chatQueue, scheduler.jobsQueue and scheduler.deadLetterQueue in src/index.ts, and with the missing secrets as npx wrangler secret put <NAME> lines, from wrangler secret list (names only).

gtm migrate [--env] [--local] checks that the migrations directory named by the DB binding exists and is numbered 0001, 0002, ... with no gaps or duplicates, then runs wrangler d1 migrations apply DB --remote (or --local). For the remote database it refuses while the database id is a placeholder.

gtm brain init [dir] [--answers <file.json>] and gtm brain init --questions (docs/BRAIN-SCHEMA.md)

  • Asks seven batches of questions on the terminal: company and sender, buyers, accounts, pain, offer and proof, the booking link, the send window, and voice. A blank answer skips.
  • Writes personas, icp, message-pillars, facts and voice into dir (default ./brain), every file status: draft. It never overwrites an existing component file, never fills a skipped answer, and never writes gtm.config.ts or the lock. The company, sender, booking and window answers are printed as gtm.config.ts lines to paste. Then it runs gtm brain validate on the folder.
  • Every answer is checked as it is given, with the brain's own rules. On the terminal an invalid answer is asked again; an answers file with an invalid answer, an unknown question id or a value that is not text exits 2 and writes nothing.
  • --answers reads one JSON object of "<question id>": "<answer>" (at most 64 KB), for scripts and coding agents. --questions prints the batches, each question's id, prompt, help and what it writes, as JSON.
  • Nothing is fetched and no model is called. To draft product.md and icp.md from your website, use the dashboard's Product and ICP page, then gtm brain pull.

gtm brain validate [dir] [--templates <dir>] [--domain <domain>] [--write-lock] checks every brain component and template; with --write-lock it writes brain.lock.json when there are no errors (warnings, such as a missing component, are allowed).

gtm brain upload [dir] [--templates <dir>] [--domain <domain>] [--env] [--dry-run]

  • Validates first, and uploads nothing on an error, when an approved component changed after it was locked, or when there is no lock.
  • Computes the locks with the core functions and writes, through wrangler kv bulk put --remote, every approved file (brain:file:<component>, template:file:<id>) and then, in a second call, the locks (brain:lock, templates:lock). The runtime serves a file only when it matches the lock, so a partial upload is never served.
  • The bulk files are written to a private temporary directory and deleted afterwards.
  • --dry-run lists the keys and sizes without calling Wrangler.

gtm brain diff [dir] [--templates <dir>] [--domain <domain>] [--env] reads brain:lock and templates:lock and lists each component and template that is new, changed or removed compared with the local files.

gtm flags list | get <key> | set <key> <value> | unset <key> [--env]

  • list shows every flag in the registry with its default and its remote value, including each member of a family, such as autonomy:<class>, that is set.
  • set refuses a key that is not in the registry and a value that does not fit its kind: booleans are stored as true or false, numbers are whole and zero or more (except the shares budget:alert_threshold, above 0 and at most 1, and outreach:holdout_rate, from 0 to 0.2), and a JSON flag takes a JSON object. A few string flags take only listed values (for example budget:enforcement is soft or hard). It refuses an autonomy level above 1 for a permanently human-only action class.
  • Reads go through wrangler kv bulk get, writes through wrangler kv bulk put, and unset through wrangler kv key delete, all with --remote.

gtm doctor [--config <dir>] [--env] [--remote] reports PASS, WARN, FAIL or INFO for each check and exits non-zero on any FAIL. Offline it reads wrangler.jsonc (the required bindings, that the only cron trigger is * * * * *, that a JOBS_QUEUE has a consumer and a dead-letter queue, and the Durable Object migrations), gtm.config.ts, adapter manifests and the names in .dev.vars. --remote also reads the deployed secret names and the halt and kill-switch flags, and resolves the sending domain's SPF, DKIM (with sending.dkimSelector) and DMARC records over DNS over HTTPS; a lookup that cannot be made is a WARN, never a PASS or a FAIL.

gtm deploy [--env] [--dry-run] runs gtm doctor (any FAIL stops it), checks that no placeholder is left, runs gtm migrate, warns when gtm brain diff finds differences, then runs wrangler deploy. --dry-run lists the pending migrations and runs wrangler deploy --dry-run instead, changing nothing; while placeholders remain, it skips the migration and brain checks.

For contributors

  • In this repository Node 24 runs the CLI's TypeScript directly; there is no build step. The published package is JavaScript, because Node does not strip types inside node_modules: the release build compiles src/ to dist/ with tsconfig.build.json and bundles the worker template and the built dashboard into dist/template/, which init finds next to its own compiled file. Keep paths that init and the other commands resolve from import.meta.url at the same depth in src/ and dist/. docs/RELEASING.md covers the build and the release smoke test.
  • Every Wrangler call goes through the injectable CommandRunner (src/lib/io.ts). Tests replace it with an in-memory account (test/fake-wrangler.ts), so no test touches Cloudflare.
  • src/lib/jsonc-edit.ts edits wrangler.jsonc by replacing string values at their exact source positions. Never re-serialize a deployer's config.
  • No command reads or prints a secret value. Secrets are listed by name and set with wrangler secret put, which prompts for the value.