|
| 1 | +--- |
| 2 | +name: constructive-blocks |
| 3 | +description: Overview of Constructive Blocks and how to consume them — the two distributions (npm packages and the @constructive shadcn registry), picking the right install root (console-kit-nextjs, a preset, console-kit-core + console-module-*, a standalone feature-pack, command-palette, or a primitive), running the shadcn add command, and rendering Console Kit with a secret-free tenant descriptor. Use when asked about Constructive Blocks, or to "add a block", "install console kit", "add a feature pack", "use the @constructive registry", or "resolve an install with the inspector". |
| 4 | +compatibility: Node 24 LTS, pnpm 10.28.0; consumer must be a shadcn project (components.json) |
| 5 | +metadata: |
| 6 | + author: constructive-io |
| 7 | + version: "1.0.0" |
| 8 | +--- |
| 9 | + |
| 10 | +# Constructive Blocks |
| 11 | + |
| 12 | +Constructive Blocks are distributed two independent ways: |
| 13 | + |
| 14 | +- **npm packages** — `@constructive-io/ui`, `@constructive-io/data`, |
| 15 | + `@constructive-io/sheets`, `@constructive-io/command-palette`, |
| 16 | + `@constructive-io/schema-builder` (packaged primitives). |
| 17 | +- **The `@constructive` shadcn registry** — editable source copied into the |
| 18 | + consumer app (Console Kit, feature packs, presets, and primitives). |
| 19 | + |
| 20 | +This skill covers consuming Blocks, focused on the **registry / "add a block" |
| 21 | +path**. The registry is served from |
| 22 | +`https://constructive-io.github.io/blocks/r/{name}.json`. |
| 23 | + |
| 24 | +## 1. One-time consumer setup |
| 25 | + |
| 26 | +Blocks install into an existing shadcn project. If the consumer has no |
| 27 | +`components.json`, initialize one: |
| 28 | + |
| 29 | +```bash |
| 30 | +pnpm dlx shadcn@latest init |
| 31 | +``` |
| 32 | + |
| 33 | +Keep the generated alias config, then register the `@constructive` namespace in |
| 34 | +`components.json` **once**: |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "registries": { |
| 39 | + "@constructive": "https://constructive-io.github.io/blocks/r/{name}.json" |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +Registry installs copy the required UI source + Constructive theme into the |
| 45 | +consumer; they do **not** add the npm package. Always invoke the CLI via |
| 46 | +`shadcn@latest`. |
| 47 | + |
| 48 | +## 2. Pick the smallest install root that owns your workflow |
| 49 | + |
| 50 | +| Goal | Install root | |
| 51 | +| --- | --- | |
| 52 | +| Full tenant console, all seven packs, one command | `console-kit-nextjs` | |
| 53 | +| Backend-aligned official composition | `preset-auth-hardened`, `preset-b2b-storage`, `preset-full` | |
| 54 | +| Custom Console Kit composition | `console-kit-core` + selected `console-module-<id>` | |
| 55 | +| Provider-neutral view, host owns data/actions (no Console Kit) | `feature-pack-<id>` | |
| 56 | +| Application command center | `command-palette` | |
| 57 | +| A single reusable primitive | npm subpath, or `@constructive/<primitive>` (e.g. `button`) | |
| 58 | + |
| 59 | +Install command (every item, same shape): |
| 60 | + |
| 61 | +```bash |
| 62 | +pnpm dlx shadcn@latest add @constructive/console-kit-nextjs |
| 63 | +pnpm dlx shadcn@latest add @constructive/preset-b2b-storage |
| 64 | +pnpm dlx shadcn@latest add @constructive/console-module-storage |
| 65 | +pnpm dlx shadcn@latest add @constructive/button |
| 66 | +``` |
| 67 | + |
| 68 | +### Feature packs and modules |
| 69 | + |
| 70 | +Seven feature-pack ids: `data`, `auth`, `users`, `organizations`, `storage`, |
| 71 | +`billing`, `notifications`. |
| 72 | + |
| 73 | +- `feature-pack-<id>` — installs only the provider-neutral view + its |
| 74 | + compatibility manifest. Renderable by a host that does not use Console Kit; |
| 75 | + the host owns resources, policy, action callbacks, and selection/routing |
| 76 | + state. Does **not** pull in Console Kit. |
| 77 | +- `console-module-<id>` — installs `console-kit-core` **and** the standalone |
| 78 | + feature-pack view transitively, then adds the module's discovery bindings, |
| 79 | + Constructive adapter, metadata resolver, and pack-owned state. |
| 80 | + |
| 81 | +### Presets (core + an exact module set) |
| 82 | + |
| 83 | +| Preset root | Installed modules | |
| 84 | +| --- | --- | |
| 85 | +| `preset-auth-hardened` | Data, Auth, Users | |
| 86 | +| `preset-b2b-storage` | Data, Auth, Users, Organizations, Storage | |
| 87 | +| `preset-full` | Data, Auth, Users, Organizations, Storage, Billing, Notifications | |
| 88 | + |
| 89 | +Navigation at runtime is the **intersection** of installed modules and the |
| 90 | +capabilities actually discovered for the active tenant — installing a pack does |
| 91 | +not prove its backend capability is exposed or authorized. |
| 92 | + |
| 93 | +## 3. Render Console Kit |
| 94 | + |
| 95 | +Console Kit takes a **secret-free** tenant descriptor (from provisioning) with |
| 96 | +explicit per-endpoint URLs. It never derives a sibling host or crosses an |
| 97 | +authorization boundary: |
| 98 | + |
| 99 | +```tsx |
| 100 | +'use client'; |
| 101 | + |
| 102 | +import { |
| 103 | + ConstructiveConsoleKit, |
| 104 | + type ConstructiveTenantDatabase |
| 105 | +} from '@/blocks/console-kit/constructive'; |
| 106 | + |
| 107 | +const database = { |
| 108 | + id: 'tenant_database_id', |
| 109 | + name: 'Acme application', |
| 110 | + endpoints: { |
| 111 | + data: 'https://data.example.com/graphql', |
| 112 | + auth: 'https://auth.example.com/graphql', |
| 113 | + admin: 'https://admin.example.com/graphql' |
| 114 | + } |
| 115 | +} satisfies ConstructiveTenantDatabase; |
| 116 | + |
| 117 | +export function TenantConsole() { |
| 118 | + return <ConstructiveConsoleKit database={database} />; |
| 119 | +} |
| 120 | +``` |
| 121 | + |
| 122 | +- Required descriptor fields: `id`, `endpoints`. Optional: `name`. |
| 123 | +- A host-owned session must declare the same `databaseId`; a mismatch fails |
| 124 | + closed. |
| 125 | +- During integration only, pass |
| 126 | + `showDiagnostics={process.env.NODE_ENV !== 'production'}` to expose endpoint |
| 127 | + and capability evidence. Never ship diagnostics in production. |
| 128 | +- Each Console Kit instance owns **one** per-instance Zustand store composed |
| 129 | + from modular slices — never a process-wide store, never credentials in |
| 130 | + Zustand, never a second provider per pack. |
| 131 | + |
| 132 | +## 4. Resolve an install with the inspector (agent-friendly) |
| 133 | + |
| 134 | +Before/without touching a tenant, ask the local inspector exactly what an item |
| 135 | +installs — CLI command, npm deps, preset profile, registry targets, endpoint / |
| 136 | +capability / `_meta` requirements, and verification steps — as deterministic |
| 137 | +JSON: |
| 138 | + |
| 139 | +```bash |
| 140 | +pnpm --silent console-kit:inspect --list |
| 141 | +pnpm --silent console-kit:inspect --item preset-b2b-storage |
| 142 | +pnpm --silent console-kit:inspect --item console-module-storage --compact |
| 143 | +``` |
| 144 | + |
| 145 | +`--silent` keeps stdout valid JSON for `jq`. The default rebuilds the aggregate |
| 146 | +registry from local inputs; `--no-build` reads the existing artifact (freshness |
| 147 | +is then the caller's responsibility). Unknown roots fail with the full |
| 148 | +valid-choice list. |
| 149 | + |
| 150 | +## 5. Verify after installing (no tenant/credentials needed) |
| 151 | + |
| 152 | +Run from the **consumer** project root, after installing its deps: |
| 153 | + |
| 154 | +```bash |
| 155 | +pnpm exec tsc --noEmit |
| 156 | +pnpm build |
| 157 | +``` |
| 158 | + |
| 159 | +Then confirm each installed pack's `.constructive/feature-packs/<id>.json` |
| 160 | +manifest exists and matches the endpoint/capability/`_meta` requirements in the |
| 161 | +inspector plan. Schema evidence (`_meta`, introspection) is **not** |
| 162 | +authorization evidence — exercise authenticated reads/writes with the intended |
| 163 | +tenant role to prove RLS authority. |
| 164 | + |
| 165 | +## Invariants (do not violate) |
| 166 | + |
| 167 | +- Every install command uses the `@constructive` namespace; the combined |
| 168 | + registry stays collision-free. |
| 169 | +- Never edit generated registry output; canonical source lives in `apps/blocks` |
| 170 | + and `packages/*`. |
| 171 | +- Blocks take injected endpoints, sessions, and adapters — do not add generated |
| 172 | + SDK trees or make normal CI depend on live endpoints. |
| 173 | +- Registry installation and schema discovery never grant authority; PostgreSQL |
| 174 | + grants and RLS remain authoritative for every request. |
| 175 | + |
| 176 | +## References |
| 177 | + |
| 178 | +- `README.md` — install quick start, registry mapping, render example, |
| 179 | + inspector usage. |
| 180 | +- `AGENTS.md` / `CLAUDE.md` — repository invariants, toolchain (Node 24 LTS, |
| 181 | + pnpm 10.28.0), verify pipeline (`pnpm check` / `check:full` / `build:pages` / |
| 182 | + `pack:local`). |
| 183 | +- `docs/CONSOLE_KIT_BACKEND_COMPATIBILITY.md` — install surfaces, preset module |
| 184 | + sets, the four evidence layers (reachability → `_meta` → introspection → |
| 185 | + runtime authority), and per-pack requirements. |
| 186 | +- `scripts/inspect-console-kit.ts` — the inspector and the |
| 187 | + `ConsoleKitInstallPlan` schema it emits. |
| 188 | +- `apps/blocks/src/feature-packs/manifest.ts` — canonical `FEATURE_PACK_IDS` |
| 189 | + and `PRESET_PROFILE_IDS`. |
| 190 | +</content> |
| 191 | +</invoke> |
0 commit comments