@hexagen-monaco/sync 0.13.0 → 0.15.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.
Files changed (55) hide show
  1. package/README.md +379 -16
  2. package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts +12 -0
  3. package/dist/application/use-cases/stamp-generator-identity.use-case.d.ts.map +1 -0
  4. package/dist/cli.js +4500 -1814
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/arch/validate-outcome.d.ts +30 -0
  7. package/dist/commands/arch/validate-outcome.d.ts.map +1 -0
  8. package/dist/commands/arch/validate.d.ts +3 -1
  9. package/dist/commands/arch/validate.d.ts.map +1 -1
  10. package/dist/commands/bootstrap/index.d.ts.map +1 -1
  11. package/dist/commands/contract/evaluate.d.ts +54 -0
  12. package/dist/commands/contract/evaluate.d.ts.map +1 -1
  13. package/dist/commands/contract/growth.d.ts +22 -0
  14. package/dist/commands/contract/growth.d.ts.map +1 -0
  15. package/dist/commands/contract/index.d.ts +11 -3
  16. package/dist/commands/contract/index.d.ts.map +1 -1
  17. package/dist/commands/evidence/check.d.ts +2 -0
  18. package/dist/commands/evidence/check.d.ts.map +1 -1
  19. package/dist/commands/evidence/index.d.ts.map +1 -1
  20. package/dist/commands/evidence/pack.d.ts.map +1 -1
  21. package/dist/commands/evidence/verify.d.ts +83 -0
  22. package/dist/commands/evidence/verify.d.ts.map +1 -0
  23. package/dist/commands/grant/issue.d.ts.map +1 -1
  24. package/dist/commands/grant/list.d.ts +72 -0
  25. package/dist/commands/grant/list.d.ts.map +1 -0
  26. package/dist/commands/grant/verify.d.ts +7 -1
  27. package/dist/commands/grant/verify.d.ts.map +1 -1
  28. package/dist/commands/manifest/migrate.d.ts +8 -0
  29. package/dist/commands/manifest/migrate.d.ts.map +1 -1
  30. package/dist/commands/remove/index.d.ts +41 -0
  31. package/dist/commands/remove/index.d.ts.map +1 -0
  32. package/dist/commands/report/exec-git.d.ts.map +1 -1
  33. package/dist/commands/shared/brownfield-sidecar.d.ts +30 -0
  34. package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -1
  35. package/dist/commands/shared/confirm.d.ts.map +1 -1
  36. package/dist/commands/shared/grant-enumerator.d.ts +32 -0
  37. package/dist/commands/shared/grant-enumerator.d.ts.map +1 -0
  38. package/dist/commands/sync/check-json.d.ts +47 -0
  39. package/dist/commands/sync/check-json.d.ts.map +1 -0
  40. package/dist/commands/workbook/export.d.ts.map +1 -1
  41. package/dist/generators/architecture-files.d.ts.map +1 -1
  42. package/dist/generators/root-file-templates.d.ts +2 -2
  43. package/dist/generators/root-file-templates.d.ts.map +1 -1
  44. package/dist/generators/root-files.d.ts.map +1 -1
  45. package/dist/index.js +450 -421
  46. package/dist/index.js.map +1 -1
  47. package/dist/infrastructure/config/index.d.ts +3 -0
  48. package/dist/infrastructure/config/index.d.ts.map +1 -0
  49. package/dist/infrastructure/index.d.ts +1 -0
  50. package/dist/infrastructure/index.d.ts.map +1 -1
  51. package/dist/types/manifest/generator.d.ts +2 -0
  52. package/dist/types/manifest/generator.d.ts.map +1 -1
  53. package/dist/types/manifest/monorepo.d.ts +1 -0
  54. package/dist/types/manifest/monorepo.d.ts.map +1 -1
  55. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1439,15 +1439,24 @@ z.object({
1439
1439
  }).strict();
1440
1440
  var UNRESOLVED_IMPORT_RULE_ID = "unresolved-import";
1441
1441
  var BUILTIN_RULE_IDS = [UNRESOLVED_IMPORT_RULE_ID];
1442
- var Rule = z.object({
1443
- id: z.string().min(1).refine((id) => !BUILTIN_RULE_IDS.includes(id), {
1444
- message: "rule id is reserved for a built-in rule"
1445
- }),
1442
+ var RuleId = z.string().min(1).refine((id) => !BUILTIN_RULE_IDS.includes(id), {
1443
+ message: "rule id is reserved for a built-in rule"
1444
+ });
1445
+ var RuleSeverity = z.enum(["error", "warn"]);
1446
+ var PrefixRule = z.object({
1447
+ id: RuleId,
1446
1448
  kind: z.enum(["forbid", "allow-only"]),
1447
1449
  from: SlicePathString,
1448
1450
  to: SlicePathString,
1449
- severity: z.enum(["error", "warn"])
1451
+ severity: RuleSeverity
1450
1452
  }).strict();
1453
+ var ClosedRule = z.object({
1454
+ id: RuleId,
1455
+ kind: z.literal("closed"),
1456
+ except: z.array(SlicePathString),
1457
+ severity: RuleSeverity
1458
+ }).strict();
1459
+ var Rule = z.discriminatedUnion("kind", [PrefixRule, ClosedRule]);
1451
1460
  function isRealCalendarDate(text) {
1452
1461
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
1453
1462
  if (!m)
@@ -1543,7 +1552,7 @@ var BUILTIN_PACKAGE_JSON_TEMPLATE = `{
1543
1552
  "format": "prettier --write \\"**/*.{ts,tsx}\\""
1544
1553
  },
1545
1554
  "devDependencies": {
1546
- "turbo": "^2.0.0",
1555
+ "turbo": "^2.11.5",
1547
1556
  "typescript": "^5.5.4",
1548
1557
  "eslint": "^9.0.0",
1549
1558
  "prettier": "^3.0.0",
@@ -1570,6 +1579,7 @@ var BUILTIN_TSCONFIG_BASE_TEMPLATE = `{
1570
1579
  `;
1571
1580
  var BUILTIN_TURBO_TEMPLATE = `{
1572
1581
  "$schema": "https://turbo.build/schema.json",
1582
+ "agentGuidance": false,
1573
1583
  "tasks": {
1574
1584
  "build": {
1575
1585
  "dependsOn": ["^build"],
@@ -1684,7 +1694,7 @@ function assertValidToolchainVersion(version, source) {
1684
1694
  function resolveToolchainVersion() {
1685
1695
  {
1686
1696
  return assertValidToolchainVersion(
1687
- "0.13.0",
1697
+ "0.15.0",
1688
1698
  "build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
1689
1699
  );
1690
1700
  }
@@ -1797,6 +1807,11 @@ function buildTurboContentFromConfig(manifest, prettierOptions) {
1797
1807
  const globalDependencies = turboConfig.globalDependencies ?? [];
1798
1808
  const doc = {
1799
1809
  $schema: builtin.$schema,
1810
+ // The opt-out the built-in template also carries (see its comment). Only a
1811
+ // manifest that states the key wins — an absent or non-boolean value keeps
1812
+ // the safe default rather than emitting turbo's own agent-rules block into
1813
+ // a project whose tree the generator owns.
1814
+ agentGuidance: typeof turboConfig.agentGuidance === "boolean" ? turboConfig.agentGuidance : false,
1800
1815
  ...globalDependencies.length > 0 ? { globalDependencies } : {},
1801
1816
  tasks
1802
1817
  };
@@ -1969,41 +1984,427 @@ async function generateRootFiles(config, report) {
1969
1984
  return result;
1970
1985
  }
1971
1986
  }
1987
+ function caseInsensitiveEnum(schema, dir = "lower") {
1988
+ return z.preprocess((value) => typeof value === "string" ? dir === "lower" ? value.trim().toLowerCase() : value.trim().toUpperCase() : value, schema);
1989
+ }
1990
+ var BoundedContextTypeSchema = boundedContextTypeSchema;
1991
+ var PLANE_NAMES = [
1992
+ "projection",
1993
+ "probabilistic",
1994
+ "infrastructure",
1995
+ "shared-kernel",
1996
+ "core",
1997
+ "supporting"
1998
+ ];
1999
+ var PlaneTypeSchema = caseInsensitiveEnum(z.enum(PLANE_NAMES));
2000
+ var StatusTypeSchema = caseInsensitiveEnum(z.enum(["active", "frozen", "deprecated", "experimental"]));
2001
+ var RelationshipPatternSchema = caseInsensitiveEnum(z.enum(["U/D", "ACL", "SK", "P", "OHS"]), "upper");
2002
+ var RelationshipRoleSchema = caseInsensitiveEnum(z.enum(["upstream", "downstream", "peer"]));
2003
+ var RelationshipSchema = z.object({
2004
+ context: z.string(),
2005
+ pattern: RelationshipPatternSchema,
2006
+ role: RelationshipRoleSchema.optional(),
2007
+ acl: z.object({
2008
+ adapter: z.string(),
2009
+ location: z.string().optional(),
2010
+ notes: z.string().optional()
2011
+ }).optional(),
2012
+ notes: z.string().optional()
2013
+ });
2014
+ var PortDefinitionSchema = z.object({
2015
+ name: z.string(),
2016
+ owner: z.string().optional()
2017
+ });
2018
+ var LegacyOrNewPortSchema = z.union([
2019
+ z.string(),
2020
+ PortDefinitionSchema
2021
+ ]);
2022
+ caseInsensitiveEnum(z.enum(["domain", "application", "infrastructure"]));
2023
+ var UiLayerSchema = z.object({
2024
+ components: z.array(z.string()).optional()
2025
+ }).passthrough();
2026
+ var BoundedContextSchema = z.object({
2027
+ name: z.string(),
2028
+ type: BoundedContextTypeSchema.optional(),
2029
+ plane: PlaneTypeSchema.optional(),
2030
+ status: StatusTypeSchema.optional(),
2031
+ description: z.string().optional(),
2032
+ relationships: z.array(RelationshipSchema).optional(),
2033
+ // PASSTHROUGH, not strict, at every level of this subtree — a deliberate
2034
+ // choice, see the note on the schema below. Zod's default `z.object` STRIPS
2035
+ // undeclared keys, which is how `layers.ui` disappeared between the file on
2036
+ // disk and every consumer of the merged manifest.
2037
+ layers: z.object({
2038
+ domain: z.object({
2039
+ entities: z.array(z.string()).optional(),
2040
+ value_objects: z.array(z.string()).optional()
2041
+ }).passthrough().optional(),
2042
+ application: z.object({
2043
+ use_cases: z.array(z.string()).optional(),
2044
+ ports: z.object({
2045
+ in: z.array(LegacyOrNewPortSchema).optional(),
2046
+ out: z.array(LegacyOrNewPortSchema).optional()
2047
+ }).passthrough().optional()
2048
+ }).passthrough().optional(),
2049
+ infrastructure: z.object({
2050
+ adapters: z.array(z.string()).optional()
2051
+ }).passthrough().optional(),
2052
+ ui: UiLayerSchema.optional()
2053
+ }).passthrough().optional(),
2054
+ depends_on: z.array(z.string()).optional(),
2055
+ wiring: z.array(z.string()).optional(),
2056
+ generator: z.record(z.unknown()).optional()
2057
+ }).passthrough();
2058
+ var AppSchema = z.object({
2059
+ name: z.string(),
2060
+ framework: z.string().optional(),
2061
+ version: z.string().optional(),
2062
+ driver: z.string().optional(),
2063
+ description: z.string().optional(),
2064
+ role: z.string().optional(),
2065
+ router: z.string().optional(),
2066
+ deployment: z.string().optional(),
2067
+ auth: z.string().optional(),
2068
+ schedule: z.string().optional(),
2069
+ ui: z.object({
2070
+ library: z.string().optional(),
2071
+ styling: z.string().optional()
2072
+ }).optional(),
2073
+ responsibilities: z.array(z.string()).optional(),
2074
+ depends_on: z.array(z.string()).optional()
2075
+ }).strip();
2076
+ var CrossContextEdgeSchema = z.object({
2077
+ consumer: z.string(),
2078
+ provider: z.string(),
2079
+ transport: z.enum(["event-bus", "network"]),
2080
+ events: z.array(z.string()).optional(),
2081
+ operations: z.array(z.string()).optional(),
2082
+ integrationPattern: z.enum(["open-host", "acl"]).optional()
2083
+ });
2084
+ var GeneratorBlockSchema = z.object({ name: z.string().min(1).optional() }).passthrough();
2085
+ var IndexManifestSchema = z.object({
2086
+ // Toolchain-compatibility stamp (see manifest-schema-version.ts). Note
2087
+ // `version` below is a DIFFERENT field — its `"2.0"` string is the
2088
+ // index-form discriminator (`isIndexManifest`), not a compatibility gate.
2089
+ schemaVersion: z.number().int().positive().optional(),
2090
+ version: z.string().optional(),
2091
+ description: z.string(),
2092
+ system: z.string().optional(),
2093
+ scope: z.string().optional(),
2094
+ architecture: z.string().optional(),
2095
+ planes: z.record(z.array(z.string())).optional(),
2096
+ bounded_contexts: z.array(z.object({
2097
+ name: z.string(),
2098
+ type: BoundedContextTypeSchema.optional(),
2099
+ plane: PlaneTypeSchema.optional(),
2100
+ status: StatusTypeSchema.optional(),
2101
+ file: z.string(),
2102
+ frozen_since: z.string().optional()
2103
+ })).optional(),
2104
+ apps: z.array(z.object({
2105
+ name: z.string(),
2106
+ file: z.string().optional()
2107
+ })).optional(),
2108
+ invariants: z.record(z.string()).optional(),
2109
+ governance: z.record(z.string()).optional(),
2110
+ agent_instructions: z.record(z.unknown()).optional(),
2111
+ relationship_patterns: z.record(z.object({
2112
+ description: z.string(),
2113
+ acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
2114
+ linter: z.string().optional()
2115
+ })).optional(),
2116
+ mvk: z.record(z.unknown()).optional(),
2117
+ cross_context: z.array(CrossContextEdgeSchema).optional(),
2118
+ workspace_config: z.string().optional(),
2119
+ legacy_config: z.string().optional()
2120
+ }).strict().refine((data) => {
2121
+ const contexts = data.bounded_contexts ?? [];
2122
+ return contexts.every((ctx) => {
2123
+ if (ctx.plane && ctx.file) {
2124
+ return ctx.file.startsWith(`contexts/${ctx.plane}/`);
2125
+ }
2126
+ return true;
2127
+ });
2128
+ }, {
2129
+ message: "Context plane does not match file path subdirectory",
2130
+ path: ["bounded_contexts"]
2131
+ });
2132
+ var ManifestSchema = z.object({
2133
+ // Toolchain-compatibility stamp (positive int; absent = legacy). NOT the
2134
+ // freeform `version` string below. Compatibility is asserted against the
2135
+ // RAW yaml BEFORE this `.strict()` parse (assertSupportedSchemaVersion in
2136
+ // manifest-schema-version.ts) — this entry only keeps strict mode from
2137
+ // rejecting stamped manifests as carrying an unknown key.
2138
+ schemaVersion: z.number().int().positive().optional(),
2139
+ version: z.string().optional(),
2140
+ description: z.string().optional(),
2141
+ system: z.string().optional(),
2142
+ scope: z.string().optional(),
2143
+ // Structured workspace metadata (the canonical `workspace:` block, also the
2144
+ // first block in the few-shot examples). `system`/`scope` above are derived
2145
+ // from `workspace.name`; `workspace.description` is the only carrier of the
2146
+ // human-readable intent. Emitted by `draftToManifest` so the generated
2147
+ // manifest survives `parseManifestToWizardData`'s strict parse on the
2148
+ // "Use this manifest" path. Optional — legacy/hand-written manifests omit it.
2149
+ workspace: z.object({
2150
+ name: z.string(),
2151
+ description: z.string()
2152
+ }).optional(),
2153
+ architecture: z.string().optional(),
2154
+ // The wizard records the chosen workspace template (e.g. "strict-enterprise")
2155
+ // alongside `architecture`; persisted into .architecture/manifest.yaml.
2156
+ workspaceTemplate: z.string().optional(),
2157
+ planes: z.record(z.array(z.string())).optional(),
2158
+ monorepo: z.record(z.unknown()).optional(),
2159
+ generator: GeneratorBlockSchema.optional(),
2160
+ mvk: z.record(z.unknown()).optional(),
2161
+ invariants: z.record(z.string()).optional(),
2162
+ governance: z.record(z.string()).optional(),
2163
+ agent_instructions: z.record(z.unknown()).optional(),
2164
+ relationship_patterns: z.record(z.object({
2165
+ description: z.string(),
2166
+ acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
2167
+ linter: z.string().optional()
2168
+ })).optional(),
2169
+ bounded_contexts: z.array(BoundedContextSchema),
2170
+ apps: z.array(AppSchema).optional(),
2171
+ cross_context: z.array(CrossContextEdgeSchema).optional(),
2172
+ context_mappings: z.array(z.object({
2173
+ upstream: z.string(),
2174
+ downstream: z.string(),
2175
+ pattern: z.string().optional(),
2176
+ mechanism: z.string().optional(),
2177
+ notes: z.string().optional(),
2178
+ events: z.array(z.string()).optional()
2179
+ })).optional(),
2180
+ workspaceDefaults: z.record(z.unknown()).optional(),
2181
+ // Both side-car pointers. `mergeSplitManifest` resolves `workspace_config`
2182
+ // into the `monorepo`/`generator` blocks above and then carries the pointer
2183
+ // through with every other index key, so the merged (flat) form has to
2184
+ // accept it — this schema is `.strict()`, and the merge output is re-parsed
2185
+ // against it (sync's `validateManifest`, `parseManifestToWizardData`).
2186
+ workspace_config: z.string().optional(),
2187
+ legacy_config: z.string().optional()
2188
+ }).strict();
1972
2189
 
1973
- // src/generators/architecture-file-templates.ts
1974
- var LAYER_RULES_COMMON = `shared_kernel:
1975
- package: "@{scope}/shared"
1976
- allowed_in_all_layers: true
1977
-
1978
- layers:
1979
- domain:
1980
- access_rule: "internal-only"
1981
- allowed_imports: ["@{scope}/shared"]
1982
-
1983
- application:
1984
- access_rule: "ports-only"
1985
- allowed_imports: ["domain", "@{scope}/shared"]
1986
-
1987
- infrastructure:
1988
- access_rule: "adapters"
1989
- allowed_imports: ["domain", "application", "@{scope}/shared"]
1990
- `;
1991
- var LAYER_RULES_STRICT_ENTERPRISE = `# HexaGen — Architectural Invariants
1992
- # Template: strict-enterprise — event-bus boundaries
2190
+ // ../project-configuration/dist/domain/model/manifest-schema/manifest-schema-version.js
2191
+ var CURRENT_MANIFEST_SCHEMA_VERSION = 1;
2192
+ function readManifestSchemaVersion(parsed) {
2193
+ if (parsed === null || typeof parsed !== "object")
2194
+ return void 0;
2195
+ const raw = parsed.schemaVersion;
2196
+ if (raw === void 0)
2197
+ return void 0;
2198
+ if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1) {
2199
+ throw new Error(`Invalid manifest schemaVersion: expected a positive integer, got ${JSON.stringify(raw)}.`);
2200
+ }
2201
+ return raw;
2202
+ }
2203
+ function assertSupportedSchemaVersion(parsed) {
2204
+ const version = readManifestSchemaVersion(parsed);
2205
+ if (version === void 0)
2206
+ return;
2207
+ if (version > CURRENT_MANIFEST_SCHEMA_VERSION) {
2208
+ throw new Error(`Manifest schemaVersion ${version} is newer than this toolchain supports (reads ≤ ${CURRENT_MANIFEST_SCHEMA_VERSION}). This manifest requires a newer @hexagen-monaco/sync — upgrade it. (Upgrading is always safe: a newer toolchain reads every older manifest, and \`hexagen manifest migrate\` brings one forward on demand.)`);
2209
+ }
2210
+ }
1993
2211
 
1994
- ${LAYER_RULES_COMMON}
1995
- cross_context:
1996
- deny_direct_imports: true
1997
- required_communication: "event-bus"
1998
- allowed_broker_patterns:
1999
- - "event-bus"
2000
- - "message-queue"
2001
- `;
2002
- var LAYER_RULES_MICRO_FRONTEND = `# HexaGen — Architectural Invariants
2003
- # Template: micro-frontend — networked boundaries
2212
+ // ../project-configuration/dist/domain/model/manifest-schema/generator-identity.js
2213
+ var HEXAGEN_GENERATOR_NAME = "@hexagen-monaco/sync";
2004
2214
 
2005
- ${LAYER_RULES_COMMON}
2006
- cross_context:
2215
+ // ../project-configuration/dist/domain/model/manifest-schema/is-index-manifest.js
2216
+ function isIndexManifest(parsed) {
2217
+ if (typeof parsed !== "object" || parsed === null) {
2218
+ return false;
2219
+ }
2220
+ const record = parsed;
2221
+ if (record.version !== "2.0") {
2222
+ return false;
2223
+ }
2224
+ const contexts = record.bounded_contexts;
2225
+ if (!Array.isArray(contexts)) {
2226
+ return false;
2227
+ }
2228
+ return contexts.some((entry) => typeof entry === "object" && entry !== null && typeof entry.file === "string");
2229
+ }
2230
+ var WorkspaceGovernanceSchema = z.object({
2231
+ workspaceName: z.string().min(1, "Workspace name is required"),
2232
+ workspaceTemplate: z.enum(["modular-monolith", "strict-enterprise", "micro-frontend"]).default("modular-monolith"),
2233
+ workspaceDescription: z.string().optional(),
2234
+ packageManager: z.enum(["yarn", "pnpm", "bun"]).default("yarn"),
2235
+ topologyStrictness: z.enum(["strict", "flexible"]).default("flexible"),
2236
+ namespacePrefix: z.string().default("@hexagen"),
2237
+ namingConventions: z.object({
2238
+ contextDirectoryPattern: z.string().default("packages/"),
2239
+ adapterSuffix: z.string().default(".adapter.ts")
2240
+ }).default({
2241
+ contextDirectoryPattern: "packages/",
2242
+ adapterSuffix: ".adapter.ts"
2243
+ })
2244
+ });
2245
+ var PortConfigurationSchema = z.object({
2246
+ inboundPorts: z.array(z.enum([
2247
+ "rest-controller",
2248
+ "graphql-resolver",
2249
+ "event-listener",
2250
+ "cli-command"
2251
+ ])).default([]),
2252
+ outboundPorts: z.array(z.enum([
2253
+ "relational-db",
2254
+ "document-db",
2255
+ "external-service-client",
2256
+ "message-publisher"
2257
+ ])).default([])
2258
+ });
2259
+ var PeerContextMappingSchema = z.object({
2260
+ consumerContext: z.string(),
2261
+ providerContext: z.string(),
2262
+ integrationPattern: z.enum(["open-host", "acl"]),
2263
+ communicationBoundary: z.enum(["in-process", "networked"])
2264
+ });
2265
+ var BoundedContextSchema2 = z.object({
2266
+ id: z.string(),
2267
+ name: z.string().min(1, "Please enter a name for this bounded context (e.g., 'UserService', 'OrderProcessing')"),
2268
+ description: z.string().optional(),
2269
+ // ADR-0041: `infrastructureTarget` (API backend) and `uiFramework` (below)
2270
+ // are PROJECT-LEVEL choices managed by the wizard's Applications step, which
2271
+ // fans a single selection out to every context. They persist per-context (the
2272
+ // source of truth `deriveApps` reads), but are NOT direct per-context input —
2273
+ // do not re-add per-context UI/API editing without revisiting ADR-0041.
2274
+ // `"none"` = the project opts out of a separate API backend (UI-only, e.g. a
2275
+ // Next.js app with built-in routes); `deriveApps` then emits no `api` app.
2276
+ // Distinct from `undefined` (legacy/unset → defaults to the preset).
2277
+ infrastructureTarget: z.enum(["nestjs", "express", "serverless", "plain-ts", "nitro", "none"]).optional(),
2278
+ coreDomainEntities: z.array(z.string()).default([]),
2279
+ valueObjects: z.array(z.string()).default([]),
2280
+ domainEvents: z.array(z.string()).default([]),
2281
+ portConfiguration: PortConfigurationSchema,
2282
+ // Backward compatibility: support legacy fields
2283
+ apiFramework: z.enum(["Fastify", "Express", "NestJS"]).optional(),
2284
+ uiFramework: z.enum(["", "Next.js", "React Router", "Remix", "Angular", "Vue.js"]).optional().default(""),
2285
+ persistenceAdapter: z.enum(["", "Prisma", "TypeORM", "Mongoose", "Drizzle"]).optional().default(""),
2286
+ messagingAdapter: z.enum(["", "BullMQ", "Temporal", "RabbitMQ"]).optional().default(""),
2287
+ telemetryProvider: z.enum(["", "OpenTelemetry", "None", "Prometheus", "Winston"]).optional().default(""),
2288
+ externalApiPorts: z.array(z.string()).optional(),
2289
+ llmProviders: z.array(z.string()).optional(),
2290
+ blockchainNetworks: z.array(z.string()).optional(),
2291
+ authenticationProvider: z.string().optional(),
2292
+ emailService: z.string().optional(),
2293
+ paymentGateway: z.string().optional(),
2294
+ storageProvider: z.string().optional(),
2295
+ searchService: z.string().optional(),
2296
+ webhookEndpoints: z.array(z.string()).optional(),
2297
+ entities: z.array(z.string()).optional(),
2298
+ useCases: z.array(z.string()).optional()
2299
+ });
2300
+ var ExternalContextSchema = z.object({
2301
+ id: z.string(),
2302
+ name: z.string().min(1, "Peer context name is required"),
2303
+ relationshipType: z.enum(["U", "D", "ACL", "SK", "P", "OHS"]),
2304
+ isEventDriven: z.boolean().optional(),
2305
+ entityNames: z.array(z.string()).optional(),
2306
+ useCaseNames: z.array(z.string()).optional()
2307
+ });
2308
+ z.object({
2309
+ boundedContexts: z.array(BoundedContextSchema2).default([]),
2310
+ externalContexts: z.array(ExternalContextSchema).default([]),
2311
+ governance: WorkspaceGovernanceSchema.default({
2312
+ workspaceName: "@hexagen",
2313
+ workspaceTemplate: "modular-monolith",
2314
+ packageManager: "yarn",
2315
+ topologyStrictness: "flexible",
2316
+ namespacePrefix: "@hexagen",
2317
+ namingConventions: {
2318
+ contextDirectoryPattern: "packages/",
2319
+ adapterSuffix: ".adapter.ts"
2320
+ }
2321
+ }),
2322
+ peerMappings: z.array(PeerContextMappingSchema).default([]),
2323
+ /**
2324
+ * Per-template install-time answers collected by the wizard. Keyed by
2325
+ * template id; each value is a record of question-id → answer. The CLI
2326
+ * use case consumes this via its `overrideAnswers` parameter, so the
2327
+ * wizard can feed answers gathered in the UI directly into a non-
2328
+ * interactive install. Defaults to an empty object for projects that
2329
+ * are scaffolded without the per-template questions step.
2330
+ */
2331
+ addOnsAnswers: z.record(z.string(), z.record(z.string(), z.union([z.string(), z.boolean(), z.array(z.string())]))).default({}),
2332
+ /**
2333
+ * Provenance of the project's `manifestYaml` (import round-trip integrity,
2334
+ * Item 1). `"imported"` = the manifest is the source of truth (accepted via
2335
+ * `parseManifestToWizardData` — file import or AI generation) and the wizard
2336
+ * projection (`wizardToManifest`) is LOSSY for it, so autosave/export paths
2337
+ * must never overwrite or impersonate the stored manifest. Deliberately
2338
+ * `.optional()` rather than `.default("wizard")`: absent ≡ `"wizard"`
2339
+ * everywhere (guards key on `=== "imported"` only), which keeps every
2340
+ * wizard-authored formState byte-identical to before this field existed and
2341
+ * lets the load perimeter distinguish "legacy record, provenance unknown"
2342
+ * (absent) from an explicit value when running its one-time discriminator.
2343
+ */
2344
+ manifestSource: z.enum(["wizard", "imported"]).optional()
2345
+ });
2346
+ var MonorepoConfigSchema = z.object({
2347
+ packageManager: z.string().optional(),
2348
+ workspaces: z.array(z.string()).optional(),
2349
+ rootFiles: z.record(z.unknown()).optional(),
2350
+ archInvariants: z.record(z.unknown()).optional()
2351
+ }).passthrough();
2352
+ var GeneratorSyncSchema = z.object({
2353
+ layers: z.record(z.unknown()).optional(),
2354
+ packageJson: z.record(z.unknown()).optional(),
2355
+ stubs: z.record(z.unknown()).optional(),
2356
+ apps: z.record(z.unknown()).optional()
2357
+ }).passthrough();
2358
+ var GeneratorConfigSchema = z.object({
2359
+ name: z.string().min(1).optional(),
2360
+ version: z.string().optional(),
2361
+ sync: GeneratorSyncSchema.optional()
2362
+ }).passthrough();
2363
+ var WorkspaceConfigSchema = z.object({
2364
+ monorepo: MonorepoConfigSchema.optional(),
2365
+ generator: GeneratorConfigSchema.optional(),
2366
+ workspaceDefaults: z.record(z.unknown()).optional(),
2367
+ tsConfigRoot: z.record(z.unknown()).optional(),
2368
+ eslint: z.record(z.unknown()).optional(),
2369
+ rootFiles: z.record(z.unknown()).optional(),
2370
+ generatorConfig: z.record(z.unknown()).optional(),
2371
+ turboConfig: z.record(z.unknown()).optional()
2372
+ }).passthrough();
2373
+
2374
+ // src/generators/architecture-file-templates.ts
2375
+ var LAYER_RULES_COMMON = `shared_kernel:
2376
+ package: "@{scope}/shared"
2377
+ allowed_in_all_layers: true
2378
+
2379
+ layers:
2380
+ domain:
2381
+ access_rule: "internal-only"
2382
+ allowed_imports: ["@{scope}/shared"]
2383
+
2384
+ application:
2385
+ access_rule: "ports-only"
2386
+ allowed_imports: ["domain", "@{scope}/shared"]
2387
+
2388
+ infrastructure:
2389
+ access_rule: "adapters"
2390
+ allowed_imports: ["domain", "application", "@{scope}/shared"]
2391
+ `;
2392
+ var LAYER_RULES_STRICT_ENTERPRISE = `# HexaGen — Architectural Invariants
2393
+ # Template: strict-enterprise — event-bus boundaries
2394
+
2395
+ ${LAYER_RULES_COMMON}
2396
+ cross_context:
2397
+ deny_direct_imports: true
2398
+ required_communication: "event-bus"
2399
+ allowed_broker_patterns:
2400
+ - "event-bus"
2401
+ - "message-queue"
2402
+ `;
2403
+ var LAYER_RULES_MICRO_FRONTEND = `# HexaGen — Architectural Invariants
2404
+ # Template: micro-frontend — networked boundaries
2405
+
2406
+ ${LAYER_RULES_COMMON}
2407
+ cross_context:
2007
2408
  deny_direct_imports: true
2008
2409
  required_communication: "network"
2009
2410
  allowed_broker_patterns:
@@ -2240,6 +2641,15 @@ function interpolateWithLogging(label, template, vars, config) {
2240
2641
  }
2241
2642
  return output;
2242
2643
  }
2644
+ function withGeneratorIdentity(manifest) {
2645
+ return {
2646
+ ...manifest,
2647
+ generator: {
2648
+ ...manifest.generator,
2649
+ name: manifest.generator?.name ?? HEXAGEN_GENERATOR_NAME
2650
+ }
2651
+ };
2652
+ }
2243
2653
  async function writeManifestIfFreshExternal(config, result, report) {
2244
2654
  if (config.mode !== "external") {
2245
2655
  return;
@@ -2272,7 +2682,7 @@ async function writeManifestIfFreshExternal(config, result, report) {
2272
2682
  result.totalOps += 1;
2273
2683
  return;
2274
2684
  }
2275
- const content = yaml3.dump(config.manifest);
2685
+ const content = yaml3.dump(withGeneratorIdentity(config.manifest));
2276
2686
  config.journal?.recordWrite(manifestPath, null);
2277
2687
  await fs5.mkdir(archDir, { recursive: true });
2278
2688
  await fs5.writeFile(manifestPath, content, { encoding: "utf8" });
@@ -4828,387 +5238,6 @@ function mergeBarrelPasses(firstPass, secondPass) {
4828
5238
  }
4829
5239
  return combined;
4830
5240
  }
4831
- function caseInsensitiveEnum(schema, dir = "lower") {
4832
- return z.preprocess((value) => typeof value === "string" ? dir === "lower" ? value.trim().toLowerCase() : value.trim().toUpperCase() : value, schema);
4833
- }
4834
- var BoundedContextTypeSchema = boundedContextTypeSchema;
4835
- var PLANE_NAMES = [
4836
- "projection",
4837
- "probabilistic",
4838
- "infrastructure",
4839
- "shared-kernel",
4840
- "core",
4841
- "supporting"
4842
- ];
4843
- var PlaneTypeSchema = caseInsensitiveEnum(z.enum(PLANE_NAMES));
4844
- var StatusTypeSchema = caseInsensitiveEnum(z.enum(["active", "frozen", "deprecated", "experimental"]));
4845
- var RelationshipPatternSchema = caseInsensitiveEnum(z.enum(["U/D", "ACL", "SK", "P", "OHS"]), "upper");
4846
- var RelationshipRoleSchema = caseInsensitiveEnum(z.enum(["upstream", "downstream", "peer"]));
4847
- var RelationshipSchema = z.object({
4848
- context: z.string(),
4849
- pattern: RelationshipPatternSchema,
4850
- role: RelationshipRoleSchema.optional(),
4851
- acl: z.object({
4852
- adapter: z.string(),
4853
- location: z.string().optional(),
4854
- notes: z.string().optional()
4855
- }).optional(),
4856
- notes: z.string().optional()
4857
- });
4858
- var PortDefinitionSchema = z.object({
4859
- name: z.string(),
4860
- owner: z.string().optional()
4861
- });
4862
- var LegacyOrNewPortSchema = z.union([
4863
- z.string(),
4864
- PortDefinitionSchema
4865
- ]);
4866
- caseInsensitiveEnum(z.enum(["domain", "application", "infrastructure"]));
4867
- var UiLayerSchema = z.object({
4868
- components: z.array(z.string()).optional()
4869
- }).passthrough();
4870
- var BoundedContextSchema = z.object({
4871
- name: z.string(),
4872
- type: BoundedContextTypeSchema.optional(),
4873
- plane: PlaneTypeSchema.optional(),
4874
- status: StatusTypeSchema.optional(),
4875
- description: z.string().optional(),
4876
- relationships: z.array(RelationshipSchema).optional(),
4877
- // PASSTHROUGH, not strict, at every level of this subtree — a deliberate
4878
- // choice, see the note on the schema below. Zod's default `z.object` STRIPS
4879
- // undeclared keys, which is how `layers.ui` disappeared between the file on
4880
- // disk and every consumer of the merged manifest.
4881
- layers: z.object({
4882
- domain: z.object({
4883
- entities: z.array(z.string()).optional(),
4884
- value_objects: z.array(z.string()).optional()
4885
- }).passthrough().optional(),
4886
- application: z.object({
4887
- use_cases: z.array(z.string()).optional(),
4888
- ports: z.object({
4889
- in: z.array(LegacyOrNewPortSchema).optional(),
4890
- out: z.array(LegacyOrNewPortSchema).optional()
4891
- }).passthrough().optional()
4892
- }).passthrough().optional(),
4893
- infrastructure: z.object({
4894
- adapters: z.array(z.string()).optional()
4895
- }).passthrough().optional(),
4896
- ui: UiLayerSchema.optional()
4897
- }).passthrough().optional(),
4898
- depends_on: z.array(z.string()).optional(),
4899
- wiring: z.array(z.string()).optional(),
4900
- generator: z.record(z.unknown()).optional()
4901
- }).passthrough();
4902
- var AppSchema = z.object({
4903
- name: z.string(),
4904
- framework: z.string().optional(),
4905
- version: z.string().optional(),
4906
- driver: z.string().optional(),
4907
- description: z.string().optional(),
4908
- role: z.string().optional(),
4909
- router: z.string().optional(),
4910
- deployment: z.string().optional(),
4911
- auth: z.string().optional(),
4912
- schedule: z.string().optional(),
4913
- ui: z.object({
4914
- library: z.string().optional(),
4915
- styling: z.string().optional()
4916
- }).optional(),
4917
- responsibilities: z.array(z.string()).optional(),
4918
- depends_on: z.array(z.string()).optional()
4919
- }).strip();
4920
- var CrossContextEdgeSchema = z.object({
4921
- consumer: z.string(),
4922
- provider: z.string(),
4923
- transport: z.enum(["event-bus", "network"]),
4924
- events: z.array(z.string()).optional(),
4925
- operations: z.array(z.string()).optional(),
4926
- integrationPattern: z.enum(["open-host", "acl"]).optional()
4927
- });
4928
- var IndexManifestSchema = z.object({
4929
- // Toolchain-compatibility stamp (see manifest-schema-version.ts). Note
4930
- // `version` below is a DIFFERENT field — its `"2.0"` string is the
4931
- // index-form discriminator (`isIndexManifest`), not a compatibility gate.
4932
- schemaVersion: z.number().int().positive().optional(),
4933
- version: z.string().optional(),
4934
- description: z.string(),
4935
- system: z.string().optional(),
4936
- scope: z.string().optional(),
4937
- architecture: z.string().optional(),
4938
- planes: z.record(z.array(z.string())).optional(),
4939
- bounded_contexts: z.array(z.object({
4940
- name: z.string(),
4941
- type: BoundedContextTypeSchema.optional(),
4942
- plane: PlaneTypeSchema.optional(),
4943
- status: StatusTypeSchema.optional(),
4944
- file: z.string(),
4945
- frozen_since: z.string().optional()
4946
- })).optional(),
4947
- apps: z.array(z.object({
4948
- name: z.string(),
4949
- file: z.string().optional()
4950
- })).optional(),
4951
- invariants: z.record(z.string()).optional(),
4952
- governance: z.record(z.string()).optional(),
4953
- agent_instructions: z.record(z.unknown()).optional(),
4954
- relationship_patterns: z.record(z.object({
4955
- description: z.string(),
4956
- acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
4957
- linter: z.string().optional()
4958
- })).optional(),
4959
- mvk: z.record(z.unknown()).optional(),
4960
- cross_context: z.array(CrossContextEdgeSchema).optional(),
4961
- workspace_config: z.string().optional(),
4962
- legacy_config: z.string().optional()
4963
- }).strict().refine((data) => {
4964
- const contexts = data.bounded_contexts ?? [];
4965
- return contexts.every((ctx) => {
4966
- if (ctx.plane && ctx.file) {
4967
- return ctx.file.startsWith(`contexts/${ctx.plane}/`);
4968
- }
4969
- return true;
4970
- });
4971
- }, {
4972
- message: "Context plane does not match file path subdirectory",
4973
- path: ["bounded_contexts"]
4974
- });
4975
- var ManifestSchema = z.object({
4976
- // Toolchain-compatibility stamp (positive int; absent = legacy). NOT the
4977
- // freeform `version` string below. Compatibility is asserted against the
4978
- // RAW yaml BEFORE this `.strict()` parse (assertSupportedSchemaVersion in
4979
- // manifest-schema-version.ts) — this entry only keeps strict mode from
4980
- // rejecting stamped manifests as carrying an unknown key.
4981
- schemaVersion: z.number().int().positive().optional(),
4982
- version: z.string().optional(),
4983
- description: z.string().optional(),
4984
- system: z.string().optional(),
4985
- scope: z.string().optional(),
4986
- // Structured workspace metadata (the canonical `workspace:` block, also the
4987
- // first block in the few-shot examples). `system`/`scope` above are derived
4988
- // from `workspace.name`; `workspace.description` is the only carrier of the
4989
- // human-readable intent. Emitted by `draftToManifest` so the generated
4990
- // manifest survives `parseManifestToWizardData`'s strict parse on the
4991
- // "Use this manifest" path. Optional — legacy/hand-written manifests omit it.
4992
- workspace: z.object({
4993
- name: z.string(),
4994
- description: z.string()
4995
- }).optional(),
4996
- architecture: z.string().optional(),
4997
- // The wizard records the chosen workspace template (e.g. "strict-enterprise")
4998
- // alongside `architecture`; persisted into .architecture/manifest.yaml.
4999
- workspaceTemplate: z.string().optional(),
5000
- planes: z.record(z.array(z.string())).optional(),
5001
- monorepo: z.record(z.unknown()).optional(),
5002
- generator: z.record(z.unknown()).optional(),
5003
- mvk: z.record(z.unknown()).optional(),
5004
- invariants: z.record(z.string()).optional(),
5005
- governance: z.record(z.string()).optional(),
5006
- agent_instructions: z.record(z.unknown()).optional(),
5007
- relationship_patterns: z.record(z.object({
5008
- description: z.string(),
5009
- acl_required: z.union([z.boolean(), z.literal("optional")]).optional(),
5010
- linter: z.string().optional()
5011
- })).optional(),
5012
- bounded_contexts: z.array(BoundedContextSchema),
5013
- apps: z.array(AppSchema).optional(),
5014
- cross_context: z.array(CrossContextEdgeSchema).optional(),
5015
- context_mappings: z.array(z.object({
5016
- upstream: z.string(),
5017
- downstream: z.string(),
5018
- pattern: z.string().optional(),
5019
- mechanism: z.string().optional(),
5020
- notes: z.string().optional(),
5021
- events: z.array(z.string()).optional()
5022
- })).optional(),
5023
- workspaceDefaults: z.record(z.unknown()).optional(),
5024
- // Both side-car pointers. `mergeSplitManifest` resolves `workspace_config`
5025
- // into the `monorepo`/`generator` blocks above and then carries the pointer
5026
- // through with every other index key, so the merged (flat) form has to
5027
- // accept it — this schema is `.strict()`, and the merge output is re-parsed
5028
- // against it (sync's `validateManifest`, `parseManifestToWizardData`).
5029
- workspace_config: z.string().optional(),
5030
- legacy_config: z.string().optional()
5031
- }).strict();
5032
-
5033
- // ../project-configuration/dist/domain/model/manifest-schema/manifest-schema-version.js
5034
- var CURRENT_MANIFEST_SCHEMA_VERSION = 1;
5035
- function readManifestSchemaVersion(parsed) {
5036
- if (parsed === null || typeof parsed !== "object")
5037
- return void 0;
5038
- const raw = parsed.schemaVersion;
5039
- if (raw === void 0)
5040
- return void 0;
5041
- if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1) {
5042
- throw new Error(`Invalid manifest schemaVersion: expected a positive integer, got ${JSON.stringify(raw)}.`);
5043
- }
5044
- return raw;
5045
- }
5046
- function assertSupportedSchemaVersion(parsed) {
5047
- const version = readManifestSchemaVersion(parsed);
5048
- if (version === void 0)
5049
- return;
5050
- if (version > CURRENT_MANIFEST_SCHEMA_VERSION) {
5051
- throw new Error(`Manifest schemaVersion ${version} is newer than this toolchain supports (reads ≤ ${CURRENT_MANIFEST_SCHEMA_VERSION}). This manifest requires a newer @hexagen-monaco/sync — upgrade it. (Upgrading is always safe: a newer toolchain reads every older manifest, and \`hexagen manifest migrate\` brings one forward on demand.)`);
5052
- }
5053
- }
5054
-
5055
- // ../project-configuration/dist/domain/model/manifest-schema/is-index-manifest.js
5056
- function isIndexManifest(parsed) {
5057
- if (typeof parsed !== "object" || parsed === null) {
5058
- return false;
5059
- }
5060
- const record = parsed;
5061
- if (record.version !== "2.0") {
5062
- return false;
5063
- }
5064
- const contexts = record.bounded_contexts;
5065
- if (!Array.isArray(contexts)) {
5066
- return false;
5067
- }
5068
- return contexts.some((entry) => typeof entry === "object" && entry !== null && typeof entry.file === "string");
5069
- }
5070
- var WorkspaceGovernanceSchema = z.object({
5071
- workspaceName: z.string().min(1, "Workspace name is required"),
5072
- workspaceTemplate: z.enum(["modular-monolith", "strict-enterprise", "micro-frontend"]).default("modular-monolith"),
5073
- workspaceDescription: z.string().optional(),
5074
- packageManager: z.enum(["yarn", "pnpm", "bun"]).default("yarn"),
5075
- topologyStrictness: z.enum(["strict", "flexible"]).default("flexible"),
5076
- namespacePrefix: z.string().default("@hexagen"),
5077
- namingConventions: z.object({
5078
- contextDirectoryPattern: z.string().default("packages/"),
5079
- adapterSuffix: z.string().default(".adapter.ts")
5080
- }).default({
5081
- contextDirectoryPattern: "packages/",
5082
- adapterSuffix: ".adapter.ts"
5083
- })
5084
- });
5085
- var PortConfigurationSchema = z.object({
5086
- inboundPorts: z.array(z.enum([
5087
- "rest-controller",
5088
- "graphql-resolver",
5089
- "event-listener",
5090
- "cli-command"
5091
- ])).default([]),
5092
- outboundPorts: z.array(z.enum([
5093
- "relational-db",
5094
- "document-db",
5095
- "external-service-client",
5096
- "message-publisher"
5097
- ])).default([])
5098
- });
5099
- var PeerContextMappingSchema = z.object({
5100
- consumerContext: z.string(),
5101
- providerContext: z.string(),
5102
- integrationPattern: z.enum(["open-host", "acl"]),
5103
- communicationBoundary: z.enum(["in-process", "networked"])
5104
- });
5105
- var BoundedContextSchema2 = z.object({
5106
- id: z.string(),
5107
- name: z.string().min(1, "Please enter a name for this bounded context (e.g., 'UserService', 'OrderProcessing')"),
5108
- description: z.string().optional(),
5109
- // ADR-0041: `infrastructureTarget` (API backend) and `uiFramework` (below)
5110
- // are PROJECT-LEVEL choices managed by the wizard's Applications step, which
5111
- // fans a single selection out to every context. They persist per-context (the
5112
- // source of truth `deriveApps` reads), but are NOT direct per-context input —
5113
- // do not re-add per-context UI/API editing without revisiting ADR-0041.
5114
- // `"none"` = the project opts out of a separate API backend (UI-only, e.g. a
5115
- // Next.js app with built-in routes); `deriveApps` then emits no `api` app.
5116
- // Distinct from `undefined` (legacy/unset → defaults to the preset).
5117
- infrastructureTarget: z.enum(["nestjs", "express", "serverless", "plain-ts", "nitro", "none"]).optional(),
5118
- coreDomainEntities: z.array(z.string()).default([]),
5119
- valueObjects: z.array(z.string()).default([]),
5120
- domainEvents: z.array(z.string()).default([]),
5121
- portConfiguration: PortConfigurationSchema,
5122
- // Backward compatibility: support legacy fields
5123
- apiFramework: z.enum(["Fastify", "Express", "NestJS"]).optional(),
5124
- uiFramework: z.enum(["", "Next.js", "React Router", "Remix", "Angular", "Vue.js"]).optional().default(""),
5125
- persistenceAdapter: z.enum(["", "Prisma", "TypeORM", "Mongoose", "Drizzle"]).optional().default(""),
5126
- messagingAdapter: z.enum(["", "BullMQ", "Temporal", "RabbitMQ"]).optional().default(""),
5127
- telemetryProvider: z.enum(["", "OpenTelemetry", "None", "Prometheus", "Winston"]).optional().default(""),
5128
- externalApiPorts: z.array(z.string()).optional(),
5129
- llmProviders: z.array(z.string()).optional(),
5130
- blockchainNetworks: z.array(z.string()).optional(),
5131
- authenticationProvider: z.string().optional(),
5132
- emailService: z.string().optional(),
5133
- paymentGateway: z.string().optional(),
5134
- storageProvider: z.string().optional(),
5135
- searchService: z.string().optional(),
5136
- webhookEndpoints: z.array(z.string()).optional(),
5137
- entities: z.array(z.string()).optional(),
5138
- useCases: z.array(z.string()).optional()
5139
- });
5140
- var ExternalContextSchema = z.object({
5141
- id: z.string(),
5142
- name: z.string().min(1, "Peer context name is required"),
5143
- relationshipType: z.enum(["U", "D", "ACL", "SK", "P", "OHS"]),
5144
- isEventDriven: z.boolean().optional(),
5145
- entityNames: z.array(z.string()).optional(),
5146
- useCaseNames: z.array(z.string()).optional()
5147
- });
5148
- z.object({
5149
- boundedContexts: z.array(BoundedContextSchema2).default([]),
5150
- externalContexts: z.array(ExternalContextSchema).default([]),
5151
- governance: WorkspaceGovernanceSchema.default({
5152
- workspaceName: "@hexagen",
5153
- workspaceTemplate: "modular-monolith",
5154
- packageManager: "yarn",
5155
- topologyStrictness: "flexible",
5156
- namespacePrefix: "@hexagen",
5157
- namingConventions: {
5158
- contextDirectoryPattern: "packages/",
5159
- adapterSuffix: ".adapter.ts"
5160
- }
5161
- }),
5162
- peerMappings: z.array(PeerContextMappingSchema).default([]),
5163
- /**
5164
- * Per-template install-time answers collected by the wizard. Keyed by
5165
- * template id; each value is a record of question-id → answer. The CLI
5166
- * use case consumes this via its `overrideAnswers` parameter, so the
5167
- * wizard can feed answers gathered in the UI directly into a non-
5168
- * interactive install. Defaults to an empty object for projects that
5169
- * are scaffolded without the per-template questions step.
5170
- */
5171
- addOnsAnswers: z.record(z.string(), z.record(z.string(), z.union([z.string(), z.boolean(), z.array(z.string())]))).default({}),
5172
- /**
5173
- * Provenance of the project's `manifestYaml` (import round-trip integrity,
5174
- * Item 1). `"imported"` = the manifest is the source of truth (accepted via
5175
- * `parseManifestToWizardData` — file import or AI generation) and the wizard
5176
- * projection (`wizardToManifest`) is LOSSY for it, so autosave/export paths
5177
- * must never overwrite or impersonate the stored manifest. Deliberately
5178
- * `.optional()` rather than `.default("wizard")`: absent ≡ `"wizard"`
5179
- * everywhere (guards key on `=== "imported"` only), which keeps every
5180
- * wizard-authored formState byte-identical to before this field existed and
5181
- * lets the load perimeter distinguish "legacy record, provenance unknown"
5182
- * (absent) from an explicit value when running its one-time discriminator.
5183
- */
5184
- manifestSource: z.enum(["wizard", "imported"]).optional()
5185
- });
5186
- var MonorepoConfigSchema = z.object({
5187
- packageManager: z.string().optional(),
5188
- workspaces: z.array(z.string()).optional(),
5189
- rootFiles: z.record(z.unknown()).optional(),
5190
- archInvariants: z.record(z.unknown()).optional()
5191
- }).passthrough();
5192
- var GeneratorSyncSchema = z.object({
5193
- layers: z.record(z.unknown()).optional(),
5194
- packageJson: z.record(z.unknown()).optional(),
5195
- stubs: z.record(z.unknown()).optional(),
5196
- apps: z.record(z.unknown()).optional()
5197
- }).passthrough();
5198
- var GeneratorConfigSchema = z.object({
5199
- version: z.string().optional(),
5200
- sync: GeneratorSyncSchema.optional()
5201
- }).passthrough();
5202
- var WorkspaceConfigSchema = z.object({
5203
- monorepo: MonorepoConfigSchema.optional(),
5204
- generator: GeneratorConfigSchema.optional(),
5205
- workspaceDefaults: z.record(z.unknown()).optional(),
5206
- tsConfigRoot: z.record(z.unknown()).optional(),
5207
- eslint: z.record(z.unknown()).optional(),
5208
- rootFiles: z.record(z.unknown()).optional(),
5209
- generatorConfig: z.record(z.unknown()).optional(),
5210
- turboConfig: z.record(z.unknown()).optional()
5211
- }).passthrough();
5212
5241
  function assertPathWithinArchitecture(workspaceRoot, relativePath) {
5213
5242
  const resolved = path7.resolve(workspaceRoot, ".architecture", relativePath);
5214
5243
  const archRoot = path7.resolve(workspaceRoot, ".architecture");