everything-dev 1.50.0 → 1.51.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.
@@ -74,7 +74,10 @@ function parseCommandInput(descriptor, argv) {
74
74
  }
75
75
  const next = inline ?? argv[i + 1];
76
76
  if (isArraySchema(fieldSchema)) {
77
- if (next === void 0 || next.startsWith("--")) throw new Error(`Missing value for ${flag}`);
77
+ if (next === void 0 || next.startsWith("--")) {
78
+ input[fieldName] = [];
79
+ continue;
80
+ }
78
81
  input[fieldName] = next.split(",").map((s) => s.trim()).filter(Boolean);
79
82
  if (!inline) i += 1;
80
83
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.cjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction isArraySchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"array\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n\n if (!fieldName && flag.startsWith(\"--no-\")) {\n const positiveFlagName = `--${flag.slice(5)}`;\n const positiveFieldName = fieldByFlag.get(positiveFlagName);\n if (!positiveFieldName) throw new Error(`Unknown flag: ${token}`);\n input[positiveFieldName] = false;\n continue;\n }\n\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n\n if (isArraySchema(fieldSchema)) {\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = next\n .split(\",\")\n .map((s: string) => s.trim())\n .filter(Boolean);\n if (!inline) i += 1;\n continue;\n }\n\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema] = candidate;\n input[fieldName] = coerceValue(positionals[0], fieldSchema);\n }\n }\n\n return schema.parse(input);\n}\n"],"mappings":";;AAYA,SAAS,OAAO,QAAgC;CAC9C,IAAI,UAAU;AACd,QAAO,MAAM;EACX,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,aAAa,SAAS,cAAc,SAAS,cAAc,SAAS,WAAW;GAC1F,MAAM,QAAQ,QAAQ,MAAM;AAC5B,OAAI,CAAC,MAAO;AACZ,aAAU;AACV;;AAEF,SAAO;;AAET,QAAO;;AAGT,SAAS,gBAAgB,QAA6B;AACpD,QAAO,OAAO,OAAO,CAAC,MAAM,SAAS;;AAGvC,SAAS,cAAc,QAA6B;AAClD,QAAO,OAAO,OAAO,CAAC,MAAM,SAAS;;AAGvC,SAAS,YAAY,KAAa,QAA6B;AAE7D,SADc,OAAO,OACR,CAAC,MAAM,MAApB;EACE,KAAK,UACH,QAAO,QAAQ,UAAU,QAAQ,OAAO,QAAQ;EAClD,KAAK,UAAU;GACb,MAAM,QAAQ,OAAO,IAAI;AACzB,OAAI,OAAO,MAAM,MAAM,CAAE,OAAM,IAAI,MAAM,mBAAmB,MAAM;AAClE,UAAO;;EAET,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;AAIb,SAAS,WAAW,OAAuB;AACzC,QAAO,KAAK,MAAM,QAAQ,sBAAsB,QAAQ,CAAC,aAAa;;AAGxE,SAAS,SAAS,QAAgD;CAEhE,MAAM,QADQ,OAAO,OACF,CAAC,MAAM;AAC1B,KAAI,CAAC,MAAO,QAAO,EAAE;AACrB,QAAO;;AAGT,SAAgB,kBAAkB,YAA+B,M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,IAAI,CACV,KAAK,MAAc,EAAE,MAAM,CAAC,CAC5B,OAAO,QAAQ;AAClB,QAAI,CAAC,OAAQ,MAAK;AAClB;;AAGF,OAAI,SAAS,UAAa,KAAK,WAAW,KAAK,CAC7C,OAAM,IAAI,MAAM,qBAAqB,OAAO;AAE9C,SAAM,aAAa,YAAY,MAAM,YAAY;AACjD,OAAI,CAAC,OAAQ,MAAK;AAClB;;AAGF,cAAY,KAAK,MAAM;;AAGzB,KAAI,iBAAiB,SAAS,EAC5B,kBAAiB,SAAS,WAAW,UAAU;EAC7C,MAAM,MAAM,YAAY;AACxB,MAAI,QAAQ,OACV,OAAM,aAAa,YAAY,KAAK,MAAM,WAAW;GAEvD;UACO,YAAY,SAAS,GAAG;EACjC,MAAM,YAAY,OAAO,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,YAAY,CAAC;AACjF,MAAI,WAAW;GACb,MAAM,CAAC,WAAW,eAAe;AACjC,SAAM,aAAa,YAAY,YAAY,IAAI,YAAY;;;AAI/D,QAAO,OAAO,MAAM,MAAM"}
1
+ {"version":3,"file":"parse.cjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction isArraySchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"array\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n\n if (!fieldName && flag.startsWith(\"--no-\")) {\n const positiveFlagName = `--${flag.slice(5)}`;\n const positiveFieldName = fieldByFlag.get(positiveFlagName);\n if (!positiveFieldName) throw new Error(`Unknown flag: ${token}`);\n input[positiveFieldName] = false;\n continue;\n }\n\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n\n if (isArraySchema(fieldSchema)) {\n if (next === undefined || next.startsWith(\"--\")) {\n input[fieldName] = [];\n continue;\n }\n input[fieldName] = next\n .split(\",\")\n .map((s: string) => s.trim())\n .filter(Boolean);\n if (!inline) i += 1;\n continue;\n }\n\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema] = candidate;\n input[fieldName] = coerceValue(positionals[0], fieldSchema);\n }\n }\n\n return schema.parse(input);\n}\n"],"mappings":";;AAYA,SAAS,OAAO,QAAgC;CAC9C,IAAI,UAAU;AACd,QAAO,MAAM;EACX,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,aAAa,SAAS,cAAc,SAAS,cAAc,SAAS,WAAW;GAC1F,MAAM,QAAQ,QAAQ,MAAM;AAC5B,OAAI,CAAC,MAAO;AACZ,aAAU;AACV;;AAEF,SAAO;;AAET,QAAO;;AAGT,SAAS,gBAAgB,QAA6B;AACpD,QAAO,OAAO,OAAO,CAAC,MAAM,SAAS;;AAGvC,SAAS,cAAc,QAA6B;AAClD,QAAO,OAAO,OAAO,CAAC,MAAM,SAAS;;AAGvC,SAAS,YAAY,KAAa,QAA6B;AAE7D,SADc,OAAO,OACR,CAAC,MAAM,MAApB;EACE,KAAK,UACH,QAAO,QAAQ,UAAU,QAAQ,OAAO,QAAQ;EAClD,KAAK,UAAU;GACb,MAAM,QAAQ,OAAO,IAAI;AACzB,OAAI,OAAO,MAAM,MAAM,CAAE,OAAM,IAAI,MAAM,mBAAmB,MAAM;AAClE,UAAO;;EAET,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;AA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UAAM,aAAa,SAAS,YAAY,QAAQ,YAAY,GAAG;AAC/D;;GAGF,MAAM,OAAO,UAAU,KAAK,IAAI;AAEhC,OAAI,cAAc,YAAY,EAAE;AAC9B,QAAI,SAAS,UAAa,KAAK,WAAW,KAAK,EAAE;AAC/C,WAAM,aAAa,EAAE;AACrB;;AAEF,UAAM,aAAa,KAChB,MAAM,IAAI,CACV,KAAK,MAAc,EAAE,MAAM,CAAC,CAC5B,OAAO,QAAQ;AAClB,QAAI,CAAC,OAAQ,MAAK;AAClB;;AAGF,OAAI,SAAS,UAAa,KAAK,WAAW,KAAK,CAC7C,OAAM,IAAI,MAAM,qBAAqB,OAAO;AAE9C,SAAM,aAAa,YAAY,MAAM,YAAY;AACjD,OAAI,CAAC,OAAQ,MAAK;AAClB;;AAGF,cAAY,KAAK,MAAM;;AAGzB,KAAI,iBAAiB,SAAS,EAC5B,kBAAiB,SAAS,WAAW,UAAU;EAC7C,MAAM,MAAM,YAAY;AACxB,MAAI,QAAQ,OACV,OAAM,aAAa,YAAY,KAAK,MAAM,WAAW;GAEvD;UACO,YAAY,SAAS,GAAG;EACjC,MAAM,YAAY,OAAO,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,YAAY,CAAC;AACjF,MAAI,WAAW;GACb,MAAM,CAAC,WAAW,eAAe;AACjC,SAAM,aAAa,YAAY,YAAY,IAAI,YAAY;;;AAI/D,QAAO,OAAO,MAAM,MAAM"}
@@ -73,7 +73,10 @@ function parseCommandInput(descriptor, argv) {
73
73
  }
74
74
  const next = inline ?? argv[i + 1];
75
75
  if (isArraySchema(fieldSchema)) {
76
- if (next === void 0 || next.startsWith("--")) throw new Error(`Missing value for ${flag}`);
76
+ if (next === void 0 || next.startsWith("--")) {
77
+ input[fieldName] = [];
78
+ continue;
79
+ }
77
80
  input[fieldName] = next.split(",").map((s) => s.trim()).filter(Boolean);
78
81
  if (!inline) i += 1;
79
82
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.mjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction isArraySchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"array\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n\n if (!fieldName && flag.startsWith(\"--no-\")) {\n const positiveFlagName = `--${flag.slice(5)}`;\n const positiveFieldName = fieldByFlag.get(positiveFlagName);\n if (!positiveFieldName) throw new Error(`Unknown flag: ${token}`);\n input[positiveFieldName] = false;\n continue;\n }\n\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n\n if (isArraySchema(fieldSchema)) {\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = next\n .split(\",\")\n .map((s: string) => s.trim())\n .filter(Boolean);\n if (!inline) i += 1;\n continue;\n }\n\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema] = candidate;\n input[fieldName] = coerceValue(positionals[0], fieldSchema);\n }\n }\n\n return schema.parse(input);\n}\n"],"mappings":";AAYA,SAAS,OAAO,QAAgC;CAC9C,IAAI,UAAU;AACd,QAAO,MAAM;EACX,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,aAAa,SAAS,cAAc,SAAS,cAAc,SAAS,WAA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,GAAG;EACjC,MAAM,YAAY,OAAO,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,YAAY,CAAC;AACjF,MAAI,WAAW;GACb,MAAM,CAAC,WAAW,eAAe;AACjC,SAAM,aAAa,YAAY,YAAY,IAAI,YAAY;;;AAI/D,QAAO,OAAO,MAAM,MAAM"}
1
+ {"version":3,"file":"parse.mjs","names":[],"sources":["../../src/cli/parse.ts"],"sourcesContent":["import type { CommandDescriptor } from \"./catalog\";\n\ntype SchemaLike = {\n _def?: {\n type?: string;\n innerType?: SchemaLike;\n shape?: Record<string, SchemaLike>;\n values?: Record<string, string> | string[];\n };\n parse: (value: unknown) => unknown;\n};\n\nfunction unwrap(schema: SchemaLike): SchemaLike {\n let current = schema;\n while (true) {\n const type = current._def?.type;\n if (type === \"default\" || type === \"optional\" || type === \"nullable\" || type === \"nullish\") {\n const inner = current._def?.innerType;\n if (!inner) break;\n current = inner;\n continue;\n }\n return current;\n }\n return current;\n}\n\nfunction isBooleanSchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"boolean\";\n}\n\nfunction isArraySchema(schema: SchemaLike): boolean {\n return unwrap(schema)._def?.type === \"array\";\n}\n\nfunction coerceValue(raw: string, schema: SchemaLike): unknown {\n const inner = unwrap(schema);\n switch (inner._def?.type) {\n case \"boolean\":\n return raw === \"true\" || raw === \"1\" || raw === \"yes\";\n case \"number\": {\n const value = Number(raw);\n if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);\n return value;\n }\n case \"enum\":\n return raw;\n default:\n return raw;\n }\n}\n\nfunction toFlagName(field: string): string {\n return `--${field.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase()}`;\n}\n\nfunction getShape(schema: SchemaLike): Record<string, SchemaLike> {\n const inner = unwrap(schema);\n const shape = inner._def?.shape;\n if (!shape) return {};\n return shape;\n}\n\nexport function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {\n const schema = (descriptor.procedure as any)[\"~orpc\"]?.inputSchema as SchemaLike | undefined;\n if (!schema) return {};\n\n const shape = getShape(schema);\n const fields = Object.entries(shape);\n const fieldByFlag = new Map<string, string>();\n const positionalFields: string[] = [];\n\n for (const [fieldName] of fields) {\n fieldByFlag.set(toFlagName(fieldName), fieldName);\n if (descriptor.meta.fields?.[fieldName]?.positional) {\n positionalFields.push(fieldName);\n }\n }\n\n const input: Record<string, unknown> = {};\n const positionals: string[] = [];\n\n for (let i = 0; i < argv.length; i += 1) {\n const token = argv[i];\n if (!token) continue;\n\n if (token.startsWith(\"--\")) {\n const [flag, inline] = token.split(\"=\", 2);\n const fieldName = fieldByFlag.get(flag);\n\n if (!fieldName && flag.startsWith(\"--no-\")) {\n const positiveFlagName = `--${flag.slice(5)}`;\n const positiveFieldName = fieldByFlag.get(positiveFlagName);\n if (!positiveFieldName) throw new Error(`Unknown flag: ${token}`);\n input[positiveFieldName] = false;\n continue;\n }\n\n if (!fieldName) throw new Error(`Unknown flag: ${token}`);\n\n const fieldSchema = shape[fieldName];\n if (isBooleanSchema(fieldSchema)) {\n input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;\n continue;\n }\n\n const next = inline ?? argv[i + 1];\n\n if (isArraySchema(fieldSchema)) {\n if (next === undefined || next.startsWith(\"--\")) {\n input[fieldName] = [];\n continue;\n }\n input[fieldName] = next\n .split(\",\")\n .map((s: string) => s.trim())\n .filter(Boolean);\n if (!inline) i += 1;\n continue;\n }\n\n if (next === undefined || next.startsWith(\"--\")) {\n throw new Error(`Missing value for ${flag}`);\n }\n input[fieldName] = coerceValue(next, fieldSchema);\n if (!inline) i += 1;\n continue;\n }\n\n positionals.push(token);\n }\n\n if (positionalFields.length > 0) {\n positionalFields.forEach((fieldName, index) => {\n const raw = positionals[index];\n if (raw !== undefined) {\n input[fieldName] = coerceValue(raw, shape[fieldName]);\n }\n });\n } else if (positionals.length > 0) {\n const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));\n if (candidate) {\n const [fieldName, fieldSchema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,OAAI,CAAC,OAAQ,MAAK;AAClB;;AAGF,cAAY,KAAK,MAAM;;AAGzB,KAAI,iBAAiB,SAAS,EAC5B,kBAAiB,SAAS,WAAW,UAAU;EAC7C,MAAM,MAAM,YAAY;AACxB,MAAI,QAAQ,OACV,OAAM,aAAa,YAAY,KAAK,MAAM,WAAW;GAEvD;UACO,YAAY,SAAS,GAAG;EACjC,MAAM,YAAY,OAAO,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,YAAY,CAAC;AACjF,MAAI,WAAW;GACb,MAAM,CAAC,WAAW,eAAe;AACjC,SAAM,aAAa,YAAY,YAAY,IAAI,YAAY;;;AAI/D,QAAO,OAAO,MAAM,MAAM"}
package/dist/cli/sync.cjs CHANGED
@@ -297,6 +297,14 @@ async function syncTemplate(projectDir, options) {
297
297
  if (!(0, node_fs.existsSync)((0, node_path.join)(sourceDir, sourceFile))) continue;
298
298
  destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);
299
299
  }
300
+ for (const pluginKey of childPlugins) {
301
+ if (!(0, node_fs.existsSync)((0, node_path.join)(projectDir, "plugins", pluginKey))) continue;
302
+ for (const tsconfigFile of ["tsconfig.json", "tsconfig.contract.json"]) {
303
+ const sourceFile = `plugins/_template/${tsconfigFile}`;
304
+ if (!(0, node_fs.existsSync)((0, node_path.join)(sourceDir, sourceFile))) continue;
305
+ destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);
306
+ }
307
+ }
300
308
  const updated = [];
301
309
  const skipped = [];
302
310
  const added = [];
@@ -1 +1 @@
1
- {"version":3,"file":"sync.cjs","names":["mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","extractSkillsBlock","buildChildAgentsMd","personalizeConfig","syncResolvedSharedDeps","loadResolvedConfig","writeSnapshot","runBunInstall","runTypesGen"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,6BAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA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,SAAMC,6BAAY,WAAW;;AAG/B,SAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;WACO;AACR,QAAM,SAAS"}
1
+ {"version":3,"file":"sync.cjs","names":["mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","extractSkillsBlock","buildChildAgentsMd","personalizeConfig","syncResolvedSharedDeps","loadResolvedConfig","writeSnapshot","runBunInstall","runTypesGen"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,6BAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAIF,SAAS,YAAY,SAAsC;AACzD,oCAAkB,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,UAAU,GAAG,GAAG;;AAe5E,SAAS,iBAAiB,YAAoB,UAAiC;CAC7E,MAAM,+BAAgB,YAAY,SAAS;AAC3C,KAAI,yBAAY,SAAS,CAAE,QAAO;AAClC,KAAI;AAEF,SAAO,sCADsB,SACH,CAAC;SACrB;AACN,SAAO;;;AAIX,SAAS,YAAY,YAAoB,WAAoC;CAC3E,MAAM,gBAAgB,UAAU,QAAQ,kDAAsB,YAAY,EAAE,CAA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a,IAAI,SAAS,IAAI,UACE,SAAS;;AAIhE,QAAMC,mCAAkB,YAAY;GAClC;GACA;GACA;GACA;GACA;GACA,SAAS;GACT,eAAe,EAAE,WAAW;GAC5B,MAAM;GACN,gBAAgB;GACjB,CAAC;AAEF,QAAMC,2CAAuB;GAC3B,WAAW;GACX,UAAU;GACX,CAAC;EAEF,MAAM,eAAe,MAAMC,kCAAmB,EAAE,KAAK,YAAY,CAAC;AAClE,MAAI,cAAc,QAChB,mCAAoB,YAAY,aAAa,QAAQ;EAGvD,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,YAAY,aAAa,MAAM,EAAE;GAC1C,MAAM,OAAO,iBAAiB,YAAY,SAAS;AACnD,OAAI,KACF,kBAAiB,YAAY;;EAIjC,MAAM,qBAAqB,aAAa,WAAW,YAAY;AAC/D,MAAI,oBAAoB;GAEtB,MAAM,cAAcJ,kFAD4B,WAAW,mBAAmB,EAAE,QACpB,CAAC;AAC7D,OAAI,aAAa;IACf,MAAM,kBAAkBC,oCAAmB,aAAa;KACtD;KACA,SAAS;KACV,CAAC;IACF,MAAM,eAAe,YAAY,gBAAgB;AAGjD,QAD0B,iBAAiB,YAAY,YAClC,KAAK,cAAc;AACtC,oDAAmB,YAAY,YAAY,EAAE,gBAAgB;AAC7D,aAAQ,KAAK,YAAY;;AAG3B,qBAAiB,eAAe;;;AAIpC,QAAMI,+BAAc,YAAY;GAC9B,WAAW,SAAS,eAAe,GAAG;GACtC,OAAO;GACR,CAAC;AAEF,MAAI,CAAC,QAAQ,WAAW;AACtB,SAAMC,+BAAc,WAAW;AAC/B,SAAMC,6BAAY,WAAW;;AAG/B,SAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;WACO;AACR,QAAM,SAAS"}
package/dist/cli/sync.mjs CHANGED
@@ -296,6 +296,14 @@ async function syncTemplate(projectDir, options) {
296
296
  if (!existsSync(join(sourceDir, sourceFile))) continue;
297
297
  destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);
298
298
  }
299
+ for (const pluginKey of childPlugins) {
300
+ if (!existsSync(join(projectDir, "plugins", pluginKey))) continue;
301
+ for (const tsconfigFile of ["tsconfig.json", "tsconfig.contract.json"]) {
302
+ const sourceFile = `plugins/_template/${tsconfigFile}`;
303
+ if (!existsSync(join(sourceDir, sourceFile))) continue;
304
+ destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);
305
+ }
306
+ }
299
307
  const updated = [];
300
308
  const skipped = [];
301
309
  const added = [];
@@ -1 +1 @@
1
- {"version":3,"file":"sync.mjs","names":["isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,6BAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAIF,SAAS,YAAY,SAAsC;AACzD,QAAO,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,UAAU,GAAG,GAAG;;AAa5E,SAAS,iBAAiB,YAAoB,UAAiC;CAC7E,MAAM,WAAW,KAAK,YAAY,SAAS;AAC3C,KAAI,CAAC,WAAW,SAAS,CAAE,QAAO;AAClC,KAAI;AAEF,SAAO,YADS,aAAa,SACH,CAAC;SACrB;AACN,SAAO;;;AAIX,SAAS,YAAY,YAAoB,WAAoC;CAC3E,MAAM,gBAAgB,UAAU,QAAQ,MAAM,WAAW,KAAK,YAAY,EAAE,CAAC,CAAC;AAC9E,KAAI,cAAc,WAAW,EAAG,QAAO;CAGvC,MAAM,YAAY,KAAK,YAAY,QAAQ,gCADzB,IAAI,MAAM,EAAC,aAAa,CAAC,QAAQ,SAAS,IACO,CAAC;AAEpE,MAAK,MAAM,YAAY,eAAe;EACpC,MAAM,MAAM,KAAK,YAAY,SAAS;EACtC,MAAM,OAAO,KAAK,WAA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AmB,EAAE,KAAK,YAAY,CAAC;AAClE,MAAI,cAAc,QAChB,qBAAoB,YAAY,aAAa,QAAQ;EAGvD,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,YAAY,aAAa,MAAM,EAAE;GAC1C,MAAM,OAAO,iBAAiB,YAAY,SAAS;AACnD,OAAI,KACF,kBAAiB,YAAY;;EAIjC,MAAM,qBAAqB,aAAa,WAAW,YAAY;AAC/D,MAAI,oBAAoB;GAEtB,MAAM,cAAc,mBADU,aAAa,KAAK,WAAW,mBAAmB,EAAE,QACpB,CAAC;AAC7D,OAAI,aAAa;IACf,MAAM,kBAAkB,mBAAmB,aAAa;KACtD;KACA,SAAS;KACV,CAAC;IACF,MAAM,eAAe,YAAY,gBAAgB;AAGjD,QAD0B,iBAAiB,YAAY,YAClC,KAAK,cAAc;AACtC,mBAAc,KAAK,YAAY,YAAY,EAAE,gBAAgB;AAC7D,aAAQ,KAAK,YAAY;;AAG3B,qBAAiB,eAAe;;;AAIpC,QAAM,cAAc,YAAY;GAC9B,WAAW,SAAS,eAAe,GAAG;GACtC,OAAO;GACR,CAAC;AAEF,MAAI,CAAC,QAAQ,WAAW;AACtB,SAAM,cAAc,WAAW;AAC/B,SAAM,YAAY,WAAW;;AAG/B,SAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;WACO;AACR,QAAM,SAAS"}
1
+ {"version":3,"file":"sync.mjs","names":["isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\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,aAAa,QAAQ;EAGvD,MAAM,mBAA2C,EAAE;AACnD,OAAK,MAAM,YAAY,aAAa,MAAM,EAAE;GAC1C,MAAM,OAAO,iBAAiB,YAAY,SAAS;AACnD,OAAI,KACF,kBAAiB,YAAY;;EAIjC,MAAM,qBAAqB,aAAa,WAAW,YAAY;AAC/D,MAAI,oBAAoB;GAEtB,MAAM,cAAc,mBADU,aAAa,KAAK,WAAW,mBAAmB,EAAE,QACpB,CAAC;AAC7D,OAAI,aAAa;IACf,MAAM,kBAAkB,mBAAmB,aAAa;KACtD;KACA,SAAS;KACV,CAAC;IACF,MAAM,eAAe,YAAY,gBAAgB;AAGjD,QAD0B,iBAAiB,YAAY,YAClC,KAAK,cAAc;AACtC,mBAAc,KAAK,YAAY,YAAY,EAAE,gBAAgB;AAC7D,aAAQ,KAAK,YAAY;;AAG3B,qBAAiB,eAAe;;;AAIpC,QAAM,cAAc,YAAY;GAC9B,WAAW,SAAS,eAAe,GAAG;GACtC,OAAO;GACR,CAAC;AAEF,MAAI,CAAC,QAAQ,WAAW;AACtB,SAAM,cAAc,WAAW;AAC/B,SAAM,YAAY,WAAW;;AAG/B,SAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;WACO;AACR,QAAM,SAAS"}
@@ -630,6 +630,54 @@ async function rewriteLegacyUiImports(projectDir) {
630
630
  }
631
631
  return migrated;
632
632
  }
633
+ const LEGACY_DIST_IMPORT_REWRITES = [["from \"everything-dev/dist/", "from \"everything-dev/"], ["from 'everything-dev/dist/", "from 'everything-dev/"]];
634
+ async function rewriteLegacyPluginScopedLayerPatterns(projectDir) {
635
+ const files = await (0, glob.glob)("plugins/*/src/index.ts", {
636
+ cwd: projectDir,
637
+ nodir: true,
638
+ dot: false,
639
+ absolute: false
640
+ });
641
+ if (files.length === 0) return [];
642
+ const migrated = [];
643
+ const effectProvidePattern = /\byield\*\s*Effect\.provide\(/g;
644
+ for (const file of files) {
645
+ const filePath = (0, node_path.join)(projectDir, file);
646
+ const original = (0, node_fs.readFileSync)(filePath, "utf-8");
647
+ let next = original;
648
+ next = next.replaceAll(effectProvidePattern, "yield* tools.buildService(");
649
+ if (next.includes("tools.buildService(")) next = next.replace(/(initialize:\s*)\((\w+)(?:,\s*(\w+))?\s*\)\s*=>/g, (_match, prefix, p1, p2) => {
650
+ if (p2) return `${prefix}(${p1}, ${p2}, tools) =>`;
651
+ return `${prefix}(${p1}, _plugins, tools) =>`;
652
+ });
653
+ if (next !== original) {
654
+ (0, node_fs.writeFileSync)(filePath, next);
655
+ migrated.push(file);
656
+ }
657
+ }
658
+ return migrated;
659
+ }
660
+ async function rewriteLegacyDistImports(projectDir) {
661
+ const files = await (0, glob.glob)("**/*.{ts,tsx,js,jsx,mjs,cjs}", {
662
+ cwd: projectDir,
663
+ nodir: true,
664
+ dot: false,
665
+ absolute: false,
666
+ ignore: ["node_modules/**", "dist/**"]
667
+ });
668
+ const migrated = [];
669
+ for (const file of files) {
670
+ const filePath = (0, node_path.join)(projectDir, file);
671
+ const original = (0, node_fs.readFileSync)(filePath, "utf-8");
672
+ let next = original;
673
+ for (const [from, to] of LEGACY_DIST_IMPORT_REWRITES) next = next.replaceAll(from, to);
674
+ if (next !== original) {
675
+ (0, node_fs.writeFileSync)(filePath, next);
676
+ migrated.push(file);
677
+ }
678
+ }
679
+ return migrated;
680
+ }
633
681
  async function upgradeTemplate(projectDir, options) {
634
682
  const timings = [];
635
683
  if (!(0, node_fs.existsSync)((0, node_path.join)(projectDir, "package.json"))) return {
@@ -730,7 +778,9 @@ async function upgradeTemplate(projectDir, options) {
730
778
  const nextMigratedFiles = [
731
779
  ...migratedBosConfigs,
732
780
  ...migratedRootPackageJson ? ["package.json"] : [],
733
- ...await rewriteLegacyUiImports(projectDir)
781
+ ...await rewriteLegacyUiImports(projectDir),
782
+ ...await rewriteLegacyPluginScopedLayerPatterns(projectDir),
783
+ ...await rewriteLegacyDistImports(projectDir)
734
784
  ];
735
785
  for (const file of OBSOLETE_FILES) {
736
786
  const filePath = (0, node_path.join)(projectDir, file);