Skip to content

feat(workspace): the declaration, findWorkspaceRoot, chant workspace init and ls (#2534) - #2593

Merged
lex00 merged 1 commit into
mainfrom
feat/2534-declaration
Sep 24, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/2534-declaration

Conversation

@lex00

@lex00 lex00 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2534. Level 1 (#2525); ws-051 (#2588) is on main.

What it adds:

  • chant.workspace.json / .jsonc, schema 1: name, schema, members required; minReader, pins, $schema, $comment and x-* fields optional; any other field refused. Schema at packages/core/src/workspace/declaration.schema.json, validated with ajv on every read. A small JSON/JSONC reader gives every parse and schema error a file, line and column, refuses duplicate keys, and never reads an empty file as a declaration. Both names present is declaration-ambiguous.
  • Members { name, dir, kind, roles?, upstream?, because? } (because required for other) and example groups { name, kind: "examples", glob } per ws-051. D2 name grammar, with _workspace/_members reported as reserved. Placement: no ../absolute paths, no two members in one directory, only "." contains members; a group match is never a member's directory, never contains one, never sits inside a nested workspace, and no two groups share one. A match may sit inside a member.
  • findWorkspaceRoot in project-root.ts: walks up to the git root (the first directory with .git), existsSync only, so a level-0 command could call it later. findProjectConfig is unchanged.
  • chant workspace init [dir] [--name] [--yes] [--verbose]: proposes members and groups from chant configs, nested declarations, npm packages and example trees. It prints the directories leaving the root project, with their .ts file counts, before asking, and writes only after a y or --yes. Without a TTY and without --yes it writes nothing.
  • chant workspace ls [dir] [--at <rev>] [--json]: an unreadable member is listed with dir-missing, unknown-kind or kind-probe-failed and the command still exits 0. --json follows ls.schema.json (contract 1, closed code lists), like records.
  • Docs: cli/workspace-init, cli/workspace-ls, reference/workspace-declaration.

The chant repo: the real chant.workspace.json is committed. It is what init proposes, with one hand edit: reference-workspace/ (#2543) is one other member until its own declaration stops being a draft, rather than the two members init finds inside it, and docs/design/chant.workspace.draft.json is removed. Nothing outside chant workspace reads the file: findWorkspaceRoot has no other caller, records doesn't look at it, and the goldens run on copies outside the repo. So chant's CI is unchanged. It differs from the draft in three places. ops is left in the root because it holds Op files with no chant.config, so kind chant would fail its probe. editors/vscode is added as other. The lexicon because texts are init's generic ones.

One interpretation: D1's root member "." is read as dir: ".", and its name follows the grammar (init names it root).

Hooks for other issues, kept small:

Level 0 is unaffected: every new module is under workspace/ and loads through await import in main.ts. The level-0 goldens and the no-workspace-module test pass unchanged.

…init and ls (#2534)

chant.workspace.json (or .jsonc) with a JSON Schema shipped in
@intentius/chant and validated on every read, parse and schema errors
with file, line and column, example groups (ws-051), placement rules,
and minReader. findWorkspaceRoot walks up to the git root.
chant workspace init proposes a declaration and prints what leaves the
root project before it writes; chant workspace ls lists members with
reason codes and a versioned --json contract. The chant repo commits
its own chant.workspace.json, replacing the design draft.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workspace: the declaration, findWorkspaceRoot, chant workspace init and ls

1 participant