@kitsy/cnos-docs 1.7.0 → 1.8.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.
@@ -54,3 +54,16 @@ runtime.registerRuntimeProvider('request', (key) => {
54
54
 
55
55
  const origin = runtime.value('app.origin');
56
56
  ```
57
+
58
+ Workspace selection can come from three places:
59
+
60
+ 1. explicit `workspace` in `createCnos({ ... })`
61
+ 2. a package-local `.cnosrc.yml`
62
+ 3. the manifest default workspace
63
+
64
+ Typical monorepo package anchor:
65
+
66
+ ```yaml
67
+ root: ../../.cnos
68
+ workspace: api
69
+ ```
package/docs/cli/init.mdx CHANGED
@@ -1,11 +1,40 @@
1
1
  ---
2
2
  title: cnos init
3
- description: Scaffold a CNOS project structure in the current repo.
3
+ description: Scaffold a CNOS project in regular mode or workspace mode.
4
4
  ---
5
5
 
6
6
  # cnos init
7
7
 
8
+ Use regular mode first:
9
+
8
10
  ```bash
9
11
  cnos init
10
- cnos init --workspace api
11
12
  ```
13
+
14
+ That creates a flat `.cnos/` tree with `profiles.default: local`.
15
+
16
+ Create workspace mode explicitly:
17
+
18
+ ```bash
19
+ cnos init --mode workspace
20
+ ```
21
+
22
+ That creates:
23
+
24
+ - `.cnos/workspaces/base`
25
+ - `.cnosrc.yml` pointing to `./.cnos`
26
+ - `.cnos-workspace.yml` with `workspace: base`
27
+
28
+ Create child workspaces during init:
29
+
30
+ ```bash
31
+ cnos init --mode workspace --workspaces api,web,agents
32
+ ```
33
+
34
+ This creates `base` plus `api`, `web`, and `agents`, with each child extending `base`.
35
+
36
+ ## Notes
37
+
38
+ - `base` is the default shared workspace convention.
39
+ - `local` is the default profile.
40
+ - If you already started in regular mode and later need multiple apps, use `cnos workspace enable` instead of reinitializing the repo.
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: cnos onboard
3
+ description: Import existing env or config files into CNOS source storage and value.*.
4
+ ---
5
+
6
+ # cnos onboard
7
+
8
+ `cnos onboard` helps migrate existing config sources into CNOS without forcing an immediate app-code rewrite.
9
+
10
+ ## Auto-discover dotenv files
11
+
12
+ ```bash
13
+ cnos onboard
14
+ ```
15
+
16
+ By default CNOS scans the repo root for `.env`, `.env.<profile>`, and `.env.*.example` files.
17
+
18
+ It copies those files into CNOS source storage and prints the proposed `value.*` mappings.
19
+
20
+ ## Explicit source formats
21
+
22
+ ```bash
23
+ cnos onboard --env .env.production
24
+ cnos onboard --yaml config/app.yml
25
+ cnos onboard --json config/settings.json
26
+ cnos onboard --toml config/app.toml
27
+ cnos onboard --config config/app.yml
28
+ ```
29
+
30
+ ## Materialize values
31
+
32
+ Interactive mode prompts before writing values.
33
+
34
+ For automation:
35
+
36
+ ```bash
37
+ cnos onboard --env .env.production --materialize
38
+ cnos onboard --yaml config/db.yml --source-only
39
+ ```
40
+
41
+ Non-interactive shells default to `--source-only` unless `--materialize` is passed explicitly.
42
+
43
+ ## Prefix imports
44
+
45
+ ```bash
46
+ cnos onboard --yaml config/db.yml --prefix db --materialize
47
+ ```
48
+
49
+ This maps:
50
+
51
+ - `host` -> `value.db.host`
52
+ - `port` -> `value.db.port`
53
+
54
+ ## Workspace-aware behavior
55
+
56
+ - Regular mode imports into the implicit `base` layer.
57
+ - Workspace mode imports into the selected workspace.
58
+ - If no workspace is specified in workspace mode, CNOS defaults to `base` when it exists.
59
+
60
+ Example:
61
+
62
+ ```bash
63
+ cnos onboard --workspace api --env .env.api --materialize
64
+ ```
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: cnos workspace
3
+ description: Enable workspace mode, add child workspaces, and manage attach or detach flows.
4
+ ---
5
+
6
+ # cnos workspace
7
+
8
+ Use `cnos workspace` when one CNOS root needs to serve more than one app or package.
9
+
10
+ ## Enable workspace mode
11
+
12
+ If the repo started with a flat `.cnos/` tree:
13
+
14
+ ```bash
15
+ cnos workspace enable
16
+ ```
17
+
18
+ CNOS moves:
19
+
20
+ - `.cnos/values` -> `.cnos/workspaces/base/values`
21
+ - `.cnos/secrets` -> `.cnos/workspaces/base/secrets`
22
+ - `.cnos/env` -> `.cnos/workspaces/base/env`
23
+ - `.cnos/profiles` -> `.cnos/workspaces/base/profiles`
24
+
25
+ and updates the root anchor to `workspace: base`.
26
+
27
+ ## Add a workspace
28
+
29
+ ```bash
30
+ cnos workspace add travel --package-root apps/travel
31
+ ```
32
+
33
+ If `base` exists, the new workspace automatically gets `extends: [base]`.
34
+
35
+ Override that when needed:
36
+
37
+ ```bash
38
+ cnos workspace add api --extends shared
39
+ cnos workspace add sandbox --extends none
40
+ ```
41
+
42
+ ## List and remove
43
+
44
+ ```bash
45
+ cnos workspace list
46
+ cnos workspace remove gallery
47
+ ```
48
+
49
+ ## Scaffold wording
50
+
51
+ If your team prefers scaffold wording:
52
+
53
+ ```bash
54
+ cnos workspace scaffold insights --package-root apps/insights --extends base
55
+ ```
56
+
57
+ ## Detach and attach
58
+
59
+ ```bash
60
+ cnos workspace detach --package-root apps/travel
61
+ cnos workspace attach --package-root apps/travel
62
+ ```
63
+
64
+ Detach makes a child package independent. Attach imports it back into the parent workspace model.
@@ -5,16 +5,19 @@ description: Go from zero to a running CNOS-backed project in a few minutes.
5
5
 
6
6
  # Quick Start
7
7
 
8
+ Start with regular mode:
9
+
8
10
  ```bash
9
11
  cnos init
10
12
  cnos value set app.name demo
11
13
  cnos value set server.port 3000
12
- cnos value set api.default_query_params '["ab", "bc"]'
13
14
  cnos read value.app.name
14
15
  cnos build env --profile local --to .env.local
15
16
  cnos run -- node server.js
16
17
  ```
17
18
 
19
+ That gives you one flat `.cnos/` tree and `profiles.default: local`.
20
+
18
21
  In app code:
19
22
 
20
23
  ```ts
@@ -24,31 +27,18 @@ await cnos.ready();
24
27
  console.log(cnos('value.app.name'));
25
28
  ```
26
29
 
27
- For explicit creation:
30
+ When the repo grows into multiple apps or packages, convert it instead of duplicating `.cnos`:
28
31
 
29
- ```ts
30
- import { createCnos } from '@kitsy/cnos/configure';
31
-
32
- const runtime = await createCnos();
33
- console.log(runtime.value('app.name'));
34
- console.log(runtime.read<string[]>('value.api.default_query_params'));
32
+ ```bash
33
+ cnos workspace enable
34
+ cnos workspace add main --package-root apps/main
35
+ cnos workspace add insights --package-root apps/insights
36
+ cnos workspace list
35
37
  ```
36
38
 
37
- If your repo still expects env files, keep `.cnos` as the source of truth and generate them:
39
+ If the repo still expects env files, keep CNOS as the source of truth and generate them:
38
40
 
39
41
  ```bash
40
42
  cnos build env --profile local --to .env.local
41
43
  cnos dev env --profile local --to .env.local -- pnpm dev
42
44
  ```
43
-
44
- For frontend builds:
45
- - Vite: `@kitsy/cnos-vite`
46
- - Webpack/static bundles: `@kitsy/cnos-webpack`
47
- - Next.js: `@kitsy/cnos-next`
48
-
49
- For webpack/static bundles, build-time settings can come from CNOS too:
50
-
51
- ```bash
52
- cnos set value dev.server.port 8800
53
- npm run dev
54
- ```
@@ -33,3 +33,11 @@ cnos vault create default
33
33
  cnos vault auth default
34
34
  cnos secret set app.token super-secret --vault default
35
35
  ```
36
+
37
+ If the project later becomes a monorepo, do not create a second `.cnos`. Convert the existing repo and add children:
38
+
39
+ ```bash
40
+ cnos workspace enable
41
+ cnos workspace add api --package-root apps/api
42
+ cnos workspace add admin --package-root apps/admin
43
+ ```
@@ -5,95 +5,97 @@ description: Use CNOS workspaces to model multiple apps inside one repo.
5
5
 
6
6
  # Workspaces and Monorepos
7
7
 
8
- For monorepos, keep one authoritative `.cnos/` tree at the repo root and put a `.cnosrc.yml` anchor in each consuming app or package.
8
+ CNOS has two repo shapes:
9
9
 
10
- Repo root as both author and consumer:
10
+ - regular mode: one flat `.cnos/` tree
11
+ - workspace mode: `.cnos/workspaces/<id>/...`
11
12
 
12
- ```yaml
13
- # .cnosrc.yml
14
- root: ./.cnos
15
- ```
16
-
17
- Child app:
18
-
19
- ```yaml
20
- # apps/travel/.cnosrc.yml
21
- root: ../../.cnos
22
- workspace: travel
23
- ```
24
-
25
- Child app from a remote config repo:
13
+ The intended progression is:
26
14
 
27
- ```yaml
28
- root: git+https://github.com/org/config.git#v2.1.0
29
- workspace: travel
15
+ ```bash
16
+ cnos init
17
+ cnos workspace enable
18
+ cnos workspace add api --package-root apps/api
19
+ cnos workspace add web --package-root apps/web
30
20
  ```
31
21
 
32
- `.cnosrc.yml` is the only discovery anchor. CNOS does not walk upward looking for `.cnos` directories. It looks for `.cnosrc.yml` within a bounded package-root search window, then resolves the real `.cnos` root from there.
22
+ ## Regular mode first
33
23
 
34
- Typical manifest shape:
24
+ `cnos init` creates:
35
25
 
36
- ```yaml
37
- workspaces:
38
- default: root
39
- items:
40
- root: {}
41
- travel:
42
- extends: [root]
43
- food:
44
- extends: [root]
26
+ ```text
27
+ .cnos/
28
+ values/
29
+ secrets/
30
+ env/
31
+ profiles/
45
32
  ```
46
33
 
47
- This lets you keep shared values in `root` and override only what each app needs in `travel`, `food`, or other child workspaces.
34
+ This is effectively the shared base layer for a single-app repo.
48
35
 
49
- Read from an app package without passing a root manually:
36
+ ## Convert to workspace mode
50
37
 
51
- ```ts
52
- import cnos from '@kitsy/cnos';
38
+ When the repo grows:
53
39
 
54
- await cnos.ready();
55
- console.log(cnos('value.app.name'));
40
+ ```bash
41
+ cnos workspace enable
56
42
  ```
57
43
 
58
- Override per command when needed:
44
+ CNOS converts the flat tree into:
59
45
 
60
- ```bash
61
- cnos list values --workspace travel
62
- cnos build server --workspace travel --profile prod --to apps/travel/.cnos-server.json
46
+ ```text
47
+ .cnos/
48
+ workspaces/
49
+ base/
50
+ values/
51
+ secrets/
52
+ env/
53
+ profiles/
63
54
  ```
64
55
 
65
- ## Runtime Projection
56
+ `base` is the default shared workspace convention. It is not resolver magic; it is just the standard scaffolded root workspace.
66
57
 
67
- The authoring tree stays at repo root. Runtime consumers do not need the full `.cnos/` layout.
68
-
69
- For server packaging:
58
+ ## Add child workspaces
70
59
 
71
60
  ```bash
72
- cnos build server --workspace api-gateway --profile prod --to apps/api-gateway/.cnos-server.json
61
+ cnos workspace add api --package-root apps/api
62
+ cnos workspace add web --package-root apps/web
73
63
  ```
74
64
 
75
- `@kitsy/cnos` then auto-loads in this order:
65
+ If `base` exists, CNOS defaults those children to `extends: [base]`.
76
66
 
77
- 1. `__CNOS_PROJECTION__`
78
- 2. `.cnos-server.json`
79
- 3. full authoring resolution through `.cnosrc.yml`
67
+ Resulting manifest shape:
80
68
 
81
- Browser packages keep using public projection through Vite, Next, webpack, or `@kitsy/cnos/build`.
69
+ ```yaml
70
+ workspaces:
71
+ default: base
72
+ items:
73
+ base: {}
74
+ api:
75
+ extends: [base]
76
+ web:
77
+ extends: [base]
78
+ ```
82
79
 
83
- ## Detach and Reattach
80
+ ## Anchors
84
81
 
85
- Detach a child package into a standalone CNOS root:
82
+ Each consuming app or package should get a `.cnosrc.yml` anchor:
86
83
 
87
- ```bash
88
- cnos workspace detach --package-root apps/travel
84
+ ```yaml
85
+ # apps/api/.cnosrc.yml
86
+ root: ../../.cnos
87
+ workspace: api
89
88
  ```
90
89
 
91
- This materializes the effective config into `apps/travel/.cnos`, rewrites `apps/travel/.cnosrc.yml` to point to that local root, and stops inheriting from the parent repo.
90
+ CNOS resolves from `.cnosrc.yml`, not by walking upward for `.cnos/` directories.
91
+
92
+ ## Onboard existing config sources
92
93
 
93
- Reattach it later:
94
+ If the repo still has env or config files:
94
95
 
95
96
  ```bash
96
- cnos workspace attach --package-root apps/travel
97
+ cnos onboard
98
+ cnos onboard --workspace api --env .env.api --materialize
97
99
  ```
98
100
 
99
- This imports the standalone child config back into the parent workspace model, archives the detached `.cnos`, and restores the package anchor.
101
+ Use onboarding to pull source files into CNOS first, then move app code to direct CNOS reads later.
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.7"
4
+ version: "1.8.1"
5
5
 
6
6
  sidebar:
7
7
  - group: Getting Started
@@ -53,6 +53,10 @@ sidebar:
53
53
  label: Overview
54
54
  - path: cli/init
55
55
  label: cnos init
56
+ - path: cli/onboard
57
+ label: cnos onboard
58
+ - path: cli/workspace
59
+ label: cnos workspace
56
60
  - path: cli/value
57
61
  label: cnos value
58
62
  - path: cli/secret
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos-docs",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Source-of-truth CNOS documentation content for Astro Starlight and other static docs consumers.",
5
5
  "type": "module",
6
6
  "exports": {