@kitsy/cnos-docs 1.8.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.
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 workspace add api --package-root apps/api --extends base
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
+ ```
@@ -1,55 +1,51 @@
1
1
  ---
2
2
  title: cnos workspace
3
- description: Add, list, remove, scaffold, attach, and detach workspaces.
3
+ description: Enable workspace mode, add child workspaces, and manage attach or detach flows.
4
4
  ---
5
5
 
6
6
  # cnos workspace
7
7
 
8
- Use `cnos workspace` when a repo has more than one app or package consuming the same CNOS root.
8
+ Use `cnos workspace` when one CNOS root needs to serve more than one app or package.
9
9
 
10
- ## Add a workspace
10
+ ## Enable workspace mode
11
+
12
+ If the repo started with a flat `.cnos/` tree:
11
13
 
12
14
  ```bash
13
- cnos workspace add travel --package-root apps/travel --extends base
15
+ cnos workspace enable
14
16
  ```
15
17
 
16
- This updates `cnos.yml`, creates `.cnos/workspaces/travel`, and writes:
18
+ CNOS moves:
17
19
 
18
- ```yaml
19
- # apps/travel/.cnosrc.yml
20
- root: ../../.cnos
21
- workspace: travel
22
- ```
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`
23
24
 
24
- ## Onboard an older single-root project into workspace mode
25
+ and updates the root anchor to `workspace: base`.
25
26
 
26
- If a repo already has a flat `.cnos/values`, `.cnos/secrets`, `.cnos/env`, and `.cnos/profiles` tree, migrate it like this:
27
+ ## Add a workspace
27
28
 
28
29
  ```bash
29
- cnos workspace add main --onboard-current
30
+ cnos workspace add travel --package-root apps/travel
30
31
  ```
31
32
 
32
- CNOS will:
33
-
34
- 1. move the existing flat config folders into `.cnos/workspaces/main`
35
- 2. rewrite the root anchor to `workspace: main`
36
- 3. keep the repo in one authoritative `.cnos` root
33
+ If `base` exists, the new workspace automatically gets `extends: [base]`.
37
34
 
38
- ## List workspaces
35
+ Override that when needed:
39
36
 
40
37
  ```bash
41
- cnos workspace list
42
- cnos workspace list --json
38
+ cnos workspace add api --extends shared
39
+ cnos workspace add sandbox --extends none
43
40
  ```
44
41
 
45
- ## Remove a workspace
42
+ ## List and remove
46
43
 
47
44
  ```bash
45
+ cnos workspace list
48
46
  cnos workspace remove gallery
49
47
  ```
50
48
 
51
- CNOS removes the manifest entry and deletes `.cnos/workspaces/gallery`. It refuses to remove the current default workspace until you change `workspaces.default`.
52
-
53
49
  ## Scaffold wording
54
50
 
55
51
  If your team prefers scaffold wording:
@@ -58,8 +54,6 @@ If your team prefers scaffold wording:
58
54
  cnos workspace scaffold insights --package-root apps/insights --extends base
59
55
  ```
60
56
 
61
- This follows the same creation path as `workspace add`.
62
-
63
57
  ## Detach and attach
64
58
 
65
59
  ```bash
@@ -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,39 +27,18 @@ await cnos.ready();
24
27
  console.log(cnos('value.app.name'));
25
28
  ```
26
29
 
27
- For explicit creation:
28
-
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'));
35
- ```
36
-
37
- If your repo grows into multiple apps or packages, switch to workspace mode instead of duplicating `.cnos` trees:
30
+ When the repo grows into multiple apps or packages, convert it instead of duplicating `.cnos`:
38
31
 
39
32
  ```bash
40
- cnos workspace add main --package-root apps/main --extends base
41
- cnos workspace add insights --package-root apps/insights --extends base
33
+ cnos workspace enable
34
+ cnos workspace add main --package-root apps/main
35
+ cnos workspace add insights --package-root apps/insights
42
36
  cnos workspace list
43
37
  ```
44
38
 
45
- 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:
46
40
 
47
41
  ```bash
48
42
  cnos build env --profile local --to .env.local
49
43
  cnos dev env --profile local --to .env.local -- pnpm dev
50
44
  ```
51
-
52
- For frontend builds:
53
- - Vite: `@kitsy/cnos-vite`
54
- - Webpack/static bundles: `@kitsy/cnos-webpack`
55
- - Next.js: `@kitsy/cnos-next`
56
-
57
- For webpack/static bundles, build-time settings can come from CNOS too:
58
-
59
- ```bash
60
- cnos set value dev.server.port 8800
61
- npm run dev
62
- ```
@@ -26,13 +26,6 @@ cnos profile create stage
26
26
  cnos use --profile stage
27
27
  ```
28
28
 
29
- If this later becomes a monorepo, do not create a second `.cnos`. Add workspaces instead:
30
-
31
- ```bash
32
- cnos workspace add api --package-root apps/api --extends base
33
- cnos workspace add admin --package-root apps/admin --extends base
34
- ```
35
-
36
29
  Create a local vault and authenticate it:
37
30
 
38
31
  ```bash
@@ -40,3 +33,11 @@ cnos vault create default
40
33
  cnos vault auth default
41
34
  cnos secret set app.token super-secret --vault default
42
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,132 +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:
13
+ The intended progression is:
18
14
 
19
- ```yaml
20
- # apps/travel/.cnosrc.yml
21
- root: ../../.cnos
22
- workspace: travel
23
- ```
24
-
25
- Child app from a remote config repo:
26
-
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
- ## Day-to-day workspace management
36
+ ## Convert to workspace mode
50
37
 
51
- Add a new app workspace:
38
+ When the repo grows:
52
39
 
53
40
  ```bash
54
- cnos workspace add insights --package-root apps/insights --extends root
55
- cnos workspace add gallery --package-root apps/gallery --extends root
41
+ cnos workspace enable
56
42
  ```
57
43
 
58
- List what exists:
44
+ CNOS converts the flat tree into:
59
45
 
60
- ```bash
61
- cnos workspace list
46
+ ```text
47
+ .cnos/
48
+ workspaces/
49
+ base/
50
+ values/
51
+ secrets/
52
+ env/
53
+ profiles/
62
54
  ```
63
55
 
64
- Remove one later:
56
+ `base` is the default shared workspace convention. It is not resolver magic; it is just the standard scaffolded root workspace.
65
57
 
66
- ```bash
67
- cnos workspace remove gallery
68
- ```
69
-
70
- ## Migrating an older single-root repo into workspace mode
71
-
72
- If a repo was initialized earlier with:
58
+ ## Add child workspaces
73
59
 
74
60
  ```bash
75
- cnos init
61
+ cnos workspace add api --package-root apps/api
62
+ cnos workspace add web --package-root apps/web
76
63
  ```
77
64
 
78
- and the current config still lives directly under `.cnos/values`, `.cnos/secrets`, `.cnos/env`, and `.cnos/profiles`, move that existing config into a real workspace with:
65
+ If `base` exists, CNOS defaults those children to `extends: [base]`.
79
66
 
80
- ```bash
81
- cnos workspace add main --onboard-current
82
- ```
67
+ Resulting manifest shape:
83
68
 
84
- CNOS will move the physical folders into `.cnos/workspaces/main` and rewrite the local anchor so the repo now behaves as a workspace-aware project.
85
-
86
- Read from an app package without passing a root manually:
87
-
88
- ```ts
89
- import cnos from '@kitsy/cnos';
90
-
91
- await cnos.ready();
92
- console.log(cnos('value.app.name'));
93
- ```
94
-
95
- Override per command when needed:
96
-
97
- ```bash
98
- cnos list values --workspace travel
99
- cnos build server --workspace travel --profile prod --to apps/travel/.cnos-server.json
69
+ ```yaml
70
+ workspaces:
71
+ default: base
72
+ items:
73
+ base: {}
74
+ api:
75
+ extends: [base]
76
+ web:
77
+ extends: [base]
100
78
  ```
101
79
 
102
- ## Runtime Projection
103
-
104
- The authoring tree stays at repo root. Runtime consumers do not need the full `.cnos/` layout.
80
+ ## Anchors
105
81
 
106
- For server packaging:
82
+ Each consuming app or package should get a `.cnosrc.yml` anchor:
107
83
 
108
- ```bash
109
- cnos build server --workspace api-gateway --profile prod --to apps/api-gateway/.cnos-server.json
84
+ ```yaml
85
+ # apps/api/.cnosrc.yml
86
+ root: ../../.cnos
87
+ workspace: api
110
88
  ```
111
89
 
112
- `@kitsy/cnos` then auto-loads in this order:
113
-
114
- 1. `__CNOS_PROJECTION__`
115
- 2. `.cnos-server.json`
116
- 3. full authoring resolution through `.cnosrc.yml`
117
-
118
- Browser packages keep using public projection through Vite, Next, webpack, or `@kitsy/cnos/build`.
119
-
120
- ## Detach and Reattach
121
-
122
- Detach a child package into a standalone CNOS root:
123
-
124
- ```bash
125
- cnos workspace detach --package-root apps/travel
126
- ```
90
+ CNOS resolves from `.cnosrc.yml`, not by walking upward for `.cnos/` directories.
127
91
 
128
- 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.
92
+ ## Onboard existing config sources
129
93
 
130
- Reattach it later:
94
+ If the repo still has env or config files:
131
95
 
132
96
  ```bash
133
- cnos workspace attach --package-root apps/travel
97
+ cnos onboard
98
+ cnos onboard --workspace api --env .env.api --materialize
134
99
  ```
135
100
 
136
- 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.8"
4
+ version: "1.8.1"
5
5
 
6
6
  sidebar:
7
7
  - group: Getting Started
@@ -53,6 +53,8 @@ sidebar:
53
53
  label: Overview
54
54
  - path: cli/init
55
55
  label: cnos init
56
+ - path: cli/onboard
57
+ label: cnos onboard
56
58
  - path: cli/workspace
57
59
  label: cnos workspace
58
60
  - path: cli/value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitsy/cnos-docs",
3
- "version": "1.8.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": {