kozou 0.0.2 → 0.1.1

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.
Files changed (44) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +97 -17
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +54 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/dev-runtime.d.ts +5 -0
  8. package/dist/commands/dev-runtime.d.ts.map +1 -0
  9. package/dist/commands/dev-runtime.js +38 -0
  10. package/dist/commands/dev-runtime.js.map +1 -0
  11. package/dist/commands/dev.d.ts +5 -0
  12. package/dist/commands/dev.d.ts.map +1 -0
  13. package/dist/commands/dev.js +96 -0
  14. package/dist/commands/dev.js.map +1 -0
  15. package/dist/commands/inspect.d.ts +10 -0
  16. package/dist/commands/inspect.d.ts.map +1 -0
  17. package/dist/commands/inspect.js +47 -0
  18. package/dist/commands/inspect.js.map +1 -0
  19. package/dist/commands/mcp.d.ts +9 -0
  20. package/dist/commands/mcp.d.ts.map +1 -0
  21. package/dist/commands/mcp.js +29 -0
  22. package/dist/commands/mcp.js.map +1 -0
  23. package/dist/config.d.ts +54 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +178 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/create-kozou.d.ts +3 -0
  28. package/dist/create-kozou.d.ts.map +1 -0
  29. package/dist/create-kozou.js +27 -0
  30. package/dist/create-kozou.js.map +1 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +22 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/scaffold.d.ts +11 -0
  36. package/dist/scaffold.d.ts.map +1 -0
  37. package/dist/scaffold.js +65 -0
  38. package/dist/scaffold.js.map +1 -0
  39. package/dist/templates/docker-compose.yml +64 -0
  40. package/dist/templates/env.example +17 -0
  41. package/dist/templates/kozou.config.yaml +29 -0
  42. package/dist/templates/migrations/0001_init.sql +25 -0
  43. package/dist/templates/ui-hints.yaml +26 -0
  44. package/package.json +52 -21
package/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Takashi Matsuyama
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.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,30 +1,110 @@
1
1
  # kozou
2
2
 
3
- PostgreSQL compiler. One source, many faithful forms.
3
+ CLI entry point for [Kozou](https://kozou.org): scaffolding,
4
+ schema introspection, and MCP server hand-off. See *Kozou v0.1
5
+ design spec* §9 for the command surface.
4
6
 
5
- Kozou reads a PostgreSQL schema once and produces every form a modern team and its AI need from it — admin UI, MCP context, TypeScript types, GraphQL endpoints, and documentation. No duplicate definitions. No drift.
7
+ ## Install
6
8
 
7
- ## Status
9
+ ```bash
10
+ # Global, so the bin entries are on PATH
11
+ npm install -g kozou
8
12
 
9
- Pre-release (v0.0.x). Core architecture and public API are being designed. Source code and documentation will land in this package as development proceeds.
13
+ # Or use npx without installing
14
+ npx kozou inspect --help
10
15
 
11
- ## Roadmap
16
+ # `create-kozou` is a secondary bin shipped by the `kozou` package
17
+ # (not a standalone npm package), so npx needs `-p kozou` to find
18
+ # it on a machine that has not installed kozou globally yet.
19
+ npx -p kozou create-kozou my-project
20
+ ```
12
21
 
13
- - v0.1: schema reader (DDL + comments + constraints)
14
- - v0.2: TypeScript type emitter
15
- - v0.3: MCP context emitter
16
- - v0.4: admin UI scaffolder
17
- - v0.5: GraphQL endpoint emitter
18
- - v0.6: documentation emitter
22
+ The package publishes through `./dist/`. `bin` exposes two entries:
19
23
 
20
- ## Name
24
+ - `kozou` - the main multi-command CLI (`inspect` / `mcp` / `dev`)
25
+ - `create-kozou` - scaffolds a project directory with
26
+ `docker-compose.yml`, `kozou.config.yaml`, `ui-hints.yaml`,
27
+ `env.example`, and a starter migration
21
28
 
22
- **Kozou** carries three meanings in three syllables:
29
+ ## Commands
23
30
 
24
- - **子象** (*kozō*) — the young elephant; the calf walking beside PostgreSQL's mascot Slonik
25
- - **構造** (*kōzō*) — structure; the structural transformation a compiler performs
26
- - **小僧** (*kozō*) — the apprentice; the quiet figure who serves something larger than itself
31
+ ### `kozou inspect`
32
+
33
+ Introspects the configured PostgreSQL database and emits a Schema
34
+ Context to stdout (or `--output <path>`):
35
+
36
+ ```bash
37
+ DATABASE_URL=postgres://kozou:kozou@localhost:5432/kozou \
38
+ kozou inspect --format yaml > schema.yaml
39
+ ```
40
+
41
+ ### `kozou mcp --stdio`
42
+
43
+ Starts an MCP server over stdio so Claude Code / other AI agents
44
+ can call the introspect / describe-table tools:
45
+
46
+ ```bash
47
+ DATABASE_URL=postgres://kozou:kozou@localhost:5432/kozou \
48
+ npx kozou mcp --stdio
49
+ ```
50
+
51
+ The `${DATABASE_URL}` placeholder inside the bundled
52
+ `kozou.config.yaml` template is what consumes that env var; the
53
+ `kozou` CLI does not honor `KOZOU_DATABASE_URL` directly (an alias
54
+ is on the roadmap). HTTP transport is available via
55
+ `kozou mcp --http` (`--port` / `--host` configure the listener;
56
+ stdio stays the default).
57
+
58
+ ### `kozou dev`
59
+
60
+ Runs the bundled `@kozou/svelte-ui` Admin UI (adapter-node)
61
+ alongside an MCP HTTP server, both wired up from
62
+ `kozou.config.yaml`. The Admin UI listens on port 3333 and the MCP
63
+ HTTP server on 3334 by default (override via `server.ui` /
64
+ `server.mcp.http` in the config); `Ctrl-C` (SIGINT / SIGTERM)
65
+ tears both down. This is the command behind the `kozou` service in
66
+ the scaffolded `docker-compose.yml`.
67
+
68
+ ### `create-kozou <dir>`
69
+
70
+ Scaffolds a project directory at `<dir>` from the templates
71
+ bundled in `dist/templates/`:
72
+
73
+ ```bash
74
+ npx -p kozou create-kozou my-project
75
+ cd my-project
76
+ cp .env.example .env
77
+ docker compose up
78
+ ```
79
+
80
+ The generated `docker-compose.yml` brings up PostgreSQL, PostgREST,
81
+ and a `kozou` service that runs `kozou dev` to host the Admin UI +
82
+ MCP HTTP server.
83
+
84
+ ## Configuration
85
+
86
+ `kozou.config.yaml` (template in `dist/templates/`) drives every
87
+ command:
88
+
89
+ ```yaml
90
+ database:
91
+ url: ${DATABASE_URL}
92
+ schemas: [public]
93
+
94
+ adapter:
95
+ type: postgrest
96
+ url: ${KOZOU_ADAPTER_URL:-http://postgrest:3000}
97
+
98
+ uiHints:
99
+ path: ./ui-hints.yaml
100
+ ```
101
+
102
+ The full schema also accepts `server.ui.{port,host}`,
103
+ `server.mcp.http.{port,host}`, `server.mcp.stdio`, and
104
+ `cache.ttlMs` overrides; defaults match the template that
105
+ `create-kozou` writes. `${VAR}` and `${VAR:-default}` are
106
+ expanded from the process environment at load time.
27
107
 
28
108
  ## License
29
109
 
30
- MIT
110
+ Apache 2.0. See [LICENSE](../../LICENSE) at the repository root.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ // `kozou` CLI entry point. Wires up the sub-commands defined in
3
+ // Kozou v0.1 design spec §9.1 via commander.
4
+ import { Command } from 'commander';
5
+ import { inspectCommand } from './commands/inspect.js';
6
+ import { mcpCommand } from './commands/mcp.js';
7
+ import { devCommand } from './commands/dev.js';
8
+ import { PACKAGE_VERSION } from './index.js';
9
+ const program = new Command()
10
+ .name('kozou')
11
+ .description('PostgreSQL compiler. One source, many faithful forms. (Kozou v0.1 design spec §9)')
12
+ .version(PACKAGE_VERSION);
13
+ program
14
+ .command('inspect')
15
+ .description('Dump the Schema Context as JSON or YAML.')
16
+ .option('--format <fmt>', 'output format: json | yaml', 'json')
17
+ .option('--output <path>', 'output file (- for stdout)', '-')
18
+ .option('--config <path>', 'path to kozou.config.yaml')
19
+ .action(async (flags) => {
20
+ await inspectCommand({
21
+ format: flags.format,
22
+ output: flags.output,
23
+ config: flags.config,
24
+ });
25
+ });
26
+ program
27
+ .command('mcp')
28
+ .description('Run the MCP server (--stdio default, or --http).')
29
+ .option('--stdio', 'use stdio transport (default)')
30
+ .option('--http', 'use Streamable HTTP transport')
31
+ .option('--port <n>', 'HTTP port (default 3334)', (raw) => parseInt(raw, 10))
32
+ .option('--host <host>', 'HTTP bind host (default 127.0.0.1)')
33
+ .option('--config <path>', 'path to kozou.config.yaml')
34
+ .action(async (flags) => {
35
+ await mcpCommand({
36
+ stdio: flags.stdio,
37
+ http: flags.http,
38
+ port: flags.port,
39
+ host: flags.host,
40
+ config: flags.config,
41
+ });
42
+ });
43
+ program
44
+ .command('dev')
45
+ .description('Run the bundled Admin UI + MCP HTTP dev server.')
46
+ .option('--config <path>', 'path to kozou.config.yaml')
47
+ .action(async (flags) => {
48
+ await devCommand({ config: flags.config });
49
+ });
50
+ program.parseAsync(process.argv).catch((err) => {
51
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
52
+ process.exit(1);
53
+ });
54
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,gEAAgE;AAChE,6CAA6C;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAoB7C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;KAC1B,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CACV,mFAAmF,CACpF;KACA,OAAO,CAAC,eAAe,CAAC,CAAC;AAE5B,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,CAAC;KAC9D,MAAM,CAAC,iBAAiB,EAAE,4BAA4B,EAAE,GAAG,CAAC;KAC5D,MAAM,CAAC,iBAAiB,EAAE,2BAA2B,CAAC;KACtD,MAAM,CAAC,KAAK,EAAE,KAAmB,EAAE,EAAE;IACpC,MAAM,cAAc,CAAC;QACnB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,CAAC,SAAS,EAAE,+BAA+B,CAAC;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
3
+ export declare function resolveOrigin(config: KozouConfig, env: NodeJS.ProcessEnv): string;
4
+ export declare function buildAdminUiEnv(config: KozouConfig, origin: string, baseEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
5
+ //# sourceMappingURL=dev-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-runtime.d.ts","sourceRoot":"","sources":["../../src/commands/dev-runtime.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,wBAAgB,mBAAmB,IAAI,MAAM,CAI5C;AAMD,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAEjF;AAID,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,CAAC,UAAU,GACzB,MAAM,CAAC,UAAU,CAUnB"}
@@ -0,0 +1,38 @@
1
+ // Pure wiring helpers for `kozou dev` (see commands/dev.ts).
2
+ //
3
+ // Kept separate from the spawn / lifecycle shell in dev.ts so the
4
+ // config -> child-process-env / origin / entry-path mapping can be unit
5
+ // tested without launching any servers.
6
+ import { createRequire } from 'node:module';
7
+ import { dirname, join } from 'node:path';
8
+ // Resolve the Admin UI's adapter-node standalone server entry. The
9
+ // `build/` directory ships in @kozou/svelte-ui's published `files`, and
10
+ // resolving the package's own package.json works whether kozou runs from
11
+ // a flat node_modules tree (Docker / npm install) or a workspace symlink
12
+ // (local dev).
13
+ export function resolveAdminUiEntry() {
14
+ const require = createRequire(import.meta.url);
15
+ const pkgJsonPath = require.resolve('@kozou/svelte-ui/package.json');
16
+ return join(dirname(pkgJsonPath), 'build', 'index.js');
17
+ }
18
+ // The browser-facing origin the Admin UI must accept form posts from.
19
+ // An explicit ORIGIN / KOZOU_ORIGIN wins; otherwise default to localhost
20
+ // on the UI port (host stays 0.0.0.0 for binding, but browsers reach it
21
+ // as localhost in the common single-host case).
22
+ export function resolveOrigin(config, env) {
23
+ return env.ORIGIN ?? env.KOZOU_ORIGIN ?? `http://localhost:${config.server.ui.port}`;
24
+ }
25
+ // Build the child-process environment for the Admin UI server. Keeping
26
+ // it pure makes the wiring unit-testable without spawning anything.
27
+ export function buildAdminUiEnv(config, origin, baseEnv) {
28
+ return {
29
+ ...baseEnv,
30
+ DATABASE_URL: config.database.url,
31
+ KOZOU_ADAPTER_URL: config.adapter.url,
32
+ PORT: String(config.server.ui.port),
33
+ HOST: config.server.ui.host,
34
+ ORIGIN: origin,
35
+ NODE_ENV: 'production',
36
+ };
37
+ }
38
+ //# sourceMappingURL=dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-runtime.js","sourceRoot":"","sources":["../../src/commands/dev-runtime.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,wCAAwC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAI1C,mEAAmE;AACnE,wEAAwE;AACxE,yEAAyE;AACzE,yEAAyE;AACzE,eAAe;AACf,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,UAAU,aAAa,CAAC,MAAmB,EAAE,GAAsB;IACvE,OAAO,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,YAAY,IAAI,oBAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;AACvF,CAAC;AAED,uEAAuE;AACvE,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAC7B,MAAmB,EACnB,MAAc,EACd,OAA0B;IAE1B,OAAO;QACL,GAAG,OAAO;QACV,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG;QACjC,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG;QACrC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACnC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI;QAC3B,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,YAAY;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type DevOptions = {
2
+ config?: string;
3
+ };
4
+ export declare function devCommand(opts?: DevOptions): Promise<void>;
5
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AA8BA,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,wBAAsB,UAAU,CAAC,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA6ErE"}
@@ -0,0 +1,96 @@
1
+ // `kozou dev` command implementation.
2
+ //
3
+ // Brings up the full local runtime described in Kozou v0.1 spec §9.1:
4
+ // - the bundled @kozou/svelte-ui Admin UI, spawned as a child process
5
+ // (`node <svelte-ui>/build/index.js` — the adapter-node standalone
6
+ // server, the same entry the svelte-ui E2E suite exercises);
7
+ // - the MCP Streamable HTTP server, run in-process via @kozou/mcp's
8
+ // startHttpServer (spec §7.1).
9
+ //
10
+ // Both default to 0.0.0.0 (spec §9.1, so `docker compose` port mapping
11
+ // works); a loud warning fires on a non-loopback bind because neither
12
+ // surface authenticates in v0.1 (spec §18.5).
13
+ //
14
+ // The Admin UI is an adapter-node (SvelteKit) server: without ORIGIN it
15
+ // assumes https and rejects every form POST over plain http with a 403.
16
+ // We default ORIGIN to http://localhost:<ui-port>; override via the
17
+ // ORIGIN / KOZOU_ORIGIN env when serving on a different public URL.
18
+ import { spawn } from 'node:child_process';
19
+ import { existsSync } from 'node:fs';
20
+ import { SchemaCache, startHttpServer, isLoopbackHost } from '@kozou/mcp';
21
+ import { loadConfig } from '../config.js';
22
+ import { buildAdminUiEnv, resolveAdminUiEntry, resolveOrigin, } from './dev-runtime.js';
23
+ const PREFIX = '[kozou dev]';
24
+ function warnIfPublic(label, host) {
25
+ if (isLoopbackHost(host))
26
+ return;
27
+ process.stderr.write(`${PREFIX} WARNING: ${label} bound to non-loopback host "${host}".\n` +
28
+ `${PREFIX} v0.1 has NO authentication (spec §18.5). Anyone who can reach\n` +
29
+ `${PREFIX} ${host} can use it. This is expected inside docker compose;\n` +
30
+ `${PREFIX} avoid it on an untrusted network or put an auth proxy in front.\n`);
31
+ }
32
+ export async function devCommand(opts = {}) {
33
+ const config = await loadConfig({ path: opts.config });
34
+ const adminUiEntry = resolveAdminUiEntry();
35
+ if (!existsSync(adminUiEntry)) {
36
+ throw new Error(`${PREFIX} Admin UI build not found at ${adminUiEntry}. ` +
37
+ 'Reinstall @kozou/svelte-ui (its `build/` output ships in the package), ' +
38
+ 'or in a workspace checkout run `pnpm --filter @kozou/svelte-ui run build`.');
39
+ }
40
+ const cache = new SchemaCache({
41
+ connection: config.database.url,
42
+ schemas: config.database.schemas,
43
+ ttlMs: config.cache.ttlMs,
44
+ });
45
+ // 1. MCP HTTP, in-process. startHttpServer already warns on a
46
+ // non-loopback bind, so we do not double-warn for it.
47
+ const mcp = await startHttpServer(cache, {
48
+ port: config.server.mcp.http.port,
49
+ host: config.server.mcp.http.host,
50
+ logPrefix: `${PREFIX} mcp`,
51
+ });
52
+ // 2. Admin UI, as a child process.
53
+ warnIfPublic('Admin UI', config.server.ui.host);
54
+ const origin = resolveOrigin(config, process.env);
55
+ const child = spawn('node', [adminUiEntry], {
56
+ env: buildAdminUiEnv(config, origin, process.env),
57
+ stdio: ['ignore', 'pipe', 'pipe'],
58
+ });
59
+ child.stdout?.on('data', (b) => process.stdout.write(`${PREFIX} ui | ${b}`));
60
+ child.stderr?.on('data', (b) => process.stderr.write(`${PREFIX} ui | ${b}`));
61
+ process.stderr.write(`${PREFIX} Admin UI on http://${config.server.ui.host}:${config.server.ui.port}` +
62
+ ` (origin ${origin})\n`);
63
+ // 3. Lifecycle: tear both down together. Resolve the promise (and thus
64
+ // let the CLI exit) only once everything has stopped.
65
+ await new Promise((resolve) => {
66
+ let shuttingDown = false;
67
+ const shutdown = (reason) => {
68
+ if (shuttingDown)
69
+ return;
70
+ shuttingDown = true;
71
+ process.stderr.write(`${PREFIX} ${reason}, shutting down\n`);
72
+ if (child.exitCode === null && child.signalCode === null) {
73
+ child.kill('SIGTERM');
74
+ }
75
+ void mcp.close().finally(() => resolve());
76
+ };
77
+ process.on('SIGINT', () => shutdown('SIGINT received'));
78
+ process.on('SIGTERM', () => shutdown('SIGTERM received'));
79
+ child.on('exit', (code, signal) => {
80
+ if (shuttingDown)
81
+ return;
82
+ // The Admin UI process died on its own — surface its exit status
83
+ // and bring the MCP server down with it.
84
+ process.stderr.write(`${PREFIX} Admin UI exited (code=${code ?? 'null'}, signal=${signal ?? 'null'})\n`);
85
+ process.exitCode = code ?? 1;
86
+ shuttingDown = true;
87
+ void mcp.close().finally(() => resolve());
88
+ });
89
+ child.on('error', (err) => {
90
+ process.stderr.write(`${PREFIX} failed to spawn Admin UI: ${err.message}\n`);
91
+ process.exitCode = 1;
92
+ shutdown('spawn error');
93
+ });
94
+ });
95
+ }
96
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,sEAAs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C,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAC;YAC7B,YAAY,GAAG,IAAI,CAAC;YACpB,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,8BAA8B,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YAC7E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type InspectOptions = {
2
+ /** Output format. Default: 'json'. */
3
+ format?: 'json' | 'yaml';
4
+ /** Output destination. '-' = stdout (default), otherwise a file path. */
5
+ output?: string;
6
+ /** Path to kozou.config.yaml. Default: ./kozou.config.yaml. */
7
+ config?: string;
8
+ };
9
+ export declare function inspectCommand(opts?: InspectOptions): Promise<void>;
10
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,cAAc,GAAG;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,cAAc,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkC7E"}