Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ This guide helps AI agents quickly navigate the Constructive monorepo. Construct

## Common Workflows (via CLI)

- Initialize workspace/module: `pgpm init workspace`, `pgpm init` (also available via `cnc init`)
**Database Operations (pgpm):**
- Initialize workspace/module: `pgpm init workspace`, `pgpm init`
- Create a change: `pgpm add <change>`
- Deploy/verify/revert: `pgpm deploy`, `pgpm verify`, `pgpm revert`
- Install PGPM modules: `pgpm install <pkg@version>`
- Start GraphQL server/explorer: `cnc server`, `cnc explorer`

**GraphQL Operations (cnc/constructive):**
- Start GraphQL server: `cnc server`
- Launch GraphiQL explorer: `cnc explorer`
- Generate types/SDK: `cnc codegen`
- Export schema SDL: `cnc get-graphql-schema`

## Tips

Expand Down
28 changes: 13 additions & 15 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# 🚀 Quickstart: Constructive CLI Basics
# Quickstart: Constructive + PGPM

Constructive is different from PGPM in that it ships with a GraphQL server and explorer. All PGPM commands are available under `constructive`, but `pgpm` does not include `server` or `explorer`.
Constructive provides GraphQL server and code generation tools, while PGPM handles database migrations and packages. Install both for the complete workflow.

### 1. Install the CLI

Make sure you have the Constructive CLI available:
### 1. Install the CLIs

```bash
npm install -g @constructive-io/cli
npm install -g @constructive-io/cli pgpm
```

### 2. Initialize a workspace

Generate a workspace along with its default services configuration:

```bash
cnc init workspace # then enter workspace name
pgpm init workspace # then enter workspace name
cd myworkspace
```

Expand All @@ -32,14 +30,14 @@ If you already have Postgres installed locally, just ensure it is running and ac
### 4. Create a module & add changes

```bash
cnc init
pgpm init
cd packages/mymodule

# Add schema
cnc add --change schemas/myschema
pgpm add --change schemas/myschema

# Add table (depends on schema)
cnc add --change schemas/myschema/tables/mytable --requires schemas/myschema
pgpm add --change schemas/myschema/tables/mytable --requires schemas/myschema
```

### 5. Example generated SQL
Expand Down Expand Up @@ -68,7 +66,7 @@ CREATE TABLE myschema.mytable (
### 6. Deploy to Postgres

```bash
cnc deploy --database testdb --createdb --yes
pgpm deploy --database testdb --createdb --yes
```

**Sample output highlights:**
Expand All @@ -79,13 +77,13 @@ cnc deploy --database testdb --createdb --yes
* Deploys schema + table successfully

```
[deploy] SUCCESS: 🚀 Starting deployment to database testdb...
[deploy] SUCCESS: Starting deployment to database testdb...
[migrate] SUCCESS: Successfully deployed: schemas/myschema
[migrate] SUCCESS: Successfully deployed: schemas/myschema/tables/mytable
[deploy] SUCCESS: Deployment complete for mymodule.
[deploy] SUCCESS: Deployment complete for mymodule.
```

### 7. Explore
### 7. Explore with GraphiQL

```bash
cnc explorer
Expand All @@ -95,7 +93,7 @@ http://localhost:5555/graphiql (default)
http://myschema.testdb.localhost:5555/graphiql (specific to a schema)


### 8. Server
### 8. Start GraphQL Server

```bash
cnc server
Expand Down
27 changes: 8 additions & 19 deletions packages/cli/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,19 @@
The `@constructive-io/cli` package provides the user-facing CLI for the Constructive ecosystem.

- **Binaries:** `constructive` (full) and `cnc` (shorthand)
- **What it covers:** PGPM database workflows (via the `pgpm` package) plus Constructive GraphQL workflows (server, explorer, schema tools, codegen)
- **What it covers:** Constructive GraphQL workflows only (server, explorer, schema tools, codegen)

**Note:** Database operations (init, add, deploy, revert, etc.) are handled by the separate `pgpm` CLI. Users should install both tools for the complete workflow.

## Entry Points

- **Router:** `packages/cli/src/commands.ts`
- Builds a command map by merging `createPgpmCommandMap()` (from the `pgpm` package) with Constructive GraphQL commands implemented in this package.
- Builds a command map with GraphQL commands implemented in this package.
- **Executable:** `packages/cli/src/index.ts` (compiled to `dist/index.js`)

## Command Sources

### PGPM Commands (delegated)

Most database/workspace commands are delegated to the `pgpm` package via `createPgpmCommandMap()`:

- `init`, `add`, `deploy`, `revert`, `verify`, `plan`, `package`, `export`, `migrate`, `install`, `extension`, `tag`, `admin-users`, etc.

Implementation lives under:

- `pgpm/pgpm/src/commands/*` (CLI behavior)
- `pgpm/core/src/*` (core engine)

### Constructive GraphQL Commands (local)
## Commands

These are implemented directly in this package:
The CLI provides 4 GraphQL-focused commands:

- `packages/cli/src/commands/server.ts` – start the Constructive GraphQL server
- `packages/cli/src/commands/explorer.ts` – start the Constructive GraphQL explorer
Expand All @@ -37,8 +26,8 @@ These are implemented directly in this package:

- **Command routing:** `packages/cli/src/commands.ts`
- **Schema generation:** `packages/cli/src/commands/get-graphql-schema.ts` delegates schema building to `@constructive-io/graphql-server`
- **PG connections cleanup:** PGPM commands are wrapped to teardown `pg-cache` pools after execution (see `pgpm/pgpm/src/commands.ts`)

## Tests

- `packages/cli/__tests__/*` covers both delegated PGPM commands (through the Constructive CLI router) and the local GraphQL commands.
- `packages/cli/__tests__/*` covers the GraphQL commands (codegen, get-graphql-schema, cli)
- Database/PGPM tests are located in `pgpm/cli/__tests__/`
Loading