create-objectstack 10.0.0 → 10.3.0
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/dist/index.js
CHANGED
|
@@ -238,6 +238,29 @@ function rewriteProjectIdentity(targetDir, projectName, namespace) {
|
|
|
238
238
|
md = md.replace(/^#\s+.*$/m, `# ${title}`);
|
|
239
239
|
fs.writeFileSync(readmePath, md);
|
|
240
240
|
}
|
|
241
|
+
writeAgentGuides(targetDir, title, projectName);
|
|
242
|
+
}
|
|
243
|
+
function writeAgentGuides(targetDir, title, projectName) {
|
|
244
|
+
const templatePath = path.join(BUNDLED_TEMPLATES_DIR, "AGENTS.md");
|
|
245
|
+
let template;
|
|
246
|
+
try {
|
|
247
|
+
template = fs.readFileSync(templatePath, "utf8");
|
|
248
|
+
} catch (err) {
|
|
249
|
+
if (err?.code === "ENOENT") return;
|
|
250
|
+
throw err;
|
|
251
|
+
}
|
|
252
|
+
const rendered = template.replace(/\{\{PROJECT_TITLE\}\}/g, title).replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
253
|
+
writeIfAbsent(path.join(targetDir, "AGENTS.md"), rendered);
|
|
254
|
+
const copilotPath = path.join(targetDir, ".github", "copilot-instructions.md");
|
|
255
|
+
fs.mkdirSync(path.dirname(copilotPath), { recursive: true });
|
|
256
|
+
writeIfAbsent(copilotPath, rendered);
|
|
257
|
+
}
|
|
258
|
+
function writeIfAbsent(filePath, contents) {
|
|
259
|
+
try {
|
|
260
|
+
fs.writeFileSync(filePath, contents, { flag: "wx" });
|
|
261
|
+
} catch (err) {
|
|
262
|
+
if (err?.code !== "EEXIST") throw err;
|
|
263
|
+
}
|
|
241
264
|
}
|
|
242
265
|
var program = new Command().name("create-objectstack").description("Create a new ObjectStack environment").version(readCliVersion()).argument("[name]", "Environment name (defaults to current directory name)").option(
|
|
243
266
|
"-t, --template <template>",
|
|
@@ -325,7 +348,8 @@ var program = new Command().name("create-objectstack").description("Create a new
|
|
|
325
348
|
console.log(chalk.dim(" npm install"));
|
|
326
349
|
}
|
|
327
350
|
console.log(chalk.dim(" npm run dev # Start development server"));
|
|
328
|
-
console.log(chalk.dim(" npm run validate #
|
|
351
|
+
console.log(chalk.dim(" npm run validate # Verify metadata: schema + predicates + bindings"));
|
|
352
|
+
console.log(chalk.dim(" # (run after every metadata edit \u2014 see AGENTS.md)"));
|
|
329
353
|
if (options.skipInstall || options.skipSkills) {
|
|
330
354
|
console.log("");
|
|
331
355
|
console.log(chalk.bold(" AI Skills (recommended):"));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
# {{PROJECT_TITLE}} —
|
|
1
|
+
# {{PROJECT_TITLE}} — Agent Instructions
|
|
2
2
|
|
|
3
|
-
> Auto-generated by `create-objectstack`.
|
|
3
|
+
> Auto-generated by `create-objectstack`. Read by Claude Code, Cursor, Codex
|
|
4
|
+
> (`AGENTS.md`) and GitHub Copilot (`.github/copilot-instructions.md`).
|
|
5
|
+
> Customise freely.
|
|
4
6
|
|
|
5
7
|
## Project Context
|
|
6
8
|
|
|
@@ -10,6 +12,27 @@ that defines business objects, views, automations, and AI agents in TypeScript.
|
|
|
10
12
|
- **Entry point:** `objectstack.config.ts` (uses `defineStack()`)
|
|
11
13
|
- **Spec package:** `@objectstack/spec` (Zod-first schemas and types)
|
|
12
14
|
|
|
15
|
+
## Verify your work (do this after every metadata change)
|
|
16
|
+
|
|
17
|
+
Metadata mistakes fail **silently at runtime**, not at edit time — a bare field
|
|
18
|
+
reference in a predicate (`done` instead of `record.done`) evaluates to `null`
|
|
19
|
+
and silently hides an action on every record; a dangling widget binding renders
|
|
20
|
+
an empty chart. Catch them before you ship:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run validate # schema + CEL predicates + widget bindings (no artifact)
|
|
24
|
+
npm run typecheck # TypeScript types against @objectstack/spec
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`npm run validate` runs the **same gates as `npm run build`** (Zod protocol
|
|
28
|
+
schema, CEL/predicate validation with `record.<field>` existence checks, and
|
|
29
|
+
dashboard widget-binding integrity) but emits no `dist/` — so it is the fast
|
|
30
|
+
inner-loop check after editing an `*.object.ts` / `*.view.ts` / `*.action.ts` /
|
|
31
|
+
`*.flow.ts`. Both exit non-zero with a located, corrective message on failure.
|
|
32
|
+
Run `npm run build` when you need the compiled `dist/objectstack.json` artifact.
|
|
33
|
+
|
|
34
|
+
**Never report a metadata change as done until `npm run validate` passes.**
|
|
35
|
+
|
|
13
36
|
## Naming Conventions
|
|
14
37
|
|
|
15
38
|
| Context | Convention | Example |
|
|
@@ -25,6 +48,10 @@ that defines business objects, views, automations, and AI agents in TypeScript.
|
|
|
25
48
|
2. `defineStack()` is the single configuration entry point in `objectstack.config.ts`.
|
|
26
49
|
3. Use `Object.values()` barrel pattern for metadata arrays.
|
|
27
50
|
4. Import from `@objectstack/spec` — never use relative paths into the spec package.
|
|
51
|
+
5. **Predicates are CEL** — `visible`, `disabled`, `requiredWhen`, validation rules,
|
|
52
|
+
flow conditions and sharing rules reference record fields as `record.<field>`,
|
|
53
|
+
never bare `<field>`. A bare reference is a silent runtime bug (`npm run validate`
|
|
54
|
+
now rejects it).
|
|
28
55
|
|
|
29
56
|
## Project Structure
|
|
30
57
|
|
|
@@ -16,6 +16,20 @@ The REST API is served at `http://localhost:3000/api`.
|
|
|
16
16
|
- `objectstack.config.ts` — environment manifest (objects, API, plugins)
|
|
17
17
|
- `src/objects/` — object definitions (one file per object)
|
|
18
18
|
|
|
19
|
+
## Verify your changes
|
|
20
|
+
|
|
21
|
+
After editing any metadata, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm validate # schema + CEL predicates + widget bindings (no artifact)
|
|
25
|
+
pnpm typecheck # TypeScript types against @objectstack/spec
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`pnpm validate` runs the same gates as `pnpm build` and catches mistakes that
|
|
29
|
+
otherwise fail *silently at runtime* — e.g. a bare `done` (instead of
|
|
30
|
+
`record.done`) in an action predicate that would hide the action on every
|
|
31
|
+
record. See `AGENTS.md` for the full convention.
|
|
32
|
+
|
|
19
33
|
## Next steps
|
|
20
34
|
|
|
21
35
|
- Add an object: see the `objectstack-data` skill.
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "objectstack
|
|
8
|
-
"start": "objectstack
|
|
7
|
+
"dev": "objectstack dev",
|
|
8
|
+
"start": "objectstack start",
|
|
9
9
|
"build": "objectstack build",
|
|
10
10
|
"validate": "objectstack validate",
|
|
11
11
|
"typecheck": "tsc --noEmit"
|