@happyvertical/smrt-cli 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +51 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +202 -0
- package/bin/smrt.js +26 -0
- package/dist/config-C8pQD-tk.js +30 -0
- package/dist/index-psX--9zT.js +9181 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1809 -0
- package/dist/json-validator-zsI8zUQC.js +912 -0
- package/package.json +79 -0
- package/scripts/verify-package-types-exports.js +573 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @happyvertical/smrt-cli
|
|
2
|
+
|
|
3
|
+
Developer CLI with lazy-loaded commands, manifest discovery, and class introspection.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
smrt introspect # Discover SMRT objects in project
|
|
9
|
+
smrt db:status # Pending schema changes + failed migration classification
|
|
10
|
+
smrt db:migrate # Apply migrations
|
|
11
|
+
smrt db:migrate-uuid # Convert schema-declared UUID text columns after data remap
|
|
12
|
+
smrt db:diff # Show schema differences without generating migration files
|
|
13
|
+
smrt db:rollback # Rollback migrations
|
|
14
|
+
smrt docs:agents # Generate .agents/smrt-framework.md
|
|
15
|
+
smrt docs:claude # Deprecated alias writing .claude/smrt-framework.md
|
|
16
|
+
smrt dev:knowledge-* # Deterministic agent knowledge index/check/diff
|
|
17
|
+
smrt knowledge:review-context --scope package --package <name>
|
|
18
|
+
smrt knowledge:architecture-context --scope project|local|package|sdk
|
|
19
|
+
smrt dev:knowledge-check --format markdown|json
|
|
20
|
+
smrt generate:mcp # Generate MCP server
|
|
21
|
+
smrt config:export # Export agent config for SSG
|
|
22
|
+
smrt init # Init new project
|
|
23
|
+
smrt gnode # Scaffold gnode site
|
|
24
|
+
smrt dispatch:* # Dispatch management (list/process/retry/cleanup)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
File-backed SQL/TypeScript migration generation is not supported. SMRT schema
|
|
28
|
+
migrations are manifest-driven through registered objects and project manifests.
|
|
29
|
+
|
|
30
|
+
`smrt test` is **deprecated** — use vitest plugin directly.
|
|
31
|
+
|
|
32
|
+
## Architecture
|
|
33
|
+
|
|
34
|
+
- **Lazy command loading**: commands loaded on-demand via dynamic import (~100ms overhead on first use)
|
|
35
|
+
- **Manifest discovery**: auto-finds `.smrt/manifest.json` + scans `node_modules/@happyvertical/smrt-*`
|
|
36
|
+
- **Class loading order**: config.entryPoint → package.json exports['.'] → package.json main → `./dist/index.js`
|
|
37
|
+
- **Object method exposure**: custom methods on SMRT objects auto-become CLI commands
|
|
38
|
+
|
|
39
|
+
## Key Files
|
|
40
|
+
|
|
41
|
+
- `src/cli-generator.ts` — core dispatcher, lazy command loading, class loading
|
|
42
|
+
- `src/commands/` — individual command implementations
|
|
43
|
+
- `src/loaders/` — class-loader, local-loader, npm-loader, git-loader, template-loader
|
|
44
|
+
- `src/discovery/manifest-discovery.ts` — manifest auto-discovery
|
|
45
|
+
- `src/commands/docs-claude.ts` — downstream AGENTS.md generation plus Claude compatibility alias
|
|
46
|
+
|
|
47
|
+
## Gotchas
|
|
48
|
+
|
|
49
|
+
- **Test mode detection**: checks `NODE_ENV=test`, `VITEST=true`, `global.it`/`describe` — could conflict with other test runners
|
|
50
|
+
- **External package load failures silenced**: one package failing doesn't prevent others from loading
|
|
51
|
+
- **Schema history nuance**: `db:status` / `db:history` should distinguish active live drift from superseded failed generated schema repairs instead of treating all failed rows as current blockers
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright <2025> <Happy Vertical Corporation>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @happyvertical/smrt-cli
|
|
2
|
+
|
|
3
|
+
Developer CLI for the SMRT framework. Provides introspection, code generation, database management, and auto-generated CRUD commands for SMRT objects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @happyvertical/smrt-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
### Introspection
|
|
14
|
+
|
|
15
|
+
| Command | Description |
|
|
16
|
+
|---------|------------|
|
|
17
|
+
| `smrt introspect` | Discover SMRT objects in project and node_modules |
|
|
18
|
+
| `smrt introspect --verbose` | Include detailed field information |
|
|
19
|
+
| `smrt objects` | List all registered SMRT objects |
|
|
20
|
+
| `smrt schema <object>` | Show detailed schema for an object |
|
|
21
|
+
| `smrt status` | Show system status (database, AI, registry) |
|
|
22
|
+
|
|
23
|
+
### Database
|
|
24
|
+
|
|
25
|
+
| Command | Description |
|
|
26
|
+
|---------|------------|
|
|
27
|
+
| `smrt db:status` | Show pending schema changes and classify failed migration history |
|
|
28
|
+
| `smrt db:migrate` | Apply pending migrations |
|
|
29
|
+
| `smrt db:migrate-uuid` | Convert schema-declared UUID text columns to native PostgreSQL uuid after data has been remapped |
|
|
30
|
+
| `smrt db:diff` | Show schema differences without generating migration files |
|
|
31
|
+
| `smrt db:rollback` | Rollback last migration |
|
|
32
|
+
| `smrt db:history` | Show migration history with active-vs-superseded failure classification |
|
|
33
|
+
|
|
34
|
+
File-backed SQL/TypeScript migration generation is not supported. SMRT schema
|
|
35
|
+
migrations are manifest-driven; model schema with SMRT objects and apply changes
|
|
36
|
+
with `smrt db:migrate`.
|
|
37
|
+
|
|
38
|
+
### Code Generation
|
|
39
|
+
|
|
40
|
+
| Command | Description |
|
|
41
|
+
|---------|------------|
|
|
42
|
+
| `smrt generate:mcp` | Generate MCP server from registered objects |
|
|
43
|
+
| `smrt generate:types` | Generate TypeScript declarations from manifest |
|
|
44
|
+
|
|
45
|
+
### Documentation
|
|
46
|
+
|
|
47
|
+
| Command | Description |
|
|
48
|
+
|---------|------------|
|
|
49
|
+
| `smrt docs:agents` | Generate `.agents/smrt-framework.md` for consumer projects |
|
|
50
|
+
| `smrt docs:claude` | Deprecated compatibility alias for `.claude/smrt-framework.md` |
|
|
51
|
+
| `smrt dev:knowledge-index --format markdown\|json` | Print the deterministic SMRT + SDK knowledge index |
|
|
52
|
+
| `smrt dev:knowledge-check --format markdown\|json` | Check agent knowledge freshness |
|
|
53
|
+
| `smrt dev:knowledge-diff --format markdown\|json` | Show changed files and affected package experts |
|
|
54
|
+
| `smrt knowledge:review-context --scope project\|local\|package\|sdk --package <name> --format markdown\|json` | Build a model-ready domain review prompt bundle |
|
|
55
|
+
| `smrt knowledge:architecture-context --scope project\|local\|package\|sdk --package <name> --format markdown\|json` | Build a model-ready domain architecture prompt bundle |
|
|
56
|
+
|
|
57
|
+
### Configuration
|
|
58
|
+
|
|
59
|
+
| Command | Description |
|
|
60
|
+
|---------|------------|
|
|
61
|
+
| `smrt config:export` | Export agent config for SSG |
|
|
62
|
+
| `smrt export` | Export data in various formats |
|
|
63
|
+
| `smrt init` | Initialize a new SMRT project |
|
|
64
|
+
|
|
65
|
+
### Dispatch
|
|
66
|
+
|
|
67
|
+
| Command | Description |
|
|
68
|
+
|---------|------------|
|
|
69
|
+
| `smrt dispatch:list` | List dispatch messages |
|
|
70
|
+
| `smrt dispatch:process` | Process pending dispatches |
|
|
71
|
+
| `smrt dispatch:retry` | Retry failed dispatches |
|
|
72
|
+
| `smrt dispatch:cleanup` | Clean up old dispatch records |
|
|
73
|
+
|
|
74
|
+
### Git Integration
|
|
75
|
+
|
|
76
|
+
| Command | Description |
|
|
77
|
+
|---------|------------|
|
|
78
|
+
| `smrt git:init` | Configure JSON-aware merge driver for data files |
|
|
79
|
+
| `smrt merge-json <base> <ours> <theirs>` | Manual JSON merge (called by git automatically) |
|
|
80
|
+
|
|
81
|
+
### Scaffolding
|
|
82
|
+
|
|
83
|
+
| Command | Description |
|
|
84
|
+
|---------|------------|
|
|
85
|
+
| `smrt gnode create <name>` | Create new gnode from template |
|
|
86
|
+
| `smrt gnode list-templates` | Show available templates |
|
|
87
|
+
| `smrt playground init` | Scaffold package or app playground modules |
|
|
88
|
+
| `smrt playground dev` | Run the shared or local playground host |
|
|
89
|
+
| `smrt playground list` | List discovered playground entries and modes |
|
|
90
|
+
|
|
91
|
+
### Playground
|
|
92
|
+
|
|
93
|
+
| Command | Description |
|
|
94
|
+
|---------|------------|
|
|
95
|
+
| `smrt playground init` | Scaffold package or app playground files |
|
|
96
|
+
| `smrt playground dev` | Run the shared workspace host or local app playground |
|
|
97
|
+
| `smrt playground list` | Show discovered playground modules and preview entries |
|
|
98
|
+
|
|
99
|
+
### Auto-Generated Object Commands
|
|
100
|
+
|
|
101
|
+
For each registered SMRT object, the CLI generates:
|
|
102
|
+
|
|
103
|
+
| Pattern | Description |
|
|
104
|
+
|---------|------------|
|
|
105
|
+
| `<object>:list` | List objects with filtering and pagination |
|
|
106
|
+
| `<object>:get <id>` | Get object by ID or slug |
|
|
107
|
+
| `<object>:create` | Create new object (interactive) |
|
|
108
|
+
| `<object>:update <id>` | Update existing object |
|
|
109
|
+
| `<object>:delete <id>` | Delete object |
|
|
110
|
+
| `<object>:<method> <id>` | Custom methods exposed via `cli: { include: [...] }` |
|
|
111
|
+
|
|
112
|
+
Custom methods on SMRT objects are auto-discovered from manifests. Method parameters become CLI options (camelCase to kebab-case).
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Discover what SMRT objects are available
|
|
118
|
+
smrt introspect
|
|
119
|
+
|
|
120
|
+
# Generate an MCP server
|
|
121
|
+
smrt generate:mcp
|
|
122
|
+
|
|
123
|
+
# Scaffold a package playground definition
|
|
124
|
+
smrt playground init
|
|
125
|
+
|
|
126
|
+
# Inspect discovered playground entries
|
|
127
|
+
smrt playground list
|
|
128
|
+
|
|
129
|
+
# Run a custom method on an object
|
|
130
|
+
smrt agent:research abc123 --query "AI safety"
|
|
131
|
+
|
|
132
|
+
# Generate agent context for downstream projects
|
|
133
|
+
smrt docs:agents
|
|
134
|
+
|
|
135
|
+
# Deprecated compatibility alias for Claude Code output
|
|
136
|
+
smrt docs:claude
|
|
137
|
+
|
|
138
|
+
# Check deterministic agent knowledge freshness
|
|
139
|
+
smrt dev:knowledge-check --changed --strict --format markdown
|
|
140
|
+
smrt dev:knowledge-check --strict --format json
|
|
141
|
+
|
|
142
|
+
# Build downstream domain context for local/manual model review
|
|
143
|
+
smrt knowledge:review-context --scope package --package content --format markdown
|
|
144
|
+
smrt knowledge:architecture-context "tenant-aware publishing workflow" --format json
|
|
145
|
+
|
|
146
|
+
# Inspect discovered package playground modules
|
|
147
|
+
smrt playground list
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## UI Surfaces
|
|
151
|
+
|
|
152
|
+
The CLI treats UI surfaces as three separate contracts:
|
|
153
|
+
|
|
154
|
+
- `./svelte` for reusable components
|
|
155
|
+
- `./playground` for preview metadata consumed by `smrt playground`
|
|
156
|
+
- package-local page shells when a package needs its own dev pages
|
|
157
|
+
|
|
158
|
+
For this release, packages only need `./svelte` and `./playground` as public UI contracts. Package-local page shells can exist for dev workflows without becoming a published package standard.
|
|
159
|
+
|
|
160
|
+
See [docs/ui-surfaces.md](../../docs/ui-surfaces.md) for the full convention.
|
|
161
|
+
|
|
162
|
+
## Configuration
|
|
163
|
+
|
|
164
|
+
The CLI uses `@happyvertical/smrt-config` (cosmiconfig). Configuration is optional -- sensible defaults apply.
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// smrt.config.js
|
|
168
|
+
export default {
|
|
169
|
+
packages: {
|
|
170
|
+
cli: {
|
|
171
|
+
entryPoint: './dist/index.js', // default: auto-detect from package.json
|
|
172
|
+
database: {
|
|
173
|
+
type: 'sqlite', // 'sqlite' | 'postgres'
|
|
174
|
+
url: './data.db' // default: ':memory:'
|
|
175
|
+
},
|
|
176
|
+
format: 'table', // 'table' | 'json' | 'yaml' | 'plain'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Entry Point Discovery
|
|
183
|
+
|
|
184
|
+
The CLI loads SMRT objects from your project entry point:
|
|
185
|
+
1. Explicit `entryPoint` in config
|
|
186
|
+
2. `package.json` exports `['.'].import` or `['.']`
|
|
187
|
+
3. `package.json` `main` field
|
|
188
|
+
4. Fallback: `./dist/index.js`
|
|
189
|
+
|
|
190
|
+
### Manifest Discovery
|
|
191
|
+
|
|
192
|
+
The CLI auto-discovers SMRT manifests from:
|
|
193
|
+
- **Project root**: `dist/manifest.json`, `dist/static-manifest.js`, `.smrt/manifest.json`, and other standard locations
|
|
194
|
+
- **Installed packages**: scans `node_modules/@happyvertical/smrt-*` for manifest files
|
|
195
|
+
|
|
196
|
+
If compiled classes cannot be loaded, the CLI falls back to manifest-only mode (introspection and code generation work, but CRUD and custom methods do not).
|
|
197
|
+
|
|
198
|
+
## Dependencies
|
|
199
|
+
|
|
200
|
+
- `@happyvertical/smrt-core` -- ORM, manifest, code generation
|
|
201
|
+
- `@happyvertical/smrt-config` -- configuration loading
|
|
202
|
+
- `@happyvertical/smrt-scanner` -- AST scanning for metadata extraction
|
package/bin/smrt.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
const distEntry = resolve(packageRoot, 'dist/index.js');
|
|
10
|
+
const sourceEntry = resolve(packageRoot, 'src/index.ts');
|
|
11
|
+
|
|
12
|
+
const command = existsSync(distEntry)
|
|
13
|
+
? [distEntry, ...process.argv.slice(2)]
|
|
14
|
+
: ['--import', 'tsx', sourceEntry, ...process.argv.slice(2)];
|
|
15
|
+
|
|
16
|
+
const result = spawnSync(process.execPath, command, { stdio: 'inherit' });
|
|
17
|
+
|
|
18
|
+
if (result.error) {
|
|
19
|
+
throw result.error;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (result.signal) {
|
|
23
|
+
process.kill(process.pid, result.signal);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const DEFAULT_CLI_CONFIG = {
|
|
2
|
+
entryPoint: null,
|
|
3
|
+
// Auto-detect from package.json
|
|
4
|
+
database: {
|
|
5
|
+
type: "sqlite",
|
|
6
|
+
url: ":memory:"
|
|
7
|
+
},
|
|
8
|
+
migrations: {
|
|
9
|
+
directory: "./migrations",
|
|
10
|
+
table: "_smrt_schema_migrations",
|
|
11
|
+
format: "sql",
|
|
12
|
+
naming: "sequence",
|
|
13
|
+
mode: "dynamic",
|
|
14
|
+
autoGenerateDown: true,
|
|
15
|
+
postgres: {
|
|
16
|
+
useConcurrently: true,
|
|
17
|
+
lockTimeout: "30s",
|
|
18
|
+
statementTimeout: "60s"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
schemaContract: {},
|
|
22
|
+
verbose: false,
|
|
23
|
+
format: "table",
|
|
24
|
+
timeout: 3e4,
|
|
25
|
+
colors: !process.env.NO_COLOR && process.stdout.isTTY,
|
|
26
|
+
interactive: !process.env.CI
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
DEFAULT_CLI_CONFIG
|
|
30
|
+
};
|