oneie 3.0.3 → 3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/file-resolver.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC;IAC5C,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,GAAG,GACjB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CA2EvB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,EAAE,CAAC,CAIzB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAaxB;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAmC;IAEhD;;;;;OAKG;IACG,OAAO,CACX,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC;IAaxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,OAAO,CAAC,WAAW;CAMpB"}
@@ -0,0 +1,196 @@
1
+ import fs from "fs/promises";
2
+ import path from "path";
3
+ /**
4
+ * Validates path for security (no .., no symlinks outside allowed dirs)
5
+ * @param filePath Path to validate
6
+ * @param basePath Base path for validation
7
+ * @returns True if valid, throws otherwise
8
+ */
9
+ export async function validateSecurePath(filePath, basePath) {
10
+ // Reject path traversal
11
+ if (filePath.includes("..")) {
12
+ throw new Error(`Path traversal not allowed: ${filePath}`);
13
+ }
14
+ // Resolve real path (follows symlinks)
15
+ let realPath;
16
+ try {
17
+ realPath = await fs.realpath(filePath);
18
+ }
19
+ catch (error) {
20
+ if (error.code === "ENOENT") {
21
+ // File doesn't exist yet - that's ok
22
+ realPath = path.resolve(filePath);
23
+ }
24
+ else {
25
+ throw error;
26
+ }
27
+ }
28
+ // Verify symlink stays within allowed directories
29
+ const resolvedBase = path.resolve(basePath);
30
+ const oneBase = path.resolve(basePath, "one");
31
+ const isWithinInstallation = realPath.startsWith(resolvedBase);
32
+ const isWithinOne = realPath.startsWith(oneBase);
33
+ if (!isWithinInstallation && !isWithinOne) {
34
+ throw new Error(`Symlink points outside allowed directories: ${realPath}`);
35
+ }
36
+ }
37
+ /**
38
+ * Checks if file exists
39
+ * @param filePath Path to check
40
+ * @returns True if exists, false otherwise
41
+ */
42
+ export async function fileExists(filePath) {
43
+ try {
44
+ await fs.access(filePath);
45
+ return true;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ /**
52
+ * Gets group path by walking up the hierarchy
53
+ * @param groupId Group ID
54
+ * @param convexClient Optional Convex client for database queries
55
+ * @returns Group path (e.g., "engineering/frontend")
56
+ *
57
+ * Note: This is a placeholder. In production, this should query Convex
58
+ * to get the actual group hierarchy from the database.
59
+ */
60
+ export async function getGroupPath(groupId, convexClient) {
61
+ // TODO: Implement actual Convex query when backend is ready
62
+ // For now, return the groupId as-is (flat structure)
63
+ //
64
+ // In production:
65
+ // const group = await convexClient.query("groups:get", { id: groupId });
66
+ // const segments = [group.slug];
67
+ // let currentParentId = group.parentGroupId;
68
+ // while (currentParentId) {
69
+ // const parent = await convexClient.query("groups:get", { id: currentParentId });
70
+ // segments.unshift(parent.slug);
71
+ // currentParentId = parent.parentGroupId;
72
+ // }
73
+ // return segments.join("/");
74
+ return groupId; // Fallback: flat structure
75
+ }
76
+ /**
77
+ * Resolves a file hierarchically across group → installation → global
78
+ * @param relativePath Relative path to file (e.g., "sprint-guide.md")
79
+ * @param options File resolution options
80
+ * @returns Resolved file with path and source
81
+ */
82
+ export async function resolveFile(relativePath, options) {
83
+ const { installationName, groupId, fallbackToGlobal = true, basePath = process.cwd(), } = options;
84
+ // Validate relative path
85
+ if (relativePath.includes("..")) {
86
+ throw new Error(`Path traversal not allowed: ${relativePath}`);
87
+ }
88
+ const resolvedBase = path.resolve(basePath);
89
+ // 1. If groupId provided, check group-specific paths (walk up hierarchy)
90
+ if (groupId) {
91
+ const groupPath = await getGroupPath(groupId);
92
+ const groupFile = path.join(resolvedBase, installationName, "groups", groupPath, relativePath);
93
+ if (await fileExists(groupFile)) {
94
+ await validateSecurePath(groupFile, resolvedBase);
95
+ return {
96
+ path: groupFile,
97
+ source: "group",
98
+ exists: true,
99
+ };
100
+ }
101
+ // TODO: Walk up parent groups when backend supports it
102
+ // For now, we only check the direct group path
103
+ }
104
+ // 2. Check installation root
105
+ const installationFile = path.join(resolvedBase, installationName, relativePath);
106
+ if (await fileExists(installationFile)) {
107
+ await validateSecurePath(installationFile, resolvedBase);
108
+ return {
109
+ path: installationFile,
110
+ source: "installation",
111
+ exists: true,
112
+ };
113
+ }
114
+ // 3. Check global /one/ (if fallbackToGlobal)
115
+ if (fallbackToGlobal) {
116
+ const globalFile = path.join(resolvedBase, "one", relativePath);
117
+ if (await fileExists(globalFile)) {
118
+ await validateSecurePath(globalFile, resolvedBase);
119
+ return {
120
+ path: globalFile,
121
+ source: "global",
122
+ exists: true,
123
+ };
124
+ }
125
+ }
126
+ // 4. Not found - return installation path as default (doesn't exist)
127
+ return {
128
+ path: installationFile,
129
+ source: "installation",
130
+ exists: false,
131
+ };
132
+ }
133
+ /**
134
+ * Resolves multiple files at once
135
+ * @param relativePaths Array of relative paths
136
+ * @param options File resolution options
137
+ * @returns Array of resolved files
138
+ */
139
+ export async function resolveFiles(relativePaths, options) {
140
+ return Promise.all(relativePaths.map((relativePath) => resolveFile(relativePath, options)));
141
+ }
142
+ /**
143
+ * Loads file content with hierarchical resolution
144
+ * @param relativePath Relative path to file
145
+ * @param options File resolution options
146
+ * @returns File content as string, or null if not found
147
+ */
148
+ export async function loadFile(relativePath, options) {
149
+ const resolved = await resolveFile(relativePath, options);
150
+ if (!resolved.exists) {
151
+ return null;
152
+ }
153
+ try {
154
+ return await fs.readFile(resolved.path, "utf-8");
155
+ }
156
+ catch (error) {
157
+ console.error(`Error reading file ${resolved.path}:`, error);
158
+ return null;
159
+ }
160
+ }
161
+ /**
162
+ * Cache for file resolution (optional performance optimization)
163
+ */
164
+ export class FileResolverCache {
165
+ constructor() {
166
+ this.cache = new Map();
167
+ }
168
+ /**
169
+ * Gets cached result or resolves file
170
+ * @param relativePath Relative path to file
171
+ * @param options File resolution options
172
+ * @returns Resolved file
173
+ */
174
+ async resolve(relativePath, options) {
175
+ const cacheKey = this.getCacheKey(relativePath, options);
176
+ if (this.cache.has(cacheKey)) {
177
+ return this.cache.get(cacheKey);
178
+ }
179
+ const resolved = await resolveFile(relativePath, options);
180
+ this.cache.set(cacheKey, resolved);
181
+ return resolved;
182
+ }
183
+ /**
184
+ * Clears cache
185
+ */
186
+ clear() {
187
+ this.cache.clear();
188
+ }
189
+ /**
190
+ * Generates cache key
191
+ */
192
+ getCacheKey(relativePath, options) {
193
+ return `${options.installationName}:${options.groupId || "root"}:${relativePath}`;
194
+ }
195
+ }
196
+ //# sourceMappingURL=file-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-resolver.js","sourceRoot":"","sources":["../../src/utils/file-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAqBxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,QAAgB;IAEhB,wBAAwB;IACxB,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,uCAAuC;IACvC,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,qCAAqC;YACrC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,kDAAkD;IAClD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE9C,MAAM,oBAAoB,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC/D,MAAM,WAA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AAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEnC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACK,WAAW,CACjB,YAAoB,EACpB,OAA4B;QAE5B,OAAO,GAAG,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,OAAO,IAAI,MAAM,IAAI,YAAY,EAAE,CAAC;IACpF,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Validates installation name (lowercase, hyphens only)
3
+ * @param name Installation identifier
4
+ * @returns True if valid, false otherwise
5
+ */
6
+ export declare function validateInstallationName(name: string): boolean;
7
+ /**
8
+ * Validates path for security (no .., no absolute paths outside allowed dirs)
9
+ * @param filePath Path to validate
10
+ * @returns True if safe, false otherwise
11
+ */
12
+ export declare function validatePath(filePath: string): boolean;
13
+ /**
14
+ * Creates the installation folder structure
15
+ * @param installationName Installation identifier (e.g., "acme")
16
+ * @param basePath Optional base path (defaults to cwd)
17
+ * @returns Path to created installation folder
18
+ */
19
+ export declare function createInstallationFolder(installationName: string, basePath?: string): Promise<string>;
20
+ /**
21
+ * Mirrors the ontology structure (6 dimensions) in installation folder
22
+ * @param installationPath Path to installation folder
23
+ */
24
+ export declare function mirrorOntologyStructure(installationPath: string): Promise<void>;
25
+ /**
26
+ * Creates README.md in installation folder
27
+ * @param installationPath Path to installation folder
28
+ * @param organizationName Display name of organization
29
+ * @param installationIdentifier Installation identifier (slug)
30
+ */
31
+ export declare function createReadme(installationPath: string, organizationName: string, installationIdentifier: string): Promise<void>;
32
+ /**
33
+ * Updates .env.local with INSTALLATION_NAME
34
+ * @param installationName Installation identifier
35
+ * @param basePath Optional base path (defaults to cwd)
36
+ */
37
+ export declare function updateEnvFile(installationName: string, basePath?: string): Promise<void>;
38
+ /**
39
+ * Updates .gitignore to optionally exclude installation folder
40
+ * @param installationName Installation identifier
41
+ * @param exclude Whether to exclude the folder from git
42
+ * @param basePath Optional base path (defaults to cwd)
43
+ */
44
+ export declare function updateGitignore(installationName: string, exclude: boolean, basePath?: string): Promise<void>;
45
+ /**
46
+ * Rollback installation folder creation on failure
47
+ * @param installationPath Path to installation folder
48
+ */
49
+ export declare function rollbackInstallation(installationPath: string): Promise<void>;
50
+ //# sourceMappingURL=installation-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation-setup.d.ts","sourceRoot":"","sources":["../../src/utils/installation-setup.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAYtD;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,gBAAgB,EAAE,MAAM,EACxB,QAAQ,GAAE,MAAsB,GAC/B,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,EACxB,sBAAsB,EAAE,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,MAAM,EACxB,QAAQ,GAAE,MAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,GAAE,MAAsB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAOf"}
@@ -0,0 +1,253 @@
1
+ import fs from "fs/promises";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ /**
7
+ * Validates installation name (lowercase, hyphens only)
8
+ * @param name Installation identifier
9
+ * @returns True if valid, false otherwise
10
+ */
11
+ export function validateInstallationName(name) {
12
+ const pattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
13
+ return pattern.test(name);
14
+ }
15
+ /**
16
+ * Validates path for security (no .., no absolute paths outside allowed dirs)
17
+ * @param filePath Path to validate
18
+ * @returns True if safe, false otherwise
19
+ */
20
+ export function validatePath(filePath) {
21
+ // Reject path traversal attempts
22
+ if (filePath.includes("..")) {
23
+ return false;
24
+ }
25
+ // Reject absolute paths (we want relative paths only)
26
+ if (path.isAbsolute(filePath)) {
27
+ return false;
28
+ }
29
+ return true;
30
+ }
31
+ /**
32
+ * Creates the installation folder structure
33
+ * @param installationName Installation identifier (e.g., "acme")
34
+ * @param basePath Optional base path (defaults to cwd)
35
+ * @returns Path to created installation folder
36
+ */
37
+ export async function createInstallationFolder(installationName, basePath = process.cwd()) {
38
+ // Validate installation name
39
+ if (!validateInstallationName(installationName)) {
40
+ throw new Error(`Invalid installation name: "${installationName}". ` +
41
+ "Must be lowercase letters, numbers, and hyphens only.");
42
+ }
43
+ // Resolve installation path
44
+ const installationPath = path.resolve(basePath, installationName);
45
+ // Check if installation folder already exists
46
+ try {
47
+ await fs.access(installationPath);
48
+ throw new Error(`Installation folder already exists: ${installationPath}`);
49
+ }
50
+ catch (error) {
51
+ // Good - folder doesn't exist, we can create it
52
+ if (error.code !== "ENOENT") {
53
+ throw error;
54
+ }
55
+ }
56
+ // Create installation folder
57
+ await fs.mkdir(installationPath, { recursive: true });
58
+ return installationPath;
59
+ }
60
+ /**
61
+ * Mirrors the ontology structure (6 dimensions) in installation folder
62
+ * @param installationPath Path to installation folder
63
+ */
64
+ export async function mirrorOntologyStructure(installationPath) {
65
+ const ontologyDirs = [
66
+ "groups",
67
+ "people",
68
+ "things",
69
+ "connections",
70
+ "events",
71
+ "knowledge",
72
+ ];
73
+ for (const dir of ontologyDirs) {
74
+ const dirPath = path.join(installationPath, dir);
75
+ await fs.mkdir(dirPath, { recursive: true });
76
+ }
77
+ }
78
+ /**
79
+ * Creates README.md in installation folder
80
+ * @param installationPath Path to installation folder
81
+ * @param organizationName Display name of organization
82
+ * @param installationIdentifier Installation identifier (slug)
83
+ */
84
+ export async function createReadme(installationPath, organizationName, installationIdentifier) {
85
+ // Read template
86
+ const templatePath = path.resolve(__dirname, "../../templates/installation-readme.md");
87
+ let template;
88
+ try {
89
+ template = await fs.readFile(templatePath, "utf-8");
90
+ }
91
+ catch (error) {
92
+ // Fallback to inline template if file doesn't exist
93
+ template = getDefaultReadmeTemplate();
94
+ }
95
+ // Replace placeholders
96
+ const content = template
97
+ .replace(/\{\{organizationName\}\}/g, organizationName)
98
+ .replace(/\{\{installationIdentifier\}\}/g, installationIdentifier)
99
+ .replace(/\{\{date\}\}/g, new Date().toISOString().split("T")[0]);
100
+ // Write README
101
+ const readmePath = path.join(installationPath, "README.md");
102
+ await fs.writeFile(readmePath, content, "utf-8");
103
+ }
104
+ /**
105
+ * Updates .env.local with INSTALLATION_NAME
106
+ * @param installationName Installation identifier
107
+ * @param basePath Optional base path (defaults to cwd)
108
+ */
109
+ export async function updateEnvFile(installationName, basePath = process.cwd()) {
110
+ const envPath = path.join(basePath, ".env.local");
111
+ let envContent = "";
112
+ try {
113
+ envContent = await fs.readFile(envPath, "utf-8");
114
+ }
115
+ catch (error) {
116
+ if (error.code !== "ENOENT") {
117
+ throw error;
118
+ }
119
+ // File doesn't exist, start with empty content
120
+ }
121
+ // Check if INSTALLATION_NAME already exists
122
+ const installationNamePattern = /^INSTALLATION_NAME=.*$/m;
123
+ if (installationNamePattern.test(envContent)) {
124
+ // Replace existing value
125
+ envContent = envContent.replace(installationNamePattern, `INSTALLATION_NAME=${installationName}`);
126
+ }
127
+ else {
128
+ // Append new value
129
+ if (envContent && !envContent.endsWith("\n")) {
130
+ envContent += "\n";
131
+ }
132
+ envContent += `\n# Installation Configuration\nINSTALLATION_NAME=${installationName}\n`;
133
+ }
134
+ await fs.writeFile(envPath, envContent, "utf-8");
135
+ }
136
+ /**
137
+ * Updates .gitignore to optionally exclude installation folder
138
+ * @param installationName Installation identifier
139
+ * @param exclude Whether to exclude the folder from git
140
+ * @param basePath Optional base path (defaults to cwd)
141
+ */
142
+ export async function updateGitignore(installationName, exclude, basePath = process.cwd()) {
143
+ if (!exclude) {
144
+ return;
145
+ }
146
+ const gitignorePath = path.join(basePath, ".gitignore");
147
+ let gitignoreContent = "";
148
+ try {
149
+ gitignoreContent = await fs.readFile(gitignorePath, "utf-8");
150
+ }
151
+ catch (error) {
152
+ if (error.code !== "ENOENT") {
153
+ throw error;
154
+ }
155
+ // File doesn't exist, start with empty content
156
+ }
157
+ const ignorePattern = `/${installationName}/`;
158
+ // Check if pattern already exists
159
+ if (gitignoreContent.includes(ignorePattern)) {
160
+ return;
161
+ }
162
+ // Append ignore pattern
163
+ if (gitignoreContent && !gitignoreContent.endsWith("\n")) {
164
+ gitignoreContent += "\n";
165
+ }
166
+ gitignoreContent += `\n# Installation folder (private docs)\n${ignorePattern}\n`;
167
+ await fs.writeFile(gitignorePath, gitignoreContent, "utf-8");
168
+ }
169
+ /**
170
+ * Rollback installation folder creation on failure
171
+ * @param installationPath Path to installation folder
172
+ */
173
+ export async function rollbackInstallation(installationPath) {
174
+ try {
175
+ await fs.rm(installationPath, { recursive: true, force: true });
176
+ }
177
+ catch (error) {
178
+ // Ignore errors during rollback
179
+ console.error(`Warning: Failed to rollback ${installationPath}:`, error);
180
+ }
181
+ }
182
+ /**
183
+ * Default README template (inline fallback)
184
+ */
185
+ function getDefaultReadmeTemplate() {
186
+ return `# {{organizationName}} Installation
187
+
188
+ **Installation Identifier:** \`{{installationIdentifier}}\`
189
+ **Created:** {{date}}
190
+
191
+ ## Overview
192
+
193
+ This installation folder contains your organization-specific documentation and configuration that overrides the global ONE platform templates.
194
+
195
+ ## Folder Structure
196
+
197
+ - \`groups/\` - Group-specific documentation (supports hierarchical nesting)
198
+ - \`people/\` - Role and governance documentation
199
+ - \`things/\` - Entity and specification documentation
200
+ - \`connections/\` - Relationship and workflow documentation
201
+ - \`events/\` - Event and deployment documentation
202
+ - \`knowledge/\` - AI training data and RAG content
203
+
204
+ ## File Resolution Priority
205
+
206
+ Files in this installation folder take priority over global \`/one/\` templates:
207
+
208
+ 1. Most specific group path (e.g., \`groups/engineering/frontend/sprint-guide.md\`)
209
+ 2. Parent group paths (walk up hierarchy)
210
+ 3. Installation root (e.g., \`things/vision.md\`)
211
+ 4. Global fallback (e.g., \`/one/things/vision.md\`)
212
+
213
+ ## Usage
214
+
215
+ ### Add Group-Specific Documentation
216
+
217
+ \`\`\`bash
218
+ # Create group folder
219
+ mkdir -p groups/engineering
220
+
221
+ # Add documentation
222
+ echo "# Engineering Practices" > groups/engineering/practices.md
223
+ \`\`\`
224
+
225
+ ### Add Installation-Wide Documentation
226
+
227
+ \`\`\`bash
228
+ # Override global vision
229
+ echo "# Our Vision" > things/vision.md
230
+ \`\`\`
231
+
232
+ ## Environment Variables
233
+
234
+ This installation is configured in \`.env.local\`:
235
+
236
+ \`\`\`
237
+ INSTALLATION_NAME={{installationIdentifier}}
238
+ \`\`\`
239
+
240
+ ## Security
241
+
242
+ - Never commit secrets or credentials to this folder
243
+ - Use \`.env.local\` for sensitive configuration
244
+ - This folder is for **documentation and configuration only**
245
+
246
+ ## Learn More
247
+
248
+ - Platform Documentation: \`/one/\`
249
+ - 6-Dimension Ontology: \`/one/knowledge/ontology.md\`
250
+ - Development Workflow: \`/one/connections/workflow.md\`
251
+ `;
252
+ }
253
+ //# sourceMappingURL=installation-setup.js.map
@@ -0,0 +1 @@
1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AED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,gBAAwB;IAExB,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gCAAgC;QAChC,OAAO,CAAC,KAAK,CAAC,+BAA+B,gBAAgB,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB;IAC/B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiER,CAAC;AACF,CAAC"}
package/folders.yaml CHANGED
@@ -87,6 +87,6 @@ exclude_patterns:
87
87
  deployment:
88
88
  github_repo: one-ie/one
89
89
  npm_package: oneie
90
- version: 3.0.3
90
+ version: 3.3.0
91
91
  homepage: https://one.ie
92
92
  license_url: https://one.ie/free-license
@@ -171,6 +171,20 @@
171
171
  },
172
172
  "active": "613025f84d05f0e8",
173
173
  "lastOpenFiles": [
174
+ "events/installation-folders-workflow-integration.md",
175
+ "events/deployment-verification.md",
176
+ "events/deployment-ops-summary.md",
177
+ "knowledge/installation-folders.md",
178
+ "knowledge/installation-folders.md.tmp.37200.1760601921359",
179
+ "events/deployment-installation-folders.md",
180
+ "things/legal/README.md",
181
+ "events/legal-assessment-2025-10-16.md",
182
+ "things/legal/terms-of-service.md",
183
+ "things/legal/privacy-policy.md",
184
+ "things/legal",
185
+ "things/agents/agent-lawyer.md",
186
+ "things/plans/group-folder-multi-tenancy.md",
187
+ "knowledge/typescript-patterns.md",
174
188
  "things/interface.md",
175
189
  "things/vision/interface.md",
176
190
  "things/plans/5-build-frontend.md",
@@ -186,26 +200,12 @@
186
200
  "events/2024-10-15-release-command-complete.md",
187
201
  "events/2024-10-15-package-manager-tests.md",
188
202
  "events/2024-10-15-handoff-to-clean.md",
189
- "events/2024-10-15-agent-clean-v2-summary.md",
190
- "events/2024-10-14-release-v2.0.6.md",
191
- "events/2024-10-14-deployment-success.md",
192
- "events/CLEANUP-RELEASE-V2.0.8.md",
193
- "events/2024-10-14-deployment-plan.md",
194
- "README.md",
195
- "readme.md",
196
- "knowledge/metadata-system.md",
197
- "things/vision/elegant-interface.md",
198
203
  "things/vision",
199
- "things/tests/2-1-test-analysis.md",
200
- "things/tests/2-1-dataprovider-interface.md",
201
204
  "things/tests",
202
- "things/system.md",
203
205
  "things/features/dataprovider-interface",
204
206
  "things/cli",
205
207
  "things/cascade/docs/examples/1-6-numbering-structure",
206
208
  "things/cascade/docs/examples/1-5-quality-loops",
207
- "things/cascade/docs/examples/1-4-knowledge-management",
208
- "things/cascade/docs/examples/1-3-event-coordination",
209
- "things/cascade/docs/examples/1-2-yaml-orchestrator"
209
+ "things/cascade/docs/examples/1-4-knowledge-management"
210
210
  ]
211
211
  }