Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/37503-generate-object-group-fields-list.md
Original file line number Diff line number Diff line change
@@ -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.
54 changes: 33 additions & 21 deletions content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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...
Expand All @@ -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)
Expand Down Expand Up @@ -1079,36 +1081,46 @@ 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
```

<Callout type="info">
**The project behind these counts.** The `os compile` and `os info` examples above were
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.
</Callout>

### Schema migrations
Expand Down
6 changes: 6 additions & 0 deletions content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ npm create objectstack@latest support-desk
cd support-desk
```

<Callout type="info">
`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.
</Callout>

The scaffolder does more than copy files. It:

- derives a **namespace** from the name (`support-desk` → `support_desk`), so
Expand Down
8 changes: 7 additions & 1 deletion content/docs/getting-started/your-first-project.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ npm create objectstack@latest my-app
cd my-app
```

<Callout type="info">
`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.
</Callout>

The scaffolder (`create-objectstack`) does four things:

1. **Copies a template** into `my-app/` and rewrites its identity — the npm
Expand Down Expand Up @@ -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
Expand Down
42 changes: 24 additions & 18 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,19 @@ const GENERATORS: Record<string, {
*
* ## The authoring style is the starter's (#32153)
*
* The `npm create objectstack` starter (`note.object.ts`) and the
* getting-started docs declare fields through the `Field.*` builders, export
* the object BY NAME (its barrel line is `export { Note } from …`), and put
* every field in a `fieldGroups` section. This scaffold used to write a raw
* `{ type: 'text', … }` literal and a default export with no field groups, so
* a newcomer — or a coding agent copying whichever file it read last — met
* two dialects in the first ten minutes. It now writes the starter's: the
* builder, a named `export const`, a `details` group the title field joins,
* and a barrel line that re-exports the name ({@link GENERATORS} `exportsByName`).
* The `npm create objectstack` starter (the blank template's
* `company.object.ts` and `contact.object.ts`, the same definitions as the
* platform's Starter app in `examples/app-starter`) and the getting-started
* docs declare fields through the `Field.*` builders, export the object BY
* NAME (its barrel line is `export { Company } from …`), and place every
* field in a `fieldGroups` section by listing it in that group's `fields`,
* after the field map — never through a per-field `group`. This scaffold
* used to write a raw `{ type: 'text', … }` literal and a default export
* with no field groups, so a newcomer — or a coding agent copying whichever
* file it read last — met two dialects in the first ten minutes. It now
* writes the starter's: the builder, a named `export const`, a `details`
* group whose `fields` list names the title field, and a barrel line that
* re-exports the name ({@link GENERATORS} `exportsByName`).
*
* The binding stays {@link toCamelCase} of the name, as it always was:
* every refusal layer in `runMetadataGeneration` — the parse check that
Expand Down Expand Up @@ -328,14 +332,6 @@ export const ${toCamelCase(name)} = ObjectSchema.create({
label: '${toTitleCase(name)}',
pluralLabel: '${toTitleCase(name)}s',

// Field groups: the sections a record's form and detail page draw, top to
// bottom in this order. A field joins one by naming its \`key\` in \`group\`.
// Give each field you add a \`group\` as well. Field groups versus a view's
// own form sections: https://objectstack.ai/docs/ui/field-grouping-and-order
fieldGroups: [
{ key: 'details', label: 'Details' },
],

fields: {
// The record's title: the platform shows it as each record's name. Add
// the fields this object needs beside it, each through a \`Field.*\`
Expand All @@ -345,9 +341,19 @@ export const ${toCamelCase(name)} = ObjectSchema.create({
label: 'Name',
required: true,
maxLength: 255,
group: 'details',
}),
},

// The Details sections of the record page and of the create and edit form,
// top to bottom in this order; a section's \`fields\` list names its fields
// in display order. \`objectstack validate\` reports a field that nothing
// displays or reads, so list each field you add in a section too. Field
// groups versus a view's own form sections:
// https://objectstack.ai/docs/ui/field-grouping-and-order
fieldGroups: [
{ key: 'details', label: 'Details', fields: ['name'] },
],

// Org-wide default (OWD): who can see records they don't own. 'private' is
// owner-only until access is widened by a permission grant or a sharing
// rule. Declaring it is required, deliberately: \`objectstack build\`
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/generate-scaffold-gates.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ describe('[#32153] a fresh `os init` project: the new generator variants pass ev
const object = read('src', 'objects', 'ticket.object.ts');
expect(object).toContain('export const ticket = ObjectSchema.create({');
expect(object).toMatch(/name: Field\.text\(\{/);
expect(object).toContain("fieldGroups: [\n { key: 'details', label: 'Details' },");
expect(object).toContain("fieldGroups: [\n { key: 'details', label: 'Details', fields: ['name'] },");
expect(object).not.toMatch(/^ +group: '/m);
expect(read('src', 'objects', 'index.ts')).toContain("export { ticket } from './ticket.object';");
});

Expand Down
12 changes: 8 additions & 4 deletions packages/cli/test/generate-scaffold-validates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,24 @@ describe('[#14087] the flow scaffold binds its trigger where the engine reads it
describe('[#32153] the generators write the starter\'s style, and each new variant passes every gate', () => {
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<string, { type?: string; group?: string }>;
};
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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
* it was, is one CLI teaching two spellings for one metadata type: `os init`
* wrote `<ns>_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 `<name>.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
Loading