create-objectstack 4.0.3 → 4.0.4

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > create-objectstack@4.0.3 build /home/runner/work/framework/framework/packages/create-objectstack
2
+ > create-objectstack@4.0.4 build /home/runner/work/framework/framework/packages/create-objectstack
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,5 +9,5 @@
9
9
  CLI Target: es2022
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
- ESM dist/index.js 16.79 KB
13
- ESM ⚡️ Build success in 30ms
12
+ ESM dist/index.js 17.97 KB
13
+ ESM ⚡️ Build success in 45ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # create-objectstack
2
2
 
3
+ ## 4.0.4
4
+
3
5
  ## 4.0.3
4
6
 
5
7
  ## 4.0.2
package/dist/index.js CHANGED
@@ -4,6 +4,10 @@ import chalk from "chalk";
4
4
  import fs from "fs";
5
5
  import path from "path";
6
6
  import { execSync } from "child_process";
7
+ import { fileURLToPath } from "url";
8
+ var __filename = fileURLToPath(import.meta.url);
9
+ var __dirname = path.dirname(__filename);
10
+ var TEMPLATES_DIR = path.resolve(__dirname, "templates");
7
11
  var TEMPLATES = {
8
12
  "minimal-api": {
9
13
  description: "Server + memory driver + 1 object + REST API",
@@ -541,6 +545,12 @@ MIT
541
545
  }
542
546
  }
543
547
  };
548
+ function readTemplate(filename) {
549
+ return fs.readFileSync(path.join(TEMPLATES_DIR, filename), "utf-8");
550
+ }
551
+ var AI_CONFIG_FILES = {
552
+ ".github/copilot-instructions.md": (name) => readTemplate("copilot-instructions.md").replaceAll("{{PROJECT_NAME}}", name).replaceAll("{{PROJECT_TITLE}}", toTitleCase(name))
553
+ };
544
554
  function toTitleCase(str) {
545
555
  return str.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
546
556
  }
@@ -600,7 +610,8 @@ var program = new Command().name("create-objectstack").description("Create a new
600
610
  if (!fs.existsSync(targetDir)) {
601
611
  fs.mkdirSync(targetDir, { recursive: true });
602
612
  }
603
- for (const [filePath, contentFn] of Object.entries(template.files)) {
613
+ const allFiles = { ...template.files, ...AI_CONFIG_FILES };
614
+ for (const [filePath, contentFn] of Object.entries(allFiles)) {
604
615
  const fullPath = path.join(targetDir, filePath);
605
616
  const dir = path.dirname(fullPath);
606
617
  if (!fs.existsSync(dir)) {
@@ -625,6 +636,21 @@ var program = new Command().name("create-objectstack").description("Create a new
625
636
  console.log("");
626
637
  }
627
638
  }
639
+ if (!options.skipInstall) {
640
+ printStep("Installing AI skills for your coding agent...");
641
+ try {
642
+ execSync("npx -y skills add objectstack-ai/framework --all", {
643
+ stdio: "inherit",
644
+ cwd: targetDir
645
+ });
646
+ console.log("");
647
+ } catch {
648
+ printWarning(
649
+ "Skills installation skipped. Run manually:\n npx skills add objectstack-ai/framework"
650
+ );
651
+ console.log("");
652
+ }
653
+ }
628
654
  printSuccess("Project created!");
629
655
  console.log("");
630
656
  console.log(chalk.bold(" Next steps:"));
@@ -636,6 +662,11 @@ var program = new Command().name("create-objectstack").description("Create a new
636
662
  }
637
663
  console.log(chalk.dim(" npm run dev # Start development server"));
638
664
  console.log(chalk.dim(" npm run validate # Check configuration"));
665
+ if (options.skipInstall) {
666
+ console.log("");
667
+ console.log(chalk.bold(" AI Skills (recommended):"));
668
+ console.log(chalk.dim(" npx skills add objectstack-ai/framework"));
669
+ }
639
670
  console.log("");
640
671
  } catch (error) {
641
672
  printError(error.message || String(error));
@@ -0,0 +1,74 @@
1
+ # {{PROJECT_TITLE}} — Copilot Instructions
2
+
3
+ > Auto-generated by `create-objectstack`. Customise freely.
4
+
5
+ ## Project Context
6
+
7
+ This is an **ObjectStack** application — a metadata-driven low-code project
8
+ that defines business objects, views, automations, and AI agents in TypeScript.
9
+
10
+ - **Entry point:** `objectstack.config.ts` (uses `defineStack()`)
11
+ - **Spec package:** `@objectstack/spec` (Zod-first schemas and types)
12
+
13
+ ## Naming Conventions
14
+
15
+ | Context | Convention | Example |
16
+ |:--------|:-----------|:--------|
17
+ | Config keys (TS props) | `camelCase` | `maxLength`, `defaultValue` |
18
+ | Machine names (data values) | `snake_case` | `project_task`, `first_name` |
19
+ | Metadata type names | singular | `'agent'`, `'view'`, `'flow'` |
20
+ | File names | `{name}.{type}.ts` | `task.object.ts`, `main.app.ts` |
21
+
22
+ ## Key Rules
23
+
24
+ 1. **Zod First** — All schema definitions start with Zod. Types are derived via `z.infer<>`.
25
+ 2. `defineStack()` is the single configuration entry point in `objectstack.config.ts`.
26
+ 3. Use `Object.values()` barrel pattern for metadata arrays.
27
+ 4. Import from `@objectstack/spec` — never use relative paths into the spec package.
28
+
29
+ ## Project Structure
30
+
31
+ ```
32
+ {{PROJECT_NAME}}/
33
+ ├── objectstack.config.ts # defineStack() — the single entry point
34
+ ├── src/
35
+ │ ├── objects/ # Business object definitions (snake_case names)
36
+ │ ├── views/ # UI view definitions (list, form, kanban, calendar)
37
+ │ ├── apps/ # App navigation & page structure
38
+ │ ├── flows/ # Automation flows & workflows
39
+ │ ├── actions/ # Custom actions (buttons, bulk ops)
40
+ │ ├── dashboards/ # BI dashboards
41
+ │ ├── reports/ # Analytics reports
42
+ │ ├── agents/ # AI agent definitions
43
+ │ ├── i18n/ # Translation bundles
44
+ │ └── handlers/ # Runtime hook handlers
45
+ ```
46
+
47
+ ## AI Skills
48
+
49
+ This project uses ObjectStack skills from `objectstack-ai/framework`.
50
+ Install or update skills with the standard [skills CLI](https://skills.sh/):
51
+
52
+ ```bash
53
+ npx skills add objectstack-ai/framework
54
+ ```
55
+
56
+ Skills are triggered automatically based on task context:
57
+
58
+ | Skill | Trigger Context |
59
+ |:------|:----------------|
60
+ | **objectstack-schema** | Define objects, fields, relationships, validations, indexes |
61
+ | **objectstack-query** | Filters, sorting, pagination, aggregation, ObjectQL |
62
+ | **objectstack-ui** | Views, dashboards, apps, reports, actions, navigation |
63
+ | **objectstack-api** | REST endpoints, authentication, service contracts |
64
+ | **objectstack-plugin** | Plugin lifecycle, DI, services, hooks, events |
65
+ | **objectstack-automation** | Flows, workflows, triggers, approvals, state machines |
66
+ | **objectstack-ai** | Agents, tools, skills, RAG pipelines, LLM config |
67
+ | **objectstack-quickstart** | Project setup, defineStack(), driver selection |
68
+ | **objectstack-i18n** | Translation bundles, locale config, coverage detection |
69
+
70
+ ## Learn More
71
+
72
+ - [ObjectStack Documentation](https://objectstack.com/docs)
73
+ - [GitHub: objectstack-ai/framework](https://github.com/objectstack-ai/framework)
74
+ - [Skills CLI](https://skills.sh/) — Manage AI skills across agents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-objectstack",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Create a new ObjectStack project — npx create-objectstack",
5
5
  "bin": {
6
6
  "create-objectstack": "./bin/create-objectstack.js"
package/src/index.ts CHANGED
@@ -5,6 +5,11 @@ import chalk from 'chalk';
5
5
  import fs from 'fs';
6
6
  import path from 'path';
7
7
  import { execSync } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const TEMPLATES_DIR = path.resolve(__dirname, 'templates');
8
13
 
9
14
  // ─── Template Registry ──────────────────────────────────────────────
10
15
 
@@ -555,6 +560,23 @@ MIT
555
560
  },
556
561
  };
557
562
 
563
+ // ─── Shared AI Configuration Files ──────────────────────────────────
564
+ // These files are added to every template so third-party developers
565
+ // get AI-assisted development (Copilot + Claude) out of the box.
566
+ // Templates are maintained as standalone files in src/templates/ for
567
+ // easy editing — no need to modify TypeScript code.
568
+
569
+ function readTemplate(filename: string): string {
570
+ return fs.readFileSync(path.join(TEMPLATES_DIR, filename), 'utf-8');
571
+ }
572
+
573
+ const AI_CONFIG_FILES: TemplateFiles = {
574
+ '.github/copilot-instructions.md': (name) =>
575
+ readTemplate('copilot-instructions.md')
576
+ .replaceAll('{{PROJECT_NAME}}', name)
577
+ .replaceAll('{{PROJECT_TITLE}}', toTitleCase(name)),
578
+ };
579
+
558
580
  // ─── Helpers ────────────────────────────────────────────────────────
559
581
 
560
582
  function toCamelCase(str: string): string {
@@ -650,8 +672,11 @@ const program = new Command()
650
672
  fs.mkdirSync(targetDir, { recursive: true });
651
673
  }
652
674
 
653
- // Write every file defined by the template
654
- for (const [filePath, contentFn] of Object.entries(template.files)) {
675
+ // Merge template files with shared AI configuration files
676
+ const allFiles: TemplateFiles = { ...template.files, ...AI_CONFIG_FILES };
677
+
678
+ // Write every file defined by the template + AI config
679
+ for (const [filePath, contentFn] of Object.entries(allFiles)) {
655
680
  const fullPath = path.join(targetDir, filePath);
656
681
  const dir = path.dirname(fullPath);
657
682
 
@@ -684,6 +709,24 @@ const program = new Command()
684
709
  }
685
710
  }
686
711
 
712
+ // Install ObjectStack AI skills via the standard skills CLI
713
+ if (!options.skipInstall) {
714
+ printStep('Installing AI skills for your coding agent...');
715
+ try {
716
+ execSync('npx -y skills add objectstack-ai/framework --all', {
717
+ stdio: 'inherit',
718
+ cwd: targetDir,
719
+ });
720
+ console.log('');
721
+ } catch {
722
+ printWarning(
723
+ 'Skills installation skipped. Run manually:\n' +
724
+ ' npx skills add objectstack-ai/framework',
725
+ );
726
+ console.log('');
727
+ }
728
+ }
729
+
687
730
  printSuccess('Project created!');
688
731
  console.log('');
689
732
 
@@ -697,6 +740,11 @@ const program = new Command()
697
740
  }
698
741
  console.log(chalk.dim(' npm run dev # Start development server'));
699
742
  console.log(chalk.dim(' npm run validate # Check configuration'));
743
+ if (options.skipInstall) {
744
+ console.log('');
745
+ console.log(chalk.bold(' AI Skills (recommended):'));
746
+ console.log(chalk.dim(' npx skills add objectstack-ai/framework'));
747
+ }
700
748
  console.log('');
701
749
 
702
750
  } catch (error: any) {
@@ -0,0 +1,74 @@
1
+ # {{PROJECT_TITLE}} — Copilot Instructions
2
+
3
+ > Auto-generated by `create-objectstack`. Customise freely.
4
+
5
+ ## Project Context
6
+
7
+ This is an **ObjectStack** application — a metadata-driven low-code project
8
+ that defines business objects, views, automations, and AI agents in TypeScript.
9
+
10
+ - **Entry point:** `objectstack.config.ts` (uses `defineStack()`)
11
+ - **Spec package:** `@objectstack/spec` (Zod-first schemas and types)
12
+
13
+ ## Naming Conventions
14
+
15
+ | Context | Convention | Example |
16
+ |:--------|:-----------|:--------|
17
+ | Config keys (TS props) | `camelCase` | `maxLength`, `defaultValue` |
18
+ | Machine names (data values) | `snake_case` | `project_task`, `first_name` |
19
+ | Metadata type names | singular | `'agent'`, `'view'`, `'flow'` |
20
+ | File names | `{name}.{type}.ts` | `task.object.ts`, `main.app.ts` |
21
+
22
+ ## Key Rules
23
+
24
+ 1. **Zod First** — All schema definitions start with Zod. Types are derived via `z.infer<>`.
25
+ 2. `defineStack()` is the single configuration entry point in `objectstack.config.ts`.
26
+ 3. Use `Object.values()` barrel pattern for metadata arrays.
27
+ 4. Import from `@objectstack/spec` — never use relative paths into the spec package.
28
+
29
+ ## Project Structure
30
+
31
+ ```
32
+ {{PROJECT_NAME}}/
33
+ ├── objectstack.config.ts # defineStack() — the single entry point
34
+ ├── src/
35
+ │ ├── objects/ # Business object definitions (snake_case names)
36
+ │ ├── views/ # UI view definitions (list, form, kanban, calendar)
37
+ │ ├── apps/ # App navigation & page structure
38
+ │ ├── flows/ # Automation flows & workflows
39
+ │ ├── actions/ # Custom actions (buttons, bulk ops)
40
+ │ ├── dashboards/ # BI dashboards
41
+ │ ├── reports/ # Analytics reports
42
+ │ ├── agents/ # AI agent definitions
43
+ │ ├── i18n/ # Translation bundles
44
+ │ └── handlers/ # Runtime hook handlers
45
+ ```
46
+
47
+ ## AI Skills
48
+
49
+ This project uses ObjectStack skills from `objectstack-ai/framework`.
50
+ Install or update skills with the standard [skills CLI](https://skills.sh/):
51
+
52
+ ```bash
53
+ npx skills add objectstack-ai/framework
54
+ ```
55
+
56
+ Skills are triggered automatically based on task context:
57
+
58
+ | Skill | Trigger Context |
59
+ |:------|:----------------|
60
+ | **objectstack-schema** | Define objects, fields, relationships, validations, indexes |
61
+ | **objectstack-query** | Filters, sorting, pagination, aggregation, ObjectQL |
62
+ | **objectstack-ui** | Views, dashboards, apps, reports, actions, navigation |
63
+ | **objectstack-api** | REST endpoints, authentication, service contracts |
64
+ | **objectstack-plugin** | Plugin lifecycle, DI, services, hooks, events |
65
+ | **objectstack-automation** | Flows, workflows, triggers, approvals, state machines |
66
+ | **objectstack-ai** | Agents, tools, skills, RAG pipelines, LLM config |
67
+ | **objectstack-quickstart** | Project setup, defineStack(), driver selection |
68
+ | **objectstack-i18n** | Translation bundles, locale config, coverage detection |
69
+
70
+ ## Learn More
71
+
72
+ - [ObjectStack Documentation](https://objectstack.com/docs)
73
+ - [GitHub: objectstack-ai/framework](https://github.com/objectstack-ai/framework)
74
+ - [Skills CLI](https://skills.sh/) — Manage AI skills across agents
package/tsup.config.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
2
 
3
3
  import { defineConfig } from 'tsup';
4
+ import { cpSync } from 'fs';
4
5
 
5
6
  export default defineConfig({
6
7
  entry: ['src/index.ts'],
7
8
  format: ['esm'],
8
9
  clean: true,
9
10
  shims: true,
11
+ onSuccess: async () => {
12
+ // Copy template files to dist/ so they sit alongside the bundled JS
13
+ cpSync('src/templates', 'dist/templates', { recursive: true });
14
+ },
10
15
  });