@kitsy/cnos-docs 1.3.0 → 1.5.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.
@@ -12,3 +12,5 @@ console.log(cnos('public.app.apiBaseUrl'));
12
12
  ```
13
13
 
14
14
  Only promoted browser-safe values are available here.
15
+
16
+ Framework integrations such as `@kitsy/cnos-vite`, `@kitsy/cnos-next`, and `@kitsy/cnos-webpack` are responsible for embedding that browser payload during the build.
@@ -5,6 +5,8 @@ description: Use the default CNOS runtime singleton from the root package.
5
5
 
6
6
  # Singleton Runtime
7
7
 
8
+ Use the default server/runtime singleton when your process is started through `cnos run`, or when you want the zero-config default entrypoint.
9
+
8
10
  ```ts
9
11
  import cnos from '@kitsy/cnos';
10
12
 
@@ -14,3 +16,52 @@ cnos('value.app.name');
14
16
  cnos.value('app.name');
15
17
  cnos.secret('app.token');
16
18
  ```
19
+
20
+ ## Available methods
21
+
22
+ The runtime currently exposes:
23
+
24
+ - `cnos(key)` as shorthand for `cnos.read(key)`
25
+ - `cnos.read(key)`
26
+ - `cnos.require(key)`
27
+ - `cnos.readOr(key, fallback)`
28
+ - `cnos.value(path)`
29
+ - `cnos.secret(path)`
30
+ - `cnos.meta(path)`
31
+ - `cnos.inspect(key)`
32
+ - `cnos.toNamespace(namespace)`
33
+ - `cnos.toEnv()`
34
+ - `cnos.toPublicEnv()`
35
+
36
+ Example:
37
+
38
+ ```ts
39
+ import cnos from '@kitsy/cnos';
40
+
41
+ await cnos.ready();
42
+
43
+ const appName = cnos.value('app.name');
44
+ const dbPassword = cnos.secret('db.password');
45
+ const profile = cnos.meta('profile');
46
+ const port = cnos.readOr('value.server.port', 3000);
47
+ const flags = cnos.toNamespace('flags');
48
+ ```
49
+
50
+ ## Typed values
51
+
52
+ CNOS values are not limited to strings. If the underlying config stores numbers, booleans, arrays, or objects, runtime reads return those values as-is.
53
+
54
+ ```ts
55
+ const enabled = cnos.value<boolean>('flags.upi_enabled');
56
+ const params = cnos.read<string[]>('value.api.default_query_params');
57
+ ```
58
+
59
+ ## What does not exist
60
+
61
+ The current v1 runtime does not expose helper methods such as:
62
+
63
+ - `readAsString()`
64
+ - `readAsNumber()`
65
+ - `readAsBoolean()`
66
+
67
+ Use `read<T>()`, `require<T>()`, or the namespace helpers instead.
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: cnos build env
3
+ description: Build flat env-file artifacts from CNOS.
4
+ ---
5
+
6
+ # cnos build env
7
+
8
+ Use `build env` when a repo still expects `.env.*` files but CNOS is the source of truth.
9
+
10
+ ```bash
11
+ cnos build env --profile local --to .env.local
12
+ cnos build env --profile stage --to .env.stage
13
+ cnos build env --public --framework vite --to .env.production
14
+ ```
15
+
16
+ `build env`:
17
+
18
+ - resolves the selected CNOS workspace/profile
19
+ - renders a deterministic flat `KEY=VALUE` file
20
+ - writes the target path
21
+ - does not start a child process
22
+
23
+ This is the preferred bridge for build systems and CI pipelines that still consume env files.
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: cnos dev env
3
+ description: Watch CNOS config, rewrite env artifacts, and restart a child process.
4
+ ---
5
+
6
+ # cnos dev env
7
+
8
+ Use `dev env` when a local development workflow still expects a `.env.*` file.
9
+
10
+ ```bash
11
+ cnos dev env --profile local --to .env.local -- pnpm dev
12
+ cnos dev env --profile stage --to .env.stage -- node server.js
13
+ cnos dev env --public --framework vite --to .env.local --signal -- pnpm dev
14
+ ```
15
+
16
+ By default `dev env`:
17
+
18
+ - writes the env artifact before first launch
19
+ - watches CNOS inputs
20
+ - rewrites the target file on change
21
+ - restarts the child process
22
+
23
+ Use `--signal` when another tool is responsible for reloads and you only want the file to stay current.
@@ -10,3 +10,16 @@ cnos export env
10
10
  cnos export env --to .env.local
11
11
  cnos export env --public --framework vite --to .env.local
12
12
  ```
13
+
14
+ `export env` is the low-level renderer.
15
+
16
+ Use it when you want:
17
+
18
+ - stdout output for piping
19
+ - one-off JSON/text export behavior
20
+ - direct control over the raw env projection
21
+
22
+ For higher-level file-oriented workflows, prefer:
23
+
24
+ - `cnos build env` for one-shot artifact generation
25
+ - `cnos dev env` for watched dev-time file generation
@@ -9,7 +9,7 @@ The CLI is organized around:
9
9
 
10
10
  - setup: `init`, `onboard`, `use`, `profile`
11
11
  - data operations: `read`, `value`, `secret`, `promote`
12
- - workflows: `run`, `export`, `dump`, `diff`, `doctor`
12
+ - workflows: `build env`, `dev env`, `run`, `export`, `dump`, `diff`, `doctor`
13
13
  - advanced tooling: `codegen`, `watch`, `migrate`, `drift`, `vault`
14
14
 
15
15
  See the individual command pages in this section.
@@ -11,3 +11,38 @@ cnos value get app.name
11
11
  cnos value list --prefix app.
12
12
  cnos value delete app.name
13
13
  ```
14
+
15
+ ## Typed input
16
+
17
+ `cnos value set` parses the input as YAML before writing it. That means you can store more than strings.
18
+
19
+ ```bash
20
+ cnos value set server.port 3000
21
+ cnos value set flags.upi_enabled false
22
+ cnos value set api.default_query_params '["ab", "bc"]'
23
+ cnos value set app.theme '{ primary: blue, density: compact }'
24
+ ```
25
+
26
+ Those values are stored and read back as:
27
+
28
+ - number
29
+ - boolean
30
+ - array
31
+ - object
32
+
33
+ ## Read forms
34
+
35
+ The most common CLI read forms are:
36
+
37
+ ```bash
38
+ cnos value get app.name
39
+ cnos get value app.name
40
+ cnos get value.app.name
41
+ cnos read value.app.name
42
+ ```
43
+
44
+ ## Notes
45
+
46
+ - Values are private by default.
47
+ - To expose a value to browser/public surfaces, use `cnos promote`.
48
+ - To expose a value as shell env, map it through `envMapping.explicit` or `cnos promote --to env`.
@@ -12,3 +12,5 @@ cnos vault list
12
12
  cnos vault logout default
13
13
  cnos vault remove default
14
14
  ```
15
+
16
+ For local vaults, `cnos vault create <name>` initializes the encrypted keystore immediately. CNOS prompts for a passphrase if one is not already available through `CNOS_SECRET_PASSPHRASE_<VAULT>`, `CNOS_SECRET_PASSPHRASE`, or the OS keychain. `cnos vault auth <name>` re-authenticates an existing vault and fails on wrong credentials.
@@ -9,3 +9,13 @@ description: Watch config changes and emit signals or restart processes.
9
9
  cnos watch -- node server.js
10
10
  cnos watch --signal
11
11
  ```
12
+
13
+ `watch` is the low-level graph watcher.
14
+
15
+ Use it when you want to react to CNOS graph changes directly.
16
+
17
+ If your repo still needs `.env.*` files during development, prefer:
18
+
19
+ ```bash
20
+ cnos dev env --profile local --to .env.local -- pnpm dev
21
+ ```
@@ -9,7 +9,9 @@ description: Go from zero to a running CNOS-backed project in a few minutes.
9
9
  cnos init
10
10
  cnos value set app.name demo
11
11
  cnos value set server.port 3000
12
+ cnos value set api.default_query_params '["ab", "bc"]'
12
13
  cnos read value.app.name
14
+ cnos build env --profile local --to .env.local
13
15
  cnos run -- node server.js
14
16
  ```
15
17
 
@@ -29,4 +31,17 @@ import { createCnos } from '@kitsy/cnos/configure';
29
31
 
30
32
  const runtime = await createCnos();
31
33
  console.log(runtime.value('app.name'));
34
+ console.log(runtime.read<string[]>('value.api.default_query_params'));
32
35
  ```
36
+
37
+ If your repo still expects env files, keep `.cnos` as the source of truth and generate them:
38
+
39
+ ```bash
40
+ cnos build env --profile local --to .env.local
41
+ cnos dev env --profile local --to .env.local -- pnpm dev
42
+ ```
43
+
44
+ For frontend builds:
45
+ - Vite: `@kitsy/cnos-vite`
46
+ - Webpack/static bundles: `@kitsy/cnos-webpack`
47
+ - Next.js: `@kitsy/cnos-next`
@@ -22,7 +22,7 @@ cnos value set server.port 3000
22
22
  Create a profile:
23
23
 
24
24
  ```bash
25
- cnos profile create stage --inherit base
25
+ cnos profile create stage
26
26
  cnos use --profile stage
27
27
  ```
28
28
 
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: Frontend with Webpack
3
+ description: Use CNOS public projection with webpack builds, webpack-dev-server, and browser-safe runtime reads.
4
+ ---
5
+
6
+ # Frontend with Webpack
7
+
8
+ CNOS integrates with webpack through `@kitsy/cnos-webpack`. This covers the common static-bundle case where webpack produces a browser build that is then deployed as static assets.
9
+
10
+ Promote browser-safe values:
11
+
12
+ ```yaml
13
+ public:
14
+ promote:
15
+ - value.app.apiUrl
16
+ - flags.upi_enabled
17
+ ```
18
+
19
+ Use an async webpack config:
20
+
21
+ ```ts
22
+ import { createCnos } from '@kitsy/cnos/configure';
23
+ import { CnosWebpackPlugin } from '@kitsy/cnos-webpack';
24
+
25
+ export default async () => {
26
+ const cnos = await createCnos({
27
+ profile: process.env.NODE_ENV === 'production' ? 'prod' : 'local',
28
+ });
29
+
30
+ return {
31
+ devServer: {
32
+ port: Number(cnos.readOr('value.devServer.port', 3000)),
33
+ },
34
+ plugins: [
35
+ new CnosWebpackPlugin({
36
+ profile: process.env.NODE_ENV === 'production' ? 'prod' : 'local',
37
+ }),
38
+ ],
39
+ };
40
+ };
41
+ ```
42
+
43
+ Read in browser code:
44
+
45
+ ```ts
46
+ import cnos from '@kitsy/cnos/browser';
47
+
48
+ console.log(cnos('public.app.apiUrl'));
49
+ console.log(cnos('public.flags.upi_enabled'));
50
+ console.log(process.env.APP_API_URL);
51
+ ```
52
+
53
+ The webpack plugin:
54
+ - injects `process.env.*` define replacements for promoted public values
55
+ - embeds `globalThis.__CNOS_BROWSER_DATA__` for `@kitsy/cnos/browser`
56
+ - keeps server-only `value.*` and `secret.*` out of the browser bundle
57
+
58
+ If you need build-time server config such as `devServer.port`, read it in the webpack config through `createCnos()` so dev and production builds use the same CNOS source of truth.
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: Generated Env Files
3
+ description: Use CNOS to generate legacy .env artifacts while keeping .cnos as the source of truth.
4
+ ---
5
+
6
+ # Generated Env Files
7
+
8
+ CNOS is runtime-first, but many repos still rely on `.env.local`, `.env.stage`, or similar files.
9
+
10
+ Use generated env files as a **bridge**, not as the source of truth.
11
+
12
+ ## One-shot build
13
+
14
+ ```bash
15
+ cnos build env --profile local --to .env.local
16
+ cnos build env --profile stage --to .env.stage
17
+ cnos build env --profile prod --to .env.prod
18
+ ```
19
+
20
+ ## Watched dev loop
21
+
22
+ ```bash
23
+ cnos dev env --profile local --to .env.local -- pnpm dev
24
+ ```
25
+
26
+ ## Public-only frontend artifacts
27
+
28
+ ```bash
29
+ cnos build env --public --framework vite --profile local --to .env.local
30
+ cnos build env --public --framework next --profile prod --to .env.production
31
+ ```
32
+
33
+ ## Recommended policy
34
+
35
+ - keep `.cnos` as the source of truth
36
+ - keep generated `.env.*` files gitignored
37
+ - migrate app code toward direct CNOS reads over time
38
+ - keep secrets on runtime/vault flows instead of materializing them into env files by default
@@ -16,6 +16,17 @@ cnos migrate --apply --rewrite
16
16
  Bridge to existing tooling:
17
17
 
18
18
  ```bash
19
- cnos export env --to .env.local
20
- cnos export env --profile stage --to .env.stage
19
+ cnos build env --to .env.local
20
+ cnos build env --profile stage --to .env.stage
21
+ cnos dev env --profile local --to .env.local -- pnpm dev
21
22
  ```
23
+
24
+ For webpack or other static bundles, pair this with `@kitsy/cnos-webpack` or `@kitsy/cnos/build` so browser-safe `public.*` values are injected at build time without keeping handwritten `.env` files as the source of truth.
25
+
26
+ Recommended migration sequence:
27
+
28
+ 1. Keep `.cnos` as the source of truth.
29
+ 2. Generate `.env.*` artifacts for legacy tools.
30
+ 3. Migrate server code to `@kitsy/cnos`.
31
+ 4. Migrate browser code to `@kitsy/cnos/browser`.
32
+ 5. Remove env-file dependencies app by app.
@@ -8,8 +8,14 @@ description: Create explicit overlays for stage, prod, and other environments.
8
8
  Profiles are explicit overlays, not implicit defaults.
9
9
 
10
10
  ```bash
11
- cnos profile create stage --inherit base
11
+ cnos profile create stage
12
12
  cnos use --profile stage
13
13
  cnos value set app.apiBaseUrl https://api.stage
14
14
  cnos diff base stage
15
15
  ```
16
+
17
+ Profiles inherit values from `base` by default. For a clean profile with no base fallback:
18
+
19
+ ```bash
20
+ cnos profile create isolated --no-inherit
21
+ ```
@@ -13,6 +13,8 @@ cnos vault auth default
13
13
  cnos secret set app.token super-secret --vault default
14
14
  ```
15
15
 
16
+ `cnos vault create default` initializes the local encrypted vault immediately. If CNOS cannot resolve a passphrase from env or keychain, it prompts interactively. `cnos vault auth default` is only for re-authenticating an existing vault and rejects wrong passphrases.
17
+
16
18
  CI-backed vault:
17
19
 
18
20
  ```bash
@@ -12,6 +12,7 @@ Key sections:
12
12
  - `profiles`
13
13
  - `envMapping`
14
14
  - `public`
15
+ - `namespaces`
15
16
  - `vaults`
16
17
  - `schema`
17
18
  - `writePolicy`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Namespaces
3
- description: Understand value, secret, meta, public, and env projection surfaces.
3
+ description: Understand value, secret, meta, public, env, and custom data namespaces.
4
4
  ---
5
5
 
6
6
  # Namespaces
@@ -10,8 +10,28 @@ Primary namespaces:
10
10
  - `value.*`
11
11
  - `secret.*`
12
12
  - `meta.*`
13
+ - `process.*` for server-only ambient runtime state
14
+ - custom data namespaces such as `flags.*` or `config.*` when declared in `.cnos/cnos.yml`
13
15
 
14
16
  Derived surfaces:
15
17
 
16
18
  - `public.*` for promoted browser-safe values
17
19
  - explicit env exports through `envMapping.explicit`
20
+
21
+ Custom data namespaces can be:
22
+
23
+ - read at runtime with `cnos('flags.upi_enabled')`
24
+ - written through the CLI with `cnos set flags.upi_enabled false`
25
+ - promoted to `public.*` when the namespace is `shareable: true`
26
+ - exported through `envMapping.explicit`
27
+
28
+ `process.*` is built in and read-only. Typical keys include:
29
+
30
+ - `process.cwd`
31
+ - `process.platform`
32
+ - `process.arch`
33
+ - `process.node.version`
34
+ - `process.args.raw`
35
+ - `process.env.PATH`
36
+
37
+ `process.*` cannot be promoted or exported.
package/manifest.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  product: cnos
2
2
  title: CNOS Documentation
3
3
  tagline: Configuration orchestration for apps, monorepos, and deployment pipelines
4
- version: "1.3"
4
+ version: "1.5"
5
5
 
6
6
  sidebar:
7
7
  - group: Getting Started
@@ -21,6 +21,8 @@ sidebar:
21
21
  label: Backend Projects
22
22
  - path: guides/frontend-vite
23
23
  label: Frontend with Vite
24
+ - path: guides/frontend-webpack
25
+ label: Frontend with Webpack
24
26
  - path: guides/frontend-next
25
27
  label: Frontend with Next.js
26
28
  - path: guides/ssr
@@ -35,6 +37,8 @@ sidebar:
35
37
  label: Secrets and Vaults
36
38
  - path: guides/migration
37
39
  label: Migrating from .env
40
+ - path: guides/generated-env-files
41
+ label: Generated Env Files
38
42
 
39
43
  - group: CLI Reference
40
44
  collapsed: true
@@ -55,6 +59,10 @@ sidebar:
55
59
  label: cnos validate
56
60
  - path: cli/export
57
61
  label: cnos export
62
+ - path: cli/build
63
+ label: cnos build env
64
+ - path: cli/dev
65
+ label: cnos dev env
58
66
  - path: cli/run
59
67
  label: cnos run
60
68
  - path: cli/diff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos-docs",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Source-of-truth CNOS documentation content for Astro Starlight and other static docs consumers.",
5
5
  "type": "module",
6
6
  "exports": {