oneie 3.3.4 → 3.3.5

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.
@@ -23,10 +23,10 @@ The ONE CLI is a bootstrap and synchronization tool that:
23
23
 
24
24
  ## User Flow
25
25
 
26
- ### Phase 1: Initial Bootstrap
26
+ ### Phase 1: Installation Initialization
27
27
 
28
28
  ```bash
29
- npx oneie
29
+ npx oneie init
30
30
  ```
31
31
 
32
32
  **What happens:**
@@ -45,53 +45,67 @@ npx oneie
45
45
 
46
46
  ✨ Welcome to ONE!
47
47
 
48
- Let's set up your environment with the 6-dimension ontology.
48
+ ONE is organized by groups which have their own people, things,
49
+ connections, events, and knowledge. Groups can have subgroups.
49
50
 
50
- 🧑 Step 1: Tell us about yourself
51
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
51
52
 
52
- What's your name? (e.g., Anthony O'Connell): _
53
- ```
53
+ 📥 Downloading ONE Framework...
54
54
 
55
- ### Phase 2: User Profile Creation
55
+ ✓ Copied 100+ ontology files from /one/
56
+ ✓ Synced 12 agent definitions to .claude/agents/
57
+ ✓ Copied Claude Code hooks and commands
56
58
 
57
- After user enters name:
59
+ ONE Setup Complete! 🎉
58
60
 
59
- ```
60
- Great to meet you, Anthony! 👋
61
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
61
62
 
62
- What's your email address? tony@one.ie
63
+ 👤 Account Setup
63
64
 
65
+ What's your name? Anthony O'Connell
66
+ What's your email? anthony@one.ie
64
67
 
65
- 🏢 Step 2: Organisation Setup
68
+ ✓ Created your profile in one/people/anthony-o-connell.md
66
69
 
67
- What's your organization name? (e.g., My Company): Company Name
68
- Organization slug (URL-friendly): company-name
69
- Organization Website: https://my-company.com
70
+ Account Setup Complete! 🎉
70
71
 
71
- Creating your profile...
72
- ✓ Created one/people/anthony-o-connell.md
73
- ✓ Created one/groups/my-company.md
74
- ✓ Linked anthony → owns → My Company
75
- ✓ Linked anthony → member_of → My Company (role: group_owner)
76
- ```
72
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
77
73
 
78
- ### Phase 3: Ontology Sync
74
+ 🏢 Organization Setup
79
75
 
80
- ```
81
- 📚 Step 3: Syncing ONE Ontology
76
+ What's your organization name? Acme Corp
77
+ Installation identifier: acme
78
+ Domain: acme.com
79
+
80
+ Creating your installation folder...
81
+ ✓ /acme/groups/
82
+ ✓ /acme/people/
83
+ ✓ /acme/things/
84
+ ✓ /acme/connections/
85
+ ✓ /acme/events/
86
+ ✓ /acme/knowledge/
87
+
88
+ ✓ Created installation README
89
+ ✓ Updated .env.local with INSTALLATION_NAME=acme
90
+
91
+ Organization Setup Complete! 🎉
82
92
 
83
- Copying ontology files from ONE framework...
93
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
84
94
 
85
- ✓ Copied 100+ .md files from /one/* to your project
86
- ✓ Updated cli/folders.yaml with all /one/* paths
87
- ✓ Synced 12 agent definitions: one/things/agents/* → .claude/agents/*
88
- ✓ Synced Claude Code hooks: .claude/hooks/*
89
- ✓ Synced Claude Code commands: .claude/commands/*
95
+ 🌐 Next: Create Your First Group
90
96
 
91
- Ontology sync complete! 🎉
97
+ Visit your web app to create groups in the database:
98
+ cd web && bun run dev
99
+
100
+ Then run this to generate group documentation:
101
+ npx oneie create-group-docs
102
+
103
+ You're all set! 🚀
92
104
  ```
93
105
 
94
- ### Phase 4: Website Setup (Optional)
106
+ ---
107
+
108
+ ### Phase 2: Website Setup (Optional)
95
109
 
96
110
  ```
97
111
  🌐 Step 4: Website Setup
@@ -99,20 +113,23 @@ Ontology sync complete! 🎉
99
113
  Would you like to build a website? (yes/no): yes
100
114
 
101
115
  Cloning frontend repository...
102
- ✓ git clone https://github.com/one-ie/frontend.git → /frontend
116
+ ✓ git clone https://github.com/one-ie/web.git → /web
103
117
  ✓ Installed dependencies (bun install)
104
- ✓ Created frontend/.env.local with your organization details
118
+ ✓ Created web/.env.local with your installation details
105
119
 
106
120
  Your website is ready at: http://localhost:4321
107
- Run: cd frontend && bun run dev
121
+ Run: cd web && bun dev
108
122
  ```
109
123
 
110
- ### Phase 5: Third-Party Docs (Optional)
124
+ ### Phase 3: Third-Party Docs (Optional)
111
125
 
112
126
  ```
113
127
  📖 Step 5: Third-Party Documentation
114
128
 
115
- Would you like to clone third-party docs for AI context? (yes/no): yes
129
+ Would you like to clone third-party docs for AI context? Don't do this unless you plan to start development. You can add later if you like. (yes/no): yes
130
+
131
+ ⚠️ This will download complete documentation repositories (~500MB)
132
+ Only needed if you plan to do development with offline AI context.
116
133
 
117
134
  Cloning documentation repositories...
118
135
  ✓ Astro docs → /docs/astro
@@ -124,7 +141,7 @@ Cloning documentation repositories...
124
141
  Documentation cloned! AI agents can now reference these offline.
125
142
  ```
126
143
 
127
- ### Phase 6: Complete
144
+ ### Phase 4: Complete
128
145
 
129
146
  ```
130
147
  ✅ Setup Complete!
@@ -132,11 +149,18 @@ Documentation cloned! AI agents can now reference these offline.
132
149
  Your ONE environment is ready:
133
150
 
134
151
  📁 Project Structure:
135
- /one/ → 6-dimension ontology (100+ files)
136
- /frontend/ → Astro + React website
152
+ /one/ → Global ontology (100+ files)
153
+ /acme/ → Installation folder (your private docs)
154
+ ├── groups/ → Hierarchical group docs
155
+ ├── people/ → People profiles
156
+ ├── things/ → Entity definitions
157
+ ├── connections/ → Relationship definitions
158
+ ├── events/ → Event specifications
159
+ └── knowledge/ → RAG, AI, embeddings
160
+ /web/ → Astro + React website
137
161
  /docs/ → Third-party documentation
138
162
  /.claude/ → AI agent integration
139
- /cli/ → CLI configuration
163
+
140
164
 
141
165
  🧑 Your Profile:
142
166
  Name: Anthony O'Connell
@@ -145,16 +169,17 @@ Your ONE environment is ready:
145
169
  Role: org_owner
146
170
  File: one/people/anthony-o-connell.md
147
171
 
148
- 🏢 Your Group:
172
+ 🏢 Your Organization:
149
173
  Name: ONE Platform
150
174
  Slug: one
151
175
  Domain: one.ie
152
- File: one/groups/one.md
176
+ File: /acme/groups/one.md
177
+ Installation: /acme/
153
178
 
154
179
  🚀 Next Steps:
155
180
 
156
181
  1. Start building:
157
- cd frontend && bun run dev
182
+ cd web && bun run dev
158
183
 
159
184
  2. Use AI agents:
160
185
  claude
@@ -163,7 +188,7 @@ Your ONE environment is ready:
163
188
  cat one/knowledge/ontology.md
164
189
 
165
190
  4. Create your first feature:
166
- /one
191
+ /build
167
192
 
168
193
  Happy building! 🎉
169
194
  ```
@@ -172,80 +197,42 @@ Happy building! 🎉
172
197
 
173
198
  ## Technical Implementation
174
199
 
175
- ### 1. Copy Ontology Files (folders.yaml)
176
-
177
- **File:** `cli/folders.yaml`
200
+ ### 1. Installation Folder Initialization
178
201
 
179
- **Current state:**
180
- ```yaml
181
- # ONE Framework - Folder Copy Configuration
182
- claude_folders:
183
- - .claude/agents
184
- - .claude/commands
185
- - .claude/hooks
202
+ **File:** `cli/src/commands/init.ts`
186
203
 
187
- one_platform_folders:
188
- - .one/checklists
189
- - .one/data
190
- - .one/missions
191
- - .one/ontology
192
- - .one/stories
193
- - .one/tasks
194
- - .one/teams
195
- - .one/templates
196
- - .one/workflows
197
-
198
- one_user_folders:
199
- - one/agents
200
- - one/brand
201
- - one/checklists
202
- - one/company
203
- - one/data
204
- - one/docs
205
- - one/engineering
206
- - one/guides
207
- - one/me
208
- - one/missions
209
- - one/prompts
210
- - one/stories
211
- - one/tasks
212
- - one/templates
213
- - one/workflows
214
-
215
- root_files:
216
- - .one/interface.md
217
- - .one/one-command.js
218
- - .one/structure.yaml
219
- - one/core-config.yaml
220
- - one/manifest.md
221
- - one/one.md
222
- - one/ontology.md
223
- - one/plan.md
224
- - one/structure.yaml
225
- - one/workflow.md
226
- ```
204
+ **Purpose:** Create installation folder with 6-dimension structure
227
205
 
228
- **Simplified configuration:**
206
+ **Configuration:**
229
207
  ```yaml
230
- # ONE CLI - Folder Copy Configuration
231
- # Simple: Copy everything from /one/* to user's project
208
+ # ONE CLI - Installation Configuration
209
+ # cli/config.yaml
232
210
 
233
- # Claude Code Integration
211
+ # Claude Code Integration (global)
234
212
  claude_folders:
235
213
  - .claude/agents
236
214
  - .claude/commands
237
215
  - .claude/hooks
238
216
 
239
- # ONE Ontology (copy ALL files from /one/*)
240
- # No need to list individual folders - CLI discovers them automatically
217
+ # Global Ontology (copy from /one/* to user's project)
241
218
  one_folders:
242
219
  - one/**/*
243
220
 
221
+ # Installation Folder Structure (created per installation)
222
+ installation_structure:
223
+ - groups/ # Hierarchical group docs (supports nesting)
224
+ - people/ # People profiles
225
+ - things/ # Entity definitions
226
+ - connections/ # Relationship definitions
227
+ - events/ # Event specifications
228
+ - knowledge/ # RAG, AI, embeddings
229
+
244
230
  # File extensions to copy
245
231
  allowed_extensions:
246
232
  - .md
247
233
  - .yaml
248
234
  - .yml
235
+ - .json
249
236
  - .sh
250
237
 
251
238
  # Files/folders to exclude
@@ -257,62 +244,154 @@ exclude_patterns:
257
244
  - "*/.DS_Store"
258
245
  - "*/package-lock.json"
259
246
  - "*/bun.lockb"
247
+
248
+ # Environment variables
249
+ env_vars:
250
+ - INSTALLATION_NAME # Set during init
251
+ - INSTALLATION_ENV # Optional: dev, staging, prod
260
252
  ```
261
253
 
262
- **Implementation (Simplified):**
254
+ **Implementation:**
263
255
 
264
256
  ```typescript
265
- // cli/src/sync-ontology.ts
257
+ // cli/src/commands/init.ts
266
258
  import fs from "fs/promises";
267
259
  import path from "path";
268
- import yaml from "yaml";
269
- import { glob } from "glob";
260
+ import prompts from "prompts";
261
+ import { syncOntologyFiles } from "../utils/sync-ontology";
262
+ import { createInstallationFolder } from "../utils/installation-setup";
263
+ import { updateEnvFile } from "../utils/env-updater";
264
+ import { updateGitignore } from "../utils/gitignore-updater";
265
+
266
+ export async function initCommand() {
267
+ // 1. Prompt for installation details
268
+ const { orgName, installationId } = await prompts([
269
+ {
270
+ type: "text",
271
+ name: "orgName",
272
+ message: "What is your organization name?",
273
+ validate: (value) => value.length > 0 ? true : "Organization name cannot be empty"
274
+ },
275
+ {
276
+ type: "text",
277
+ name: "installationId",
278
+ message: "Installation identifier (lowercase, hyphens only):",
279
+ validate: (value) => /^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)
280
+ ? true
281
+ : "Must be lowercase letters, numbers, and hyphens only"
282
+ }
283
+ ]);
284
+
285
+ // 2. Create installation folder
286
+ console.log(`\nCreating installation folder: /${installationId}`);
287
+ await createInstallationFolder(installationId, orgName);
288
+
289
+ // 3. Sync global ontology
290
+ console.log("\nCopying ontology files from /one/*...");
291
+ await syncOntologyFiles();
270
292
 
271
- interface FoldersConfig {
272
- claude_folders: string[];
273
- one_folders: string[];
274
- allowed_extensions: string[];
275
- exclude_patterns: string[];
293
+ // 4. Update environment
294
+ console.log("\n✓ Updated .env.local with INSTALLATION_NAME=" + installationId);
295
+ await updateEnvFile({ INSTALLATION_NAME: installationId });
296
+
297
+ // 5. Update .gitignore
298
+ console.log("✓ Updated .gitignore");
299
+ await updateGitignore(installationId);
300
+
301
+ console.log("\n🎉 Installation initialized!");
302
+ console.log(`\nYour private docs go in /${installationId}/`);
303
+ console.log("\nNext steps:");
304
+ console.log(" 1. Create your first group in the database (via web UI)");
305
+ console.log(` 2. Add group-specific docs: /${installationId}/groups/<group-slug>/`);
306
+ console.log(" 3. Run: npx oneie dev");
276
307
  }
277
308
 
278
- export async function syncOntologyFiles() {
279
- // 1. Read config
280
- const configPath = path.join(__dirname, "../../cli/folders.yaml");
281
- const configContent = await fs.readFile(configPath, "utf-8");
282
- const config: FoldersConfig = yaml.parse(configContent);
309
+ // cli/src/utils/installation-setup.ts
310
+ import fs from "fs/promises";
311
+ import path from "path";
283
312
 
284
- // 2. Build glob pattern for all allowed extensions
285
- const patterns = config.allowed_extensions.map(
286
- (ext) => `one/**/*${ext}`
287
- );
313
+ const INSTALLATION_DIMENSIONS = [
314
+ "groups",
315
+ "people",
316
+ "things",
317
+ "connections",
318
+ "events",
319
+ "knowledge"
320
+ ];
288
321
 
289
- // 3. Find all matching files
290
- const oneFiles: string[] = [];
291
- for (const pattern of patterns) {
292
- const files = await glob(pattern, {
293
- cwd: path.join(__dirname, "../.."),
294
- ignore: config.exclude_patterns,
295
- });
296
- oneFiles.push(...files);
322
+ export async function createInstallationFolder(
323
+ installationId: string,
324
+ orgName: string
325
+ ) {
326
+ const installationPath = path.join(process.cwd(), installationId);
327
+
328
+ // Create root folder
329
+ await fs.mkdir(installationPath, { recursive: true });
330
+
331
+ // Create 6-dimension folders
332
+ for (const dimension of INSTALLATION_DIMENSIONS) {
333
+ const dimensionPath = path.join(installationPath, dimension);
334
+ await fs.mkdir(dimensionPath, { recursive: true });
335
+ console.log(`✓ /${installationId}/${dimension}/`);
297
336
  }
298
337
 
299
- // 4. Copy all files to user directory
300
- for (const file of oneFiles) {
301
- const sourcePath = path.join(__dirname, "../..", file);
302
- const targetPath = path.join(process.cwd(), file);
338
+ // Create README
339
+ const readmeContent = `# ${orgName} - ONE Installation
303
340
 
304
- // Create directory if needed
305
- await fs.mkdir(path.dirname(targetPath), { recursive: true });
341
+ **Installation ID:** \`${installationId}\`
342
+ **Created:** ${new Date().toISOString().split('T')[0]}
306
343
 
307
- // Copy file
308
- await fs.copyFile(sourcePath, targetPath);
309
- }
344
+ ---
310
345
 
311
- console.log(`✓ Copied ${oneFiles.length} ontology files`);
346
+ ## Structure
312
347
 
313
- return {
314
- filesCopied: oneFiles.length,
315
- };
348
+ This installation folder follows the 6-dimension ontology:
349
+
350
+ - **groups/** - Hierarchical group documentation (supports nesting)
351
+ - **people/** - People profiles and roles
352
+ - **things/** - Entity definitions and specs
353
+ - **connections/** - Relationship definitions
354
+ - **events/** - Event specifications
355
+ - **knowledge/** - RAG, AI, embeddings
356
+
357
+ ## File Resolution
358
+
359
+ Files in this folder override global templates in \`/one/\`:
360
+
361
+ 1. \`/${installationId}/groups/<group-path>/<file>\` (most specific)
362
+ 2. \`/${installationId}/<dimension>/<file>\` (installation-wide)
363
+ 3. \`/one/<dimension>/<file>\` (global fallback)
364
+
365
+ ## Hierarchical Groups
366
+
367
+ Create nested group documentation matching your database structure:
368
+
369
+ \`\`\`bash
370
+ mkdir -p /${installationId}/groups/engineering/frontend
371
+ echo "# Frontend Practices" > /${installationId}/groups/engineering/frontend/practices.md
372
+ \`\`\`
373
+
374
+ ## Security
375
+
376
+ - **DO NOT** store secrets or credentials here
377
+ - Use \`.env.local\` for environment variables
378
+ - This folder is for documentation and configuration only
379
+ - Optionally exclude from git (see .gitignore)
380
+
381
+ ---
382
+
383
+ **Built with ONE Platform:** https://one.ie
384
+ `;
385
+
386
+ await fs.writeFile(
387
+ path.join(installationPath, "README.md"),
388
+ readmeContent,
389
+ "utf-8"
390
+ );
391
+
392
+ console.log(`✓ Created /${installationId}/README.md`);
393
+
394
+ return installationPath;
316
395
  }
317
396
  ```
318
397
 
@@ -538,7 +617,7 @@ ${profile.website ? `- **Website:** ${profile.website}\n` : ""}
538
617
  }
539
618
  ```
540
619
 
541
- **Group Profile:** `one/groups/{name}.md`
620
+ **Group Profile:** `/{installation-name}/groups/{slug}.md`
542
621
 
543
622
  ```typescript
544
623
  // cli/src/create-group-profile.ts
@@ -551,15 +630,24 @@ interface GroupProfile {
551
630
  domain: string;
552
631
  ownerName: string;
553
632
  ownerUsername: string;
633
+ installationName: string;
634
+ parentGroupSlug?: string; // For hierarchical groups
635
+ groupType?: string; // One of 6 group types
554
636
  }
555
637
 
556
638
  export async function createGroupProfile(profile: GroupProfile) {
639
+ // Determine file path based on hierarchy
640
+ let groupPath = profile.slug;
641
+ if (profile.parentGroupSlug) {
642
+ groupPath = `${profile.parentGroupSlug}/${profile.slug}`;
643
+ }
644
+
557
645
  const filePath = path.join(
558
646
  process.cwd(),
559
- `one/groups/${profile.slug}.md`
647
+ `${profile.installationName}/groups/${groupPath}.md`
560
648
  );
561
649
 
562
- // Create directory
650
+ // Create directory (supports nested hierarchies)
563
651
  await fs.mkdir(path.dirname(filePath), { recursive: true });
564
652
 
565
653
  // Generate content
@@ -570,6 +658,7 @@ export async function createGroupProfile(profile: GroupProfile) {
570
658
  **Owner:** ${profile.ownerName} (100%)
571
659
  **Status:** Active
572
660
  **Plan:** Enterprise
661
+ ${profile.parentGroupSlug ? `**Parent Group:** ${profile.parentGroupSlug}` : "**Type:** Top-level organization"}
573
662
 
574
663
  ---
575
664
 
@@ -581,6 +670,8 @@ export async function createGroupProfile(profile: GroupProfile) {
581
670
  - **Owner:** ${profile.ownerName}
582
671
  - **Status:** Active
583
672
  - **Plan:** Enterprise
673
+ - **Group Type:** ${profile.groupType || "organization"}
674
+ ${profile.parentGroupSlug ? `- **Parent Group:** ${profile.parentGroupSlug}` : ""}
584
675
 
585
676
  ---
586
677
 
@@ -590,13 +681,14 @@ export async function createGroupProfile(profile: GroupProfile) {
590
681
  {
591
682
  _id: Id<"groups">,
592
683
  name: "${profile.name}",
593
- type: "organization", // One of 6 group types
594
- parentGroupId: undefined, // Top-level group
684
+ type: "${profile.groupType || "organization"}", // One of 6 group types
685
+ parentGroupId: ${profile.parentGroupSlug ? `parentGroupId` : "undefined"}, // ${profile.parentGroupSlug ? "Nested group" : "Top-level group"}
595
686
  properties: {
596
687
  // Identity
597
688
  slug: "${profile.slug}",
598
689
  domain: "${profile.domain}",
599
690
  description: "Group created via ONE CLI",
691
+ installationName: "${profile.installationName}",
600
692
 
601
693
  // Status & Plan
602
694
  plan: "enterprise",
@@ -634,6 +726,23 @@ export async function createGroupProfile(profile: GroupProfile) {
634
726
 
635
727
  ---
636
728
 
729
+ ## File Resolution for This Group
730
+
731
+ **Hierarchical file lookup:**
732
+ 1. \`/${profile.installationName}/groups/${groupPath}/<file>\` (most specific)
733
+ ${profile.parentGroupSlug ? `2. \`/${profile.installationName}/groups/${profile.parentGroupSlug}/<file>\` (parent group)` : ""}
734
+ ${profile.parentGroupSlug ? `3. \`/${profile.installationName}/<file>\` (installation-wide)` : `2. \`/${profile.installationName}/<file>\` (installation-wide)`}
735
+ ${profile.parentGroupSlug ? `4. \`/one/<file>\` (global fallback)` : `3. \`/one/<file>\` (global fallback)`}
736
+
737
+ **Example:**
738
+ \`\`\`bash
739
+ # Create group-specific documentation
740
+ mkdir -p /${profile.installationName}/groups/${groupPath}
741
+ echo "# ${profile.name} Practices" > /${profile.installationName}/groups/${groupPath}/practices.md
742
+ \`\`\`
743
+
744
+ ---
745
+
637
746
  ## Ownership Connections
638
747
 
639
748
  ### ${profile.ownerName} Owns ${profile.name}
@@ -661,7 +770,7 @@ export async function createGroupProfile(profile: GroupProfile) {
661
770
  toThingId: ${profile.slug}Id,
662
771
  relationshipType: "member_of",
663
772
  metadata: {
664
- role: "group_owner",
773
+ role: "org_owner",
665
774
  permissions: ["*"], // All permissions
666
775
  joinedAt: Date.now(),
667
776
  },
@@ -673,7 +782,8 @@ export async function createGroupProfile(profile: GroupProfile) {
673
782
 
674
783
  ## Key Principles
675
784
 
676
- - **Multi-Tenant Isolation** - Group partitions the data space
785
+ - **Installation-Based Multi-Tenancy** - Group docs stored in installation folder
786
+ - **Hierarchical Groups** - ${profile.parentGroupSlug ? "This is a nested subgroup" : "Top-level organization, can have subgroups"}
677
787
  - **Owner Control** - ${profile.ownerName} has full control (100% ownership)
678
788
  - **Enterprise Plan** - Unlimited resources for growth
679
789
  - **Ontology Mapping** - Dimension 1 (Groups) in the 6-dimension model
@@ -681,11 +791,28 @@ export async function createGroupProfile(profile: GroupProfile) {
681
791
 
682
792
  ---
683
793
 
794
+ ## Creating Subgroups
795
+
796
+ ${profile.parentGroupSlug ? `This group can have its own subgroups:` : `Create subgroups for this organization:`}
797
+
798
+ \`\`\`bash
799
+ # Example: Create engineering/frontend subgroup
800
+ npx oneie create-group \\
801
+ --name "Frontend Team" \\
802
+ --slug "frontend" \\
803
+ --parent "${profile.slug}" \\
804
+ --type "business"
805
+
806
+ # This creates: /${profile.installationName}/groups/${profile.slug}/frontend/frontend.md
807
+ \`\`\`
808
+
809
+ ---
810
+
684
811
  ## See Also
685
812
 
686
- - [Owner Profile](../people/${profile.ownerUsername}.md)
687
- - [Group Structure](./groups.md)
688
- - [Multi-Tenancy](../connections/multitenant.md)
813
+ - [Owner Profile](../../people/${profile.ownerUsername}.md)
814
+ - [Installation README](../../README.md)
815
+ - [Multi-Tenancy Plan](../../../one/things/plans/group-folder-multi-tenancy.md)
689
816
  `;
690
817
 
691
818
  // Write file
@@ -699,7 +826,320 @@ export async function createGroupProfile(profile: GroupProfile) {
699
826
 
700
827
  ---
701
828
 
702
- ### 4. Clone Frontend Repository
829
+ ### 4. Create Group Documentation (After Database Groups Exist)
830
+
831
+ **Command:** `npx oneie create-group-docs`
832
+
833
+ **Purpose:** Create markdown documentation for groups that exist in the database
834
+
835
+ ```typescript
836
+ // cli/src/commands/create-group-docs.ts
837
+ import fs from "fs/promises";
838
+ import path from "path";
839
+ import prompts from "prompts";
840
+ import { ConvexHttpClient } from "convex/browser";
841
+ import { api } from "../../convex/_generated/api";
842
+
843
+ export async function createGroupDocsCommand() {
844
+ const installationName = process.env.INSTALLATION_NAME;
845
+ if (!installationName) {
846
+ console.error("❌ INSTALLATION_NAME not set in .env.local");
847
+ console.log("Run: npx oneie init");
848
+ process.exit(1);
849
+ }
850
+
851
+ // 1. Connect to Convex backend
852
+ const convexUrl = process.env.PUBLIC_CONVEX_URL;
853
+ if (!convexUrl) {
854
+ console.error("❌ PUBLIC_CONVEX_URL not set in .env.local");
855
+ process.exit(1);
856
+ }
857
+
858
+ const convex = new ConvexHttpClient(convexUrl);
859
+
860
+ // 2. Fetch all groups from database
861
+ console.log("Fetching groups from database...");
862
+ const groups = await convex.query(api.queries.groups.list, {});
863
+
864
+ if (groups.length === 0) {
865
+ console.log("No groups found in database.");
866
+ console.log("Create your first group in the web UI: /groups/new");
867
+ return;
868
+ }
869
+
870
+ // 3. Display groups and let user select
871
+ const { selectedGroupIds } = await prompts({
872
+ type: "multiselect",
873
+ name: "selectedGroupIds",
874
+ message: "Select groups to create documentation for:",
875
+ choices: groups.map((g) => ({
876
+ title: `${g.name} (${g.properties.slug})${g.parentGroupId ? " → subgroup" : ""}`,
877
+ value: g._id,
878
+ })),
879
+ });
880
+
881
+ if (!selectedGroupIds || selectedGroupIds.length === 0) {
882
+ console.log("No groups selected. Exiting.");
883
+ return;
884
+ }
885
+
886
+ // 4. Create documentation for each selected group
887
+ for (const groupId of selectedGroupIds) {
888
+ const group = groups.find((g) => g._id === groupId);
889
+ if (!group) continue;
890
+
891
+ // Build hierarchical path
892
+ const groupPath = await buildGroupPath(group, groups);
893
+
894
+ const docsPath = path.join(
895
+ process.cwd(),
896
+ installationName,
897
+ "groups",
898
+ groupPath,
899
+ "README.md"
900
+ );
901
+
902
+ await fs.mkdir(path.dirname(docsPath), { recursive: true });
903
+
904
+ const content = `# ${group.name}
905
+
906
+ **Slug:** \`${group.properties.slug}\`
907
+ **Type:** ${group.type}
908
+ ${group.parentGroupId ? `**Parent:** ${getParentName(group.parentGroupId, groups)}` : "**Level:** Top-level"}
909
+ **Created:** ${new Date(group.createdAt).toISOString().split("T")[0]}
910
+
911
+ ---
912
+
913
+ ## About
914
+
915
+ This folder contains documentation specific to the **${group.name}** group.
916
+
917
+ ## File Resolution
918
+
919
+ When AI agents or the web app load documentation for this group, files are resolved in this order:
920
+
921
+ 1. \`/${installationName}/groups/${groupPath}/<file>\` (most specific)
922
+ ${group.parentGroupId ? `2. \`/${installationName}/groups/${getParentPath(group.parentGroupId, groups)}/<file>\` (parent group)\n` : ""}${group.parentGroupId ? `3. \`/${installationName}/<file>\` (installation-wide)\n` : `2. \`/${installationName}/<file>\` (installation-wide)\n`}${group.parentGroupId ? `4. \`/one/<file>\` (global fallback)` : `3. \`/one/<file>\` (global fallback)`}
923
+
924
+ ## Add Custom Documentation
925
+
926
+ Create markdown files in this folder for group-specific content:
927
+
928
+ \`\`\`bash
929
+ # Practices and guidelines
930
+ echo "# ${group.name} Practices" > ${docsPath.replace("README.md", "practices.md")}
931
+
932
+ # Meeting notes
933
+ echo "# Sprint Planning" > ${docsPath.replace("README.md", "sprint-planning.md")}
934
+
935
+ # Technical specs
936
+ echo "# Architecture" > ${docsPath.replace("README.md", "architecture.md")}
937
+ \`\`\`
938
+
939
+ ## Database Entity
940
+
941
+ \`\`\`typescript
942
+ {
943
+ _id: "${group._id}",
944
+ name: "${group.name}",
945
+ type: "${group.type}",
946
+ parentGroupId: ${group.parentGroupId ? `"${group.parentGroupId}"` : "undefined"},
947
+ properties: {
948
+ slug: "${group.properties.slug}",
949
+ installationName: "${installationName}",
950
+ // ...
951
+ }
952
+ }
953
+ \`\`\`
954
+
955
+ ---
956
+
957
+ **Updated:** ${new Date().toISOString().split("T")[0]}
958
+ `;
959
+
960
+ await fs.writeFile(docsPath, content, "utf-8");
961
+ console.log(`✓ Created ${docsPath}`);
962
+ }
963
+
964
+ console.log("\n✅ Group documentation created!");
965
+ console.log("Add custom markdown files to these folders to override global templates.");
966
+ }
967
+
968
+ // Helper: Build hierarchical path for group
969
+ async function buildGroupPath(group: any, allGroups: any[]): Promise<string> {
970
+ const segments = [group.properties.slug];
971
+
972
+ let currentParentId = group.parentGroupId;
973
+ while (currentParentId) {
974
+ const parent = allGroups.find((g) => g._id === currentParentId);
975
+ if (parent) {
976
+ segments.unshift(parent.properties.slug);
977
+ currentParentId = parent.parentGroupId;
978
+ } else {
979
+ break;
980
+ }
981
+ }
982
+
983
+ return segments.join("/");
984
+ }
985
+
986
+ // Helper: Get parent group name
987
+ function getParentName(parentId: string, allGroups: any[]): string {
988
+ const parent = allGroups.find((g) => g._id === parentId);
989
+ return parent ? parent.name : "Unknown";
990
+ }
991
+
992
+ // Helper: Get parent group path
993
+ function getParentPath(parentId: string, allGroups: any[]): string {
994
+ const parent = allGroups.find((g) => g._id === parentId);
995
+ if (!parent) return "";
996
+ // Recursively build parent path
997
+ return buildGroupPath(parent, allGroups);
998
+ }
999
+ ```
1000
+
1001
+ ---
1002
+
1003
+ ### 5. File Resolution with Hierarchical Groups
1004
+
1005
+ **File:** `cli/src/utils/file-resolver.ts`
1006
+
1007
+ **Purpose:** Resolve markdown files with hierarchical group support
1008
+
1009
+ ```typescript
1010
+ // cli/src/utils/file-resolver.ts
1011
+ import fs from "fs/promises";
1012
+ import path from "path";
1013
+ import { Id } from "../../convex/_generated/dataModel";
1014
+
1015
+ interface ResolveOptions {
1016
+ installationName: string;
1017
+ groupId?: Id<"groups">;
1018
+ convexClient: any; // ConvexHttpClient
1019
+ }
1020
+
1021
+ export async function resolveFile(
1022
+ relativePath: string,
1023
+ options: ResolveOptions
1024
+ ): Promise<string | null> {
1025
+ const { installationName, groupId, convexClient } = options;
1026
+
1027
+ // If groupId provided, resolve hierarchically
1028
+ if (groupId) {
1029
+ const groupPath = await getGroupPath(groupId, convexClient);
1030
+
1031
+ // 1. Check most-specific group first
1032
+ const groupFile = path.join(
1033
+ process.cwd(),
1034
+ installationName,
1035
+ "groups",
1036
+ groupPath,
1037
+ relativePath
1038
+ );
1039
+ if (await fileExists(groupFile)) {
1040
+ return await fs.readFile(groupFile, "utf-8");
1041
+ }
1042
+
1043
+ // 2. Walk up parent groups
1044
+ let currentGroupId = groupId;
1045
+ while (currentGroupId) {
1046
+ const group = await convexClient.query(api.queries.groups.get, {
1047
+ id: currentGroupId,
1048
+ });
1049
+
1050
+ if (group?.parentGroupId) {
1051
+ const parentPath = await getGroupPath(group.parentGroupId, convexClient);
1052
+ const parentFile = path.join(
1053
+ process.cwd(),
1054
+ installationName,
1055
+ "groups",
1056
+ parentPath,
1057
+ relativePath
1058
+ );
1059
+ if (await fileExists(parentFile)) {
1060
+ return await fs.readFile(parentFile, "utf-8");
1061
+ }
1062
+ currentGroupId = group.parentGroupId;
1063
+ } else {
1064
+ break;
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+ // 3. Check installation root (non-group-specific)
1070
+ const installFile = path.join(
1071
+ process.cwd(),
1072
+ installationName,
1073
+ relativePath
1074
+ );
1075
+ if (await fileExists(installFile)) {
1076
+ return await fs.readFile(installFile, "utf-8");
1077
+ }
1078
+
1079
+ // 4. Fallback to global template
1080
+ const globalFile = path.join(process.cwd(), "one", relativePath);
1081
+ if (await fileExists(globalFile)) {
1082
+ return await fs.readFile(globalFile, "utf-8");
1083
+ }
1084
+
1085
+ // 5. Not found
1086
+ return null;
1087
+ }
1088
+
1089
+ // Helper: Get group's full path (e.g., "engineering/frontend")
1090
+ async function getGroupPath(
1091
+ groupId: Id<"groups">,
1092
+ convexClient: any
1093
+ ): Promise<string> {
1094
+ const group = await convexClient.query(api.queries.groups.get, { id: groupId });
1095
+ if (!group) throw new Error("Group not found");
1096
+
1097
+ const segments: string[] = [group.properties.slug];
1098
+
1099
+ // Walk up to root
1100
+ let currentParentId = group.parentGroupId;
1101
+ while (currentParentId) {
1102
+ const parent = await convexClient.query(api.queries.groups.get, {
1103
+ id: currentParentId,
1104
+ });
1105
+ if (parent) {
1106
+ segments.unshift(parent.properties.slug);
1107
+ currentParentId = parent.parentGroupId;
1108
+ } else {
1109
+ break;
1110
+ }
1111
+ }
1112
+
1113
+ return segments.join("/");
1114
+ }
1115
+
1116
+ // Helper: Check if file exists
1117
+ async function fileExists(filePath: string): Promise<boolean> {
1118
+ try {
1119
+ await fs.access(filePath);
1120
+ return true;
1121
+ } catch {
1122
+ return false;
1123
+ }
1124
+ }
1125
+
1126
+ // Example usage:
1127
+ // const content = await resolveFile("practices.md", {
1128
+ // installationName: "acme",
1129
+ // groupId: "frontend-group-id" as Id<"groups">,
1130
+ // convexClient: convex
1131
+ // });
1132
+ //
1133
+ // Checks in order:
1134
+ // 1. /acme/groups/engineering/frontend/practices.md
1135
+ // 2. /acme/groups/engineering/practices.md (parent)
1136
+ // 3. /acme/practices.md (installation root)
1137
+ // 4. /one/practices.md (global fallback)
1138
+ ```
1139
+
1140
+ ---
1141
+
1142
+ ### 6. Clone Frontend Repository
703
1143
 
704
1144
  ```typescript
705
1145
  // cli/src/clone-frontend.ts
@@ -715,7 +1155,7 @@ export async function cloneFrontend(orgProfile: {
715
1155
  slug: string;
716
1156
  domain: string;
717
1157
  }) {
718
- const targetDir = path.join(process.cwd(), "frontend");
1158
+ const targetDir = path.join(process.cwd(), "web");
719
1159
 
720
1160
  // Check if frontend already exists
721
1161
  if (await fs.stat(targetDir).catch(() => null)) {
@@ -726,7 +1166,7 @@ export async function cloneFrontend(orgProfile: {
726
1166
  // Clone repository
727
1167
  console.log("Cloning frontend repository...");
728
1168
  await execAsync(
729
- "git clone https://github.com/one-ie/frontend.git frontend",
1169
+ "git clone https://github.com/one-ie/web.git web",
730
1170
  {
731
1171
  cwd: process.cwd(),
732
1172
  }
@@ -740,7 +1180,7 @@ export async function cloneFrontend(orgProfile: {
740
1180
  console.log("✓ Installed dependencies");
741
1181
 
742
1182
  // Create .env.local with organization details
743
- const envContent = `# ONE Platform Configuration
1183
+ const envContent = `# ONE Configuration
744
1184
  # Generated by CLI on ${new Date().toISOString()}
745
1185
 
746
1186
  # Organization
@@ -1186,12 +1626,15 @@ main().catch((error) => {
1186
1626
  ## Success Metrics
1187
1627
 
1188
1628
  - ✅ All 100+ ontology files copied from `/one/*`
1189
- - ✅ `cli/folders.yaml` auto-updated with discovered paths
1629
+ - ✅ Installation folder created with 6-dimension structure
1190
1630
  - ✅ 12 agent definitions synced to `.claude/agents/`
1191
1631
  - ✅ User profile created with correct ontology mapping
1192
- - ✅ Organization profile created with ownership connections
1193
- - ✅ Frontend cloned and configured with org details
1194
- - ✅ Third-party docs cloned for offline AI context
1632
+ - ✅ `INSTALLATION_NAME` set in `.env.local`
1633
+ - ✅ `.gitignore` updated to exclude installation folder (optional)
1634
+ - ✅ Group documentation command available for database groups
1635
+ - ✅ Hierarchical file resolution working (group → parent → installation → global)
1636
+ - ✅ Frontend cloned and configured with installation details
1637
+ - ✅ Third-party docs cloned for offline AI context (optional)
1195
1638
  - ✅ Complete setup in < 5 minutes
1196
1639
 
1197
1640
  ---
@@ -1202,33 +1645,63 @@ main().catch((error) => {
1202
1645
 
1203
1646
  ```bash
1204
1647
  npx oneie sync
1205
- # Sync only changed files from upstream
1648
+ # Sync only changed files from upstream /one/ to local
1649
+ # Preserves installation folder customizations
1650
+ ```
1651
+
1652
+ ### Phase 3: Multi-Installation Support
1653
+
1654
+ ```bash
1655
+ npx oneie switch acme-staging
1656
+ # Switch between multiple installations in same project
1657
+ # Useful for dev/staging/prod environments
1206
1658
  ```
1207
1659
 
1208
- ### Phase 3: Multi-User Support
1660
+ ### Phase 4: Group Documentation Templates
1209
1661
 
1210
1662
  ```bash
1211
- npx oneie add-user
1212
- # Add additional users to existing organization
1663
+ npx oneie create-group-docs --template=engineering
1664
+ npx oneie create-group-docs --template=marketing
1665
+ # Pre-populated documentation templates for common group types
1213
1666
  ```
1214
1667
 
1215
- ### Phase 4: Template Selection
1668
+ ### Phase 5: Cloud Sync (KV/R2)
1216
1669
 
1217
1670
  ```bash
1218
- npx oneie create --template=creator-platform
1219
- npx oneie create --template=saas
1220
- npx oneie create --template=marketplace
1671
+ npx oneie sync --upload # Push installation docs to Cloudflare KV
1672
+ npx oneie sync --download # Pull from Cloudflare KV
1673
+ # Enable runtime doc updates without rebuilds
1221
1674
  ```
1222
1675
 
1223
1676
  ---
1224
1677
 
1225
1678
  ## Related Documentation
1226
1679
 
1680
+ - [Installation Folder Multi-Tenancy Plan](../plans/group-folder-multi-tenancy.md) - Complete architecture
1227
1681
  - [CLI Overview](../cli.md) - Complete CLI architecture
1228
1682
  - [Ontology](../../knowledge/ontology.md) - 6-dimension ontology
1229
1683
  - [People](../../people/people.md) - People & roles
1230
1684
  - [Groups](../../groups/groups.md) - Group structure (6 types, hierarchical)
1231
1685
  - [Agents](../agents/agent-director.md) - AI agent definitions
1686
+ - [File Resolution](../../knowledge/file-resolution.md) - Hierarchical file loading logic
1687
+
1688
+ ---
1689
+
1690
+ ## Key Differences from Legacy
1691
+
1692
+ **OLD (Pre-v2.0.0):**
1693
+ - Created `one/groups/{name}.md` immediately
1694
+ - No installation folder concept
1695
+ - No hierarchical group documentation
1696
+ - Groups were filesystem folders only
1697
+
1698
+ **NEW (v2.0.0+):**
1699
+ - Creates installation folder (e.g., `/acme/`) with 6-dimension structure
1700
+ - Groups are database entities with `groupId` and `parentGroupId`
1701
+ - Group documentation created AFTER groups exist in database
1702
+ - Hierarchical file resolution: group → parent → installation → global
1703
+ - Installation folder = organization-wide customization
1704
+ - Database groups = runtime data isolation
1232
1705
 
1233
1706
  ---
1234
1707