diff --git a/.changeset/37503-generate-object-group-fields-list.md b/.changeset/37503-generate-object-group-fields-list.md new file mode 100644 index 00000000000..49f4dd44334 --- /dev/null +++ b/.changeset/37503-generate-object-group-fields-list.md @@ -0,0 +1,10 @@ +--- +'@objectstack/cli': patch +--- + +fix(cli): `os generate object` places its field the way the starter does, through the group's `fields` list + +Clause-②: no +Metadata-protocol: none + +`objectstack generate object NAME` now writes its field group as `fieldGroups: [{ key: 'details', label: 'Details', fields: ['name'] }]`, after the field map, and the `name` field no longer carries `group: 'details'`. That is how the `npm create objectstack` starter's companies and contacts place every field, so a generated object and the starter's objects are written in one style. Both spellings mean the same placement, and an object generated by an earlier release keeps working unchanged. When you add a field to a generated object, list its name in the group's `fields` too. diff --git a/content/docs/deployment/cli.mdx b/content/docs/deployment/cli.mdx index 4837a98a6eb..1d3ed2522a9 100644 --- a/content/docs/deployment/cli.mdx +++ b/content/docs/deployment/cli.mdx @@ -27,7 +27,7 @@ npm create objectstack@latest my-app cd my-app ``` -This scaffolds a working project with `objectstack.config.ts`, a sample object, and all dependencies installed — plus the AI skills bundle and an `AGENTS.md` for coding agents. (`os init` is the CLI's own scaffolder for metadata-package skeletons and bare configs — see [below](#os-init).) +This scaffolds a working project with `objectstack.config.ts`, the starter's companies and contacts, and all dependencies installed — plus the AI skills bundle and an `AGENTS.md` for coding agents. (`os init` is the CLI's own scaffolder for metadata-package skeletons and bare configs — see [below](#os-init).) ### Add more metadata @@ -933,7 +933,7 @@ os compile --json # JSON output for CI pipelines ──────────────────────────────────────── → Loading configuration... Config: objectstack.config.ts - Load time: 57ms + Load time: 62ms → Normalizing stack definition... → Lowering inline handlers... → Validating protocol compliance... @@ -942,13 +942,15 @@ os compile --json # JSON output for CI pipelines → Collecting package docs (ADR-0046)... 0 collected → Writing artifact... - ✓ Build complete (74ms) + ✓ Build complete (158ms) - Data: 2 Objects 6 Fields - UI: 1 Views 1 Actions - Runtime: 3 plugins + Data: 3 Objects 18 Fields + UI: 1 Apps 3 Views 1 Actions + Logic: 0 Flows + Security: 0 Positions 0 Permissions + Runtime: 0 plugins - Artifact: dist/objectstack.json (7.6 KB) + Artifact: dist/objectstack.json (19.6 KB) ``` Those counts are from a sample project, named in full under [`os info`](#os-info) @@ -1079,19 +1081,25 @@ os info --json # JSON output for tooling ──────────────────────────────────────── My App v0.1.0 - my-app + com.example.my-app Namespace: my_app Type: app - Data: 2 Objects 6 Fields - UI: 1 Views 1 Actions - Runtime: 3 plugins + Data: 3 Objects 18 Fields + UI: 1 Apps 3 Views 1 Actions + Logic: 0 Flows + Security: 0 Positions 0 Permissions + Runtime: 0 plugins Objects: - my_app_note (2 fields, user) — Note + my_app_company (7 fields, user) — Company + my_app_contact (7 fields, user) — Contact my_app_ticket (4 fields, user) — Ticket - Loaded in 59ms + Apps: + my_app_main_app — Main + + Loaded in 57ms ``` @@ -1099,16 +1107,20 @@ os info --json # JSON output for tooling run against one fixture, so the numbers can be rebuilt and checked rather than taken on trust: the project this page scaffolds in [Your First App in 2 Minutes](#your-first-app-in-2-minutes) — -`npm create objectstack@latest my-app`, whose `blank` starter supplies the two-field -`my_app_note` object and the three connector plugins — plus the four-field ticket object, -the view and the action listed under +`npm create objectstack@latest my-app`, whose `blank` starter supplies the seven-field +`my_app_company` and `my_app_contact` objects, a list view of each and the `main` app, and +no plugins — plus the four-field ticket object, the view and the action listed under [Build with Claude Code](/docs/getting-started/build-with-claude-code#3-what-claude-code-writes), renamed out of that page's `support_desk_` namespace into `my_app_`. That page's `support` -app is **not** added, and a zero count is never printed, which is why the `UI:` row reads -`1 Views 1 Actions` with no `Apps`. The walkthrough's `os generate` commands are **not** -part of the fixture — run those as well and the summary gains `my_app_customer`, a second -action and a `Logic:` row. Timings are machine identity, and the rule count and artifact size track the -CLI version; everything else is fixture identity and reproduces. +app is **not** added, which is why the `UI:` row reads `1 Apps`: the starter's own. A +section with nothing in it still prints its zero row (`Logic: 0 Flows`). The ticket view +declares an internal create and edit form, so a real compile also prints one +`form-view-internal-not-loaded` warning after the rules step and a +`⚠ 1 author-time warning(s)` line under `Build complete`; the `os compile` transcript +leaves both out. The walkthrough's `os generate` commands are **not** part of the fixture — run those +as well and the summary gains `my_app_customer`, a second action and `Logic: 1 Flows`. +Timings are machine identity, and the rule count and artifact size track the CLI version; +everything else is fixture identity and reproduces. ### Schema migrations diff --git a/content/docs/getting-started/build-with-claude-code.mdx b/content/docs/getting-started/build-with-claude-code.mdx index f36f60fa711..b4b5dd8a57a 100644 --- a/content/docs/getting-started/build-with-claude-code.mdx +++ b/content/docs/getting-started/build-with-claude-code.mdx @@ -52,6 +52,12 @@ npm create objectstack@latest support-desk cd support-desk ``` + +`npm create objectstack@latest` installs `create-objectstack` 18.6.0 today, which +still scaffolds the earlier `blank` template with its single `note` object; the +companies-and-contacts template this page describes ships with 19.0. + + The scaffolder does more than copy files. It: - derives a **namespace** from the name (`support-desk` → `support_desk`), so diff --git a/content/docs/getting-started/your-first-project.mdx b/content/docs/getting-started/your-first-project.mdx index dbf19480112..1f2cf294ea5 100644 --- a/content/docs/getting-started/your-first-project.mdx +++ b/content/docs/getting-started/your-first-project.mdx @@ -50,6 +50,12 @@ npm create objectstack@latest my-app cd my-app ``` + +`npm create objectstack@latest` installs `create-objectstack` 18.6.0 today, which +still scaffolds the earlier `blank` template with its single `note` object; the +companies-and-contacts template this page describes ships with 19.0. + + The scaffolder (`create-objectstack`) does four things: 1. **Copies a template** into `my-app/` and rewrites its identity — the npm @@ -77,7 +83,7 @@ bundle) with `--skip-skills` if you prefer — `AGENTS.md` is always written. | Template | Source | Description | |:---|:---|:---| -| `blank` *(default)* | bundled, works offline | One object, REST API — a clean slate | +| `blank` *(default)* | bundled, works offline | Companies and contacts, with platform tasks and notes in the menu — ready to extend | ```bash npm create objectstack@latest my-app -- --template blank diff --git a/packages/cli/src/commands/generate.ts b/packages/cli/src/commands/generate.ts index cc07b8ecde4..7a7a6cc3d30 100644 --- a/packages/cli/src/commands/generate.ts +++ b/packages/cli/src/commands/generate.ts @@ -292,15 +292,19 @@ const GENERATORS: Record { it('`os g object` declares its field through the `Field.*` builder, in a field group, exported by name', async () => { const source = target('object').generate(PREREQUISITE_STEM.object, NS); - // The starter's `note.object.ts` style: a builder, never a raw `type:` literal… + // The starter's style (the blank template's `company.object.ts`): a + // builder, never a raw `type:` literal… expect(source).toContain("import { ObjectSchema, Field } from '@objectstack/spec/data';"); expect(source).toMatch(/name: Field\.text\(\{/); expect(source).not.toMatch(/type: 'text'/); // …a named export (the barrel re-exports it by name)… expect(source).toContain(`export const probeTarget = ObjectSchema.create({`); expect(target('object').exportsByName).toBe(true); - // …and the field placed in a declared group. + // …and the field placed in a declared group the way the starter places + // it: named in the group's `fields` list, with no per-field `group`. const artifact = (await loadScaffold('object', source)) as { - fieldGroups?: { key: string }[]; + fieldGroups?: { key: string; fields?: string[] }[]; fields: Record; }; expect(artifact.fieldGroups?.map((g) => g.key)).toEqual(['details']); - expect(artifact.fields.name).toMatchObject({ type: 'text', group: 'details' }); + expect(artifact.fieldGroups?.[0]?.fields).toEqual(['name']); + expect(artifact.fields.name).toMatchObject({ type: 'text' }); + expect(artifact.fields.name.group).toBeUndefined(); }); it('`os g action` in a stack that declares no flow writes a declarative update, with zero findings', async () => { diff --git a/packages/cli/test/init-scaffold-file-name-registry-parity.test.ts b/packages/cli/test/init-scaffold-file-name-registry-parity.test.ts index 37a9eab8e07..7547f0d9c59 100644 --- a/packages/cli/test/init-scaffold-file-name-registry-parity.test.ts +++ b/packages/cli/test/init-scaffold-file-name-registry-parity.test.ts @@ -33,8 +33,9 @@ * it was, is one CLI teaching two spellings for one metadata type: `os init` * wrote `_item.ts`, `os g object customer` (after commit 50fb191dc) writes * `customer.object.ts`, `create-objectstack`'s own blank starter already - * shipped `note.object.ts`, and the examples (`app-crm/src/objects/ - * account.object.ts`) plus the registry's own glob keys speak the same shape. + * shipped `.object.ts` files (`company.object.ts` today), and the + * examples (`app-crm/src/objects/account.object.ts`) plus the registry's own + * glob keys speak the same shape. * The scaffold is the first thing a new author reads as the house convention. * * That is why the assertion below is `matchesGlob` against the REGISTRY and diff --git a/packages/create-objectstack/src/blank-template-console-disclosure.test.ts b/packages/create-objectstack/src/blank-template-console-disclosure.test.ts index 3c5a0d12ec8..dba7a506889 100644 --- a/packages/create-objectstack/src/blank-template-console-disclosure.test.ts +++ b/packages/create-objectstack/src/blank-template-console-disclosure.test.ts @@ -21,8 +21,8 @@ // authors in step 2 of the README loop, and the README disclosed the empty // Console instead. The maintainer's card #32152 (2026-11-10, filed on // 「立卡处理」) reversed that: a newcomer who opens the Console the dev banner -// points to must see their own project, so the template now ships the starter -// app `src/apps/main.app.ts` and the sample object's list view +// points to must see their own project, so the template then shipped the +// starter app `src/apps/main.app.ts` and the sample object's list view // `src/views/note.view.ts` — the files `objectstack generate app main --object // note` and `objectstack generate view note` write, with the object referenced // as `Note.name` because scaffolding renames it. The README keeps the rule diff --git a/packages/create-objectstack/src/starter-comments-self-contained.test.ts b/packages/create-objectstack/src/starter-comments-self-contained.test.ts index 026e3fbae17..1c920d9a2b0 100644 --- a/packages/create-objectstack/src/starter-comments-self-contained.test.ts +++ b/packages/create-objectstack/src/starter-comments-self-contained.test.ts @@ -151,7 +151,7 @@ const MONOREPO_ONLY: MonorepoOnlyPattern[] = [ // "the shallowest point a path reaches"). In THIS population the two give // the same answer, for a measured reason: every relative reference the // shipped tree carries is `./`-anchored and points DOWNWARD from the file - // that writes it (`./note.object.js`, `./src/objects`), so the + // that writes it (`./company.object.js`, `./src/objects`), so the // count of `../` here — escaping or merely climbing — is zero. The bare // anchor therefore has no correct text to redden. The leading lookbehind is // what keeps it that way: it refuses a `..` that is itself part of a longer @@ -176,9 +176,12 @@ const MONOREPO_ONLY: MonorepoOnlyPattern[] = [ // exemption back. // // That condition arrived with card #32152: the blank template's starter app - // and list view (`src/apps/main.app.ts`, `src/views/note.view.ts`) import the - // sample object as `../objects/note.object.js`, a climb that stays inside the - // project. So the depth judgement is now in place: every `../` run is still + // and list view (`src/apps/main.app.ts`, `src/views/note.view.ts`) imported + // the sample object as `../objects/note.object.js`, a climb that stays inside + // the project. Card #36945 replaced that sample object with the Starter's + // company and contact, whose app and views name each object by its string + // name and so climb nowhere; the depth judgement stays in place regardless, + // so the next intra-project climb is judged correctly: every `../` run is still // matched, and each one is resolved from the directory of the file that // writes it; it is a hit only when the path it reaches lies outside that // file's project (`escapesProject`). The escaping spelling this entry exists @@ -205,7 +208,7 @@ function projectRootOf(rel: string): string { * Whether the relative path `found`, written in the shipped file `rel`, * reaches outside that file's project — the shallowest point the path walks * to is above the project root. A climb that stays inside the project - * (`../objects/note.object.js` from `src/apps/`) is not. + * (`../objects/company.object.js` from `src/apps/`) is not. */ function escapesProject(rel: string, found: string): boolean { const root = projectRootOf(rel); @@ -288,7 +291,7 @@ describe('shipped template comments are followable by a stranger', () => { // Commit 21756b325's two rewrites (ADR-0097 -> a public docs link; "the ObjectStack // framework repo" -> the followable install form) are RATIONALE entries // too, for the same reason blank/objectstack.config.ts and - // note.object.ts already are: assertions 1/3/4 only ever check that + // company.object.ts already are: assertions 1/3/4 only ever check that // something UNFOLLOWABLE is absent or that a present URL resolves -- // none of them notice a fact quietly disappearing along the way. file: 'blank/README.md', diff --git a/packages/spec/src/system/constants/platform-object-names.test.ts b/packages/spec/src/system/constants/platform-object-names.test.ts index 9b62b08b0e5..6068deb0f85 100644 --- a/packages/spec/src/system/constants/platform-object-names.test.ts +++ b/packages/spec/src/system/constants/platform-object-names.test.ts @@ -39,8 +39,9 @@ const PACKAGES_DIR = join(REPO_ROOT, 'packages'); /** * Packages whose `*.object.ts` files are FIXTURES, not platform contributions: * a downstream-contract QA harness and the `create-objectstack` scaffolding - * templates (the `blank` starter's `note.object.ts`). Neither ships objects - * into a running platform, so neither belongs in the registry. + * templates (the `blank` starter's `company.object.ts` and `contact.object.ts`). + * Neither ships objects into a running platform, so neither belongs in the + * registry. */ const FIXTURE_PACKAGES = new Set(['qa', 'create-objectstack']);