gorig-cli 1.0.25 → 1.0.27

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 jom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,61 +1,71 @@
1
- # Gorig CLI
1
+ # Gorig CLI: Project Generator and AI Skill Installer
2
2
 
3
- Gorig CLI is the command-line tool for initializing Gorig projects, generating modules, installing the `gorig-backend` skill, and keeping generated projects aligned with the verified Gorig backend roadmap.
3
+ `gorig-cli` is the command-line entry point for Gorig backend development. It creates runnable Gorig projects, generates feature modules, builds persistence-backed CRUD services, produces API documentation, and installs the `gorig-backend` skill for Codex and Claude.
4
4
 
5
- ## Roadmap Status
5
+ Use it when you want generated code to follow the same Gorig structure and framework conventions instead of starting from ad hoc scaffolding.
6
6
 
7
- The `gorig-backend` skill roadmap is tracked in [docs/gorig-backend-skill-roadmap.md](docs/gorig-backend-skill-roadmap.md). This README documents the stable CLI workflows and the currently verified skill surface.
7
+ Main Gorig framework repository: [https://github.com/jom-io/gorig](https://github.com/jom-io/gorig)
8
8
 
9
- | Scope | Status |
9
+ ## What It Does
10
+
11
+ | Capability | Description |
10
12
  |---|---|
11
- | Skill foundation, source rules, and version detection | verified |
12
- | Locally runnable basic project generation | verified |
13
- | HTTP API, modules, database, cache, cron, messaging, SSE, auth, security, and outbound networking guidance | verified |
14
- | Observability, deployment, and operations guidance | pending |
13
+ | Project bootstrap | Create a locally runnable Gorig service with `_cmd`, environment configs, domain registration, example routes, and tests. |
14
+ | Module generation | Add flat feature modules under `domain/<module>/` using Router -> Controller -> Service -> Model boundaries. |
15
+ | Persistent CRUD | Generate MySQL or MongoDB CRUD modules backed by Gorig `domainx/dx`, with tests, docs, and non-secret config skeletons. |
16
+ | API documentation | Generate OpenAPI/Redoc documentation for generated HTTP modules. |
17
+ | AI skill installation | Install the bundled `gorig-backend` skill so Codex or Claude can work with Gorig projects using framework-aware rules. |
18
+ | Framework development | Generate projects against a local Gorig checkout with `--gorig-replace` when developing the framework itself. |
15
19
 
16
20
  ## Installation
17
21
 
18
- Install globally using npm:
22
+ Run without installing globally:
19
23
 
20
24
  ```sh
21
- npm install -g gorig-cli
25
+ npx gorig-cli@latest <command>
22
26
  ```
23
27
 
24
- Or run directly using npx:
28
+ Or install globally:
25
29
 
26
30
  ```sh
27
- npx gorig-cli@latest <command>
31
+ npm install -g gorig-cli
32
+ gorig-cli <command>
28
33
  ```
29
34
 
30
- ## Quick Start
31
-
32
- ### Initialize a Runnable Project
33
-
34
- Use the `init` command to create a new project:
35
+ ## Create a New Backend
35
36
 
36
37
  ```sh
37
- gorig-cli init my-new-project --gorig-version v0.0.52 --no-start
38
+ npx gorig-cli@latest init my-new-project --no-start
38
39
  ```
39
40
 
40
- Or use npx:
41
+ Or with a global install:
41
42
 
42
43
  ```sh
43
- npx gorig-cli@latest init my-new-project --gorig-version v0.0.52 --no-start
44
+ gorig-cli init my-new-project --no-start
44
45
  ```
45
46
 
46
- This creates a locally runnable project with `local`, `dev`, and `prod` configuration, one `_cmd` entry point, and a Router-Controller-Service example under `domain/hello`. The basic project does not require MySQL, MongoDB, or Redis.
47
+ The generated project includes:
48
+
49
+ - one `_cmd` entry point
50
+ - `local`, `dev`, and `prod` configuration
51
+ - `domain/init.go` registration
52
+ - an example `domain/hello` module
53
+ - tests under `test/`
54
+ - no required MySQL, MongoDB, or Redis dependency in the basic profile
47
55
 
48
56
  Useful automation options:
49
57
 
50
58
  ```sh
51
- # Use a custom Go module and base port
52
59
  gorig-cli init my-new-project \
53
60
  --module example.com/my-new-project \
54
- --gorig-version v0.0.52 \
61
+ --gorig-version latest \
55
62
  --port 9527 \
56
63
  --no-start
64
+ ```
65
+
66
+ For framework development against a local checkout:
57
67
 
58
- # Framework development against a local Gorig checkout
68
+ ```sh
59
69
  gorig-cli init my-new-project \
60
70
  --gorig-replace ../gorig \
61
71
  --no-start \
@@ -64,21 +74,21 @@ gorig-cli init my-new-project \
64
74
 
65
75
  Use `--force` only when an existing non-empty destination may be replaced. Use `--start` to start immediately; otherwise initialization is non-interactive and does not start the service.
66
76
 
67
- ### Create a Basic Module
77
+ ## Add a Module
68
78
 
69
- Use the `create` command in the project root directory to create a new module:
79
+ Run from the generated project root:
70
80
 
71
81
  ```sh
72
- gorig-cli create user
82
+ npx gorig-cli@latest create user
73
83
  ```
74
84
 
75
- Or use npx:
85
+ Or with a global install:
76
86
 
77
87
  ```sh
78
- npx gorig-cli@latest create user
88
+ gorig-cli create user
79
89
  ```
80
90
 
81
- This creates a flat feature-first module under `domain/user`, using the Gorig Router -> Controller -> Service shape without adding database or Redis requirements:
91
+ This creates:
82
92
 
83
93
  ```text
84
94
  domain/user/
@@ -90,11 +100,11 @@ domain/user/
90
100
  └── user.go
91
101
  ```
92
102
 
93
- The generated routes are `GET /user/info` and `POST /user/echo`. More complex persistence-backed CRUD modules should keep the same flat module boundary and add `domainx/dx` access in `service.go` plus storage structs under `model/`.
103
+ The generated basic routes are `GET /user/info` and `POST /user/echo`.
94
104
 
95
- ### Create a Persistent CRUD Module
105
+ ## Generate Persistent CRUD
96
106
 
97
- To generate a persistent CRUD module backed by Gorig `domainx/dx`, choose MySQL or MongoDB explicitly:
107
+ Choose the storage backend explicitly:
98
108
 
99
109
  ```sh
100
110
  # MySQL CRUD module, with HTTP routes enabled by default
@@ -109,11 +119,16 @@ gorig-cli create order --crud --db mysql --no-http
109
119
 
110
120
  Persistent CRUD generation currently supports MySQL and MongoDB. The generated code compiles without a live database, but effect-level create/list/page/update/delete verification requires a matching development database configuration.
111
121
 
112
- The CRUD generator preserves existing named connections and adds non-secret configuration skeletons to `_bin/local.yaml`, `_bin/dev.yaml`, `_bin/prod.yaml`, and `test/_bin/local.yaml`. After filling local values or exporting the documented `GORIG_...` variables, run `go test -tags=integration,mysql ./test/... -v` or `go test -tags=integration,mongo ./test/... -v`.
122
+ The CRUD generator preserves existing named connections and adds non-secret configuration skeletons to `_bin/local.yaml`, `_bin/dev.yaml`, `_bin/prod.yaml`, and `test/_bin/local.yaml`.
113
123
 
114
- ### Generate API Documentation
124
+ After filling local values or exporting the documented `GORIG_...` variables, run:
115
125
 
116
- Use the `doc` command to generate OpenAPI documentation:
126
+ ```sh
127
+ go test -tags=integration,mysql ./test/... -v
128
+ go test -tags=integration,mongo ./test/... -v
129
+ ```
130
+
131
+ ## Generate API Documentation
117
132
 
118
133
  ```sh
119
134
  # Generate documentation for all modules
@@ -130,36 +145,30 @@ npx gorig-cli@latest doc
130
145
  npx gorig-cli@latest doc user
131
146
  ```
132
147
 
133
- After generating the documentation, you can access it through:
134
- http://127.0.0.1:8080/redoc.html
148
+ After generating documentation, access it through:
135
149
 
136
- ### Install Gorig Skill
150
+ ```text
151
+ http://127.0.0.1:8080/redoc.html
152
+ ```
137
153
 
138
- Use the `skill` command to install the bundled `gorig-backend` skill for Codex or Claude.
154
+ ## Install Gorig Backend Skill
139
155
 
140
- Install the Codex skill globally:
156
+ The CLI bundles the `gorig-backend` skill for Codex and Claude. Install it when you want AI agents to implement, review, test, or troubleshoot Gorig projects with framework-aware rules.
141
157
 
142
158
  ```sh
159
+ # Codex global skill
143
160
  gorig-cli skill install codex
144
- ```
145
-
146
- Install both Codex and Claude skills globally:
147
161
 
148
- ```sh
162
+ # Codex and Claude global skills
149
163
  gorig-cli skill install all
150
- ```
151
164
 
152
- Install the Codex skill into the current repository:
153
-
154
- ```sh
165
+ # Codex skill stored in the current repository
155
166
  gorig-cli skill install codex project
156
167
  ```
157
168
 
158
169
  The install scope defaults to `user`. Use `project` only when the skill should be stored in the current repository.
159
170
 
160
- ### Use with AI Agents
161
-
162
- After installing the skill, open a Gorig project in Codex or Claude and ask for framework-specific backend work:
171
+ Example prompts:
163
172
 
164
173
  ```text
165
174
  Use the gorig-backend skill to add a MySQL order CRUD module with tests and API docs.
@@ -173,9 +182,7 @@ Use the gorig-backend skill to review startup, routing, config, and middleware u
173
182
  Use the gorig-backend skill to add login, protected routes, logout, and security tests.
174
183
  ```
175
184
 
176
- ### Run the Project
177
-
178
- After entering the project directory, you can run the project using the following commands:
185
+ ## Run the Project
179
186
 
180
187
  ```sh
181
188
  cd my-new-project
@@ -185,21 +192,13 @@ GORIG_SYS_MODE=local go run ./_cmd
185
192
  Or run it after building:
186
193
 
187
194
  ```sh
188
- go build -o my-new-project _cmd/main.go && ./my-new-project
195
+ go build -o my-new-project _cmd/main.go
196
+ GORIG_SYS_MODE=local ./my-new-project
189
197
  ```
190
198
 
191
- ## Verified Capabilities
192
-
193
- - Dependency-free project bootstrap with `local`, `dev`, and `prod` configuration.
194
- - Flat feature-first module generation under `domain/<module>/`.
195
- - MySQL and MongoDB CRUD generation through Gorig `domainx/dx`.
196
- - API documentation generation for generated HTTP modules.
197
- - Skill installation for Codex and Claude from one canonical bundled source.
198
- - Skill references and fixtures for cache, scheduled tasks, messaging, SSE, authentication, security, and outbound networking.
199
-
200
- ## Current Boundaries
199
+ ## Verification Notes
201
200
 
202
- - Persistent CRUD generation is verified for MySQL and MongoDB.
203
- - Runtime verification for MySQL, MongoDB, and Redis requires configured development infrastructure.
204
- - Observability, deployment, and operations guidance is the next roadmap phase.
205
- - Real remote deployment or production mutation requires explicit user authorization.
201
+ - Basic project generation is dependency-light and should build without MySQL, MongoDB, or Redis.
202
+ - Persistent CRUD is generated for MySQL and MongoDB.
203
+ - Database and Redis behavior should be verified against configured development infrastructure.
204
+ - Remote deployment or production mutation should be performed only after explicit authorization.
package/bin/cli.js CHANGED
@@ -1,22 +1,56 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import chalk from 'chalk';
4
+ import fs from 'fs';
4
5
  import path from 'path';
6
+ import { fileURLToPath } from 'url';
5
7
 
6
8
  // Get command line arguments
7
9
  const args = process.argv.slice(2);
8
10
 
11
+ // Get current file directory
12
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
+
14
+ const availableCommands = 'create, init, doc, skill';
15
+
16
+ const printUsage = () => {
17
+ console.log(`Usage: gorig-cli <command> [options]
18
+
19
+ Commands:
20
+ init Initialize a new Gorig project
21
+ create Create a module in an existing Gorig project
22
+ doc Generate API documentation
23
+ skill Install the bundled gorig-backend skill
24
+
25
+ Options:
26
+ -h, --help Show this help
27
+ -v, --version Show gorig-cli version`);
28
+ };
29
+
30
+ const readPackageVersion = () => {
31
+ const packagePath = path.join(__dirname, '../package.json');
32
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
33
+ return packageJson.version;
34
+ };
35
+
9
36
  // Validate if a command is provided
10
37
  if (args.length < 1) {
11
- console.error(chalk.red('Please provide a valid command, e.g.: create, init, doc, or skill'));
38
+ console.error(chalk.red(`Please provide a valid command, e.g.: ${availableCommands}`));
12
39
  process.exit(1);
13
40
  }
14
41
 
15
42
  // Extract command
16
43
  const command = args[0];
17
44
 
18
- // Get current file directory
19
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
45
+ if (command === '--version' || command === '-v' || command === 'version') {
46
+ console.log(readPackageVersion());
47
+ process.exit(0);
48
+ }
49
+
50
+ if (command === '--help' || command === '-h' || command === 'help') {
51
+ printUsage();
52
+ process.exit(0);
53
+ }
20
54
 
21
55
  // Execute different logic based on command
22
56
  switch (command) {
@@ -59,6 +93,6 @@ switch (command) {
59
93
 
60
94
  default:
61
95
  console.error(chalk.red(`Unknown command: ${command}`));
62
- console.error(chalk.yellow('Available commands: create, init, doc, skill'));
96
+ console.error(chalk.yellow(`Available commands: ${availableCommands}`));
63
97
  process.exit(1);
64
98
  }
package/commands/init.js CHANGED
@@ -340,6 +340,11 @@ export const initProject = async (options, runtime = {}) => {
340
340
  };
341
341
 
342
342
  const initModule = async (args) => {
343
+ if (args.length === 1 && ['--help', '-h', 'help'].includes(args[0])) {
344
+ printUsage();
345
+ return 0;
346
+ }
347
+
343
348
  try {
344
349
  const options = parseInitArgs(args);
345
350
  await initProject(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gorig-cli",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "type": "module",
5
5
  "description": "gorig build tool",
6
6
  "main": "bin/cli.js",
@@ -7,7 +7,7 @@ Use this workflow when creating a new locally runnable Gorig backend.
7
7
  Confirm or infer safely:
8
8
 
9
9
  - Project directory and Go module name.
10
- - Gorig version: preserve a requested version; otherwise use the selected stable version and report the resolution.
10
+ - Gorig version: preserve a requested version; otherwise use `latest` and report the resolution.
11
11
  - Whether an existing non-empty directory may be replaced. Never pass `--force` without explicit authorization.
12
12
  - Local base port.
13
13
  - Git initialization is a post-generation skill step. Ask after generation and verification; do not let the CLI initialize Git implicitly.
@@ -27,7 +27,7 @@ When `gorig-cli` is installed:
27
27
  ```sh
28
28
  gorig-cli init demo-api \
29
29
  --module example.com/demo-api \
30
- --gorig-version v0.0.52 \
30
+ --gorig-version latest \
31
31
  --port 9527 \
32
32
  --no-start \
33
33
  --no-git
@@ -38,7 +38,7 @@ Unreleased sibling-checkout validation:
38
38
  ```sh
39
39
  node ../gorig-cli/bin/cli.js init demo-api \
40
40
  --module example.com/demo-api \
41
- --gorig-version v0.0.52 \
41
+ --gorig-version latest \
42
42
  --port 9527 \
43
43
  --no-start \
44
44
  --no-git