Skip to content
Kitsy Docs Open CNOS

Workspaces and Monorepos

Workspaces and Monorepos

For monorepos, keep one authoritative .cnos/ tree at the repo root and put a .cnosrc.yml anchor in each consuming app or package.

Repo root as both author and consumer:

.cnosrc.yml
root: ./.cnos

Child app:

apps/travel/.cnosrc.yml
root: ../../.cnos
workspace: travel

.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.

Typical manifest shape:

workspaces:
default: root
items:
root: {}
travel:
extends: [root]
food:
extends: [root]

This lets you keep shared values in root and override only what each app needs in travel, food, or other child workspaces.

Read from an app package without passing a root manually:

import cnos from '@kitsy/cnos';
await cnos.ready();
console.log(cnos('value.app.name'));

Override per command when needed:

Terminal window
cnos list values --workspace travel
cnos build server --workspace travel --profile prod --to apps/travel/.cnos-server.json

Runtime Projection

The authoring tree stays at repo root. Runtime consumers do not need the full .cnos/ layout.

For server packaging:

Terminal window
cnos build server --workspace api-gateway --profile prod --to apps/api-gateway/.cnos-server.json

@kitsy/cnos then auto-loads in this order:

  1. __CNOS_PROJECTION__
  2. .cnos-server.json
  3. full authoring resolution through .cnosrc.yml

Browser packages keep using public projection through Vite, Next, webpack, or @kitsy/cnos/build.

Detach and Reattach

Detach a child package into a standalone CNOS root:

Terminal window
cnos workspace detach --package-root apps/travel

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.

Reattach it later:

Terminal window
cnos workspace attach --package-root apps/travel

This imports the standalone child config back into the parent workspace model, archives the detached .cnos, and restores the package anchor.