@happyvertical/smrt-app-cli 0.40.13 → 0.40.15
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/README.md +114 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @happyvertical/smrt-app-cli
|
|
2
|
+
|
|
3
|
+
Reusable, application-branded CLI support for s-m-r-t apps. It combines resource
|
|
4
|
+
discovery, generated command invocation, device-code authentication, local
|
|
5
|
+
configuration, and an MCP stdio bridge without coupling the CLI to one app.
|
|
6
|
+
|
|
7
|
+
Use this package when a deployed s-m-r-t application should expose a branded
|
|
8
|
+
`<app> <resource> <command>` CLI. Use
|
|
9
|
+
[`@happyvertical/smrt-cli`](../cli/README.md) for framework development,
|
|
10
|
+
schema, and code-generation commands.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @happyvertical/smrt-app-cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Node.js 24.18 or newer is required.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
#!/usr/bin/env node
|
|
24
|
+
import { createAppCli } from '@happyvertical/smrt-app-cli';
|
|
25
|
+
|
|
26
|
+
const cli = createAppCli({
|
|
27
|
+
name: 'acme',
|
|
28
|
+
defaultServerUrl: 'https://app.acme.test',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await cli.run(process.argv.slice(2));
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The resulting CLI includes:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
acme auth login [--server <url>] [--no-open]
|
|
38
|
+
acme auth status
|
|
39
|
+
acme auth logout
|
|
40
|
+
acme resources [--json] [--debug]
|
|
41
|
+
acme mcp
|
|
42
|
+
acme <resource> <command> [flags]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Resources and their commands are discovered from the app's `/_resources`
|
|
46
|
+
surface. JSON Schema becomes CLI flags, while unsupported schema shapes are
|
|
47
|
+
reported instead of silently guessed.
|
|
48
|
+
|
|
49
|
+
## Add an app-specific command
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const cli = createAppCli({
|
|
53
|
+
name: 'acme',
|
|
54
|
+
extraCommands: [
|
|
55
|
+
{
|
|
56
|
+
name: 'doctor',
|
|
57
|
+
description: 'Check the deployed app',
|
|
58
|
+
async run(_args, context) {
|
|
59
|
+
const health = await context.requestJson('/api/health');
|
|
60
|
+
context.stdout.write(`${JSON.stringify(health, null, 2)}\n`);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
App-specific commands win over built-ins. Avoid names that may collide with a
|
|
68
|
+
discovered resource slug.
|
|
69
|
+
|
|
70
|
+
## MCP bridge
|
|
71
|
+
|
|
72
|
+
The same app CLI can expose the deployed application's MCP surface to local
|
|
73
|
+
stdio clients:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
await cli.startMcpBridge({ name: 'acme-mcp', version: '1.0.0' });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The package also ships the generic `smrt-mcp-bridge` binary. The remote app
|
|
80
|
+
surface is typically mounted with
|
|
81
|
+
[`@happyvertical/smrt-app-mcp`](../smrt-app-mcp/README.md).
|
|
82
|
+
|
|
83
|
+
## Configuration and authentication
|
|
84
|
+
|
|
85
|
+
- `name` supplies the display name and default environment-variable prefix.
|
|
86
|
+
- `envPrefix` overrides that prefix; `configDir` overrides the local config
|
|
87
|
+
namespace.
|
|
88
|
+
- `defaultServerUrl` is used only when neither environment nor stored config
|
|
89
|
+
supplies a server.
|
|
90
|
+
- Device-code login distinguishes pending approval, expiry, transient network
|
|
91
|
+
failure, and hard rejection.
|
|
92
|
+
- Tokens and server configuration stay in the app-specific local config path.
|
|
93
|
+
|
|
94
|
+
## Public API
|
|
95
|
+
|
|
96
|
+
| Export | Purpose |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `createAppCli()` | Build the branded CLI and MCP bridge |
|
|
99
|
+
| `createMcpStdioBridge()` / `runMcpStdioBridge()` | Lower-level bridge control |
|
|
100
|
+
| `fetchResourceList()` | Fetch the deployed resource catalog |
|
|
101
|
+
| `invokeCommand()` | Invoke one generated resource command |
|
|
102
|
+
| `buildFlagParser()` | Convert supported JSON Schema to flags |
|
|
103
|
+
| `loadCliConfig()` / `saveCliConfig()` | Read and write namespaced CLI config |
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pnpm --filter @happyvertical/smrt-app-cli test
|
|
109
|
+
pnpm --filter @happyvertical/smrt-app-cli typecheck
|
|
110
|
+
pnpm --filter @happyvertical/smrt-app-cli build
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Maintainer patterns and authentication invariants are documented in
|
|
114
|
+
[`AGENTS.md`](./AGENTS.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-app-cli",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.15",
|
|
4
4
|
"description": "Reusable CLI factory for SMRT apps — branded `<name> <resource> <command>` CLI + stdio MCP bridge with decorator-driven resource discovery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
24
|
-
"@happyvertical/smrt-users": "0.40.
|
|
24
|
+
"@happyvertical/smrt-users": "0.40.15"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "24.13.2",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"vite": "8.1.4",
|
|
30
30
|
"vite-plugin-dts": "4.5.4",
|
|
31
31
|
"vitest": "4.1.10",
|
|
32
|
-
"@happyvertical/smrt-core": "0.40.
|
|
32
|
+
"@happyvertical/smrt-core": "0.40.15"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=24.18.0"
|