From 75d5fb363bbb09c26f544147bbc8aba003e6224d Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:01:45 -0700 Subject: [PATCH 1/2] docs(scripts): point script headers and runbooks at compiled dist The backend runtime image installs production dependencies only, so ts-node is gone there. Script headers and the AGENT_AVATARS and token-copy runbooks still printed `npx ts-node scripts/.ts`, which fails in the backend pod. They now print `node dist/scripts/.js`, and the repo-root forms run from backend/. Comment and docs only. Co-Authored-By: Claude Haiku 5.5 Co-authored-by: rivet Agent-Model: claude/claude-haiku-5-5/default --- backend/scripts/backfill-byo-host-stamp.ts | 4 ++-- backend/scripts/backfill-explicit-runtime-identity.ts | 4 ++-- backend/scripts/cleanup-ghost-pod-members.ts | 4 ++-- backend/scripts/dedupe-agent-display-names.ts | 4 ++-- backend/scripts/generate-team-avatars.ts | 10 +++++----- backend/scripts/migrate-agent-dm-multimember.ts | 4 ++-- backend/scripts/migrate-agent-room-multimember.ts | 4 ++-- backend/scripts/migrate-connector-gates.ts | 4 ++-- backend/scripts/migrate-guide-identity-convention.ts | 4 ++-- backend/scripts/migrate-guide-per-user-identity.ts | 4 ++-- backend/scripts/purge-unstamped-post-summaries.ts | 4 ++-- backend/scripts/remove-task-github-fields.ts | 4 ++-- backend/scripts/repair-first-party-labels.ts | 2 +- backend/scripts/rewrap-connector-secrets.ts | 4 ++-- backend/scripts/rotate-bot-passwords.ts | 4 ++-- backend/scripts/unlist-internal-registry-agents.ts | 4 ++-- docs/AGENT_AVATARS.md | 6 +++--- docs/runbooks/migrate-chat-token-copies.md | 6 +++--- docs/runbooks/scrub-feed-token-copies.md | 6 +++--- 19 files changed, 43 insertions(+), 43 deletions(-) diff --git a/backend/scripts/backfill-byo-host-stamp.ts b/backend/scripts/backfill-byo-host-stamp.ts index 4ff8996bec..6e83578ca2 100644 --- a/backend/scripts/backfill-byo-host-stamp.ts +++ b/backend/scripts/backfill-byo-host-stamp.ts @@ -30,8 +30,8 @@ * an explicit host are never touched. * * Usage: - * npx ts-node backend/scripts/backfill-byo-host-stamp.ts # dry run - * npx ts-node backend/scripts/backfill-byo-host-stamp.ts --apply + * cd backend && node dist/scripts/backfill-byo-host-stamp.js # dry run + * cd backend && node dist/scripts/backfill-byo-host-stamp.js --apply */ /* eslint-disable no-console */ diff --git a/backend/scripts/backfill-explicit-runtime-identity.ts b/backend/scripts/backfill-explicit-runtime-identity.ts index 754fd24842..b42e7b6bf5 100644 --- a/backend/scripts/backfill-explicit-runtime-identity.ts +++ b/backend/scripts/backfill-explicit-runtime-identity.ts @@ -26,8 +26,8 @@ * Rows already carrying an explicit runtimeType AND host are untouched. * * Usage: - * npx ts-node backend/scripts/backfill-explicit-runtime-identity.ts - * npx ts-node backend/scripts/backfill-explicit-runtime-identity.ts --apply + * cd backend && node dist/scripts/backfill-explicit-runtime-identity.js + * cd backend && node dist/scripts/backfill-explicit-runtime-identity.js --apply * ... --include-inactive # default is ACTIVE only; see #949's reasoning */ diff --git a/backend/scripts/cleanup-ghost-pod-members.ts b/backend/scripts/cleanup-ghost-pod-members.ts index 588c127d10..e039acf9ec 100644 --- a/backend/scripts/cleanup-ghost-pod-members.ts +++ b/backend/scripts/cleanup-ghost-pod-members.ts @@ -32,8 +32,8 @@ * `--apply` to write. Run it on the operator's word, never inline in a deploy. * * Usage: - * ts-node backend/scripts/cleanup-ghost-pod-members.ts # report - * ts-node backend/scripts/cleanup-ghost-pod-members.ts --apply # delete + * cd backend && node dist/scripts/cleanup-ghost-pod-members.js # report + * cd backend && node dist/scripts/cleanup-ghost-pod-members.js --apply # delete */ import mongoose from 'mongoose'; diff --git a/backend/scripts/dedupe-agent-display-names.ts b/backend/scripts/dedupe-agent-display-names.ts index afe9d2b986..9b31aeecc2 100644 --- a/backend/scripts/dedupe-agent-display-names.ts +++ b/backend/scripts/dedupe-agent-display-names.ts @@ -26,8 +26,8 @@ * keys; only displayName (the human-facing label) is rewritten. * - `username` — DB-unique already; collisions there are impossible. * - * Run with: `cd backend && npx ts-node scripts/dedupe-agent-display-names.ts` - * (from backend/, so ts-node and mongoose resolve from backend/node_modules). + * Run with: `cd backend && node dist/scripts/dedupe-agent-display-names.js` + * (from backend/, so the compiled script and mongoose resolve from backend/node_modules). * * Idempotent: safe to re-run. New duplicates introduced later can be * cleaned up by re-running. diff --git a/backend/scripts/generate-team-avatars.ts b/backend/scripts/generate-team-avatars.ts index fb1b69be82..a3e75ca8ec 100644 --- a/backend/scripts/generate-team-avatars.ts +++ b/backend/scripts/generate-team-avatars.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env node /** * Generate personality-matched AI portraits for the core team agents and * save them to their User records. @@ -9,12 +9,12 @@ * or OpenAI/LiteLLM when OPENAI_API_KEY is set. * * Usage (inside backend pod with env already set): - * npx ts-node scripts/generate-team-avatars.ts - * npx ts-node scripts/generate-team-avatars.ts --force + * node dist/scripts/generate-team-avatars.js + * node dist/scripts/generate-team-avatars.js --force * * Or locally: - * GEMINI_API_KEY=AIza... MONGO_URI=... npx ts-node backend/scripts/generate-team-avatars.ts - * OPENAI_API_KEY=sk-... MONGO_URI=... npx ts-node backend/scripts/generate-team-avatars.ts + * cd backend && GEMINI_API_KEY=AIza... MONGO_URI=... node dist/scripts/generate-team-avatars.js + * cd backend && OPENAI_API_KEY=sk-... MONGO_URI=... node dist/scripts/generate-team-avatars.js * * The script is idempotent: agents whose profilePicture is already set (to a * data URI or URL) are skipped unless --force is passed. diff --git a/backend/scripts/migrate-agent-dm-multimember.ts b/backend/scripts/migrate-agent-dm-multimember.ts index ab5714b1bc..340edf55b8 100644 --- a/backend/scripts/migrate-agent-dm-multimember.ts +++ b/backend/scripts/migrate-agent-dm-multimember.ts @@ -47,8 +47,8 @@ * CLAUDE.md "Identity is separate from package." * * Usage: - * ts-node backend/scripts/migrate-agent-dm-multimember.ts # apply - * ts-node backend/scripts/migrate-agent-dm-multimember.ts --dry # report + * cd backend && node dist/scripts/migrate-agent-dm-multimember.js # apply + * cd backend && node dist/scripts/migrate-agent-dm-multimember.js --dry # report */ import mongoose from 'mongoose'; diff --git a/backend/scripts/migrate-agent-room-multimember.ts b/backend/scripts/migrate-agent-room-multimember.ts index a4489e53a2..37fc8ba474 100644 --- a/backend/scripts/migrate-agent-room-multimember.ts +++ b/backend/scripts/migrate-agent-room-multimember.ts @@ -32,8 +32,8 @@ * the action plan without writing. * * Usage: - * ts-node backend/scripts/migrate-agent-room-multimember.ts # apply - * ts-node backend/scripts/migrate-agent-room-multimember.ts --dry # report + * cd backend && node dist/scripts/migrate-agent-room-multimember.js # apply + * cd backend && node dist/scripts/migrate-agent-room-multimember.js --dry # report */ import mongoose from 'mongoose'; diff --git a/backend/scripts/migrate-connector-gates.ts b/backend/scripts/migrate-connector-gates.ts index 355f2197c0..bc0bf26048 100644 --- a/backend/scripts/migrate-connector-gates.ts +++ b/backend/scripts/migrate-connector-gates.ts @@ -8,8 +8,8 @@ * gate between this script's read and write. * * Usage: - * ts-node backend/scripts/migrate-connector-gates.ts --dry - * ts-node backend/scripts/migrate-connector-gates.ts + * cd backend && node dist/scripts/migrate-connector-gates.js --dry + * cd backend && node dist/scripts/migrate-connector-gates.js */ import mongoose from 'mongoose'; diff --git a/backend/scripts/migrate-guide-identity-convention.ts b/backend/scripts/migrate-guide-identity-convention.ts index 1d53a13c76..e5c54a6096 100644 --- a/backend/scripts/migrate-guide-identity-convention.ts +++ b/backend/scripts/migrate-guide-identity-convention.ts @@ -23,8 +23,8 @@ * only. Idempotent: convention-form installs are skipped. * * Usage: - * ts-node backend/scripts/migrate-guide-identity-convention.ts # apply - * ts-node backend/scripts/migrate-guide-identity-convention.ts --dry # report + * cd backend && node dist/scripts/migrate-guide-identity-convention.js # apply + * cd backend && node dist/scripts/migrate-guide-identity-convention.js --dry # report */ import { createHash } from 'crypto'; diff --git a/backend/scripts/migrate-guide-per-user-identity.ts b/backend/scripts/migrate-guide-per-user-identity.ts index 797c01947f..bff323d4f5 100644 --- a/backend/scripts/migrate-guide-per-user-identity.ts +++ b/backend/scripts/migrate-guide-per-user-identity.ts @@ -26,8 +26,8 @@ * Idempotent: a second run finds zero 'default' guide installs. * * Usage: - * ts-node backend/scripts/migrate-guide-per-user-identity.ts # apply - * ts-node backend/scripts/migrate-guide-per-user-identity.ts --dry # report + * cd backend && node dist/scripts/migrate-guide-per-user-identity.js # apply + * cd backend && node dist/scripts/migrate-guide-per-user-identity.js --dry # report */ import mongoose from 'mongoose'; diff --git a/backend/scripts/purge-unstamped-post-summaries.ts b/backend/scripts/purge-unstamped-post-summaries.ts index 8a4ba7b75a..a6f1705c51 100644 --- a/backend/scripts/purge-unstamped-post-summaries.ts +++ b/backend/scripts/purge-unstamped-post-summaries.ts @@ -19,8 +19,8 @@ * Dry run by default; pass `--apply` to delete. Run it on the operator's word. * * Usage: - * ts-node backend/scripts/purge-unstamped-post-summaries.ts # report - * ts-node backend/scripts/purge-unstamped-post-summaries.ts --apply # delete + * cd backend && node dist/scripts/purge-unstamped-post-summaries.js # report + * cd backend && node dist/scripts/purge-unstamped-post-summaries.js --apply # delete */ import mongoose from 'mongoose'; diff --git a/backend/scripts/remove-task-github-fields.ts b/backend/scripts/remove-task-github-fields.ts index 8f0305a9c9..ac03886241 100644 --- a/backend/scripts/remove-task-github-fields.ts +++ b/backend/scripts/remove-task-github-fields.ts @@ -7,8 +7,8 @@ * half of the schema removal. * * Usage: - * npx ts-node backend/scripts/remove-task-github-fields.ts - * npx ts-node backend/scripts/remove-task-github-fields.ts --apply + * cd backend && node dist/scripts/remove-task-github-fields.js + * cd backend && node dist/scripts/remove-task-github-fields.js --apply */ /* eslint-disable no-console */ diff --git a/backend/scripts/repair-first-party-labels.ts b/backend/scripts/repair-first-party-labels.ts index 27af8d5906..2c931c6cde 100644 --- a/backend/scripts/repair-first-party-labels.ts +++ b/backend/scripts/repair-first-party-labels.ts @@ -33,7 +33,7 @@ * row means the bot has never posted, so it has no users row yet: its Mongo label * is still written, and its first post creates the row from that label. * - * Run: cd backend && npx ts-node scripts/repair-first-party-labels.ts [--apply] + * Run: cd backend && node dist/scripts/repair-first-party-labels.js [--apply] */ import mongoose from 'mongoose'; import { FIRST_PARTY_DISPLAY_NAMES } from '../constants/firstPartyDisplayNames'; diff --git a/backend/scripts/rewrap-connector-secrets.ts b/backend/scripts/rewrap-connector-secrets.ts index 28567cbc42..717afb20b8 100644 --- a/backend/scripts/rewrap-connector-secrets.ts +++ b/backend/scripts/rewrap-connector-secrets.ts @@ -8,8 +8,8 @@ * leaves rows already under the active key untouched. * * Usage: - * npx ts-node backend/scripts/rewrap-connector-secrets.ts # dry run - * npx ts-node backend/scripts/rewrap-connector-secrets.ts --apply + * cd backend && node dist/scripts/rewrap-connector-secrets.js # dry run + * cd backend && node dist/scripts/rewrap-connector-secrets.js --apply */ /* eslint-disable no-console */ diff --git a/backend/scripts/rotate-bot-passwords.ts b/backend/scripts/rotate-bot-passwords.ts index 9f6a0286f5..b2c1910951 100644 --- a/backend/scripts/rotate-bot-passwords.ts +++ b/backend/scripts/rotate-bot-passwords.ts @@ -29,8 +29,8 @@ * operator's word, never inline in a deploy. * * Usage: - * ts-node backend/scripts/rotate-bot-passwords.ts # report - * ts-node backend/scripts/rotate-bot-passwords.ts --apply # rotate + * cd backend && node dist/scripts/rotate-bot-passwords.js # report + * cd backend && node dist/scripts/rotate-bot-passwords.js --apply # rotate */ import crypto from 'crypto'; diff --git a/backend/scripts/unlist-internal-registry-agents.ts b/backend/scripts/unlist-internal-registry-agents.ts index 4fbe87b3de..491ce63748 100644 --- a/backend/scripts/unlist-internal-registry-agents.ts +++ b/backend/scripts/unlist-internal-registry-agents.ts @@ -29,8 +29,8 @@ * list is enumerated and anything unrecognised is left alone and reported. * * Usage: - * npx ts-node backend/scripts/unlist-internal-registry-agents.ts # dry run - * npx ts-node backend/scripts/unlist-internal-registry-agents.ts --apply + * cd backend && node dist/scripts/unlist-internal-registry-agents.js # dry run + * cd backend && node dist/scripts/unlist-internal-registry-agents.js --apply */ /* eslint-disable no-console */ diff --git a/docs/AGENT_AVATARS.md b/docs/AGENT_AVATARS.md index 4fb3bd9776..7a5b136a9c 100644 --- a/docs/AGENT_AVATARS.md +++ b/docs/AGENT_AVATARS.md @@ -133,11 +133,11 @@ Preferred: run the script **inside the backend pod** so it picks up the same ```bash # One-shot inside the running backend pod kubectl exec -n commonly-dev deployment/backend -it -- \ - npx ts-node backend/scripts/generate-team-avatars.ts + cd backend && node dist/scripts/generate-team-avatars.js # Force regeneration (even if profilePicture is already set) kubectl exec -n commonly-dev deployment/backend -it -- \ - npx ts-node backend/scripts/generate-team-avatars.ts --force + cd backend && node dist/scripts/generate-team-avatars.js --force ``` Local / off-cluster run (direct OpenAI, no proxy): @@ -145,7 +145,7 @@ Local / off-cluster run (direct OpenAI, no proxy): ```bash cd /path/to/commonly OPENAI_API_KEY=sk-... MONGO_URI=mongodb://... \ - npx ts-node backend/scripts/generate-team-avatars.ts + cd backend && node dist/scripts/generate-team-avatars.js ``` The script is idempotent: it skips any agent whose `profilePicture` already diff --git a/docs/runbooks/migrate-chat-token-copies.md b/docs/runbooks/migrate-chat-token-copies.md index 88d474530f..3f4ad540cc 100644 --- a/docs/runbooks/migrate-chat-token-copies.md +++ b/docs/runbooks/migrate-chat-token-copies.md @@ -36,10 +36,10 @@ key ring (`CONNECTOR_SECRET_KEYS`, `CONNECTOR_SECRET_ACTIVE_KEY`) supplied by th existing ops-runner secret environment (never paste them into a command): ```sh -npx ts-node scripts/migrate-chat-token-copies.ts +node dist/scripts/migrate-chat-token-copies.js # Review the DRY-RUN counts by type, then explicitly apply: -npx ts-node scripts/migrate-chat-token-copies.ts --apply -npx ts-node scripts/migrate-chat-token-copies.ts +node dist/scripts/migrate-chat-token-copies.js --apply +node dist/scripts/migrate-chat-token-copies.js ``` **What the counts mean.** The final dry run should report zero candidates and diff --git a/docs/runbooks/scrub-feed-token-copies.md b/docs/runbooks/scrub-feed-token-copies.md index e06381710b..917e5c3525 100644 --- a/docs/runbooks/scrub-feed-token-copies.md +++ b/docs/runbooks/scrub-feed-token-copies.md @@ -17,10 +17,10 @@ From the deployed backend directory, with `MONGO_URI` supplied by the existing ops-runner secret environment (never paste it into a command): ```sh -npx ts-node scripts/scrub-feed-token-copies.ts +node dist/scripts/scrub-feed-token-copies.js # Review DRY-RUN counts by type, then explicitly apply: -npx ts-node scripts/scrub-feed-token-copies.ts --apply -npx ts-node scripts/scrub-feed-token-copies.ts +node dist/scripts/scrub-feed-token-copies.js --apply +node dist/scripts/scrub-feed-token-copies.js ``` The final dry run should report zero candidates for both types. Reports contain From e67f97b4a53305a81305b3188817d81256f02259 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:09:57 -0700 Subject: [PATCH 2/2] docs(avatars): run compiled generator from the right directory kubectl exec cannot run `cd`, and the backend image already starts in /app, so the pod command drops the `cd`. The local run changes into backend/ before setting env. The add-an-agent steps now rebuild dist before running the script, since dist is what runs. Co-Authored-By: Claude Haiku 5.5 Co-authored-by: rivet Agent-Model: claude/claude-haiku-5-5/default --- docs/AGENT_AVATARS.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/AGENT_AVATARS.md b/docs/AGENT_AVATARS.md index 7a5b136a9c..e336f26921 100644 --- a/docs/AGENT_AVATARS.md +++ b/docs/AGENT_AVATARS.md @@ -133,19 +133,19 @@ Preferred: run the script **inside the backend pod** so it picks up the same ```bash # One-shot inside the running backend pod kubectl exec -n commonly-dev deployment/backend -it -- \ - cd backend && node dist/scripts/generate-team-avatars.js + node dist/scripts/generate-team-avatars.js # Force regeneration (even if profilePicture is already set) kubectl exec -n commonly-dev deployment/backend -it -- \ - cd backend && node dist/scripts/generate-team-avatars.js --force + node dist/scripts/generate-team-avatars.js --force ``` Local / off-cluster run (direct OpenAI, no proxy): ```bash -cd /path/to/commonly +cd /path/to/commonly/backend OPENAI_API_KEY=sk-... MONGO_URI=mongodb://... \ - cd backend && node dist/scripts/generate-team-avatars.js + node dist/scripts/generate-team-avatars.js ``` The script is idempotent: it skips any agent whose `profilePicture` already @@ -162,8 +162,8 @@ Required env vars (any one combo works): 1. Open `backend/scripts/generate-team-avatars.ts`. 2. Add a new entry to the `TEAM` array with `agentName`, `instanceId`, `displayName`, `role`, `personality`, and `style`. -3. Run the script. Existing agents will be skipped; only the new one is - generated. +3. Run `npm run build` in `backend/` so `dist` picks up the new entry, then run + the script. Existing agents are skipped; only the new one is generated. ## Record on the User document