From f1480492da5a68f3b892247c3ce1d2058c808550 Mon Sep 17 00:00:00 2001 From: DuncanAForbes Date: Thu, 16 Jul 2026 22:54:55 +0100 Subject: [PATCH] feat: scaffold + local-dev KV namespace bindings for edge projects [BDOK-685] - init: scaffold `kv: { OPERATOR_CONFIG }` for edge projects (the per-installation lifecycle/config state store edge adapters/comms already expect). - dev: emit `[[kv_namespaces]]` in the generated wrangler.toml for any declared `kv`, with a deterministic `local-dev-` id/preview_id so local Miniflare persists KV between runs. Guarded by `config.kv` (no effect on projects without KV). Uses the existing KvDeclaration type + the deploy handler's lowercase-binding convention. tsc clean, 28 tests pass, verified end-to-end (init scaffold + valid wrangler.toml). Bumps to 0.10.1. --- CHANGELOG.md | 7 +++++++ package.json | 2 +- src/dev.ts | 12 ++++++++++++ src/init.ts | 5 +++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d177fb..b667152 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.10.1] - 2026-07-16 + +### Added + +- `bagdock init` scaffolds an `OPERATOR_CONFIG` KV namespace for edge projects (the per-installation lifecycle/config state store edge adapters use). +- `bagdock dev` now emits `[[kv_namespaces]]` bindings in the generated `wrangler.toml` for any `kv` declared in `bagdock.json`, so local Miniflare persists KV between runs. No effect on projects without KV. + ## [0.10.0] - 2026-07-16 ### Added diff --git a/package.json b/package.json index 15c7a9b..ca62e37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bagdock/cli", - "version": "0.10.0", + "version": "0.10.1", "description": "Bagdock developer CLI — build, test, and deploy apps and edges on the Bagdock platform", "keywords": [ "bagdock", diff --git a/src/dev.ts b/src/dev.ts index b3e29dc..b7ef0c2 100644 --- a/src/dev.ts +++ b/src/dev.ts @@ -81,6 +81,18 @@ function generateWranglerToml(config: ReturnType & {}, p lines.push('') } + // KV namespace bindings (local dev uses preview_id for Miniflare persistence) + if (config.kv && Object.keys(config.kv).length > 0) { + for (const [binding, meta] of Object.entries(config.kv)) { + lines.push(`# ${meta.description ?? binding}`) + lines.push(`[[kv_namespaces]]`) + lines.push(`binding = "${binding}"`) + lines.push(`id = "local-dev-${binding.toLowerCase()}"`) + lines.push(`preview_id = "local-dev-${binding.toLowerCase()}"`) + lines.push('') + } + } + // Environment variable bindings (declared in [vars] for dev, actual values from .dev.vars) if (config.env && Object.keys(config.env).length > 0) { lines.push(`[vars]`) diff --git a/src/init.ts b/src/init.ts index ae49be8..cfbf4c0 100644 --- a/src/init.ts +++ b/src/init.ts @@ -56,6 +56,11 @@ export async function init(dir: string, opts: InitOptions) { env: { API_KEY: { description: 'Provider API key', required: true }, }, + ...(type === 'edge' ? { + kv: { + OPERATOR_CONFIG: { description: 'Per-installation state store for lifecycle and config' }, + }, + } : {}), } await promptPublisherOverrides(config, opts)