From b226cc202d1980ce2328b2a4d85761161c7293e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 20:33:15 +0000 Subject: [PATCH] =?UTF-8?q?TB0:=20the=20telegram-ai-bot=20spec=20=E2=80=94?= =?UTF-8?q?=20intent,=20CI,=20tooling=20and=20the=20epic=20doc=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repository's frame on top of its first README commit, and the epic it is built under. intent.yaml with the placeholder workspace ws_CHANGE_ME (CI plans nothing until the repository is linked), the three environments (dev verify-only, stage, prod after stage) with kv-redis-starter's per-environment Terraform parameters, and the trigger bindings. ci.yml is turso-starter's byte for byte but for its one credential comment (a single Cloudflare token, as kv-redis-starter's copy says), carrying the manual-deploy contract. The shared TypeScript and ESLint configuration, the wrangler renderer, the component-docs generator, the root pnpm workspace and turbo pipeline, and the spec index. The epic (key TB): ChatGPT-Telegram-Workers on one Worker, its upstream libraries kept as workspace packages, Workers AI the keyless default model, the KV namespace from Terraform, the bot token an optional Orun secret bound to Telegram's webhook after each deploy — and the five task contracts. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn --- .github/workflows/ci.yml | 294 +++++ .gitignore | 32 + .vscode/settings.json | 4 + README.md | 13 +- apps/.gitkeep | 0 infra/.gitkeep | 0 intent.yaml | 186 +++ package.json | 26 + packages/.gitkeep | 0 pnpm-lock.yaml | 1004 +++++++++++++++++ pnpm-workspace.yaml | 12 + specs/README.md | 14 + specs/epics/README.md | 12 + .../telegram-ai-bot/IMPLEMENTATION-STATUS.md | 13 + specs/epics/telegram-ai-bot/README.md | 41 + specs/epics/telegram-ai-bot/design.md | 112 ++ specs/epics/telegram-ai-bot/epic.yaml | 39 + .../telegram-ai-bot/implementation-plan.md | 48 + .../risks-and-open-questions.md | 13 + tasks/TB-1.TaskContract.yaml | 18 + tasks/TB-2.TaskContract.yaml | 18 + tasks/TB-3.TaskContract.yaml | 13 + tasks/TB-4.TaskContract.yaml | 15 + tasks/TB-5.TaskContract.yaml | 23 + tests/.gitkeep | 0 tooling/catalog/gen-component-docs.py | 550 +++++++++ tooling/eslint/index.js | 31 + tooling/eslint/package.json | 13 + tooling/tsconfig/base.json | 22 + tooling/tsconfig/package.json | 7 + tooling/tsconfig/web.json | 7 + tooling/tsconfig/worker.json | 8 + tooling/wire/live.mjs | 91 ++ tooling/wire/render.mjs | 108 ++ turbo.json | 32 + 35 files changed, 2817 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 apps/.gitkeep create mode 100644 infra/.gitkeep create mode 100644 intent.yaml create mode 100644 package.json create mode 100644 packages/.gitkeep create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 specs/README.md create mode 100644 specs/epics/README.md create mode 100644 specs/epics/telegram-ai-bot/IMPLEMENTATION-STATUS.md create mode 100644 specs/epics/telegram-ai-bot/README.md create mode 100644 specs/epics/telegram-ai-bot/design.md create mode 100644 specs/epics/telegram-ai-bot/epic.yaml create mode 100644 specs/epics/telegram-ai-bot/implementation-plan.md create mode 100644 specs/epics/telegram-ai-bot/risks-and-open-questions.md create mode 100644 tasks/TB-1.TaskContract.yaml create mode 100644 tasks/TB-2.TaskContract.yaml create mode 100644 tasks/TB-3.TaskContract.yaml create mode 100644 tasks/TB-4.TaskContract.yaml create mode 100644 tasks/TB-5.TaskContract.yaml create mode 100644 tests/.gitkeep create mode 100644 tooling/catalog/gen-component-docs.py create mode 100644 tooling/eslint/index.js create mode 100644 tooling/eslint/package.json create mode 100644 tooling/tsconfig/base.json create mode 100644 tooling/tsconfig/package.json create mode 100644 tooling/tsconfig/web.json create mode 100644 tooling/tsconfig/worker.json create mode 100644 tooling/wire/live.mjs create mode 100644 tooling/wire/render.mjs create mode 100644 turbo.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..21e1451 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,294 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + # A MANUAL RUN. Orunbase's Run and Deploy buttons start this workflow on + # main with component names, an environment and the deploy record's id + # (the deploys contract: ci.yml on main; inputs component, environment, + # deploy_id); "Run workflow" in the Actions tab does the same by hand. The + # plan step plans those components in that environment under the + # push-to-main trigger, so each one runs exactly as a merge runs it: stage + # and prod apply and deploy, dev verifies. An empty `component` means + # every component in the environment, a redeploy with nothing changed. + workflow_dispatch: + inputs: + component: + description: "Component names, comma-separated (component.yaml metadata.name); empty for every component" + required: false + type: string + default: "" + environment: + description: "Target environment" + required: true + type: choice + options: [dev, stage, prod] + deploy_id: + description: "Orunbase deploy record (dpl_…), set by Orunbase; appears in the run name" + required: false + type: string + default: "" + +# A manual run names itself after what it runs: Orunbase finds a deploy's run +# by the id in this name (GitHub's dispatch API returns no run id). Every +# other event keeps GitHub's default name (an empty run-name falls back to it). +run-name: ${{ github.event_name == 'workflow_dispatch' && format('Deploy {0} → {1} · {2}', inputs.component || 'every component', inputs.environment, inputs.deploy_id || 'by hand') || '' }} + +# PR runs share a group per ref and superseded runs are cancelled (each +# push re-plans anyway), which stops stale fan-outs from starving the +# runner pool. Main pushes get a unique group each: convergence runs plan +# --changed per commit, and GitHub replaces *pending* runs in a shared +# group even with cancel-in-progress false — a superseded main run's +# components would silently never converge. +concurrency: + group: ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + packages: write + id-token: write + # A lane of several jobs posts one check run per job, named by the job's + # check title, so branch protection sees the same names as before lanes. + checks: write + +jobs: + plan: + runs-on: ubuntu-latest + outputs: + lane-matrix: ${{ steps.matrix.outputs.lane-matrix }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + # A TREE THAT NAMES NO WORKSPACE PLANS NOTHING. `ws_CHANGE_ME` is the + # placeholder this repository ships with until someone links it; every + # remote op of a plan here would be refused, so the job says so and + # stops green, and `run` below has no lanes to start. A site built from + # this baseline never carries the placeholder — its bootstrap writes the + # product's own workspace into intent.yaml — and a bootstrap that had no + # workspace to write leaves `ws_SET_ME`, which is NOT skipped: it fails + # here loudly rather than deploying nothing in silence. + # + # This replaced an `ORUN_CI` repository variable, which a bootstrap has + # no way to set: every site it built would have converged on nothing. + - id: linked + run: | + if grep -Eq '^[[:space:]]*workspace:[[:space:]]*ws_CHANGE_ME[[:space:]]*$' intent.yaml; then + echo "::notice title=Orun CI::intent.yaml names no Orun workspace (ws_CHANGE_ME) — nothing to plan. Link this repository (orun cloud link) and set execution.state.workspace to turn the pipeline on." + echo "linked=false" >> "$GITHUB_OUTPUT" + else + echo "linked=true" >> "$GITHUB_OUTPUT" + fi + - if: steps.linked.outputs.linked == 'true' + uses: sourceplane/orun-action@v1.2.0 + with: + version: v2.78.4 + - if: steps.linked.outputs.linked == 'true' + env: + # Surface the best-effort catalog auto-sync (execution.state.autopushCatalog). + # A successful push prints "✓ pushed catalog …"; ORUN_VERBOSE also makes + # any skip/failure visible instead of silent. + ORUN_VERBOSE: "1" + # A manual run's selection, read from the environment, never + # interpolated into the script. + DISPATCH_COMPONENT: ${{ inputs.component }} + DISPATCH_ENVIRONMENT: ${{ inputs.environment }} + run: | + set -euo pipefail + + if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then + # A MANUAL RUN plans under the push-to-main trigger: the profiles + # a merge runs, filtered to the environment and the components it + # names. Not --changed: a redeploy is asked for when nothing has + # changed. Main only, because that trigger deploys stage and prod. + if [ "$GITHUB_REF" != "refs/heads/main" ]; then + echo "::error title=Orun CI::A manual run deploys main only; this one was started on ${GITHUB_REF}." + exit 1 + fi + plan_args=( + --trigger github-push-main + --env "$DISPATCH_ENVIRONMENT" + --intent intent.yaml + --output plan.json + ) + if [ -n "${DISPATCH_COMPONENT//[[:space:],]/}" ]; then + # Keep the named components that have something to run in this + # environment. orun refuses the others as unmatched (a test + # suite has no job in prod), and a run of only those is nothing + # selected, not a failure: it stays green with no lanes, which + # Orunbase reads as nothing selected. + orun plan --trigger github-push-main --env "$DISPATCH_ENVIRONMENT" \ + --intent intent.yaml --output env-plan.json --no-catalog-refresh >/dev/null + kept=0 + IFS=',' read -ra picked <<< "$DISPATCH_COMPONENT" + for c in "${picked[@]}"; do + c="${c//[[:space:]]/}" + [ -z "$c" ] && continue + if ! [[ "$c" =~ ^[a-z0-9][a-z0-9._-]{0,99}$ ]]; then + echo "::error title=Orun CI::'$c' is not a component name (component.yaml metadata.name)." + exit 1 + fi + if jq -e --arg c "$c" 'any(.jobs[]; .component == $c)' env-plan.json >/dev/null; then + plan_args+=(--component "$c") + kept=$((kept + 1)) + else + echo "::notice title=Orun CI::$c has nothing to run in ${DISPATCH_ENVIRONMENT} (or is not a component); left out." + fi + done + if [ "$kept" = 0 ]; then + jq '.jobs = [] | .lanes = []' env-plan.json > plan.json + plan_args=() + fi + fi + else + plan_args=( + --from-ci github + --event-file "$GITHUB_EVENT_PATH" + --intent intent.yaml + --output plan.json + --changed + ) + fi + + if [ "${#plan_args[@]}" -gt 0 ]; then + orun plan "${plan_args[@]}" + fi + + # A manual run that selects nothing runs nothing, and says so. + if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ "$(jq '.jobs | length' plan.json)" = 0 ]; then + echo "::notice title=Orun CI::Nothing to run for ${DISPATCH_COMPONENT:-every component} in ${DISPATCH_ENVIRONMENT}." + fi + # One matrix entry per LANE (execution.lanes in intent.yaml). A plan + # without lanes gets one per job, exactly the old matrix, and + # `orun run --lane ` on it is `--job `. + - id: matrix + if: steps.linked.outputs.linked == 'true' + run: | + echo "lane-matrix=$(jq -c 'if ((.lanes // []) | length) > 0 + then [.lanes[] | {"lane": .id, "name": .name}] + else [.jobs[] | {"lane": .id, "name": .checkName}] end' plan.json)" >> "$GITHUB_OUTPUT" + - if: steps.linked.outputs.linked == 'true' + uses: actions/upload-artifact@v7 + with: + name: orun-plan + path: plan.json + + run: + needs: plan + runs-on: ubuntu-latest + # A BOOTSTRAP LANDING IS CHECKED BY `plan` ALONE. Every phase of the + # baseline bootstrap lands on a branch named for its task — the provenance + # pen's `orun/-`, and the bootstrap's tasks are all `BASE-n` — + # and is merged by `orun.pr/land@v1` as soon as this workflow is green. + # On those pull requests `plan` above is the check: the intent, every + # component and every composition resolve, the changed set is computed, + # and the plan is uploaded. The lanes are not run there, because the merge + # runs every one of them again on main moments later, for real, and the + # bootstrap watches that convergence to green before the next phase — the + # PR pass was the same work twice, and a third of a bootstrap's wall-clock. + # Every other pull request runs its lanes exactly as before. + if: >- + ${{ needs.plan.outputs.lane-matrix != '[]' && needs.plan.outputs.lane-matrix != '' + && !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'orun/BASE-')) }} + strategy: + fail-fast: false + # Stagger the fan-out: every lane hits the lease-bound resolve at job + # start, and an unbounded herd (fifty lanes) saturated it twice. Sixteen + # keeps the herd well under that and is above execution.lanes.maxLanes + # (6), so a packed plan starts every lane at once; it only binds on a + # small plan that runs one lane per job. Inside a lane a job that waits + # on another lane holds no slot. + max-parallel: 16 + matrix: + include: ${{ fromJson(needs.plan.outputs.lane-matrix) }} + name: ${{ matrix.name }} + env: + # One pnpm store for every lane, restored below. Each lane installs the + # whole workspace with --frozen-lockfile; without this every one of them + # downloaded all ~500 packages from the registry again. + npm_config_store_dir: /home/runner/.pnpm-store + PNPM_STORE_DIR: /home/runner/.pnpm-store + steps: + - uses: actions/checkout@v6 + # Keyed by the lockfile alone, so every lane of every run shares one + # entry until a dependency changes. The first lane to finish saves it; + # the rest find the key taken and skip the save. + - name: pnpm store cache + uses: actions/cache@v4 + with: + path: /home/runner/.pnpm-store + key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + pnpm-store-${{ runner.os }}- + - uses: actions/download-artifact@v8 + with: + name: orun-plan + - name: Log in to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: sourceplane/orun-action@v1.2.0 + with: + version: v2.78.4 + # exec-id is the RUN id alone (no attempt suffix): a `gh run rerun + # --failed` then RESUMES the same orun execution — jobs that succeeded in + # a prior attempt stay completed, so re-run lanes' cross-job dependencies + # are already satisfied instead of waiting forever on lanes that are not + # re-running (the partial-rerun deadlock). --retry re-opens THIS + # lane's failed jobs when they terminally failed in a prior attempt + # (no-op on first attempts); its completed jobs stay completed — together + # they make `gh run rerun --failed` a true resume. + - run: | + # --retry only on re-run attempts: on a fresh attempt a failed + # upstream is a genuine failure and dependents must fail fast; on a + # resume (gh run rerun --failed) the upstream's own retry lane will + # re-open it, so lanes wait out the race instead. + retry_flag="" + if [ "${GITHUB_RUN_ATTEMPT:-1}" -gt 1 ]; then retry_flag="--retry"; fi + # EVERY RUN REPORTS TO THE PLATFORM, a pull request's included. + # + # A PR lane resolves its secrets like any other (a verify lane still + # reads the wiring its fixture stands in for, an infra lane plans + # against the real account), and a job's secret refs are resolved + # before its first step whatever its profile does — so a PR run + # without remote state failed every lane that declares one: + # + # ✗ cloudflare-d1.stage.terraform: secret resolution failed: local + # runs resolve secrets only from ORUN_SECRET_ overrides + # + # and a phase's PR could never be verified before it merged. This + # used to drop the state flag on PRs, on the belief that the backend + # refuses a pull_request OIDC token by design. It does not: the + # exchange's only gate is the repo link's CI settings (oidcEnabled, + # allowedRefPattern, allowedEnvironments — identity-worker + # oidc-exchange.ts), and the resource-hidden `not_found` seen at the + # time is exactly what an UNLINKED repository answers, push or PR. + # Remote state on a PR also puts the PR's runs in front of the + # platform, which renders runs on refs/pull/ as that PR's row. + # Fork PRs get no OIDC token from GitHub at all and still fail + # closed. Nothing mutating runs here: deploy/apply profiles are gated + # on triggerRef github-push-main. + state_flag="--remote-state" + orun run \ + --plan plan.json \ + --runner github-actions \ + $state_flag \ + --lane "${{ matrix.lane }}" \ + --exec-id "${{ github.run_id }}" \ + $retry_flag + env: + # GITHUB_TOKEN is the only credential CI holds — GitHub-issued and + # ephemeral. Every provider credential (the Cloudflare token and + # account id — there is no second provider) is an orun-managed + # secret: + # brokered fresh per run from the workspace's integrations, resolved + # lease-bound by the jobs that declare it (profile secretBindings or + # component secretEnv), and log-redacted. Nothing provider-shaped is + # stored in GitHub. + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_CONFIG: /home/runner/.docker diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eddaa80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +node_modules/ +dist/ +.next/ +.open-next/ +.wrangler/ +.turbo/ +coverage/ +*.tsbuildinfo +.env +.env.local +.env*.local +.dev.vars +.dev.vars.* +!.dev.vars.example +*.log +plan.json +next-env.d.ts + +# Terraform +.terraform/ +*.tfstate +*.tfstate.backup +crash.log +.workspace/ + +# orun per-job staged workspaces and object-model caches. +**/.orun/runs/ +**/.orun/ + +# apps/bot/wrangler.jsonc is NOT ignored: it is committed as the fixture render +# of wrangler.template.jsonc, because the deploy lane checks the config exists +# before it builds (and re-renders it for its environment in the build). diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..35a6d34 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib", + "editor.formatOnSave": true +} diff --git a/README.md b/README.md index 5f28c88..76bdb26 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # telegram-ai-bot -An Orunbase starter baseline, being built: ChatGPT-Telegram-Workers' multi-model Telegram bot on Cloudflare Workers, KV and Workers AI, on the Cirrus baseline conventions. +TBXark's [ChatGPT-Telegram-Workers](https://github.com/TBXark/ChatGPT-Telegram-Workers) +— a multi-model Telegram bot with a Telegram Mini-App admin — on **one +Cloudflare Worker**, its settings and chat history in a **Workers KV** +namespace and **Workers AI** its keyless default model, deployed by +[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge, +and then packaged as an Orun baseline. -Upstream: https://github.com/TBXark/ChatGPT-Telegram-Workers +This is the repository's frame: `intent.yaml` (with the placeholder +workspace `ws_CHANGE_ME`, so CI plans nothing until it is linked), the Orun +CI workflow, the shared TypeScript, ESLint, wiring and catalog tooling, and +the spec index. The work is tracked as an epic under +[`specs/epics/telegram-ai-bot`](specs/epics/telegram-ai-bot/README.md). diff --git a/apps/.gitkeep b/apps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/infra/.gitkeep b/infra/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/intent.yaml b/intent.yaml new file mode 100644 index 0000000..16e1663 --- /dev/null +++ b/intent.yaml @@ -0,0 +1,186 @@ +apiVersion: sourceplane.io/v1 +kind: Intent + +metadata: + name: telegram-ai-bot + description: A multi-model Telegram bot with a Mini-App admin — one Cloudflare Worker answering Telegram's webhook with Workers AI by default, its settings and chat history in a Workers KV namespace provisioned by Terraform + namespace: sourceplane + +execution: + state: + backendUrl: https://api-edge-prod.oruncloud.workers.dev + # Declared, enforced tenancy: the workspace claim is sent on every remote op + # (including the credential-free CI OIDC exchange) so the platform can + # enforce claim ⊆ authorized. Declaring it implies strict mode — a + # non-interactive run that resolves no workspace fails fast. + # + # `ws_CHANGE_ME` is the one value `ci.yml` treats as "not linked yet" and + # plans nothing for. A bootstrap writes the product's workspace here; by + # hand, set it to yours (`orun cloud link`) and the Orun pipeline runs. + workspace: ws_CHANGE_ME + requireOrg: true + # Push the resolved catalog after a successful plan on the default branch, + # keeping the workspace-global catalog head fresh without an explicit + # `--push-catalog`. + autopushCatalog: true + # Lanes (orun ≥ v2.76.0): CI runs one GitHub job per LANE, not per orun job. + lanes: + mode: auto + maxLanes: 6 + concurrency: 6 + +compositions: + sources: + # The composition stack lives in sourceplane/stack-tectonic and is consumed + # as a published OCI artifact rather than a repo-local directory. Pin an + # explicit version: a bare repository reference resolves to `:latest`, + # which would let a catalog release change this repo's execution contracts + # without a commit here. Bumping the tag is the deliberate upgrade step. + # + # 0.19.0, NOT 0.20.0 (cirrus-baseline's pin). 0.20.0 makes the workspace + # install lane-scoped: it runs once in the source checkout and every job's + # staged tree LINKS its top-level node_modules there — out of the tree. + # Next 16's Turbopack refuses a dependency that resolves outside its root + # ("Symlink … points out of the filesystem root"), so the Next.js products + # on these conventions pin 0.19.0, and this one keeps the same pin for one + # convention. This Worker builds with wrangler's esbuild, which follows the + # link, but under 0.19.0 each job installs inside its own tree, and the bot + # has one job per lane, so the shared install would save nothing anyway. + # 0.19.0 also retries a first deploy that loses Cloudflare's 10007 race and + # retries the smoke while a new workers.dev route propagates. A bump is a + # deliberate pull request that re-runs the lane's steps in a job tree + # staged with the new layout. + - name: stack-tectonic + kind: oci + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.19.0 + resolution: + precedence: + - stack-tectonic + bindings: + terraform: stack-tectonic + cloudflare-domain: stack-tectonic + db-migrate: stack-tectonic + +discovery: + roots: + - apps/ + - infra/ + - packages/ + - tests/ + +# Where the work lives (initiative-lifecycle): an epic is a directory with an +# epic.yaml under `epics`, a task a contract under `tasks`; the `orun plan` on +# main reconciles the tree into the workspace's work plane after a merge. +# +# THIS BLOCK IS THE BASELINE'S OWN. A product built from this baseline has no +# epics or task contracts of its own (its bootstrap work lives on the +# platform), so the bootstrap removes the block, and this comment with it, +# from the product's copy. +work: + epics: specs/epics + tasks: tasks + sync: on-merge + +automation: + triggerBindings: + github-pull-request: + description: Pull request validation + on: + provider: github + event: pull_request + actions: + - opened + - synchronize + - reopened + - ready_for_review + baseBranches: + - main + plan: + scope: changed + base: pull_request.base.sha + head: pull_request.head.sha + + github-push-main: + description: Main branch stack convergence after merge + on: + provider: github + event: push + branches: + - main + + local-development: + description: Local testing with full Terraform execution + on: + provider: local + +environments: + dev: + description: Verify-only. Pull requests plan and verify here; nothing is deployed. + activation: + triggerRefs: + - github-pull-request + - github-push-main + - local-development + dependencyMode: advisory + parameterDefaults: + terraform: + lane: verify + namespace: sourceplane + namespacePrefix: dev- + owner: sourceplane + repo: telegram-ai-bot + policies: + requireApproval: "false" + env: + BASE_DOMAIN: telegram-ai-bot.example.com + + stage: + description: Deployed on every merge to main, before prod. + url: https://telegram-ai-bot-bot-stage.your-workers-subdomain.workers.dev + activation: + triggerRefs: + - github-pull-request + - github-push-main + parameterDefaults: + terraform: + lane: verify + namespace: sourceplane + namespacePrefix: stg- + owner: sourceplane + repo: telegram-ai-bot + policies: + requireApproval: "false" + env: + BASE_DOMAIN: telegram-ai-bot.example.com + + prod: + description: Where visitors are. Deploys after stage converges on the same commit. + url: https://telegram-ai-bot-bot-prod.your-workers-subdomain.workers.dev + activation: + triggerRefs: + - github-pull-request + - github-push-main + promotion: + dependsOn: + - environment: stage + parameterDefaults: + terraform: + lane: verify + namespace: sourceplane + namespacePrefix: prod- + owner: sourceplane + repo: telegram-ai-bot + policies: + requireApproval: "false" + env: + BASE_DOMAIN: telegram-ai-bot.example.com + +# Repo-level catalog entity: front page + role-tagged docs (rendered in the +# workspace Docs library, pinned to the commit by `orun plan`). +repo: + displayName: telegram-ai-bot + docs: + overview: README.md + pages: + - { path: ai/context/operations.md, role: runbook, title: Operating contract } + - { path: ai/context/deployment.md, role: reference, title: Live deployment manifest } diff --git a/package.json b/package.json new file mode 100644 index 0000000..6f16ad9 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "telegram-ai-bot", + "private": true, + "version": "0.0.0", + "packageManager": "pnpm@10.12.1", + "engines": { + "node": ">=22", + "pnpm": ">=10" + }, + "scripts": { + "dev": "turbo run dev", + "build": "turbo run build", + "test": "turbo run test", + "lint": "turbo run lint", + "typecheck": "turbo run typecheck", + "deploy": "turbo run deploy", + "wire:fixture": "turbo run wire:fixture" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^8.32.0", + "@typescript-eslint/parser": "^8.32.0", + "eslint": "^9.27.0", + "turbo": "^2.5.4", + "typescript": "^5.8.3" + } +} diff --git a/packages/.gitkeep b/packages/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..556857a --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,1004 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@typescript-eslint/eslint-plugin': + specifier: ^8.32.0 + version: 8.72.1(@typescript-eslint/parser@8.72.1(eslint@9.39.5)(typescript@5.9.3))(eslint@9.39.5)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.32.0 + version: 8.72.1(eslint@9.39.5)(typescript@5.9.3) + eslint: + specifier: ^9.27.0 + version: 9.39.5 + turbo: + specifier: ^2.5.4 + version: 2.11.10 + typescript: + specifier: ^5.8.3 + version: 5.9.3 + + tooling/eslint: + devDependencies: + '@typescript-eslint/eslint-plugin': + specifier: ^8.32.0 + version: 8.72.1(@typescript-eslint/parser@8.72.1(eslint@9.39.5)(typescript@5.9.3))(eslint@9.39.5)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.32.0 + version: 8.72.1(eslint@9.39.5)(typescript@5.9.3) + eslint: + specifier: ^9.27.0 + version: 9.39.5 + + tooling/tsconfig: {} + +packages: + + '@eslint-community/eslint-utils@4.10.1': + resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/regexpp@4.12.2': + resolution: {integrity: sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + '@eslint/config-array@0.21.2': + resolution: {integrity: sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/config-helpers@0.4.2': + resolution: {integrity: sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/core@0.17.0': + resolution: {integrity: sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/eslintrc@3.3.7': + resolution: {integrity: sha512-F42g89Qd5oAWtp0k0nnSrjziAKza7w8SVT4mStc18LZMaRb4J1HQAHLCalEtDCxrTuksx7NU9qsmeLwpOfPqWw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/js@9.39.5': + resolution: {integrity: sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/object-schema@2.1.7': + resolution: {integrity: sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@eslint/plugin-kit@0.4.1': + resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@humanfs/core@0.19.2': + resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} + engines: {node: '>=18.18.0'} + + '@humanfs/node@0.16.8': + resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==} + engines: {node: '>=18.18.0'} + + '@humanfs/types@0.15.0': + resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==} + engines: {node: '>=18.18.0'} + + '@humanwhocodes/module-importer@1.0.1': + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} + + '@humanwhocodes/retry@0.4.3': + resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} + engines: {node: '>=18.18'} + + '@turbo/darwin-64@2.11.10': + resolution: {integrity: sha512-By4idRap5+nLnMuRzLB4qkOPRlvNdyY1ne4VJYDyUoUB11H94k7uif9mbe3JT8JSNXs1D68uMcBj6hJ/jMQRvA==} + cpu: [x64] + os: [darwin] + + '@turbo/darwin-arm64@2.11.10': + resolution: {integrity: sha512-pyEYlVcuexOPa92p0Wlwl9YT1Is5D60lxN3ItWm3g30YLvFaUq86TF4BBWg5ZAc0uMTnrOzCvuCsOBTdzUWnRQ==} + cpu: [arm64] + os: [darwin] + + '@turbo/linux-64@2.11.10': + resolution: {integrity: sha512-1tYeR/IDZ5HEdsb0jNq2L2xam5nMQ+g80tlV2BZmv4OFw+pMcUM0mMmUcfc5wXPPNHVNPuDMjh9Y8G8HgXPLZA==} + cpu: [x64] + os: [android, linux] + + '@turbo/linux-arm64@2.11.10': + resolution: {integrity: sha512-HuekQxvVGhUd46g1Im/DKdOtglHr4/gguZAvzEpPUgtxNkztSa8lWhQEGQ+EmPQ0n7w19qjThFU+OfEEd0uvlw==} + cpu: [arm64] + os: [android, linux] + + '@turbo/windows-64@2.11.10': + resolution: {integrity: sha512-UJOP3BkbreY3/JlMgJR6ZiimxYIBn+c+B4tnBIxD0E9c3Estmk+XoVNVBNBottZLNRXe3/ScgOU4+/k8tIWysg==} + cpu: [x64] + os: [win32] + + '@turbo/windows-arm64@2.11.10': + resolution: {integrity: sha512-xOkEjF3ws/b/YNlc+bvJHMYBn+vL+QbEISZFVi0qS+ImmhA1X3/gmNmBrjjIG3dg6aeN+n6gQitzSkXQ286qJQ==} + cpu: [arm64] + os: [win32] + + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@typescript-eslint/eslint-plugin@8.72.1': + resolution: {integrity: sha512-5CokTWXpmbylfFabsbvHC0CAw3XLaGnoa+nFJX5FR592h/LoZsENUE6p/rg5xvkKrFEXz6pYmgI29AgXc2N3BQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.72.1 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/parser@8.72.1': + resolution: {integrity: sha512-ZGwZP4OCfyA0AQTpEAMWz+rtX01DRhQWW5hB0ucKDEIX5U7jdmPSaMx94rQfaPAQzIYz2BimOgKOJtjfpRFQ9g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/project-service@8.72.1': + resolution: {integrity: sha512-fAuVMkwdO/huI8nyo/WKnNKf6Gag93S56Rh3Ts5mGcavwSdaN8tRg1gCeIGX8PF+nzp1BjGfO4gHhGzW1J6jTg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/scope-manager@8.72.1': + resolution: {integrity: sha512-lC/t6eMCZZQAAKZEYGL6RDVSuFehpdmMT6h+nJIjIa6oylN/PwDgDVtEIbB7O9xFfZYtZAYLoLlDNWKJhtF+uQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.72.1': + resolution: {integrity: sha512-e4D5R5vpeAEPBxT2BAzsFQL3sbwyeeeo5+aczgNSRK1V734jE7pTqaGFU+fXapWEQwnZbpFaTn32+Z8DwS6OTg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/type-utils@8.72.1': + resolution: {integrity: sha512-iY2wlmyrXJmx4yxUGP3aYCFF3cA/6ShddOKmLU2dx7LnEykbAM8WThlxZEfd1NddqceF6eJmZUayxx9oKIYNlg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/types@8.72.1': + resolution: {integrity: sha512-LmE5IhQet1BWOWEXqBrVtBPsMAOQ6Nzk35d+WLh3mk4EUF33sqlfxjio1MdYeSvKSG5skactKKuixBIKXhL4Rw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/typescript-estree@8.72.1': + resolution: {integrity: sha512-DAlUoUV93hIvrtIQLwCbmZQYVZwOMhiHJrOVUUIWicFZaIYjTRqlY3I/NZevfkLmSqkNHRu2qYDcq9lrn16oOQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/utils@8.72.1': + resolution: {integrity: sha512-5v5liypurJBFHCBNqh/RjsymAD+VWcE0djuGY/BUqp5fC3Qn+luWDEksjuTtWjPn6i5zQlUtkZCRG/CYG0yCkA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/visitor-keys@8.72.1': + resolution: {integrity: sha512-SB8xqipSzZHUePCCLNeYxqnxq83X61/qzNhjQGbTfjxGZIeOEP7tBgWYX05Tcd6CgE02WdTJnh5b8kMZJ/+bnQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + acorn-jsx@5.3.2: + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + acorn@8.19.0: + resolution: {integrity: sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==} + engines: {node: '>=0.4.0'} + hasBin: true + + ajv@6.15.0: + resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + + argparse@2.0.1: + resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + balanced-match@4.0.4: + resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} + engines: {node: 18 || 20 || >=22} + + brace-expansion@1.1.21: + resolution: {integrity: sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==} + + brace-expansion@5.0.12: + resolution: {integrity: sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==} + engines: {node: 20 || >=22} + + callsites@3.1.0: + resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} + engines: {node: '>=6'} + + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + deep-is@0.1.4: + resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + + eslint-scope@8.4.0: + resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint-visitor-keys@4.2.1: + resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + eslint-visitor-keys@5.0.1: + resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint@9.39.5: + resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. + hasBin: true + peerDependencies: + jiti: '*' + peerDependenciesMeta: + jiti: + optional: true + + espree@10.4.0: + resolution: {integrity: sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + esquery@1.7.0: + resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==} + engines: {node: '>=0.10'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + + esutils@2.0.3: + resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} + engines: {node: '>=0.10.0'} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fast-levenshtein@2.0.6: + resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + file-entry-cache@8.0.0: + resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} + engines: {node: '>=16.0.0'} + + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + + flat-cache@4.0.1: + resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} + engines: {node: '>=16'} + + flatted@3.4.4: + resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==} + + glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + + globals@14.0.0: + resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} + engines: {node: '>=18'} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + + ignore@7.0.14: + resolution: {integrity: sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==} + engines: {node: '>= 4'} + + import-fresh@3.3.1: + resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} + engines: {node: '>=6'} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + js-yaml@4.3.2: + resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==} + hasBin: true + + json-buffer@3.0.1: + resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + keyv@4.5.4: + resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + + minimatch@10.2.6: + resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} + engines: {node: 18 || 20 || >=22} + + minimatch@3.1.5: + resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + parent-module@1.0.1: + resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} + engines: {node: '>=6'} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + resolve-from@4.0.0: + resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} + engines: {node: '>=4'} + + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + ts-api-utils@2.5.0: + resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + + turbo@2.11.10: + resolution: {integrity: sha512-3GJYwig8ygEI89oaOZdduJX8/aw6O9eRPYHoIt6T3FZl9hkKjiyIspufJoVgqXihPoJu8M5CSV0DlZvzfohBCw==} + hasBin: true + + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + +snapshots: + + '@eslint-community/eslint-utils@4.10.1(eslint@9.39.5)': + dependencies: + eslint: 9.39.5 + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.2': {} + + '@eslint/config-array@0.21.2': + dependencies: + '@eslint/object-schema': 2.1.7 + debug: 4.4.3 + minimatch: 3.1.5 + transitivePeerDependencies: + - supports-color + + '@eslint/config-helpers@0.4.2': + dependencies: + '@eslint/core': 0.17.0 + + '@eslint/core@0.17.0': + dependencies: + '@types/json-schema': 7.0.15 + + '@eslint/eslintrc@3.3.7': + dependencies: + ajv: 6.15.0 + debug: 4.4.3 + espree: 10.4.0 + globals: 14.0.0 + ignore: 5.3.2 + import-fresh: 3.3.1 + js-yaml: 4.3.2 + minimatch: 3.1.5 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + + '@eslint/js@9.39.5': {} + + '@eslint/object-schema@2.1.7': {} + + '@eslint/plugin-kit@0.4.1': + dependencies: + '@eslint/core': 0.17.0 + levn: 0.4.1 + + '@humanfs/core@0.19.2': + dependencies: + '@humanfs/types': 0.15.0 + + '@humanfs/node@0.16.8': + dependencies: + '@humanfs/core': 0.19.2 + '@humanfs/types': 0.15.0 + '@humanwhocodes/retry': 0.4.3 + + '@humanfs/types@0.15.0': {} + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/retry@0.4.3': {} + + '@turbo/darwin-64@2.11.10': + optional: true + + '@turbo/darwin-arm64@2.11.10': + optional: true + + '@turbo/linux-64@2.11.10': + optional: true + + '@turbo/linux-arm64@2.11.10': + optional: true + + '@turbo/windows-64@2.11.10': + optional: true + + '@turbo/windows-arm64@2.11.10': + optional: true + + '@types/estree@1.0.9': {} + + '@types/json-schema@7.0.15': {} + + '@typescript-eslint/eslint-plugin@8.72.1(@typescript-eslint/parser@8.72.1(eslint@9.39.5)(typescript@5.9.3))(eslint@9.39.5)(typescript@5.9.3)': + dependencies: + '@eslint-community/regexpp': 4.12.2 + '@typescript-eslint/parser': 8.72.1(eslint@9.39.5)(typescript@5.9.3) + '@typescript-eslint/scope-manager': 8.72.1 + '@typescript-eslint/type-utils': 8.72.1(eslint@9.39.5)(typescript@5.9.3) + '@typescript-eslint/utils': 8.72.1(eslint@9.39.5)(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.72.1 + eslint: 9.39.5 + ignore: 7.0.14 + natural-compare: 1.4.0 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@8.72.1(eslint@9.39.5)(typescript@5.9.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.72.1 + '@typescript-eslint/types': 8.72.1 + '@typescript-eslint/typescript-estree': 8.72.1(typescript@5.9.3) + '@typescript-eslint/visitor-keys': 8.72.1 + debug: 4.4.3 + eslint: 9.39.5 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.72.1(typescript@5.9.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.72.1(typescript@5.9.3) + '@typescript-eslint/types': 8.72.1 + debug: 4.4.3 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@8.72.1': + dependencies: + '@typescript-eslint/types': 8.72.1 + '@typescript-eslint/visitor-keys': 8.72.1 + + '@typescript-eslint/tsconfig-utils@8.72.1(typescript@5.9.3)': + dependencies: + typescript: 5.9.3 + + '@typescript-eslint/type-utils@8.72.1(eslint@9.39.5)(typescript@5.9.3)': + dependencies: + '@typescript-eslint/types': 8.72.1 + '@typescript-eslint/typescript-estree': 8.72.1(typescript@5.9.3) + '@typescript-eslint/utils': 8.72.1(eslint@9.39.5)(typescript@5.9.3) + debug: 4.4.3 + eslint: 9.39.5 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@8.72.1': {} + + '@typescript-eslint/typescript-estree@8.72.1(typescript@5.9.3)': + dependencies: + '@typescript-eslint/project-service': 8.72.1(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.72.1(typescript@5.9.3) + '@typescript-eslint/types': 8.72.1 + '@typescript-eslint/visitor-keys': 8.72.1 + debug: 4.4.3 + minimatch: 10.2.6 + semver: 7.8.5 + tinyglobby: 0.2.17 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.72.1(eslint@9.39.5)(typescript@5.9.3)': + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5) + '@typescript-eslint/scope-manager': 8.72.1 + '@typescript-eslint/types': 8.72.1 + '@typescript-eslint/typescript-estree': 8.72.1(typescript@5.9.3) + eslint: 9.39.5 + typescript: 5.9.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/visitor-keys@8.72.1': + dependencies: + '@typescript-eslint/types': 8.72.1 + eslint-visitor-keys: 5.0.1 + + acorn-jsx@5.3.2(acorn@8.19.0): + dependencies: + acorn: 8.19.0 + + acorn@8.19.0: {} + + ajv@6.15.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + argparse@2.0.1: {} + + balanced-match@1.0.2: {} + + balanced-match@4.0.4: {} + + brace-expansion@1.1.21: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@5.0.12: + dependencies: + balanced-match: 4.0.4 + + callsites@3.1.0: {} + + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + concat-map@0.0.1: {} + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + deep-is@0.1.4: {} + + escape-string-regexp@4.0.0: {} + + eslint-scope@8.4.0: + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint-visitor-keys@4.2.1: {} + + eslint-visitor-keys@5.0.1: {} + + eslint@9.39.5: + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@9.39.5) + '@eslint-community/regexpp': 4.12.2 + '@eslint/config-array': 0.21.2 + '@eslint/config-helpers': 0.4.2 + '@eslint/core': 0.17.0 + '@eslint/eslintrc': 3.3.7 + '@eslint/js': 9.39.5 + '@eslint/plugin-kit': 0.4.1 + '@humanfs/node': 0.16.8 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.3 + '@types/estree': 1.0.9 + ajv: 6.15.0 + chalk: 4.1.2 + cross-spawn: 7.0.6 + debug: 4.4.3 + escape-string-regexp: 4.0.0 + eslint-scope: 8.4.0 + eslint-visitor-keys: 4.2.1 + espree: 10.4.0 + esquery: 1.7.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + lodash.merge: 4.6.2 + minimatch: 3.1.5 + natural-compare: 1.4.0 + optionator: 0.9.4 + transitivePeerDependencies: + - supports-color + + espree@10.4.0: + dependencies: + acorn: 8.19.0 + acorn-jsx: 5.3.2(acorn@8.19.0) + eslint-visitor-keys: 4.2.1 + + esquery@1.7.0: + dependencies: + estraverse: 5.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@5.3.0: {} + + esutils@2.0.3: {} + + fast-deep-equal@3.1.3: {} + + fast-json-stable-stringify@2.1.0: {} + + fast-levenshtein@2.0.6: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + file-entry-cache@8.0.0: + dependencies: + flat-cache: 4.0.1 + + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + + flat-cache@4.0.1: + dependencies: + flatted: 3.4.4 + keyv: 4.5.4 + + flatted@3.4.4: {} + + glob-parent@6.0.2: + dependencies: + is-glob: 4.0.3 + + globals@14.0.0: {} + + has-flag@4.0.0: {} + + ignore@5.3.2: {} + + ignore@7.0.14: {} + + import-fresh@3.3.1: + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + + imurmurhash@0.1.4: {} + + is-extglob@2.1.1: {} + + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + + isexe@2.0.0: {} + + js-yaml@4.3.2: + dependencies: + argparse: 2.0.1 + + json-buffer@3.0.1: {} + + json-schema-traverse@0.4.1: {} + + json-stable-stringify-without-jsonify@1.0.1: {} + + keyv@4.5.4: + dependencies: + json-buffer: 3.0.1 + + levn@0.4.1: + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + + lodash.merge@4.6.2: {} + + minimatch@10.2.6: + dependencies: + brace-expansion: 5.0.12 + + minimatch@3.1.5: + dependencies: + brace-expansion: 1.1.21 + + ms@2.1.3: {} + + natural-compare@1.4.0: {} + + optionator@0.9.4: + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + + parent-module@1.0.1: + dependencies: + callsites: 3.1.0 + + path-exists@4.0.0: {} + + path-key@3.1.1: {} + + picomatch@4.0.7: {} + + prelude-ls@1.2.1: {} + + punycode@2.3.1: {} + + resolve-from@4.0.0: {} + + semver@7.8.5: {} + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + strip-json-comments@3.1.1: {} + + supports-color@7.2.0: + dependencies: + has-flag: 4.0.0 + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + ts-api-utils@2.5.0(typescript@5.9.3): + dependencies: + typescript: 5.9.3 + + turbo@2.11.10: + optionalDependencies: + '@turbo/darwin-64': 2.11.10 + '@turbo/darwin-arm64': 2.11.10 + '@turbo/linux-64': 2.11.10 + '@turbo/linux-arm64': 2.11.10 + '@turbo/windows-64': 2.11.10 + '@turbo/windows-arm64': 2.11.10 + + type-check@0.4.0: + dependencies: + prelude-ls: 1.2.1 + + typescript@5.9.3: {} + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + word-wrap@1.2.5: {} + + yocto-queue@0.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..939c4e9 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,12 @@ +packages: + - "apps/*" + - "packages/*" + - "tests/*" + - "tooling/*" + +# pnpm 10 blocks dependency build scripts unless allow-listed; wrangler's +# workerd and esbuild need theirs to verify their platform binaries. +onlyBuiltDependencies: + - esbuild + - workerd + - sharp diff --git a/specs/README.md b/specs/README.md new file mode 100644 index 0000000..47b5391 --- /dev/null +++ b/specs/README.md @@ -0,0 +1,14 @@ +# Spec pack + +Status: Normative index + +| Tier | Directory | What it holds | +|------|-----------|---------------| +| **Epics** | [`epics/`](./epics/) | The work programs: one epic per capability, each a directory with its `epic.yaml` declaration and the doc set (`README.md`, `design.md`, `implementation-plan.md`, `risks-and-open-questions.md`, `IMPLEMENTATION-STATUS.md`). | +| **Tasks** | [`../tasks/`](../tasks/) | One `TaskContract.yaml` per task key the epics name; the ceiling on what each pull request may touch. | + +Ground rule: trust code reality over stale docs. When a spec and the running +system disagree, the system is the source of truth and the spec is the bug. + +Status legend: `Draft` → `Ready for implementation` → `In progress` → +✅ `Shipped` · ⛔ `Blocked` · `Closed`. diff --git a/specs/epics/README.md b/specs/epics/README.md new file mode 100644 index 0000000..e13bdb6 --- /dev/null +++ b/specs/epics/README.md @@ -0,0 +1,12 @@ +# Epics + +Orun-style work programs. Each epic is a folder carrying `epic.yaml` (the +declaration the platform reads: slug, key prefix, milestones with exit +criteria and task keys) beside its doc set. The pull request that adds the +folder is the adoption; the merge creates the epic in the workspace. + +| Epic | Cluster | Status | What it is | +|------|---------|--------|------------| +| [`telegram-ai-bot/`](./telegram-ai-bot/) | **TB** | In progress (TB0) | TBXark's ChatGPT-Telegram-Workers — a multi-model Telegram bot with a Telegram Mini-App admin — on one Cloudflare Worker, Workers AI its keyless default model and its settings and history in Workers KV, and an Orun baseline that instantiates it in one landing (TB4) | + +As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/telegram-ai-bot/IMPLEMENTATION-STATUS.md b/specs/epics/telegram-ai-bot/IMPLEMENTATION-STATUS.md new file mode 100644 index 0000000..7ea7bb2 --- /dev/null +++ b/specs/epics/telegram-ai-bot/IMPLEMENTATION-STATUS.md @@ -0,0 +1,13 @@ +# telegram-ai-bot — implementation status + +| Milestone | State | Landed | +|---|---|---| +| TB0 — the spec | ✅ | TB-1 | +| TB1 — the bot on Workers | planned | TB-2 | +| TB2 — the KV namespace from Terraform | planned | TB-3 | +| TB3 — ready to instantiate | planned | TB-4 | +| TB4 — a baseline | planned | TB-5 | + +## Departures from the upstream + +Recorded as they land, from TB1 on. diff --git a/specs/epics/telegram-ai-bot/README.md b/specs/epics/telegram-ai-bot/README.md new file mode 100644 index 0000000..f405661 --- /dev/null +++ b/specs/epics/telegram-ai-bot/README.md @@ -0,0 +1,41 @@ +# telegram-ai-bot — TBXark's ChatGPT-Telegram-Workers on one Cloudflare Worker + +**The upstream is a Telegram bot made for Cloudflare Workers already: one +Worker answers Telegram's webhook, keeps its settings and every chat's +history in a KV namespace, calls whichever model API the owner configured — +OpenAI-compatible, Anthropic, the Responses API or Workers AI — streams the +reply back into the chat, and serves a Telegram Mini-App where the owner +manages it all. The port keeps that code as it is, builds it in this +workspace, makes Workers AI the model a fresh bot answers with before anyone +has a vendor key, provisions the KV namespace with Terraform, hands the bot +token to the Worker as a secret and binds the webhook after each deploy — and +the baseline makes a copy of it somebody else's in one landing.** + +| | | +|---|---| +| Status | In progress — TB0 on main | +| Upstream | [TBXark/ChatGPT-Telegram-Workers](https://github.com/TBXark/ChatGPT-Telegram-Workers) (MIT), v1.10.7 at `0d152e5` (2026-09-15) | +| Reference | [hono-api](https://github.com/sourceplane/hono-api) — a plain Worker on the `cloudflare-worker-turbo` composition and its bootstrap; [kv-redis-starter](https://github.com/sourceplane/kv-redis-starter) — a KV root and its wiring; [rag-chatbot](https://github.com/sourceplane/rag-chatbot) — Workers AI as the keyless default | +| Key | `TB` | + +## Read in this order + +1. [design.md](design.md) — what the upstream is, how each piece of its + Cloudflare deploy maps to Orun, the workspace, the default model, the + token and the webhook, and the alternatives rejected. +2. [implementation-plan.md](implementation-plan.md) — the milestones and + what each one lands. +3. [risks-and-open-questions.md](risks-and-open-questions.md) — what is not + proven, and what was accepted. +4. [IMPLEMENTATION-STATUS.md](IMPLEMENTATION-STATUS.md) — what shipped, and + every departure from the upstream. + +## Milestones + +| Milestone | What it lands | Task | +|---|---|---| +| TB0 — the spec | the repository's intent, CI, tooling and spec index; this doc set | TB-1 | +| TB1 — the bot on Workers | the upstream libraries in `packages/`, the Worker in `apps/bot`, the default model, `/health`, the webhook binding, the tests | TB-2 | +| TB2 — the KV namespace from Terraform | `infra/terraform/cloudflare-kv` and the deploy's wait on it | TB-3 | +| TB3 — ready to instantiate | the README, the as-built status | TB-4 | +| TB4 — a baseline | the console card, the build document, the context pack and the baseline's tests | TB-5 | diff --git a/specs/epics/telegram-ai-bot/design.md b/specs/epics/telegram-ai-bot/design.md new file mode 100644 index 0000000..dbf5ec2 --- /dev/null +++ b/specs/epics/telegram-ai-bot/design.md @@ -0,0 +1,112 @@ +# telegram-ai-bot — design + +## What the upstream is + +[ChatGPT-Telegram-Workers](https://github.com/TBXark/ChatGPT-Telegram-Workers) +(MIT, v1.10.7) is a Telegram bot written for Cloudflare Workers. One Worker: + +- answers Telegram's webhook at `POST /telegram//webhook` (or + `safehook`, through an optional `API_GUARD` service binding): commands + (`/new`, `/model`, `/img`, `/help`, custom commands and plugin commands), + private and group chats, replies streamed by editing the message as + tokens arrive, images from an image model; +- calls the model API the owner chose per provider — OpenAI-compatible chat + completions, Anthropic messages, the Responses API, or Workers AI (through + the Worker's `AI` binding or an account token); +- keeps everything in one KV namespace bound as `DATABASE`: the global + configuration (`config:global` — providers, their keys, settings, plugins, + custom commands) and each chat's history and state; +- serves one single-page app (built by Vite into an HTML string the Worker + returns) at `/`, `/help`, `/init`, `/admin` and `/interpolate`, whose data + comes from one JSON-RPC endpoint, `POST /rpc`. `/admin` is a Telegram + Mini-App: the owner opens it from the bot's menu button, authenticated by + Telegram's signed `initData` (or a password from a plain browser), and + manages providers, settings, plugins and commands there; +- reads four environment values: `TELEGRAM_TOKEN`, `ADMIN_ID`, + `ADMIN_PASSWORD` and the optional `TELEGRAM_SECRET_TOKEN` / `PUBLIC_BASE_URL`. + +Upstream deploys it with "Deploy to Cloudflare" (the KV namespace created, +the token asked for, `wrangler deploy`), then the owner opens `/init` and +binds the webhook by hand. It is a pnpm monorepo: `packages/lib/*` (types, +i18n, telegram, plugins, ai, config, agent, web, core), `packages/apps/workers` +(the entry), plus a Node/Vercel/Docker server and test packages. + +## How it maps to Orun + +| Upstream | Here | +|---|---| +| "Deploy to Cloudflare" creates the KV namespace | `infra/terraform/cloudflare-kv` (kv-redis-starter's root), applied per environment before the Worker deploys; the id reaches the Worker's config through the wiring document it publishes | +| `wrangler.jsonc` with `"id": "local"` filled in by hand | `apps/bot/wrangler.template.jsonc` rendered per environment by `tooling/wire` (the committed `wrangler.jsonc` is the fixture render) | +| `TELEGRAM_TOKEN`, `ADMIN_ID`, `ADMIN_PASSWORD`, `TELEGRAM_SECRET_TOKEN` set in the dashboard | optional Orun secrets (`orun secrets set … --env stage|prod`), pushed to the Worker as Worker secrets by the composition's `secrets-live` step after each deploy; none is needed for the Worker to deploy and serve | +| Open `/init` and press "bind" | the deploy's smoke binds it: `apps/bot/scripts/bind-webhook.mjs` posts to the Worker's own `/init/bind`, authenticated by the token itself, which runs upstream's bind (webhook, commands, the Mini-App menu button). With no token it is a named no-op | +| No model until the owner adds a provider in `/admin` | a built-in Workers AI provider (the `AI` binding, no key), the default for chat and images; any other provider is added in `/admin` as upstream | +| `pnpm -w run build:workers` (esbuild) | `wrangler deploy --dry-run --outdir dist` over the same entry, after turbo builds the libraries; the bundle guard (`check-bundle`) kept | +| Workers Builds deploy on push | Orun applies the namespace and deploys `-bot-{stage,prod}` on merge to `main` | +| The repository's README | `apps/bot/README.md` carries upstream's credit and licence; `apps/bot/LICENSE` is upstream's MIT licence | + +## The workspace + +The upstream libraries keep their layout and their code under `packages/` +(`@bot/types`, `@bot/i18n`, `@bot/telegram`, `@bot/plugins`, `@bot/ai`, +`@bot/config`, `@bot/agent`, `@bot/web`, `@bot/core`): each builds with +`tsc -b` as upstream (`@bot/web` with Vite), and their unit tests stay next +to their code. The scope is renamed from `@chatgpt-telegram-workers/*` so the +product's packages are its own. The Worker is `apps/bot` (`@app/bot`), the +upstream's `packages/apps/workers` entry plus the two routes the port adds. + +Node 22 and pnpm 10.12.1 (the lanes' pins) replace upstream's Node 24, pnpm 12 +and TypeScript 7: the code needs nothing either adds, and the workspace keeps +one toolchain. The Node/Vercel/Docker server, the mock packages and the +browser tests are not ported: the product runs on Workers only, and +`testing/` carries its own stand-ins. + +Orun plans by component path, so `apps/bot` declares +`change.inputs: [packages/**]` — a change to a library redeploys the Worker — +and `tests/bot`, which runs every library's tests and the port's own, does +the same for `packages/**` and `apps/bot/**`. + +## The default model + +Upstream ships no provider: a fresh bot answers nothing until the owner adds +one in `/admin`. Here the default configuration carries one Workers AI chat +provider (`@cf/meta/llama-4-scout-17b-16e-instruct`, as rag-chatbot) and one +image provider (`@cf/black-forest-labs/flux-1-schnell`), both on the `AI` +binding with no account id or token, and both the defaults. The owner can add, +reorder or remove providers in `/admin` exactly as upstream; a saved +configuration replaces the default, as any saved configuration does. + +The default language becomes English (`en`; upstream's default is `zh-cn`). + +## The token and the webhook + +The bot token is the one thing a product cannot invent. The build mints no +Telegram credential, so the Worker deploys without one: `/` and `/admin` +serve, and `GET /health` (added) answers `"telegram":"connect a bot token"`. +The owner stores `TELEGRAM_TOKEN` (and `ADMIN_ID`) as Orun secrets per +environment and re-runs the deploy (the console's Deploy button); the deploy +pushes them to the Worker as secrets, and its post-deploy smoke calls the +Worker's `POST /init/bind` with `Authorization: Bearer `. The Worker +compares the bearer to its own token in constant time and runs upstream's +bind: `setWebhook` at its own workers.dev URL, `setMyCommands`, and the +Mini-App menu button. The token never reaches a log or a command line: the +script reads it from its environment and prints only the outcome. + +Stage and prod are two Workers and need two bots (one webhook per token). + +## The smoke + +`/health` reads the KV namespace through the binding (the stored +configuration, or its absence) and answers `"kv":"ok"` with the environment's +name — only the Worker, bound to its namespace, can produce it. The smoke +asserts it after the webhook binding ran. + +## Alternatives rejected + +- **Flatten the libraries into the Worker package.** One component, but every + upstream file moves and every import changes: an upstream release could no + longer be compared file for file. +- **Bind the webhook from the script, calling Telegram directly.** It would + duplicate upstream's bind (commands, menu button, the stored public URL); + the Worker already has it. +- **A Durable Object, Queues or AI Gateway.** Upstream uses none, and Orun has + no composition for them; nothing is dropped. diff --git a/specs/epics/telegram-ai-bot/epic.yaml b/specs/epics/telegram-ai-bot/epic.yaml new file mode 100644 index 0000000..55a9735 --- /dev/null +++ b/specs/epics/telegram-ai-bot/epic.yaml @@ -0,0 +1,39 @@ +# The epic's declaration. metadata.name equals the directory name; metadata.key +# is the task-key prefix this epic reserves (TB → TB-1, TB-2, …). Owner, target +# date and health are the platform's — never written here. +apiVersion: orun.io/v1 +kind: Epic +metadata: + name: telegram-ai-bot + key: TB +spec: + title: "TBXark's ChatGPT-Telegram-Workers on one Cloudflare Worker with Workers KV and Workers AI" + summary: "TBXark's ChatGPT-Telegram-Workers — a Telegram bot that answers in private and group chats with any of several model APIs, streams its replies, draws images, runs custom commands and plugins, and is configured from a Telegram Mini-App admin page — runs as one Cloudflare Worker deployed by Orun, its settings and chat history in a Workers KV namespace Terraform provisions per environment, Workers AI its keyless default model through the Worker's own AI binding, and the bot token an optional Orun secret the deploy hands to the Worker and binds to Telegram's webhook. Then it becomes an Orun baseline that takes a new bot from nothing to live on stage and prod in one landing." + state: started + milestones: + - name: "TB0 — the spec" + exitCriteria: + - "the repository has its intent, CI, tooling and spec index, and this doc set and the task contracts are on main" + tasks: [TB-1] + - name: "TB1 — the bot on Workers" + exitCriteria: + - "apps/bot is the upstream Workers entry over the upstream libraries in packages/, built by wrangler into one Worker that loads as dependency-free ESM" + - "with no bot token the Worker serves its home page, its admin page and /health, which says to connect a bot token; with one, a Telegram update posted to its webhook is answered" + - "Workers AI answers through the AI binding when no vendor key is configured, and the admin page adds any other provider as upstream does" + - "`pnpm typecheck`, `pnpm lint`, `pnpm test` and `pnpm build` are green" + tasks: [TB-2] + - name: "TB2 — the KV namespace from Terraform" + exitCriteria: + - "infra/terraform/cloudflare-kv provisions the stage and prod namespaces and publishes the wiring document the Worker's config renders from; the deploy waits for it" + tasks: [TB-3] + - name: "TB3 — ready to instantiate" + exitCriteria: + - "the README says how to run, test, connect a bot and deploy it, and how every piece maps from the upstream's Cloudflare deploy" + - "the as-built status records every departure from the upstream" + tasks: [TB-4] + - name: "TB4 — a baseline" + exitCriteria: + - "blueprint.yaml (the console card) and repo-blueprint.yaml (the build) take a new bot from nothing to live on stage and prod in one landing, then record it" + - "a product built from it carries the product only, renamed throughout to its own name, repository, Worker and namespace names, with the upstream's MIT licence intact" + - "Baseline CI is green: contract tests, generated component docs, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the end-to-end tier — the stage lanes' steps in staged job trees, the Worker served with no token and against a stand-in Telegram API and model API" + tasks: [TB-5] diff --git a/specs/epics/telegram-ai-bot/implementation-plan.md b/specs/epics/telegram-ai-bot/implementation-plan.md new file mode 100644 index 0000000..a1eac4a --- /dev/null +++ b/specs/epics/telegram-ai-bot/implementation-plan.md @@ -0,0 +1,48 @@ +# telegram-ai-bot — implementation plan + +## TB0 — the spec (TB-1) + +The repository's frame on top of its first README commit: hono-api's intent +(with kv-redis-starter's per-environment Terraform parameters), CI (turso-starter's +`ci.yml`, byte for byte but for the one credential comment), the shared +TypeScript, ESLint, wiring and catalog tooling, the pnpm workspace and turbo +pipeline, the spec index; this doc set and the five task contracts. + +## TB1 — the bot on Workers (TB-2) + +1. The upstream libraries (at `0d152e5`) into `packages/`, scope `@bot/*`, + built by `tsc -b` (`@bot/web` by Vite into its HTML string module), their + tests beside them. +2. `apps/bot`: the upstream Workers entry, `/health`, `/init/bind`; the + wrangler template (the `DATABASE` KV namespace from the `cloudflare-kv` + wiring, the `AI` binding, per-environment vars), the fixture and its + committed render; the build (`wrangler deploy --dry-run`) and the bundle + guard; the component on `cloudflare-worker-turbo` with the optional + secrets and the post-deploy binding. +3. The defaults: a Workers AI chat and image provider, English. +4. `tests/bot`: every library's tests, and the port's own — the health route + with and without a token, the bind route's authentication, the default + providers, the bind script. + +## TB2 — the KV namespace from Terraform (TB-3) + +kv-redis-starter's `infra/terraform/cloudflare-kv` root, renamed, adopting a +namespace of the same title; `apps/bot` waits on it (enforced on a push to +main, advisory on a pull request) and resolves its wiring document per +environment. + +## TB3 — ready to instantiate (TB-4) + +The README: what it is, how it runs, tests, connects a bot and deploys, how +each upstream piece maps here; the as-built status. + +## TB4 — a baseline (TB-5) + +The card (one Cloudflare provider; the bot token connected after the build), +the build document (one landing, then the record), the identity and the rename +seam (`BOT_NAME`), the context pack, the deployment record probing `/health`, +and the baseline's tests: contract tiers, generated component docs, the leak +gate, placement, the offline bootstrap, and the e2e — the stage lanes in +staged job trees, the Worker served with no token, then with one, bound and +answering an update against stand-in Telegram and model APIs. Then +`baseline-v1`. diff --git a/specs/epics/telegram-ai-bot/risks-and-open-questions.md b/specs/epics/telegram-ai-bot/risks-and-open-questions.md new file mode 100644 index 0000000..9ff311d --- /dev/null +++ b/specs/epics/telegram-ai-bot/risks-and-open-questions.md @@ -0,0 +1,13 @@ +# telegram-ai-bot — risks and open questions + +| ID | Risk | State | Notes | +|---|---|---|---| +| TB-A | `baseline-v1` is not yet proven live: the namespace's apply and its wiring publish, the deploy, the secrets push and the workers.dev probes | OPEN | Proven offline in Baseline CI. One bootstrap from the tag closes it | +| TB-B | Telegram itself is unproven here: `setWebhook`, `setMyCommands`, the menu button and real updates | OPEN | Exercised against a stand-in Telegram API that refuses any token but the bot's; one connected bot closes it | +| TB-C | Workers AI is unproven offline: `wrangler dev` cannot reach it without an account | OPEN | The e2e answers through a stand-in OpenAI-compatible provider configured in `/admin`'s own RPC; the binding provider is held to upstream's unit tests | +| TB-D | Stage and prod need two bot tokens | ACCEPTED | One webhook per token: the second bind would move the first environment's webhook | +| TB-E | The webhook URL carries the token (upstream's design) | ACCEPTED | As upstream; `TELEGRAM_SECRET_TOKEN` adds Telegram's secret header check | +| TB-F | `POST /init/bind` accepts the bot token as a bearer | ACCEPTED | Whoever holds the token can bind the webhook through Telegram already; compared in constant time, and refused when the Worker has no token | +| TB-G | Chat history is kept in KV with no expiry, as upstream | ACCEPTED | `/new` clears a chat; Workers Free allows 1,000 KV writes a day | +| TB-H | A token removed from Orun stays on the Worker | ACCEPTED | The deploy pushes the secrets that exist and deletes none; `wrangler secret delete` removes one | +| TB-I | Upstream's toolchain is Node 24, pnpm 12, TypeScript 7 | ACCEPTED | Built and tested here on Node 22, pnpm 10.12.1 and TypeScript 5.8 | diff --git a/tasks/TB-1.TaskContract.yaml b/tasks/TB-1.TaskContract.yaml new file mode 100644 index 0000000..0d3d6d2 --- /dev/null +++ b/tasks/TB-1.TaskContract.yaml @@ -0,0 +1,18 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TB-1 + title: "The spec" +spec: + goal: The repository has its intent, CI, tooling and spec index, and the telegram-ai-bot epic — declaration, doc set and task contracts — is on main + affects: + - intent.yaml + - .github/workflows/ci.yml + - tooling + - specs + - tasks + - README.md + doneWhen: + - epic.yaml, README, design, implementation plan, risks and status are merged + - the five task contracts exist + gates: [] diff --git a/tasks/TB-2.TaskContract.yaml b/tasks/TB-2.TaskContract.yaml new file mode 100644 index 0000000..68b701e --- /dev/null +++ b/tasks/TB-2.TaskContract.yaml @@ -0,0 +1,18 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TB-2 + title: "The bot on Workers" +spec: + goal: ChatGPT-Telegram-Workers runs as one Cloudflare Worker built in this workspace — the upstream libraries in packages/, the Worker in apps/bot, Workers AI its default model, /health and the webhook binding added — with its tests + affects: + - apps/bot + - packages + - tests/bot + - pnpm-lock.yaml + - pnpm-workspace.yaml + - package.json + doneWhen: + - pnpm typecheck, lint, test and build are green, and the bundle is dependency-free ESM + - wrangler dev serves the home and admin pages and /health with no token, and with one answers an update posted to its webhook + gates: [] diff --git a/tasks/TB-3.TaskContract.yaml b/tasks/TB-3.TaskContract.yaml new file mode 100644 index 0000000..9698093 --- /dev/null +++ b/tasks/TB-3.TaskContract.yaml @@ -0,0 +1,13 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TB-3 + title: "The KV namespace from Terraform" +spec: + goal: The KV namespace the bot binds as DATABASE is provisioned per environment by Terraform, its id published as a wiring document the Worker's config renders from, and the deploy waits for it + affects: + - infra/terraform/cloudflare-kv + - apps/bot/component.yaml + doneWhen: + - the root validates and its wiring keys match the template's tokens + gates: [] diff --git a/tasks/TB-4.TaskContract.yaml b/tasks/TB-4.TaskContract.yaml new file mode 100644 index 0000000..8b6676c --- /dev/null +++ b/tasks/TB-4.TaskContract.yaml @@ -0,0 +1,15 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TB-4 + title: "Ready to instantiate" +spec: + goal: A reader can run, test, connect a bot to and deploy telegram-ai-bot from its README, and the as-built status records every departure from the upstream + affects: + - README.md + - apps/bot/README.md + - specs/epics/telegram-ai-bot + doneWhen: + - the README says how to run, test, connect a bot and deploy, and maps every upstream piece + - IMPLEMENTATION-STATUS.md lists the departures + gates: [] diff --git a/tasks/TB-5.TaskContract.yaml b/tasks/TB-5.TaskContract.yaml new file mode 100644 index 0000000..8f5cb9d --- /dev/null +++ b/tasks/TB-5.TaskContract.yaml @@ -0,0 +1,23 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TB-5 + title: "A baseline" +spec: + goal: telegram-ai-bot becomes an Orun baseline that takes a new bot from nothing to live on stage and prod in one landing, then records it + affects: + - blueprint.yaml + - repo-blueprint.yaml + - BOOTSTRAP.md + - .baseline + - docs/phases + - hooks + - testing + - tooling/rebrand + - tooling/bootstrap + - ai/context + - .github/workflows/baseline.yml + - .github/workflows/tag.yml + doneWhen: + - Baseline CI is green — contract tests, generated component docs, the blueprint read by the pinned orun, the leak gate, placement and e2e + gates: [] diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py new file mode 100644 index 0000000..743782b --- /dev/null +++ b/tooling/catalog/gen-component-docs.py @@ -0,0 +1,550 @@ +#!/usr/bin/env python3 +"""Generate each component's docs (overview / architecture / runbook). + + python3 tooling/catalog/gen-component-docs.py # write + python3 tooling/catalog/gen-component-docs.py --check # fail on drift (CI) + +Every `component.yaml` attaches its `docs/` folder in `spec.docs` (overview, +architecture, runbook), which is what the Orun workspace's Docs library shows +and what the catalog's docs and runbook checks read; a folder nothing declares +is never attached (testing/coverage.test.sh holds the rule). These pages are +generated, not hand-written, because almost +everything in them is already declared somewhere CI validates: the component's +manifest (type, description, dependencies, environments, the secrets a lane +resolves, the smoke), its Worker config (bindings, triggers, the wiring the +deploy fills in), its Terraform (resources and outputs), its migrations and its +package scripts. A hand-written copy of those facts drifts the first time one +changes; a generated one cannot, because `--check` fails the pull request that +changes the fact without the page. + +What is NOT derivable (why a component exists, what a failure means for this +product in particular) belongs in the component's `description` and in the +product's own docs, not here. + +The pages ship with the component into every product built from this tree, so +they say nothing about where they came from: no factory paths, no generator +path, no provenance. Zero dependencies beyond PyYAML. +""" + +from __future__ import annotations + +import json +import pathlib +import re +import sys + +try: + import yaml +except ImportError: # pragma: no cover - the contract job installs it + sys.exit("gen-component-docs needs PyYAML (pip install pyyaml)") + +ROOT = pathlib.Path(__file__).resolve().parents[2] +ROOTS = ("apps", "packages", "infra", "tests") +SKIP_DIRS = {"node_modules", "dist", ".turbo", "docs", ".next", ".open-next", + ".wrangler", ".svelte-kit", ".nuxt", ".output", ".astro", "coverage"} + +# Paths a shipped page must never name: products are not placed with them. +FACTORY = re.compile( + r"repo-blueprint|BOOTSTRAP\.md|(? str: + """JSONC → JSON: drop comments outside strings, then trailing commas.""" + out, i, n, in_str = [], 0, len(text), False + while i < n: + c = text[i] + if in_str: + out.append(c) + if c == "\\" and i + 1 < n: + out.append(text[i + 1]) + i += 2 + continue + if c == '"': + in_str = False + i += 1 + continue + if c == '"': + in_str = True + out.append(c) + i += 1 + elif text.startswith("//", i): + j = text.find("\n", i) + i = n if j < 0 else j + elif text.startswith("/*", i): + j = text.find("*/", i + 2) + i = n if j < 0 else j + 2 + else: + out.append(c) + i += 1 + return re.sub(r",(\s*[}\]])", r"\1", "".join(out)) + + +def read_json(path: pathlib.Path) -> dict | None: + try: + return json.loads(strip_jsonc(path.read_text(encoding="utf-8"))) + except (OSError, ValueError): + return None + + +def rel(p: pathlib.Path) -> str: + return p.relative_to(ROOT).as_posix() + + +def discover() -> list[dict]: + found = [] + for root in ROOTS: + base = ROOT / root + if not base.is_dir(): + continue + stack = [base] + while stack: + d = stack.pop() + for entry in sorted(d.iterdir()): + if entry.is_dir(): + if entry.name in SKIP_DIRS or entry.name.startswith("."): + continue + if (entry / "main.tf").exists() and not (entry / "component.yaml").exists(): + continue + if len(entry.relative_to(base).parts) <= 3: + stack.append(entry) + elif entry.name == "component.yaml": + found.append(read_component(entry)) + comps = [c for c in found if c["name"] and c["type"]] + return sorted(comps, key=lambda c: c["name"]) + + +def read_component(file: pathlib.Path) -> dict: + doc = yaml.safe_load(file.read_text(encoding="utf-8")) or {} + meta, spec = doc.get("metadata") or {}, doc.get("spec") or {} + params = spec.get("parameters") or {} + deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] + envs = [] + # Secrets may be declared for the whole component or per environment + # (`subscribe.environments[].secretEnv`); a page lists both. + req_env = set((spec.get("secretEnv") or {}).keys()) + opt_env = set((spec.get("optionalSecretEnv") or {}).keys()) + for e in ((spec.get("subscribe") or {}).get("environments") or []): + req_env |= set((e.get("secretEnv") or {}).keys()) + opt_env |= set((e.get("optionalSecretEnv") or {}).keys()) + rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) + for r in (e.get("profileRules") or [])] + envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) + return { + "dir": file.parent, + "path": rel(file.parent), + "name": meta.get("name"), + "description": (meta.get("description") or "").strip(), + "type": spec.get("type"), + "deps": [d for d in deps if d], + "secret_env": sorted(req_env), + "optional_env": sorted(opt_env - req_env), + "envs": envs, + "params": params, + "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, + } + + +def package_of(c: dict) -> dict | None: + return read_json(c["dir"] / "package.json") + + +def worker_config(c: dict) -> tuple[str | None, dict | None]: + """The config a deploy uses: the template when wiring renders one.""" + names = ["wrangler.template.jsonc", c["params"].get("wranglerConfig") or "", + "wrangler.jsonc", "wrangler.json"] + for name in names: + if name and (c["dir"] / name).is_file(): + return name, read_json(c["dir"] / name) + return None, None + + +WIRING = re.compile(r"@@wiring\(([^/)]+)/__ENV__:([^)]+)\)@@") + + +def wired(value) -> str | None: + m = WIRING.search(str(value)) if value is not None else None + return f"`{m.group(2)}` from `{m.group(1)}`" if m else None + + +def bindings(cfg: dict) -> list[tuple[str, str, str]]: + rows = [] + for kv in cfg.get("kv_namespaces") or []: + rows.append((kv.get("binding"), "Workers KV namespace", wired(kv.get("id")) or "declared in the config")) + for b in cfg.get("r2_buckets") or []: + rows.append((b.get("binding"), "R2 bucket", wired(b.get("bucket_name")) or f"`{b.get('bucket_name')}`")) + for d in cfg.get("d1_databases") or []: + rows.append((d.get("binding"), "D1 database", wired(d.get("database_id")) or "declared in the config")) + for h in cfg.get("hyperdrive") or []: + rows.append((h.get("binding"), "Hyperdrive (pooled Postgres)", wired(h.get("id")) or "declared in the config")) + if isinstance(cfg.get("ai"), dict) and cfg["ai"].get("binding"): + rows.append((cfg["ai"]["binding"], "Workers AI", "account-level; no resource to provision")) + for d in ((cfg.get("durable_objects") or {}).get("bindings") or []): + rows.append((d.get("name"), "Durable Object", f"class `{d.get('class_name')}`")) + for s in cfg.get("services") or []: + rows.append((s.get("binding"), "Service binding", f"Worker `{s.get('service')}`")) + for q in ((cfg.get("queues") or {}).get("producers") or []): + rows.append((q.get("binding"), "Queue producer", f"queue `{q.get('queue')}`")) + for r in cfg.get("ratelimits") or []: + simple = r.get("simple") or {} + rows.append((r.get("name"), "Rate limiter", + f"{simple.get('limit')} requests / {simple.get('period')}s per location")) + assets = cfg.get("assets") or {} + if assets.get("binding"): + rows.append((assets["binding"], "Static assets", f"`{assets.get('directory')}`")) + return [r for r in rows if r[0]] + + +def tf_facts(c: dict) -> dict: + tf_dir = c["dir"] / (c["params"].get("terraformDir") or "terraform") + resources, outputs, variables, backend = [], [], [], None + for f in sorted(tf_dir.glob("*.tf")) if tf_dir.is_dir() else []: + text = f.read_text(encoding="utf-8") + resources += [f"{t}.{n}" for t, n in re.findall(r'^resource\s+"([^"]+)"\s+"([^"]+)"', text, re.M)] + outputs += re.findall(r'^output\s+"([^"]+)"', text, re.M) + variables += re.findall(r'^variable\s+"([^"]+)"', text, re.M) + m = re.search(r'backend\s+"([^"]+)"', text) + backend = backend or (m.group(1) if m else None) + imports = (tf_dir / "adopt.tf").is_file() if tf_dir.is_dir() else False + return {"dir": rel(tf_dir) if tf_dir.is_dir() else None, "resources": resources, + "outputs": outputs, "variables": variables, "backend": backend, "adopt": imports} + + +def published(c: dict) -> list[tuple[str, str]]: + spec = c["params"].get("secretOutputs") or "" + pairs = [] + for part in str(spec).split(","): + if "=" in part: + k, v = part.split("=", 1) + pairs.append((k.strip(), v.strip())) + return pairs + + +def test_files(c: dict) -> list[str]: + out = [] + for p in sorted(c["dir"].rglob("*")): + if any(part in SKIP_DIRS for part in p.relative_to(c["dir"]).parts): + continue + if p.is_file() and re.search(r"\.(test|spec)\.(ts|tsx|js|mjs|cjs)$", p.name): + out.append(p.name) + return out + + +def migrations(c: dict) -> list[str]: + path = c["migrations_path"] + if not path: + return [] + d = ROOT / path + if not d.is_dir(): + return [] + return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") + + +# ── markdown ───────────────────────────────────────────────────────────── + +def md_table(header: list[str], rows: list[list[str]]) -> list[str]: + """A table laid out the way prettier lays it out, so a repo whose lint is + `prettier --check` accepts the page as written.""" + cols = len(header) + width = [max(3, len(header[i]), *(len(r[i]) for r in rows)) for i in range(cols)] + def line(cells): + return "| " + " | ".join(c.ljust(width[i]) for i, c in enumerate(cells)) + " |" + return [line(header), "| " + " | ".join("-" * w for w in width) + " |", *(line(r) for r in rows)] + + +# ── phrasing ───────────────────────────────────────────────────────────── + +KIND = { + "cloudflare-worker-turbo": "A Cloudflare Worker, deployed per environment by its CI lane.", + "cloudflare-workers-assets-turbo": "A Cloudflare Worker with Static Assets (server rendering plus " + "static files), deployed per environment by its CI lane.", + "terraform": "Terraform-managed infrastructure, planned and applied per environment by its CI lane.", + "db-migrate": "Applies this repository's ordered database migrations per environment: " + "plan on pull requests, apply on merge to `main`.", + "turbo-package": "A workspace package built by the turbo pipeline. It deploys nothing itself: " + "its lane type-checks, lints, tests and builds it.", +} + +TRIGGER = {"github-push-main": "a push to `main`", "github-pull-request": "a pull request"} + + +def env_line(e: dict) -> str: + s = f"`{e['name']}`: `{e['profile']}`" + for profile, ref in e["rules"]: + s += f", `{profile}` on {TRIGGER.get(ref, f'`{ref}`')}" + return s + + +def is_tests(c: dict) -> bool: + return c["name"].endswith("-tests") or c["path"].startswith("tests/") + + +def subject_of(c: dict, by_name: dict) -> str | None: + if c["name"].endswith("-tests"): + s = c["name"][: -len("-tests")] + return s if s in by_name else None + return None + + +def names_list(c: dict, keep) -> list[str]: + """Secret names a lane resolves, required first; an optional one (from + `optionalSecretEnv`) is resolved when it exists and skipped when not.""" + req = [f"- `{k}`" for k in c["secret_env"] if keep(k)] + opt = [f"- `{k}` (optional)" for k in c["optional_env"] if keep(k)] + return req + opt + + +def bullet_list(names: list[str], by_name: dict) -> list[str]: + if not names: + return ["- (none)"] + out = [] + for n in names: + d = by_name.get(n) + out.append(f"- **{n}** — {d['description']}" if d and d["description"] else f"- **{n}**") + return out + + +# ── pages ──────────────────────────────────────────────────────────────── + +def overview(c: dict, by_name: dict, dependents: list[str]) -> str: + pkg = package_of(c) + kind = KIND.get(c["type"], f"A `{c['type']}` component.") + subject = subject_of(c, by_name) + if is_tests(c): + kind = (f"The test suite for **{subject}**. " if subject else "A test suite. ") + \ + "It deploys nothing: its lane installs, builds and runs the tests." + lines = [f"# {c['name']}", ""] + if c["description"]: + lines += [c["description"], ""] + facts = [["Type", f"`{c['type']}`"], ["Source", f"`{c['path']}`"]] + if pkg and pkg.get("name"): + facts.append(["Package", f"`{pkg['name']}`"]) + if c["envs"]: + facts.append(["Environments", " · ".join(env_line(e) for e in c["envs"])]) + lines += [kind, "", *md_table(["", ""], facts)] + lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), + "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] + return "\n".join(lines) + + +def architecture(c: dict, by_name: dict) -> str: + lines = [f"# {c['name']} — architecture", ""] + t = c["type"] + + if t == "terraform": + f = tf_facts(c) + lines += [f"A `terraform` root at `{f['dir'] or c['path']}`.", ""] + if f["backend"] == "http": + lines += ["- **State** lives in the Orun Cloud HTTP state backend — no local state and", + " no state bucket to manage."] + lines += ["- **Credentials are brokered per run** from the workspace's provider", + " connections and resolved by name; none is stored in this repository."] + if f["adopt"]: + lines += ["- **Adoption** (`adopt.tf`): when state is empty but the resource already", + " exists, plan-time import adopts it instead of failing."] + lines.append("") + if f["resources"]: + lines += ["## Resources", "", *[f"- `{r}`" for r in f["resources"]], ""] + pub = published(c) + if pub: + lines += ["## Published outputs", "", + "Written as job-output secrets on each environment after an apply; deploy", + "lanes downstream resolve them by name.", "", + *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] + elif f["outputs"]: + lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] + return "\n".join(lines) + + if t == "db-migrate": + migs = migrations(c) + lines += [f"Applies the migrations under `{c['migrations_path']}` in order, recording each one", + "it applies so a run only ever applies what is new. An already-applied migration", + "is never edited: a change is a new, later migration.", ""] + if migs: + lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] + return "\n".join(lines) + + pkg = package_of(c) + if t.startswith("cloudflare-"): + cfg_name, cfg = worker_config(c) + lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] + if cfg: + facts = [["Worker config", f"`{c['path']}/{cfg_name}`"]] + if cfg.get("main"): + facts.append(["Entry", f"`{cfg['main']}`"]) + if cfg.get("compatibility_date"): + facts.append(["Compatibility date", f"`{cfg['compatibility_date']}`"]) + if cfg.get("compatibility_flags"): + facts.append(["Compatibility flags", ", ".join(f"`{x}`" for x in cfg["compatibility_flags"])]) + lines += [*md_table(["", ""], facts), ""] + rows = bindings(cfg) + lines += ["## Bindings", ""] + if rows: + lines += [*md_table(["Binding", "Kind", "Source"], [[f"`{b}`", k, s] for b, k, s in rows]), ""] + if any("from `" in s for _, _, s in rows): + lines += ["Identifiers marked _from_ a component are filled in at deploy time from", + "that component's published outputs for the environment being deployed.", ""] + else: + lines += ["None: the Worker binds no storage or service.", ""] + crons = (cfg.get("triggers") or {}).get("crons") or [] + if crons: + lines += ["## Scheduled triggers", "", *[f"- `{x}`" for x in crons], ""] + env_names = sorted((cfg.get("env") or {}).keys()) + var_names = sorted((cfg.get("vars") or {}).keys()) + if var_names: + lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." + if env_names else "."), ""] + wiring = names_list(c, lambda k: k.startswith("WIRING_")) + others = names_list(c, lambda k: not k.startswith("WIRING_")) + if wiring: + lines += ["## Wiring", "", + "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", + "", *wiring, ""] + if others: + lines += ["## Secrets resolved by the lane (names only)", "", *others, ""] + return "\n".join(lines) + + # turbo-package + if is_tests(c): + files = test_files(c) + lines += [f"A test package at `{c['path']}`. Its lane runs the suite before it builds.", ""] + if files: + lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] + return "\n".join(lines) + lines += [f"A workspace package at `{c['path']}`, consumed by the components that depend", + "on it. It has no deployed surface of its own.", ""] + if pkg and pkg.get("exports"): + ex = pkg["exports"] + keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] + lines += ["## Exports", "", *[f"- `{k}`" for k in keys], ""] + return "\n".join(lines) + + +def runbook(c: dict, by_name: dict) -> str: + t = c["type"] + pkg = package_of(c) + lines = [f"# {c['name']} — runbook", "", "## How it runs", ""] + deploys = [e["name"] for e in c["envs"] + if any(ref == "github-push-main" for _, ref in e["rules"])] + if deploys and t in ("terraform", "db-migrate"): + lines += [f"Pull requests plan it; a merge to `main` applies it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + elif deploys: + lines += [f"Pull requests verify it; a merge to `main` deploys it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + else: + lines += ["Its lane runs on every pull request that changes it; it has no deployed surface."] + lines += ["CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;", + "the plan orders a component after everything it depends on.", ""] + + if pkg and pkg.get("scripts"): + name = pkg.get("name") + wanted = [s for s in ("dev", "build", "test", "typecheck", "lint", "preview") if s in pkg["scripts"]] + if name and wanted: + lines += ["## Local commands", "", "```bash", + *[f"pnpm --filter {name} {s}" for s in wanted], "```", ""] + + smoke = c["params"].get("smokeCommand") + if smoke and "No smoke" not in str(smoke): + lines += ["## Verify", "", "After a deploy the lane runs this smoke against the environment it", + "deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:", "", + "```bash", str(smoke).strip(), "```", ""] + + lines += ["## Rollback", "", + "Revert the commit on `main`. The next convergence applies the previous desired", + "state; nothing was changed out of band, so there is nothing else to undo.", "", + "## Common failures", ""] + if t == "terraform": + lines += ["- **Provider authentication fails**: the workspace's provider connection is", + " missing or revoked. Reconnect it in the console; credentials are brokered", + " from it per run.", + "- **\"Already exists\" on a first apply**: state is empty but the resource is", + " not." + (" `adopt.tf` imports it at plan time; if it still fails, the resource" + " was renamed outside Terraform." if tf_facts(c)["adopt"] else + " Import it, or delete the stray resource, then re-run."), ""] + elif t == "db-migrate": + lines += ["- **An applied migration's file changed**: the run stops rather than guess.", + " Restore the file and write the change as a new migration.", + "- **The database is unreachable**: the infrastructure lane it depends on has", + " not applied for this environment; that lane runs first in a convergence.", ""] + elif t.startswith("cloudflare-"): + _, cfg = worker_config(c) + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"] + c["optional_env"]) or \ + bool(cfg and WIRING.search(json.dumps(cfg))) + if takes_wiring: + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane."] + lines += ["- **The smoke fails right after a first deploy**: a new workers.dev route can", + " answer 4xx for a few seconds and the lane retries. A failure that persists", + " is a regression in the deployed code.", ""] + else: + lines += ["- **A dependent fails to build after a change here**: run `pnpm typecheck`", + " across the workspace before merging.", ""] + return "\n".join(lines) + + +# ── main ───────────────────────────────────────────────────────────────── + +def main() -> int: + check = "--check" in sys.argv[1:] + comps = discover() + if not comps: + print("no component.yaml found", file=sys.stderr) + return 1 + by_name = {c["name"]: c for c in comps} + dependents: dict[str, list[str]] = {c["name"]: [] for c in comps} + for c in comps: + for d in c["deps"]: + dependents.setdefault(d, []).append(c["name"]) + + drifted, written, leaks = [], 0, [] + for c in comps: + pages = { + "overview.md": overview(c, by_name, sorted(dependents.get(c["name"], []))), + "architecture.md": architecture(c, by_name), + "runbook.md": runbook(c, by_name), + } + for fname, body in pages.items(): + target = c["dir"] / "docs" / fname + for n, line in enumerate(body.splitlines(), 1): + m = FACTORY.search(line) + if m: + leaks.append(f"{rel(target)}:{n} would name {m.group(0)!r}") + current = target.read_text(encoding="utf-8") if target.exists() else None + if current == body: + continue + if check: + drifted.append(rel(target)) + continue + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(body, encoding="utf-8") + written += 1 + + if leaks: + print("✗ a generated page would name a path products do not have:", file=sys.stderr) + for l in leaks: + print(f" {l}", file=sys.stderr) + return 1 + if check: + if drifted: + print(f"✗ {len(drifted)} component doc(s) differ from what the manifests say:", file=sys.stderr) + for f in drifted: + print(f" {f}", file=sys.stderr) + print("\nRun: python3 tooling/catalog/gen-component-docs.py", file=sys.stderr) + return 1 + print(f"✓ component docs match {len(comps)} component.yaml file(s)") + return 0 + print(f"✓ wrote {written} page(s) for {len(comps)} component(s)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tooling/eslint/index.js b/tooling/eslint/index.js new file mode 100644 index 0000000..a4210a6 --- /dev/null +++ b/tooling/eslint/index.js @@ -0,0 +1,31 @@ +// @ts-check +import tsPlugin from "@typescript-eslint/eslint-plugin"; +import tsParser from "@typescript-eslint/parser"; + +/** @type {import('eslint').Linter.FlatConfig[]} */ +const config = [ + { + files: ["**/*.ts", "**/*.tsx"], + plugins: { + "@typescript-eslint": tsPlugin, + }, + languageOptions: { + parser: tsParser, + parserOptions: { + ecmaVersion: 2022, + sourceType: "module", + ecmaFeatures: { jsx: true }, + }, + }, + rules: { + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], + "@typescript-eslint/no-explicit-any": "warn", + "no-console": ["warn", { allow: ["warn", "error"] }], + }, + }, + { + ignores: ["dist/**", ".next/**", ".open-next/**", ".wrangler/**", "coverage/**", "*.tsbuildinfo"], + }, +]; + +export default config; diff --git a/tooling/eslint/package.json b/tooling/eslint/package.json new file mode 100644 index 0000000..6ac3900 --- /dev/null +++ b/tooling/eslint/package.json @@ -0,0 +1,13 @@ +{ + "name": "@app/eslint-config", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "index.js", + "license": "MIT", + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^8.32.0", + "@typescript-eslint/parser": "^8.32.0", + "eslint": "^9.27.0" + } +} diff --git a/tooling/tsconfig/base.json b/tooling/tsconfig/base.json new file mode 100644 index 0000000..0082914 --- /dev/null +++ b/tooling/tsconfig/base.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "bundler", + "lib": ["ES2022"], + "strict": true, + "noUncheckedIndexedAccess": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "isolatedModules": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "composite": true, + "incremental": true + } +} diff --git a/tooling/tsconfig/package.json b/tooling/tsconfig/package.json new file mode 100644 index 0000000..d1eb243 --- /dev/null +++ b/tooling/tsconfig/package.json @@ -0,0 +1,7 @@ +{ + "name": "@app/tsconfig", + "version": "0.0.0", + "private": true, + "files": ["*.json"], + "license": "MIT" +} diff --git a/tooling/tsconfig/web.json b/tooling/tsconfig/web.json new file mode 100644 index 0000000..b54564c --- /dev/null +++ b/tooling/tsconfig/web.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./base.json", + "compilerOptions": { + "lib": ["ES2022", "DOM", "DOM.Iterable"] + } +} diff --git a/tooling/tsconfig/worker.json b/tooling/tsconfig/worker.json new file mode 100644 index 0000000..28b9842 --- /dev/null +++ b/tooling/tsconfig/worker.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./base.json", + "compilerOptions": { + "lib": ["ES2022", "WebWorker"], + "types": ["@cloudflare/workers-types"] + } +} diff --git a/tooling/wire/live.mjs b/tooling/wire/live.mjs new file mode 100644 index 0000000..6045445 --- /dev/null +++ b/tooling/wire/live.mjs @@ -0,0 +1,91 @@ +#!/usr/bin/env node +// Deploy-time wiring for deployables whose composition has no wire-live step +// (cloudflare-workers-assets-turbo). Reads the wiring documents the infra +// components lease-publish — WIRING__ in the job env, each a +// JSON document — into a temp dir and renders the wrangler template with +// render.mjs. Fails loudly on any unresolved token. +// +// node live.mjs --template wrangler.template.jsonc --out wrangler.jsonc \ +// --components cloudflare-kv,cloudflare-r2 --env stage \ +// [--fixture wiring.fixture.json --fixture-envs dev] +// +// A VERIFY-ONLY ENVIRONMENT HAS NO WIRING DOCUMENT. `dev` deploys nothing and +// no infra component applies there, so nothing ever publishes +// WIRING__DEV; its lane still builds and dry-deploys the Worker. +// `--fixture-envs` names those environments, and for them — only them — a +// missing document renders from the committed fixture instead. Every other +// environment needs the real document: a deploy job resolves it before its +// first step (the component's secretEnv), so a missing one here is a real +// fault, never a reason to deploy a placeholder id. +import * as fs from "node:fs"; +import * as os from "node:os"; +import * as path from "node:path"; +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; + +function arg(name) { + const i = process.argv.indexOf(`--${name}`); + return i >= 0 ? process.argv[i + 1] : undefined; +} + +const template = arg("template"); +const out = arg("out"); +const components = (arg("components") ?? "").split(",").filter(Boolean); +const env = arg("env"); +const envs = (arg("envs") ?? env ?? "stage,prod").split(",").filter(Boolean); +const fixture = arg("fixture"); +const fixtureEnvs = new Set((arg("fixture-envs") ?? "").split(",").filter(Boolean)); +if (!template || !out || components.length === 0 || (fixtureEnvs.size > 0 && !fixture)) { + console.error( + "usage: live.mjs --template --out --components a,b (--env stage | --envs stage,prod) [--fixture --fixture-envs dev]", + ); + process.exit(2); +} + +const fixtureMap = fixture ? JSON.parse(fs.readFileSync(fixture, "utf8")) : {}; +const dir = fs.mkdtempSync(path.join(os.tmpdir(), "wiring-")); +const missing = []; +const fromFixture = []; +for (const component of components) { + for (const env of envs) { + const key = `WIRING_${component.toUpperCase().replace(/-/g, "_")}_${env.toUpperCase()}`; + let value = process.env[key]; + if (!value && fixtureEnvs.has(env) && fixtureMap[`${component}/${env}`]) { + value = JSON.stringify(fixtureMap[`${component}/${env}`]); + fromFixture.push(`${component}/${env}`); + } + if (!value) { + missing.push(key); + continue; + } + fs.writeFileSync(path.join(dir, `${component}__${env}.json`), value); + } +} +if (missing.length > 0) { + console.error("wire: missing wiring documents in the environment:"); + for (const m of missing) console.error(` ${m}`); + fs.rmSync(dir, { recursive: true, force: true }); + process.exit(1); +} +for (const f of fromFixture) { + console.log(`wire: ${f} is verify-only — rendered from ${path.basename(fixture)}, not a published document`); +} + +// A single-environment render (the workers-assets composition deploys one +// environment per job, with no wrangler `--env`): `__ENV__` in the template +// becomes that environment before the wiring tokens are resolved. +let templatePath = template; +if (env) { + const text = fs.readFileSync(template, "utf8").replace(/__ENV__/g, env); + templatePath = path.join(dir, path.basename(template)); + fs.writeFileSync(templatePath, text); +} + +const render = path.join(path.dirname(fileURLToPath(import.meta.url)), "render.mjs"); +const result = spawnSync( + process.execPath, + [render, "--template", templatePath, "--out", out, "--secrets-dir", dir], + { stdio: "inherit" }, +); +fs.rmSync(dir, { recursive: true, force: true }); +process.exit(result.status ?? 1); diff --git a/tooling/wire/render.mjs b/tooling/wire/render.mjs new file mode 100644 index 0000000..188154c --- /dev/null +++ b/tooling/wire/render.mjs @@ -0,0 +1,108 @@ +#!/usr/bin/env node +// BF6 deploy-time wiring renderer (zero-dependency). +// +// Renders a wrangler config from a committed template by substituting wiring +// tokens of the form: +// +// @@wiring(/:)@@ +// +// Token values come from one of two sources: +// --map a single JSON file: { "/": { "": "..." } } +// (the committed wiring.fixture.json — offline PR dry-runs) +// --secrets-dir one JSON file per component/env named __.json, +// each containing that environment's payload (fetched from +// AWS Secrets Manager by the composition's wire-live step) +// +// Fails loudly listing every unresolved token — a missing wiring key must +// never produce a deployable config. +// +// Usage: +// node render.mjs --template wrangler.template.jsonc --out wrangler.jsonc --map wiring.fixture.json +// node render.mjs --template wrangler.template.jsonc --out wrangler.jsonc --secrets-dir /tmp/wiring + +import * as fs from "node:fs"; +import * as path from "node:path"; + +function arg(name) { + const i = process.argv.indexOf(`--${name}`); + return i >= 0 ? process.argv[i + 1] : undefined; +} + +const templatePath = arg("template"); +const outPath = arg("out"); +const mapPath = arg("map"); +const secretsDir = arg("secrets-dir"); + +if (!templatePath || !outPath || (!mapPath && !secretsDir)) { + console.error( + "usage: render.mjs --template --out (--map | --secrets-dir )", + ); + process.exit(2); +} + +const envName = arg("env"); +// `__ENV__` names the environment a single-environment config is rendered +// for (see live.mjs); a fixture render picks one the same way. +const template = fs + .readFileSync(templatePath, "utf8") + .replace(/__ENV__/g, envName ?? "stage"); +const TOKEN_RE = /@@wiring\(([a-z0-9-]+)\/([a-z0-9-]+):([a-zA-Z0-9_]+)\)@@/g; + +/** "component/env" -> payload object */ +const sources = new Map(); + +function payloadFor(component, env) { + const id = `${component}/${env}`; + if (sources.has(id)) return sources.get(id); + let payload; + if (mapPath) { + const map = JSON.parse(fs.readFileSync(mapPath, "utf8")); + payload = map[id]; + } else { + const file = path.join(secretsDir, `${component}__${env}.json`); + if (fs.existsSync(file)) payload = JSON.parse(fs.readFileSync(file, "utf8")); + } + sources.set(id, payload); + return payload; +} + +const unresolved = []; +const rendered = template.replace(TOKEN_RE, (token, component, env, key) => { + const payload = payloadFor(component, env); + const value = payload?.[key]; + if (typeof value !== "string" || value.length === 0) { + unresolved.push(token); + return token; + } + return value; +}); + +if (unresolved.length > 0) { + console.error("wire: unresolved wiring tokens:"); + for (const t of unresolved) console.error(` ${t}`); + process.exit(1); +} + +// Guard: a rendered config must contain no leftover *well-formed* tokens. +// (A fresh regex — TOKEN_RE is /g-stateful; doc comments describing the token +// shape with intentionally do not match.) +if (/@@wiring\([a-z0-9-]+\/[a-z0-9-]+:[a-zA-Z0-9_]+\)@@/.test(rendered)) { + console.error("wire: rendered output still contains wiring tokens"); + process.exit(1); +} + +// The output says what it is. The template's own header comment (its leading +// `//` lines) describes the template, so it is replaced by one that names the +// source: a rendered config is never the file to edit. +const body = rendered.replace(/^(?:\/\/[^\n]*\n)+/, ""); +const banner = [ + `// GENERATED from ${path.basename(templatePath)} by tooling/wire — edit the`, + "// template, not this file. The committed copy is the fixture render", + "// (`pnpm run wire:fixture`); every Orun lane renders its own environment.", + "", +].join("\n"); +fs.mkdirSync(path.dirname(path.resolve(outPath)), { recursive: true }); +fs.writeFileSync(outPath, banner + body); +console.log( + `wire: rendered ${path.basename(outPath)} from ${path.basename(templatePath)} (${sources.size} wiring source(s))`, +); diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..8996e84 --- /dev/null +++ b/turbo.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://turbo.build/schema.json", + "tasks": { + "build": { + "dependsOn": ["^build"], + "outputs": ["dist/**", ".wrangler/**"] + }, + "dev": { + "cache": false, + "persistent": true + }, + "test": { + "dependsOn": ["^build"], + "outputs": ["coverage/**"] + }, + "lint": { + "outputs": [] + }, + "typecheck": { + "dependsOn": ["^build"], + "outputs": [] + }, + "wire:fixture": { + "cache": false, + "outputs": [] + }, + "deploy": { + "dependsOn": ["build", "test", "typecheck", "lint"], + "cache": false + } + } +}