@elevasis/sdk 1.29.0 → 1.30.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 (41) hide show
  1. package/dist/cli.cjs +1608 -594
  2. package/dist/index.d.ts +87 -1
  3. package/dist/index.js +30 -25
  4. package/dist/node/index.d.ts +84 -1
  5. package/dist/test-utils/index.d.ts +84 -1
  6. package/dist/test-utils/index.js +242 -23
  7. package/dist/worker/index.js +1 -0
  8. package/package.json +2 -2
  9. package/reference/claude-config/rules/topbar-actions.md +70 -0
  10. package/reference/claude-config/skills/om/SKILL.md +18 -1
  11. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  12. package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +45 -45
  13. package/reference/claude-config/sync-notes/2026-05-15-om-skill-rename-and-write-family.md +52 -52
  14. package/reference/claude-config/sync-notes/2026-05-17-sdk-boundary-consolidation.md +33 -33
  15. package/reference/claude-config/sync-notes/2026-05-20-om-define-helpers.md +32 -32
  16. package/reference/claude-config/sync-notes/2026-05-22-access-model-and-right-panel.md +43 -43
  17. package/reference/claude-config/sync-notes/2026-05-22-lead-gen-tenant-config.md +40 -40
  18. package/reference/claude-config/sync-notes/2026-05-22-org-model-multi-file-split.md +61 -61
  19. package/reference/claude-config/sync-notes/2026-05-23-branding-names-to-identity.md +49 -49
  20. package/reference/claude-config/sync-notes/2026-05-23-lead-gen-manage-access.md +31 -31
  21. package/reference/claude-config/sync-notes/2026-05-23-om-deployment-drift-detection.md +42 -42
  22. package/reference/claude-config/sync-notes/2026-05-23-om-full-model-deploy-contract.md +33 -33
  23. package/reference/claude-config/sync-notes/2026-05-23-ui-sdk-package-fixes.md +37 -37
  24. package/reference/claude-config/sync-notes/2026-05-24-platform-invite-router-core-baseline.md +28 -28
  25. package/reference/claude-config/sync-notes/2026-05-24-system-interface-readiness.md +43 -43
  26. package/reference/claude-config/sync-notes/2026-05-25-invitation-login-loader.md +26 -0
  27. package/reference/claude-config/sync-notes/2026-05-25-om-topbar-requests.md +33 -0
  28. package/reference/claude-config/sync-notes/2026-05-25-system-interface-profile-registry-and-substrate.md +35 -0
  29. package/reference/claude-config/sync-notes/2026-05-25-tenant-om-scaffold-cli.md +49 -0
  30. package/reference/claude-config/sync-notes/2026-05-25-vibe-operate-intent.md +47 -0
  31. package/reference/examples/organization-model.ts +18 -0
  32. package/reference/rules/organization-model.md +4 -1
  33. package/reference/rules/organization-os.md +7 -1
  34. package/reference/rules/ui.md +207 -207
  35. package/reference/rules/vibe.md +52 -18
  36. package/reference/scaffold/index.mdx +9 -7
  37. package/reference/scaffold/operations/scaffold-maintenance.md +14 -4
  38. package/reference/scaffold/reference/contracts.md +423 -338
  39. package/reference/scaffold/reference/glossary.md +14 -2
  40. package/reference/scaffold/reference/system-interface-capabilities.md +50 -0
  41. /package/reference/claude-config/skills/deploy/{skill.md → SKILL.md} +0 -0
package/dist/cli.cjs CHANGED
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
9
12
  var __commonJS = (cb, mod) => function __require() {
10
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
14
  };
@@ -104,7 +107,7 @@ var require_main = __commonJS({
104
107
  "../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
105
108
  var fs2 = require("fs");
106
109
  var path3 = require("path");
107
- var os2 = require("os");
110
+ var os3 = require("os");
108
111
  var crypto = require("crypto");
109
112
  var packageJson = require_package();
110
113
  var version2 = packageJson.version;
@@ -227,7 +230,7 @@ var require_main = __commonJS({
227
230
  return null;
228
231
  }
229
232
  function _resolveHome(envPath2) {
230
- return envPath2[0] === "~" ? path3.join(os2.homedir(), envPath2.slice(1)) : envPath2;
233
+ return envPath2[0] === "~" ? path3.join(os3.homedir(), envPath2.slice(1)) : envPath2;
231
234
  }
232
235
  function _configVault(options) {
233
236
  const debug = Boolean(options && options.debug);
@@ -3127,6 +3130,522 @@ var require_commander = __commonJS({
3127
3130
  }
3128
3131
  });
3129
3132
 
3133
+ // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
3134
+ function assembleStyles() {
3135
+ const codes = /* @__PURE__ */ new Map();
3136
+ for (const [groupName, group] of Object.entries(styles)) {
3137
+ for (const [styleName, style] of Object.entries(group)) {
3138
+ styles[styleName] = {
3139
+ open: `\x1B[${style[0]}m`,
3140
+ close: `\x1B[${style[1]}m`
3141
+ };
3142
+ group[styleName] = styles[styleName];
3143
+ codes.set(style[0], style[1]);
3144
+ }
3145
+ Object.defineProperty(styles, groupName, {
3146
+ value: group,
3147
+ enumerable: false
3148
+ });
3149
+ }
3150
+ Object.defineProperty(styles, "codes", {
3151
+ value: codes,
3152
+ enumerable: false
3153
+ });
3154
+ styles.color.close = "\x1B[39m";
3155
+ styles.bgColor.close = "\x1B[49m";
3156
+ styles.color.ansi = wrapAnsi16();
3157
+ styles.color.ansi256 = wrapAnsi256();
3158
+ styles.color.ansi16m = wrapAnsi16m();
3159
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
3160
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
3161
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
3162
+ Object.defineProperties(styles, {
3163
+ rgbToAnsi256: {
3164
+ value(red, green, blue) {
3165
+ if (red === green && green === blue) {
3166
+ if (red < 8) {
3167
+ return 16;
3168
+ }
3169
+ if (red > 248) {
3170
+ return 231;
3171
+ }
3172
+ return Math.round((red - 8) / 247 * 24) + 232;
3173
+ }
3174
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
3175
+ },
3176
+ enumerable: false
3177
+ },
3178
+ hexToRgb: {
3179
+ value(hex3) {
3180
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex3.toString(16));
3181
+ if (!matches) {
3182
+ return [0, 0, 0];
3183
+ }
3184
+ let [colorString] = matches;
3185
+ if (colorString.length === 3) {
3186
+ colorString = [...colorString].map((character) => character + character).join("");
3187
+ }
3188
+ const integer2 = Number.parseInt(colorString, 16);
3189
+ return [
3190
+ /* eslint-disable no-bitwise */
3191
+ integer2 >> 16 & 255,
3192
+ integer2 >> 8 & 255,
3193
+ integer2 & 255
3194
+ /* eslint-enable no-bitwise */
3195
+ ];
3196
+ },
3197
+ enumerable: false
3198
+ },
3199
+ hexToAnsi256: {
3200
+ value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
3201
+ enumerable: false
3202
+ },
3203
+ ansi256ToAnsi: {
3204
+ value(code) {
3205
+ if (code < 8) {
3206
+ return 30 + code;
3207
+ }
3208
+ if (code < 16) {
3209
+ return 90 + (code - 8);
3210
+ }
3211
+ let red;
3212
+ let green;
3213
+ let blue;
3214
+ if (code >= 232) {
3215
+ red = ((code - 232) * 10 + 8) / 255;
3216
+ green = red;
3217
+ blue = red;
3218
+ } else {
3219
+ code -= 16;
3220
+ const remainder = code % 36;
3221
+ red = Math.floor(code / 36) / 5;
3222
+ green = Math.floor(remainder / 6) / 5;
3223
+ blue = remainder % 6 / 5;
3224
+ }
3225
+ const value = Math.max(red, green, blue) * 2;
3226
+ if (value === 0) {
3227
+ return 30;
3228
+ }
3229
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
3230
+ if (value === 2) {
3231
+ result += 60;
3232
+ }
3233
+ return result;
3234
+ },
3235
+ enumerable: false
3236
+ },
3237
+ rgbToAnsi: {
3238
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
3239
+ enumerable: false
3240
+ },
3241
+ hexToAnsi: {
3242
+ value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
3243
+ enumerable: false
3244
+ }
3245
+ });
3246
+ return styles;
3247
+ }
3248
+ var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
3249
+ var init_ansi_styles = __esm({
3250
+ "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
3251
+ ANSI_BACKGROUND_OFFSET = 10;
3252
+ wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
3253
+ wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
3254
+ wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
3255
+ styles = {
3256
+ modifier: {
3257
+ reset: [0, 0],
3258
+ // 21 isn't widely supported and 22 does the same thing
3259
+ bold: [1, 22],
3260
+ dim: [2, 22],
3261
+ italic: [3, 23],
3262
+ underline: [4, 24],
3263
+ overline: [53, 55],
3264
+ inverse: [7, 27],
3265
+ hidden: [8, 28],
3266
+ strikethrough: [9, 29]
3267
+ },
3268
+ color: {
3269
+ black: [30, 39],
3270
+ red: [31, 39],
3271
+ green: [32, 39],
3272
+ yellow: [33, 39],
3273
+ blue: [34, 39],
3274
+ magenta: [35, 39],
3275
+ cyan: [36, 39],
3276
+ white: [37, 39],
3277
+ // Bright color
3278
+ blackBright: [90, 39],
3279
+ gray: [90, 39],
3280
+ // Alias of `blackBright`
3281
+ grey: [90, 39],
3282
+ // Alias of `blackBright`
3283
+ redBright: [91, 39],
3284
+ greenBright: [92, 39],
3285
+ yellowBright: [93, 39],
3286
+ blueBright: [94, 39],
3287
+ magentaBright: [95, 39],
3288
+ cyanBright: [96, 39],
3289
+ whiteBright: [97, 39]
3290
+ },
3291
+ bgColor: {
3292
+ bgBlack: [40, 49],
3293
+ bgRed: [41, 49],
3294
+ bgGreen: [42, 49],
3295
+ bgYellow: [43, 49],
3296
+ bgBlue: [44, 49],
3297
+ bgMagenta: [45, 49],
3298
+ bgCyan: [46, 49],
3299
+ bgWhite: [47, 49],
3300
+ // Bright color
3301
+ bgBlackBright: [100, 49],
3302
+ bgGray: [100, 49],
3303
+ // Alias of `bgBlackBright`
3304
+ bgGrey: [100, 49],
3305
+ // Alias of `bgBlackBright`
3306
+ bgRedBright: [101, 49],
3307
+ bgGreenBright: [102, 49],
3308
+ bgYellowBright: [103, 49],
3309
+ bgBlueBright: [104, 49],
3310
+ bgMagentaBright: [105, 49],
3311
+ bgCyanBright: [106, 49],
3312
+ bgWhiteBright: [107, 49]
3313
+ }
3314
+ };
3315
+ modifierNames = Object.keys(styles.modifier);
3316
+ foregroundColorNames = Object.keys(styles.color);
3317
+ backgroundColorNames = Object.keys(styles.bgColor);
3318
+ colorNames = [...foregroundColorNames, ...backgroundColorNames];
3319
+ ansiStyles = assembleStyles();
3320
+ ansi_styles_default = ansiStyles;
3321
+ }
3322
+ });
3323
+
3324
+ // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
3325
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
3326
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
3327
+ const position = argv.indexOf(prefix + flag);
3328
+ const terminatorPosition = argv.indexOf("--");
3329
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
3330
+ }
3331
+ function envForceColor() {
3332
+ if ("FORCE_COLOR" in env) {
3333
+ if (env.FORCE_COLOR === "true") {
3334
+ return 1;
3335
+ }
3336
+ if (env.FORCE_COLOR === "false") {
3337
+ return 0;
3338
+ }
3339
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
3340
+ }
3341
+ }
3342
+ function translateLevel(level) {
3343
+ if (level === 0) {
3344
+ return false;
3345
+ }
3346
+ return {
3347
+ level,
3348
+ hasBasic: true,
3349
+ has256: level >= 2,
3350
+ has16m: level >= 3
3351
+ };
3352
+ }
3353
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
3354
+ const noFlagForceColor = envForceColor();
3355
+ if (noFlagForceColor !== void 0) {
3356
+ flagForceColor = noFlagForceColor;
3357
+ }
3358
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
3359
+ if (forceColor === 0) {
3360
+ return 0;
3361
+ }
3362
+ if (sniffFlags) {
3363
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
3364
+ return 3;
3365
+ }
3366
+ if (hasFlag("color=256")) {
3367
+ return 2;
3368
+ }
3369
+ }
3370
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
3371
+ return 1;
3372
+ }
3373
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
3374
+ return 0;
3375
+ }
3376
+ const min = forceColor || 0;
3377
+ if (env.TERM === "dumb") {
3378
+ return min;
3379
+ }
3380
+ if (import_node_process.default.platform === "win32") {
3381
+ const osRelease = import_node_os.default.release().split(".");
3382
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
3383
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
3384
+ }
3385
+ return 1;
3386
+ }
3387
+ if ("CI" in env) {
3388
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
3389
+ return 3;
3390
+ }
3391
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
3392
+ return 1;
3393
+ }
3394
+ return min;
3395
+ }
3396
+ if ("TEAMCITY_VERSION" in env) {
3397
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
3398
+ }
3399
+ if (env.COLORTERM === "truecolor") {
3400
+ return 3;
3401
+ }
3402
+ if (env.TERM === "xterm-kitty") {
3403
+ return 3;
3404
+ }
3405
+ if (env.TERM === "xterm-ghostty") {
3406
+ return 3;
3407
+ }
3408
+ if (env.TERM === "wezterm") {
3409
+ return 3;
3410
+ }
3411
+ if ("TERM_PROGRAM" in env) {
3412
+ const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
3413
+ switch (env.TERM_PROGRAM) {
3414
+ case "iTerm.app": {
3415
+ return version2 >= 3 ? 3 : 2;
3416
+ }
3417
+ case "Apple_Terminal": {
3418
+ return 2;
3419
+ }
3420
+ }
3421
+ }
3422
+ if (/-256(color)?$/i.test(env.TERM)) {
3423
+ return 2;
3424
+ }
3425
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
3426
+ return 1;
3427
+ }
3428
+ if ("COLORTERM" in env) {
3429
+ return 1;
3430
+ }
3431
+ return min;
3432
+ }
3433
+ function createSupportsColor(stream, options = {}) {
3434
+ const level = _supportsColor(stream, {
3435
+ streamIsTTY: stream && stream.isTTY,
3436
+ ...options
3437
+ });
3438
+ return translateLevel(level);
3439
+ }
3440
+ var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
3441
+ var init_supports_color = __esm({
3442
+ "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js"() {
3443
+ import_node_process = __toESM(require("node:process"), 1);
3444
+ import_node_os = __toESM(require("node:os"), 1);
3445
+ import_node_tty = __toESM(require("node:tty"), 1);
3446
+ ({ env } = import_node_process.default);
3447
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
3448
+ flagForceColor = 0;
3449
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
3450
+ flagForceColor = 1;
3451
+ }
3452
+ supportsColor = {
3453
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
3454
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
3455
+ };
3456
+ supports_color_default = supportsColor;
3457
+ }
3458
+ });
3459
+
3460
+ // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
3461
+ function stringReplaceAll(string4, substring, replacer) {
3462
+ let index = string4.indexOf(substring);
3463
+ if (index === -1) {
3464
+ return string4;
3465
+ }
3466
+ const substringLength = substring.length;
3467
+ let endIndex = 0;
3468
+ let returnValue = "";
3469
+ do {
3470
+ returnValue += string4.slice(endIndex, index) + substring + replacer;
3471
+ endIndex = index + substringLength;
3472
+ index = string4.indexOf(substring, endIndex);
3473
+ } while (index !== -1);
3474
+ returnValue += string4.slice(endIndex);
3475
+ return returnValue;
3476
+ }
3477
+ function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
3478
+ let endIndex = 0;
3479
+ let returnValue = "";
3480
+ do {
3481
+ const gotCR = string4[index - 1] === "\r";
3482
+ returnValue += string4.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
3483
+ endIndex = index + 1;
3484
+ index = string4.indexOf("\n", endIndex);
3485
+ } while (index !== -1);
3486
+ returnValue += string4.slice(endIndex);
3487
+ return returnValue;
3488
+ }
3489
+ var init_utilities = __esm({
3490
+ "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js"() {
3491
+ }
3492
+ });
3493
+
3494
+ // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
3495
+ function createChalk(options) {
3496
+ return chalkFactory(options);
3497
+ }
3498
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
3499
+ var init_source = __esm({
3500
+ "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js"() {
3501
+ init_ansi_styles();
3502
+ init_supports_color();
3503
+ init_utilities();
3504
+ ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
3505
+ GENERATOR = Symbol("GENERATOR");
3506
+ STYLER = Symbol("STYLER");
3507
+ IS_EMPTY = Symbol("IS_EMPTY");
3508
+ levelMapping = [
3509
+ "ansi",
3510
+ "ansi",
3511
+ "ansi256",
3512
+ "ansi16m"
3513
+ ];
3514
+ styles2 = /* @__PURE__ */ Object.create(null);
3515
+ applyOptions = (object2, options = {}) => {
3516
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
3517
+ throw new Error("The `level` option should be an integer from 0 to 3");
3518
+ }
3519
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
3520
+ object2.level = options.level === void 0 ? colorLevel : options.level;
3521
+ };
3522
+ chalkFactory = (options) => {
3523
+ const chalk2 = (...strings) => strings.join(" ");
3524
+ applyOptions(chalk2, options);
3525
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
3526
+ return chalk2;
3527
+ };
3528
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
3529
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
3530
+ styles2[styleName] = {
3531
+ get() {
3532
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
3533
+ Object.defineProperty(this, styleName, { value: builder });
3534
+ return builder;
3535
+ }
3536
+ };
3537
+ }
3538
+ styles2.visible = {
3539
+ get() {
3540
+ const builder = createBuilder(this, this[STYLER], true);
3541
+ Object.defineProperty(this, "visible", { value: builder });
3542
+ return builder;
3543
+ }
3544
+ };
3545
+ getModelAnsi = (model, level, type, ...arguments_) => {
3546
+ if (model === "rgb") {
3547
+ if (level === "ansi16m") {
3548
+ return ansi_styles_default[type].ansi16m(...arguments_);
3549
+ }
3550
+ if (level === "ansi256") {
3551
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
3552
+ }
3553
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
3554
+ }
3555
+ if (model === "hex") {
3556
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
3557
+ }
3558
+ return ansi_styles_default[type][model](...arguments_);
3559
+ };
3560
+ usedModels = ["rgb", "hex", "ansi256"];
3561
+ for (const model of usedModels) {
3562
+ styles2[model] = {
3563
+ get() {
3564
+ const { level } = this;
3565
+ return function(...arguments_) {
3566
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
3567
+ return createBuilder(this, styler, this[IS_EMPTY]);
3568
+ };
3569
+ }
3570
+ };
3571
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
3572
+ styles2[bgModel] = {
3573
+ get() {
3574
+ const { level } = this;
3575
+ return function(...arguments_) {
3576
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
3577
+ return createBuilder(this, styler, this[IS_EMPTY]);
3578
+ };
3579
+ }
3580
+ };
3581
+ }
3582
+ proto = Object.defineProperties(() => {
3583
+ }, {
3584
+ ...styles2,
3585
+ level: {
3586
+ enumerable: true,
3587
+ get() {
3588
+ return this[GENERATOR].level;
3589
+ },
3590
+ set(level) {
3591
+ this[GENERATOR].level = level;
3592
+ }
3593
+ }
3594
+ });
3595
+ createStyler = (open, close, parent) => {
3596
+ let openAll;
3597
+ let closeAll;
3598
+ if (parent === void 0) {
3599
+ openAll = open;
3600
+ closeAll = close;
3601
+ } else {
3602
+ openAll = parent.openAll + open;
3603
+ closeAll = close + parent.closeAll;
3604
+ }
3605
+ return {
3606
+ open,
3607
+ close,
3608
+ openAll,
3609
+ closeAll,
3610
+ parent
3611
+ };
3612
+ };
3613
+ createBuilder = (self2, _styler, _isEmpty) => {
3614
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
3615
+ Object.setPrototypeOf(builder, proto);
3616
+ builder[GENERATOR] = self2;
3617
+ builder[STYLER] = _styler;
3618
+ builder[IS_EMPTY] = _isEmpty;
3619
+ return builder;
3620
+ };
3621
+ applyStyle = (self2, string4) => {
3622
+ if (self2.level <= 0 || !string4) {
3623
+ return self2[IS_EMPTY] ? "" : string4;
3624
+ }
3625
+ let styler = self2[STYLER];
3626
+ if (styler === void 0) {
3627
+ return string4;
3628
+ }
3629
+ const { openAll, closeAll } = styler;
3630
+ if (string4.includes("\x1B")) {
3631
+ while (styler !== void 0) {
3632
+ string4 = stringReplaceAll(string4, styler.close, styler.open);
3633
+ styler = styler.parent;
3634
+ }
3635
+ }
3636
+ const lfIndex = string4.indexOf("\n");
3637
+ if (lfIndex !== -1) {
3638
+ string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
3639
+ }
3640
+ return openAll + string4 + closeAll;
3641
+ };
3642
+ Object.defineProperties(createChalk.prototype, styles2);
3643
+ chalk = createChalk();
3644
+ chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
3645
+ source_default = chalk;
3646
+ }
3647
+ });
3648
+
3130
3649
  // ../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js
3131
3650
  var require_mimic_fn = __commonJS({
3132
3651
  "../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js"(exports2, module2) {
@@ -5246,7 +5765,7 @@ var require_buffer_list = __commonJS({
5246
5765
  }
5247
5766
  }, {
5248
5767
  key: "join",
5249
- value: function join7(s) {
5768
+ value: function join13(s) {
5250
5769
  if (this.length === 0) return "";
5251
5770
  var p = this.head;
5252
5771
  var ret = "" + p.data;
@@ -23005,530 +23524,945 @@ var require_zod = __commonJS({
23005
23524
  }
23006
23525
  });
23007
23526
 
23008
- // src/cli/index.ts
23009
- var index_exports = {};
23010
- __export(index_exports, {
23011
- getProjectRoot: () => getProjectRoot
23527
+ // src/cli/config.ts
23528
+ function resolveApiUrl(cliOverride, prod) {
23529
+ if (cliOverride) return cliOverride;
23530
+ if (prod) return PROD_API_URL;
23531
+ if (process.env.ELEVASIS_API_URL) return process.env.ELEVASIS_API_URL;
23532
+ if (process.env.NODE_ENV === "development") return DEV_API_URL;
23533
+ return PROD_API_URL;
23534
+ }
23535
+ function resolveEnvironment(prod) {
23536
+ if (prod) return "production";
23537
+ return process.env.NODE_ENV === "development" ? "development" : "production";
23538
+ }
23539
+ function resolveApiKey(prod) {
23540
+ if (!prod && process.env.NODE_ENV === "development") {
23541
+ return process.env.ELEVASIS_PLATFORM_KEY_DEV ?? process.env.ELEVASIS_PLATFORM_KEY ?? "";
23542
+ }
23543
+ return process.env.ELEVASIS_PLATFORM_KEY ?? "";
23544
+ }
23545
+ function tryFindProjectRoot(startDir) {
23546
+ const raw = (0, import_path.resolve)(startDir);
23547
+ let dir;
23548
+ try {
23549
+ dir = (0, import_fs.realpathSync)(raw);
23550
+ } catch {
23551
+ dir = raw;
23552
+ }
23553
+ while (true) {
23554
+ if ((0, import_fs.existsSync)((0, import_path.join)(dir, ".elevasis"))) return dir;
23555
+ const parent = (0, import_path.dirname)(dir);
23556
+ if (parent === dir) break;
23557
+ dir = parent;
23558
+ }
23559
+ return null;
23560
+ }
23561
+ function findProjectRoot(startDir) {
23562
+ const root = tryFindProjectRoot(startDir);
23563
+ if (root !== null) return root;
23564
+ process.stderr.write(
23565
+ "Not inside an Elevasis project. Run this command from a project directory (an Elevasis project has a .elevasis file at its root).\n"
23566
+ );
23567
+ process.exit(1);
23568
+ }
23569
+ function isHelpOrVersionOnly() {
23570
+ const args = process.argv.slice(2);
23571
+ return args.length > 0 && args.every((a) => ["--help", "-h", "--version", "-V"].includes(a));
23572
+ }
23573
+ function getProjectRoot() {
23574
+ if (_projectRoot !== void 0) return _projectRoot;
23575
+ _projectRoot = isHelpOrVersionOnly() ? process.cwd() : findProjectRoot(process.cwd());
23576
+ return _projectRoot;
23577
+ }
23578
+ function resolveProjectRelative(relOrAbsPath) {
23579
+ if ((0, import_path.isAbsolute)(relOrAbsPath)) return relOrAbsPath;
23580
+ return (0, import_path.resolve)(getProjectRoot(), relOrAbsPath);
23581
+ }
23582
+ function findEnvFile(_startDir) {
23583
+ const projectRoot = tryFindProjectRoot(process.cwd());
23584
+ if (projectRoot === null) return void 0;
23585
+ const candidate = (0, import_path.join)(projectRoot, ".env");
23586
+ return (0, import_fs.existsSync)(candidate) ? candidate : void 0;
23587
+ }
23588
+ function findPackageRoot(startDir) {
23589
+ const raw = (0, import_path.resolve)(startDir);
23590
+ let dir;
23591
+ try {
23592
+ dir = (0, import_fs.realpathSync)(raw);
23593
+ } catch {
23594
+ dir = raw;
23595
+ }
23596
+ const projectRoot = tryFindProjectRoot(dir);
23597
+ while (true) {
23598
+ if ((0, import_fs.existsSync)((0, import_path.join)(dir, "package.json"))) return dir;
23599
+ const parent = (0, import_path.dirname)(dir);
23600
+ if (parent === dir) break;
23601
+ if (projectRoot !== null && dir === projectRoot) break;
23602
+ dir = parent;
23603
+ }
23604
+ process.stderr.write(
23605
+ "No package.json found between the current directory and the project root.\nRemediation: run this command from inside a package directory (one that contains package.json).\n"
23606
+ );
23607
+ process.exit(1);
23608
+ }
23609
+ function getPackageRoot() {
23610
+ if (_packageRoot !== void 0) return _packageRoot;
23611
+ _packageRoot = isHelpOrVersionOnly() ? process.cwd() : findPackageRoot(process.cwd());
23612
+ return _packageRoot;
23613
+ }
23614
+ function resolvePackageRelative(relOrAbsPath) {
23615
+ if ((0, import_path.isAbsolute)(relOrAbsPath)) return relOrAbsPath;
23616
+ return (0, import_path.resolve)(getPackageRoot(), relOrAbsPath);
23617
+ }
23618
+ var import_fs, import_path, DEV_API_URL, PROD_API_URL, _projectRoot, _packageRoot;
23619
+ var init_config = __esm({
23620
+ "src/cli/config.ts"() {
23621
+ "use strict";
23622
+ import_fs = require("fs");
23623
+ import_path = require("path");
23624
+ DEV_API_URL = "http://localhost:5170";
23625
+ PROD_API_URL = "https://api.elevasis.io";
23626
+ }
23012
23627
  });
23013
- module.exports = __toCommonJS(index_exports);
23014
- var import_dotenv = __toESM(require_main(), 1);
23015
- var import_fs4 = require("fs");
23016
- var import_path4 = require("path");
23017
23628
 
23018
- // ../../node_modules/.pnpm/commander@11.1.0/node_modules/commander/esm.mjs
23019
- var import_index = __toESM(require_commander(), 1);
23020
- var {
23021
- program,
23022
- createCommand,
23023
- createArgument,
23024
- createOption,
23025
- CommanderError,
23026
- InvalidArgumentError,
23027
- InvalidOptionArgumentError,
23028
- // deprecated old name
23029
- Command,
23030
- Argument,
23031
- Option,
23032
- Help
23033
- } = import_index.default;
23629
+ // src/cli/commands/om/project-layout.ts
23630
+ function assertSplitLayout(projectDir) {
23631
+ const omDir = (0, import_node_path7.join)(projectDir, "core", "config", "organization-model");
23632
+ const missing = REQUIRED_FILES.filter((f) => !(0, import_node_fs7.existsSync)((0, import_node_path7.join)(omDir, f)));
23633
+ if (missing.length > 0) {
23634
+ throw new Error(
23635
+ "Legacy single-file OM layout detected. Split into `core/config/organization-model/{profile.ts, systems.ts, navigation.ts}` before scaffolding."
23636
+ );
23637
+ }
23638
+ }
23639
+ var import_node_fs7, import_node_path7, REQUIRED_FILES;
23640
+ var init_project_layout = __esm({
23641
+ "src/cli/commands/om/project-layout.ts"() {
23642
+ "use strict";
23643
+ import_node_fs7 = require("node:fs");
23644
+ import_node_path7 = require("node:path");
23645
+ REQUIRED_FILES = ["profile.ts", "systems.ts", "navigation.ts"];
23646
+ }
23647
+ });
23034
23648
 
23035
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
23036
- var ANSI_BACKGROUND_OFFSET = 10;
23037
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
23038
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
23039
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
23040
- var styles = {
23041
- modifier: {
23042
- reset: [0, 0],
23043
- // 21 isn't widely supported and 22 does the same thing
23044
- bold: [1, 22],
23045
- dim: [2, 22],
23046
- italic: [3, 23],
23047
- underline: [4, 24],
23048
- overline: [53, 55],
23049
- inverse: [7, 27],
23050
- hidden: [8, 28],
23051
- strikethrough: [9, 29]
23052
- },
23053
- color: {
23054
- black: [30, 39],
23055
- red: [31, 39],
23056
- green: [32, 39],
23057
- yellow: [33, 39],
23058
- blue: [34, 39],
23059
- magenta: [35, 39],
23060
- cyan: [36, 39],
23061
- white: [37, 39],
23062
- // Bright color
23063
- blackBright: [90, 39],
23064
- gray: [90, 39],
23065
- // Alias of `blackBright`
23066
- grey: [90, 39],
23067
- // Alias of `blackBright`
23068
- redBright: [91, 39],
23069
- greenBright: [92, 39],
23070
- yellowBright: [93, 39],
23071
- blueBright: [94, 39],
23072
- magentaBright: [95, 39],
23073
- cyanBright: [96, 39],
23074
- whiteBright: [97, 39]
23075
- },
23076
- bgColor: {
23077
- bgBlack: [40, 49],
23078
- bgRed: [41, 49],
23079
- bgGreen: [42, 49],
23080
- bgYellow: [43, 49],
23081
- bgBlue: [44, 49],
23082
- bgMagenta: [45, 49],
23083
- bgCyan: [46, 49],
23084
- bgWhite: [47, 49],
23085
- // Bright color
23086
- bgBlackBright: [100, 49],
23087
- bgGray: [100, 49],
23088
- // Alias of `bgBlackBright`
23089
- bgGrey: [100, 49],
23090
- // Alias of `bgBlackBright`
23091
- bgRedBright: [101, 49],
23092
- bgGreenBright: [102, 49],
23093
- bgYellowBright: [103, 49],
23094
- bgBlueBright: [104, 49],
23095
- bgMagentaBright: [105, 49],
23096
- bgCyanBright: [106, 49],
23097
- bgWhiteBright: [107, 49]
23649
+ // src/cli/commands/om/prompt-helpers.ts
23650
+ async function promptIfAbsent(value, question, options) {
23651
+ if (value !== void 0) return value;
23652
+ if (!process.stdin.isTTY) {
23653
+ return options?.default ?? "";
23098
23654
  }
23099
- };
23100
- var modifierNames = Object.keys(styles.modifier);
23101
- var foregroundColorNames = Object.keys(styles.color);
23102
- var backgroundColorNames = Object.keys(styles.bgColor);
23103
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
23104
- function assembleStyles() {
23105
- const codes = /* @__PURE__ */ new Map();
23106
- for (const [groupName, group] of Object.entries(styles)) {
23107
- for (const [styleName, style] of Object.entries(group)) {
23108
- styles[styleName] = {
23109
- open: `\x1B[${style[0]}m`,
23110
- close: `\x1B[${style[1]}m`
23111
- };
23112
- group[styleName] = styles[styleName];
23113
- codes.set(style[0], style[1]);
23114
- }
23115
- Object.defineProperty(styles, groupName, {
23116
- value: group,
23117
- enumerable: false
23655
+ const rl = readline2.createInterface({
23656
+ input: process.stdin,
23657
+ output: process.stdout
23658
+ });
23659
+ return new Promise((resolve5) => {
23660
+ const prompt = options?.default ? `${question} [${options.default}]: ` : `${question}: `;
23661
+ rl.question(prompt, (answer) => {
23662
+ rl.close();
23663
+ resolve5(answer.trim() || (options?.default ?? ""));
23118
23664
  });
23119
- }
23120
- Object.defineProperty(styles, "codes", {
23121
- value: codes,
23122
- enumerable: false
23123
23665
  });
23124
- styles.color.close = "\x1B[39m";
23125
- styles.bgColor.close = "\x1B[49m";
23126
- styles.color.ansi = wrapAnsi16();
23127
- styles.color.ansi256 = wrapAnsi256();
23128
- styles.color.ansi16m = wrapAnsi16m();
23129
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
23130
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
23131
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
23132
- Object.defineProperties(styles, {
23133
- rgbToAnsi256: {
23134
- value(red, green, blue) {
23135
- if (red === green && green === blue) {
23136
- if (red < 8) {
23137
- return 16;
23138
- }
23139
- if (red > 248) {
23140
- return 231;
23141
- }
23142
- return Math.round((red - 8) / 247 * 24) + 232;
23143
- }
23144
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
23666
+ }
23667
+ var readline2;
23668
+ var init_prompt_helpers = __esm({
23669
+ "src/cli/commands/om/prompt-helpers.ts"() {
23670
+ "use strict";
23671
+ readline2 = __toESM(require("node:readline"), 1);
23672
+ }
23673
+ });
23674
+
23675
+ // src/cli/commands/om/error-map.ts
23676
+ function mapValidationError(stderr) {
23677
+ for (const entry of ERROR_MAP) {
23678
+ if (entry.pattern.test(stderr)) {
23679
+ return entry.friendlyMessage;
23680
+ }
23681
+ }
23682
+ return "Validation failed \u2014 see below. Fix the issue and re-run, or use `om:scaffold:fill` for guided remediation:\n" + stderr;
23683
+ }
23684
+ var ERROR_MAP;
23685
+ var init_error_map = __esm({
23686
+ "src/cli/commands/om/error-map.ts"() {
23687
+ "use strict";
23688
+ ERROR_MAP = [
23689
+ {
23690
+ pattern: /systemPath.*not assignable/i,
23691
+ friendlyMessage: "The system path you entered doesn't match any authored system. Check `templateSystems` in `systems.ts` for valid IDs."
23145
23692
  },
23146
- enumerable: false
23147
- },
23148
- hexToRgb: {
23149
- value(hex3) {
23150
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex3.toString(16));
23151
- if (!matches) {
23152
- return [0, 0, 0];
23153
- }
23154
- let [colorString] = matches;
23155
- if (colorString.length === 3) {
23156
- colorString = [...colorString].map((character) => character + character).join("");
23157
- }
23158
- const integer2 = Number.parseInt(colorString, 16);
23159
- return [
23160
- /* eslint-disable no-bitwise */
23161
- integer2 >> 16 & 255,
23162
- integer2 >> 8 & 255,
23163
- integer2 & 255
23164
- /* eslint-enable no-bitwise */
23165
- ];
23693
+ {
23694
+ pattern: /apiInterface.*required/i,
23695
+ friendlyMessage: "This system is API-backed but is missing the `apiInterface` block. Run `om:scaffold:system --id {path} --api-backed`."
23166
23696
  },
23167
- enumerable: false
23168
- },
23169
- hexToAnsi256: {
23170
- value: (hex3) => styles.rgbToAnsi256(...styles.hexToRgb(hex3)),
23171
- enumerable: false
23172
- },
23173
- ansi256ToAnsi: {
23174
- value(code) {
23175
- if (code < 8) {
23176
- return 30 + code;
23177
- }
23178
- if (code < 16) {
23179
- return 90 + (code - 8);
23180
- }
23181
- let red;
23182
- let green;
23183
- let blue;
23184
- if (code >= 232) {
23185
- red = ((code - 232) * 10 + 8) / 255;
23186
- green = red;
23187
- blue = red;
23188
- } else {
23189
- code -= 16;
23190
- const remainder = code % 36;
23191
- red = Math.floor(code / 36) / 5;
23192
- green = Math.floor(remainder / 6) / 5;
23193
- blue = remainder % 6 / 5;
23194
- }
23195
- const value = Math.max(red, green, blue) * 2;
23196
- if (value === 0) {
23197
- return 30;
23198
- }
23199
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
23200
- if (value === 2) {
23201
- result += 60;
23202
- }
23203
- return result;
23697
+ {
23698
+ pattern: /primaryAction.*not in.*actions/i,
23699
+ friendlyMessage: "The primary action you set is not in the resource's `actions` list. Add it to `resource.ontology.actions` first."
23204
23700
  },
23205
- enumerable: false
23206
- },
23207
- rgbToAnsi: {
23208
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
23209
- enumerable: false
23210
- },
23211
- hexToAnsi: {
23212
- value: (hex3) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex3)),
23213
- enumerable: false
23214
- }
23215
- });
23216
- return styles;
23217
- }
23218
- var ansiStyles = assembleStyles();
23219
- var ansi_styles_default = ansiStyles;
23701
+ {
23702
+ pattern: /ZodError.*required/i,
23703
+ friendlyMessage: "A required field is missing. Run `om:scaffold:fill --system {id}` to see what's needed."
23704
+ },
23705
+ {
23706
+ pattern: /Cannot find module.*organization-model/i,
23707
+ friendlyMessage: "OM config files can't be loaded. Run `pnpm -C operations check-types` directly to see the full TypeScript error."
23708
+ }
23709
+ ];
23710
+ }
23711
+ });
23220
23712
 
23221
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
23222
- var import_node_process = __toESM(require("node:process"), 1);
23223
- var import_node_os = __toESM(require("node:os"), 1);
23224
- var import_node_tty = __toESM(require("node:tty"), 1);
23225
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
23226
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
23227
- const position = argv.indexOf(prefix + flag);
23228
- const terminatorPosition = argv.indexOf("--");
23229
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
23230
- }
23231
- var { env } = import_node_process.default;
23232
- var flagForceColor;
23233
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
23234
- flagForceColor = 0;
23235
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
23236
- flagForceColor = 1;
23713
+ // src/cli/commands/om/emit-system.ts
23714
+ function emitSystemEntry(opts) {
23715
+ const apiInterfaceBlock = opts.apiBacked ? `
23716
+ apiInterface: {
23717
+ lifecycle: 'active',
23718
+ readinessProfile: 'standard',
23719
+ resourceIds: []
23720
+ },` : "";
23721
+ const code = ` {
23722
+ id: '${opts.id}',
23723
+ title: '${opts.title}',
23724
+ kind: '${opts.kind}',
23725
+ enabled: true,
23726
+ governedByKnowledge: [],
23727
+ drivesGoals: [],
23728
+ lifecycle: 'active',${apiInterfaceBlock}
23729
+ },
23730
+ `;
23731
+ const anchor = /^\] as const\s*$/m;
23732
+ return { code, anchor };
23237
23733
  }
23238
- function envForceColor() {
23239
- if ("FORCE_COLOR" in env) {
23240
- if (env.FORCE_COLOR === "true") {
23241
- return 1;
23734
+ var init_emit_system = __esm({
23735
+ "src/cli/commands/om/emit-system.ts"() {
23736
+ "use strict";
23737
+ }
23738
+ });
23739
+
23740
+ // src/cli/commands/om/splice.ts
23741
+ async function withSnapshotRollback(filePaths, op) {
23742
+ const snapshots = /* @__PURE__ */ new Map();
23743
+ for (const filePath of filePaths) {
23744
+ try {
23745
+ snapshots.set(filePath, (0, import_node_fs8.readFileSync)(filePath, "utf8"));
23746
+ } catch {
23747
+ snapshots.set(filePath, null);
23242
23748
  }
23243
- if (env.FORCE_COLOR === "false") {
23244
- return 0;
23749
+ }
23750
+ try {
23751
+ return await op();
23752
+ } catch (err) {
23753
+ for (const [filePath, snapshot] of snapshots) {
23754
+ if (snapshot !== null) {
23755
+ try {
23756
+ (0, import_node_fs8.writeFileSync)(filePath, snapshot, "utf8");
23757
+ } catch {
23758
+ }
23759
+ }
23245
23760
  }
23246
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
23761
+ throw err;
23247
23762
  }
23248
23763
  }
23249
- function translateLevel(level) {
23250
- if (level === 0) {
23251
- return false;
23764
+ function insertBeforeAnchorInContent(content, code, anchor) {
23765
+ const lines = content.split("\n");
23766
+ const anchorIndex = lines.findIndex((line) => anchor.test(line));
23767
+ if (anchorIndex === -1) {
23768
+ throw new Error(
23769
+ `[om:scaffold] Anchor pattern ${anchor} not found in file. The file may have been manually edited. Rollback will restore the original.`
23770
+ );
23252
23771
  }
23253
- return {
23254
- level,
23255
- hasBasic: true,
23256
- has256: level >= 2,
23257
- has16m: level >= 3
23258
- };
23772
+ const codeLines = code.endsWith("\n") ? code.slice(0, -1).split("\n") : code.split("\n");
23773
+ lines.splice(anchorIndex, 0, ...codeLines);
23774
+ return lines.join("\n");
23259
23775
  }
23260
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
23261
- const noFlagForceColor = envForceColor();
23262
- if (noFlagForceColor !== void 0) {
23263
- flagForceColor = noFlagForceColor;
23776
+ async function appendBeforeAnchor(filePath, code, anchor) {
23777
+ const content = (0, import_node_fs8.readFileSync)(filePath, "utf8");
23778
+ const updated = insertBeforeAnchorInContent(content, code, anchor);
23779
+ (0, import_node_fs8.writeFileSync)(filePath, updated, "utf8");
23780
+ }
23781
+ async function applyConstImport(systemsFilePath, importLine, fieldLine, importAnchor, fieldAnchor, newConstFilePath, newConstFileCode) {
23782
+ (0, import_node_fs8.mkdirSync)((0, import_node_path8.dirname)(newConstFilePath), { recursive: true });
23783
+ (0, import_node_fs8.writeFileSync)(newConstFilePath, newConstFileCode, "utf8");
23784
+ const systemsContent = (0, import_node_fs8.readFileSync)(systemsFilePath, "utf8");
23785
+ const afterImport = insertBeforeAnchorInContent(systemsContent, importLine + "\n", importAnchor);
23786
+ const lines = afterImport.split("\n");
23787
+ const fieldAnchorIndex = lines.findIndex((line) => fieldAnchor.test(line));
23788
+ if (fieldAnchorIndex === -1) {
23789
+ throw new Error(
23790
+ `[om:scaffold] Field anchor pattern ${fieldAnchor} not found in ${systemsFilePath}. The system entry may not exist yet. Run om:scaffold:system first.`
23791
+ );
23264
23792
  }
23265
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
23266
- if (forceColor === 0) {
23267
- return 0;
23793
+ lines.splice(fieldAnchorIndex + 1, 0, fieldLine);
23794
+ (0, import_node_fs8.writeFileSync)(systemsFilePath, lines.join("\n"), "utf8");
23795
+ }
23796
+ var import_node_fs8, import_node_path8;
23797
+ var init_splice = __esm({
23798
+ "src/cli/commands/om/splice.ts"() {
23799
+ "use strict";
23800
+ import_node_fs8 = require("node:fs");
23801
+ import_node_path8 = require("node:path");
23268
23802
  }
23269
- if (sniffFlags) {
23270
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
23271
- return 3;
23272
- }
23273
- if (hasFlag("color=256")) {
23274
- return 2;
23803
+ });
23804
+
23805
+ // src/cli/commands/om/scaffold-system.ts
23806
+ var scaffold_system_exports = {};
23807
+ __export(scaffold_system_exports, {
23808
+ default: () => scaffoldSystem
23809
+ });
23810
+ function runValidation(projectDir) {
23811
+ for (const script of ["check-types", "check"]) {
23812
+ const result = (0, import_node_child_process2.spawnSync)("pnpm", ["-C", "operations", "run", script], {
23813
+ cwd: projectDir,
23814
+ encoding: "utf8",
23815
+ shell: true
23816
+ });
23817
+ if (result.status !== 0) {
23818
+ return (result.stderr ?? "") + (result.stdout ?? "");
23275
23819
  }
23276
23820
  }
23277
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
23278
- return 1;
23279
- }
23280
- if (haveStream && !streamIsTTY && forceColor === void 0) {
23281
- return 0;
23282
- }
23283
- const min = forceColor || 0;
23284
- if (env.TERM === "dumb") {
23285
- return min;
23821
+ return null;
23822
+ }
23823
+ async function scaffoldSystem(opts) {
23824
+ const projectDir = getProjectRoot();
23825
+ assertSplitLayout(projectDir);
23826
+ const options = opts;
23827
+ const id = await promptIfAbsent(options.id, "System path (e.g. sales.crm)");
23828
+ if (!id) {
23829
+ process.stderr.write(source_default.red("System path is required. Pass --id <path> or enter it at the prompt.\n"));
23830
+ process.exit(1);
23286
23831
  }
23287
- if (import_node_process.default.platform === "win32") {
23288
- const osRelease = import_node_os.default.release().split(".");
23289
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
23290
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
23291
- }
23292
- return 1;
23832
+ const title = await promptIfAbsent(options.title, "Display title");
23833
+ if (!title) {
23834
+ process.stderr.write(source_default.red("Display title is required. Pass --title <text> or enter it at the prompt.\n"));
23835
+ process.exit(1);
23293
23836
  }
23294
- if ("CI" in env) {
23295
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
23296
- return 3;
23837
+ const rawKind = await promptIfAbsent(
23838
+ options.kind,
23839
+ "Kind (operational / analytical / support)",
23840
+ {
23841
+ default: "operational"
23297
23842
  }
23298
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
23299
- return 1;
23843
+ );
23844
+ const kind = rawKind || "operational";
23845
+ let apiBacked = Boolean(options.apiBacked);
23846
+ if (!apiBacked && process.stdin.isTTY) {
23847
+ const answer = await promptIfAbsent(void 0, "Is this system API-backed? (adds apiInterface) [y/N]", {
23848
+ default: "N"
23849
+ });
23850
+ apiBacked = answer.trim().toLowerCase() === "y";
23851
+ }
23852
+ const { code, anchor } = emitSystemEntry({ id, title, kind, apiBacked });
23853
+ if (options.dryRun) {
23854
+ console.log(source_default.cyan("Dry-run mode \u2014 no files written.\n"));
23855
+ console.log(source_default.gray("Proposed addition to core/config/organization-model/systems.ts:"));
23856
+ console.log(code);
23857
+ if (apiBacked) {
23858
+ console.log(
23859
+ source_default.yellow("Reminder: add resource IDs to the `apiInterface.resourceIds` array after scaffolding resources.")
23860
+ );
23300
23861
  }
23301
- return min;
23862
+ return;
23302
23863
  }
23303
- if ("TEAMCITY_VERSION" in env) {
23304
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
23864
+ const systemsFilePath = (0, import_node_path9.join)(projectDir, "core", "config", "organization-model", "systems.ts");
23865
+ try {
23866
+ await withSnapshotRollback([systemsFilePath], async () => {
23867
+ await appendBeforeAnchor(systemsFilePath, code, anchor);
23868
+ const validationError = runValidation(projectDir);
23869
+ if (validationError !== null) {
23870
+ throw new Error(validationError);
23871
+ }
23872
+ });
23873
+ } catch (err) {
23874
+ const raw = err instanceof Error ? err.message : String(err);
23875
+ process.stderr.write(source_default.red(mapValidationError(raw)) + "\n");
23876
+ process.exit(1);
23305
23877
  }
23306
- if (env.COLORTERM === "truecolor") {
23307
- return 3;
23878
+ console.log(source_default.green(`System \`${id}\` scaffolded in core/config/organization-model/systems.ts`));
23879
+ if (apiBacked) {
23880
+ console.log(
23881
+ source_default.yellow("Reminder: add resource IDs to the `apiInterface.resourceIds` array after scaffolding resources.")
23882
+ );
23308
23883
  }
23309
- if (env.TERM === "xterm-kitty") {
23310
- return 3;
23884
+ }
23885
+ var import_node_path9, import_node_child_process2;
23886
+ var init_scaffold_system = __esm({
23887
+ "src/cli/commands/om/scaffold-system.ts"() {
23888
+ "use strict";
23889
+ import_node_path9 = require("node:path");
23890
+ import_node_child_process2 = require("node:child_process");
23891
+ init_source();
23892
+ init_config();
23893
+ init_project_layout();
23894
+ init_prompt_helpers();
23895
+ init_error_map();
23896
+ init_emit_system();
23897
+ init_splice();
23898
+ }
23899
+ });
23900
+
23901
+ // src/cli/commands/om/emit-resource.ts
23902
+ function emitResourceEntry(opts) {
23903
+ const ontologyBlock = opts.primaryAction !== void 0 ? ` ontology: {
23904
+ actions: ['${opts.primaryAction}'],
23905
+ primaryAction: '${opts.primaryAction}'
23906
+ },
23907
+ ` : ` ontology: {},
23908
+ `;
23909
+ const code = ` '${opts.id}': {
23910
+ id: '${opts.id}',
23911
+ order: 10,
23912
+ kind: 'workflow',
23913
+ systemPath: '${opts.systemPath}',
23914
+ systemId: '${opts.systemPath}',
23915
+ title: '${opts.title}',
23916
+ description: '',
23917
+ status: 'active',
23918
+ ${ontologyBlock} codeRefs: []
23919
+ },
23920
+ `;
23921
+ const anchor = /^export const templateResources\s*=/m;
23922
+ return { code, anchor };
23923
+ }
23924
+ var init_emit_resource = __esm({
23925
+ "src/cli/commands/om/emit-resource.ts"() {
23926
+ "use strict";
23311
23927
  }
23312
- if (env.TERM === "xterm-ghostty") {
23313
- return 3;
23928
+ });
23929
+
23930
+ // src/cli/commands/om/scaffold-resource.ts
23931
+ var scaffold_resource_exports = {};
23932
+ __export(scaffold_resource_exports, {
23933
+ default: () => scaffoldResource
23934
+ });
23935
+ function runValidation2(projectDir) {
23936
+ for (const script of ["check-types", "check"]) {
23937
+ const result = (0, import_node_child_process3.spawnSync)("pnpm", ["-C", "operations", "run", script], {
23938
+ cwd: projectDir,
23939
+ encoding: "utf8",
23940
+ shell: true
23941
+ });
23942
+ if (result.status !== 0) {
23943
+ return (result.stderr ?? "") + (result.stdout ?? "");
23944
+ }
23314
23945
  }
23315
- if (env.TERM === "wezterm") {
23316
- return 3;
23946
+ return null;
23947
+ }
23948
+ async function scaffoldResource(opts) {
23949
+ const projectDir = getProjectRoot();
23950
+ assertSplitLayout(projectDir);
23951
+ const options = opts;
23952
+ const id = await promptIfAbsent(options.id, "Resource id (e.g. lead-discovery-workflow)");
23953
+ if (!id) {
23954
+ process.stderr.write(source_default.red("Resource id is required. Pass --id <id> or enter it at the prompt.\n"));
23955
+ process.exit(1);
23317
23956
  }
23318
- if ("TERM_PROGRAM" in env) {
23319
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
23320
- switch (env.TERM_PROGRAM) {
23321
- case "iTerm.app": {
23322
- return version2 >= 3 ? 3 : 2;
23323
- }
23324
- case "Apple_Terminal": {
23325
- return 2;
23326
- }
23327
- }
23957
+ const systemPath = await promptIfAbsent(
23958
+ options.systemPath,
23959
+ "System path to attach to (e.g. sales.crm)"
23960
+ );
23961
+ if (!systemPath) {
23962
+ process.stderr.write(source_default.red("System path is required. Pass --system-path <path> or enter it at the prompt.\n"));
23963
+ process.exit(1);
23328
23964
  }
23329
- if (/-256(color)?$/i.test(env.TERM)) {
23330
- return 2;
23965
+ const title = await promptIfAbsent(options.title, "Resource display title");
23966
+ if (!title) {
23967
+ process.stderr.write(source_default.red("Display title is required. Pass --title <text> or enter it at the prompt.\n"));
23968
+ process.exit(1);
23331
23969
  }
23332
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
23333
- return 1;
23970
+ const rawPrimaryAction = await promptIfAbsent(
23971
+ options.primaryAction,
23972
+ "Primary action id (leave blank to omit)",
23973
+ { default: "" }
23974
+ );
23975
+ const primaryAction = rawPrimaryAction || void 0;
23976
+ const { code, anchor } = emitResourceEntry({ id, systemPath, title, primaryAction });
23977
+ if (options.dryRun) {
23978
+ console.log(source_default.cyan("Dry-run mode \u2014 no files written.\n"));
23979
+ console.log(source_default.gray("Proposed addition to core/config/organization-model/systems.ts:"));
23980
+ console.log(code);
23981
+ return;
23334
23982
  }
23335
- if ("COLORTERM" in env) {
23336
- return 1;
23983
+ const systemsFilePath = (0, import_node_path10.join)(projectDir, "core", "config", "organization-model", "systems.ts");
23984
+ try {
23985
+ await withSnapshotRollback([systemsFilePath], async () => {
23986
+ await appendBeforeAnchor(systemsFilePath, code, anchor);
23987
+ const validationError = runValidation2(projectDir);
23988
+ if (validationError !== null) {
23989
+ const systemPathHint = /systemPath.*not assignable/i.test(validationError) ? `
23990
+ Resource \`${id}\` references system \`${systemPath}\` which is not in \`templateSystems\`. Run \`om:scaffold:system --id ${systemPath}\` first.` : "";
23991
+ throw new Error(validationError + systemPathHint);
23992
+ }
23993
+ });
23994
+ } catch (err) {
23995
+ const raw = err instanceof Error ? err.message : String(err);
23996
+ process.stderr.write(source_default.red(mapValidationError(raw)) + "\n");
23997
+ process.exit(1);
23337
23998
  }
23338
- return min;
23999
+ console.log(source_default.green(`Resource \`${id}\` scaffolded in core/config/organization-model/systems.ts`));
23339
24000
  }
23340
- function createSupportsColor(stream, options = {}) {
23341
- const level = _supportsColor(stream, {
23342
- streamIsTTY: stream && stream.isTTY,
23343
- ...options
23344
- });
23345
- return translateLevel(level);
24001
+ var import_node_path10, import_node_child_process3;
24002
+ var init_scaffold_resource = __esm({
24003
+ "src/cli/commands/om/scaffold-resource.ts"() {
24004
+ "use strict";
24005
+ import_node_path10 = require("node:path");
24006
+ import_node_child_process3 = require("node:child_process");
24007
+ init_source();
24008
+ init_config();
24009
+ init_project_layout();
24010
+ init_prompt_helpers();
24011
+ init_error_map();
24012
+ init_emit_resource();
24013
+ init_splice();
24014
+ }
24015
+ });
24016
+
24017
+ // src/cli/commands/om/emit-role.ts
24018
+ function emitRoleEntry(opts) {
24019
+ const code = ` {
24020
+ id: '${opts.id}',
24021
+ title: '${opts.title}',
24022
+ description: '${opts.description}'
24023
+ },
24024
+ `;
24025
+ const anchor = /^ {2}\]\s*$/m;
24026
+ return { code, anchor };
23346
24027
  }
23347
- var supportsColor = {
23348
- stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
23349
- stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
23350
- };
23351
- var supports_color_default = supportsColor;
24028
+ var init_emit_role = __esm({
24029
+ "src/cli/commands/om/emit-role.ts"() {
24030
+ "use strict";
24031
+ }
24032
+ });
23352
24033
 
23353
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
23354
- function stringReplaceAll(string4, substring, replacer) {
23355
- let index = string4.indexOf(substring);
23356
- if (index === -1) {
23357
- return string4;
24034
+ // src/cli/commands/om/scaffold-role.ts
24035
+ var scaffold_role_exports = {};
24036
+ __export(scaffold_role_exports, {
24037
+ default: () => scaffoldRole
24038
+ });
24039
+ function runValidation3(projectDir) {
24040
+ for (const script of ["check-types", "check"]) {
24041
+ const result = (0, import_node_child_process4.spawnSync)("pnpm", ["-C", "operations", "run", script], {
24042
+ cwd: projectDir,
24043
+ encoding: "utf8",
24044
+ shell: true
24045
+ });
24046
+ if (result.status !== 0) {
24047
+ return (result.stderr ?? "") + (result.stdout ?? "");
24048
+ }
23358
24049
  }
23359
- const substringLength = substring.length;
23360
- let endIndex = 0;
23361
- let returnValue = "";
23362
- do {
23363
- returnValue += string4.slice(endIndex, index) + substring + replacer;
23364
- endIndex = index + substringLength;
23365
- index = string4.indexOf(substring, endIndex);
23366
- } while (index !== -1);
23367
- returnValue += string4.slice(endIndex);
23368
- return returnValue;
24050
+ return null;
23369
24051
  }
23370
- function stringEncaseCRLFWithFirstIndex(string4, prefix, postfix, index) {
23371
- let endIndex = 0;
23372
- let returnValue = "";
23373
- do {
23374
- const gotCR = string4[index - 1] === "\r";
23375
- returnValue += string4.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
23376
- endIndex = index + 1;
23377
- index = string4.indexOf("\n", endIndex);
23378
- } while (index !== -1);
23379
- returnValue += string4.slice(endIndex);
23380
- return returnValue;
24052
+ async function scaffoldRole(opts) {
24053
+ const projectDir = getProjectRoot();
24054
+ assertSplitLayout(projectDir);
24055
+ const options = opts;
24056
+ const id = await promptIfAbsent(options.id, "Role id (e.g. ops-lead)");
24057
+ if (!id) {
24058
+ process.stderr.write(source_default.red("Role id is required. Pass --id <id> or enter it at the prompt.\n"));
24059
+ process.exit(1);
24060
+ }
24061
+ const title = await promptIfAbsent(options.title, "Display label");
24062
+ if (!title) {
24063
+ process.stderr.write(source_default.red("Display label is required. Pass --title <text> or enter it at the prompt.\n"));
24064
+ process.exit(1);
24065
+ }
24066
+ const description = await promptIfAbsent(options.description, "Short description", {
24067
+ default: ""
24068
+ });
24069
+ const { code, anchor } = emitRoleEntry({ id, title, description: description || "" });
24070
+ if (options.dryRun) {
24071
+ console.log(source_default.cyan("Dry-run mode \u2014 no files written.\n"));
24072
+ console.log(source_default.gray("Proposed addition to core/config/organization-model/profile.ts:"));
24073
+ console.log(code);
24074
+ return;
24075
+ }
24076
+ const profileFilePath = (0, import_node_path11.join)(projectDir, "core", "config", "organization-model", "profile.ts");
24077
+ try {
24078
+ await withSnapshotRollback([profileFilePath], async () => {
24079
+ await appendBeforeAnchor(profileFilePath, code, anchor);
24080
+ const validationError = runValidation3(projectDir);
24081
+ if (validationError !== null) {
24082
+ throw new Error(validationError);
24083
+ }
24084
+ });
24085
+ } catch (err) {
24086
+ const raw = err instanceof Error ? err.message : String(err);
24087
+ process.stderr.write(source_default.red(mapValidationError(raw)) + "\n");
24088
+ process.exit(1);
24089
+ }
24090
+ console.log(source_default.green(`Role \`${id}\` scaffolded in core/config/organization-model/profile.ts`));
24091
+ }
24092
+ var import_node_path11, import_node_child_process4;
24093
+ var init_scaffold_role = __esm({
24094
+ "src/cli/commands/om/scaffold-role.ts"() {
24095
+ "use strict";
24096
+ import_node_path11 = require("node:path");
24097
+ import_node_child_process4 = require("node:child_process");
24098
+ init_source();
24099
+ init_config();
24100
+ init_project_layout();
24101
+ init_prompt_helpers();
24102
+ init_error_map();
24103
+ init_emit_role();
24104
+ init_splice();
24105
+ }
24106
+ });
24107
+
24108
+ // src/cli/commands/om/emit-knowledge.ts
24109
+ function emitKnowledgeNode(opts) {
24110
+ const filePath = `core/config/knowledge/nodes/${opts.id}.mdx`;
24111
+ const systemLine = opts.systemPath !== void 0 ? `
24112
+ system: '${opts.systemPath}'` : "";
24113
+ const updatedAt = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
24114
+ const content = `---
24115
+ id: '${opts.id}'
24116
+ kind: ${opts.kind}
24117
+ title: ''
24118
+ description: ''${systemLine}
24119
+ updatedAt: ${updatedAt}
24120
+ ---
24121
+
24122
+ <!-- Add the content for this knowledge node below. -->
24123
+ `;
24124
+ return { filePath, content };
23381
24125
  }
24126
+ var init_emit_knowledge = __esm({
24127
+ "src/cli/commands/om/emit-knowledge.ts"() {
24128
+ "use strict";
24129
+ }
24130
+ });
23382
24131
 
23383
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
23384
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
23385
- var GENERATOR = Symbol("GENERATOR");
23386
- var STYLER = Symbol("STYLER");
23387
- var IS_EMPTY = Symbol("IS_EMPTY");
23388
- var levelMapping = [
23389
- "ansi",
23390
- "ansi",
23391
- "ansi256",
23392
- "ansi16m"
23393
- ];
23394
- var styles2 = /* @__PURE__ */ Object.create(null);
23395
- var applyOptions = (object2, options = {}) => {
23396
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
23397
- throw new Error("The `level` option should be an integer from 0 to 3");
24132
+ // src/cli/commands/om/scaffold-knowledge.ts
24133
+ var scaffold_knowledge_exports = {};
24134
+ __export(scaffold_knowledge_exports, {
24135
+ default: () => scaffoldKnowledge
24136
+ });
24137
+ async function scaffoldKnowledge(opts) {
24138
+ const projectDir = getProjectRoot();
24139
+ assertSplitLayout(projectDir);
24140
+ const options = opts;
24141
+ const id = await promptIfAbsent(options.id, "Knowledge node id (e.g. outreach-playbook)");
24142
+ if (!id) {
24143
+ process.stderr.write(source_default.red("Knowledge node id is required. Pass --id <id> or enter it at the prompt.\n"));
24144
+ process.exit(1);
23398
24145
  }
23399
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
23400
- object2.level = options.level === void 0 ? colorLevel : options.level;
23401
- };
23402
- var chalkFactory = (options) => {
23403
- const chalk2 = (...strings) => strings.join(" ");
23404
- applyOptions(chalk2, options);
23405
- Object.setPrototypeOf(chalk2, createChalk.prototype);
23406
- return chalk2;
23407
- };
23408
- function createChalk(options) {
23409
- return chalkFactory(options);
24146
+ const rawKind = await promptIfAbsent(
24147
+ options.kind,
24148
+ "Node kind (playbook / strategy / reference / policy)",
24149
+ { default: "reference" }
24150
+ );
24151
+ const kind = rawKind || "reference";
24152
+ if (!VALID_KINDS.includes(kind)) {
24153
+ process.stderr.write(source_default.red(`Invalid kind \`${kind}\`. Must be one of: ${VALID_KINDS.join(", ")}.
24154
+ `));
24155
+ process.exit(1);
24156
+ }
24157
+ const rawSystemPath = await promptIfAbsent(
24158
+ options.systemPath,
24159
+ "Governing system path (leave blank for global)",
24160
+ { default: "" }
24161
+ );
24162
+ const systemPath = rawSystemPath || void 0;
24163
+ const { filePath: relativeFilePath, content } = emitKnowledgeNode({ id, kind, systemPath });
24164
+ if (options.dryRun) {
24165
+ console.log(source_default.cyan("Dry-run mode \u2014 no files written.\n"));
24166
+ console.log(source_default.gray(`Proposed file: ${relativeFilePath}`));
24167
+ console.log(content);
24168
+ console.log(source_default.yellow("Run `elevasis-sdk om:generate` to register this node."));
24169
+ return;
24170
+ }
24171
+ const absoluteFilePath = (0, import_node_path12.join)(projectDir, relativeFilePath);
24172
+ if ((0, import_node_fs9.existsSync)(absoluteFilePath)) {
24173
+ process.stderr.write(
24174
+ source_default.red(`Knowledge node file already exists at \`${relativeFilePath}\`. Choose a different id.
24175
+ `)
24176
+ );
24177
+ process.exit(1);
24178
+ }
24179
+ (0, import_node_fs9.mkdirSync)((0, import_node_path12.join)(projectDir, "core", "config", "knowledge", "nodes"), { recursive: true });
24180
+ (0, import_node_fs9.writeFileSync)(absoluteFilePath, content, "utf8");
24181
+ console.log(source_default.green(`Knowledge node \`${id}\` written to \`${relativeFilePath}\``));
24182
+ console.log(source_default.yellow("Run `elevasis-sdk om:generate` to register this node."));
23410
24183
  }
23411
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
23412
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
23413
- styles2[styleName] = {
23414
- get() {
23415
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
23416
- Object.defineProperty(this, styleName, { value: builder });
23417
- return builder;
23418
- }
24184
+ var import_node_path12, import_node_fs9, VALID_KINDS;
24185
+ var init_scaffold_knowledge = __esm({
24186
+ "src/cli/commands/om/scaffold-knowledge.ts"() {
24187
+ "use strict";
24188
+ import_node_path12 = require("node:path");
24189
+ import_node_fs9 = require("node:fs");
24190
+ init_source();
24191
+ init_config();
24192
+ init_project_layout();
24193
+ init_prompt_helpers();
24194
+ init_emit_knowledge();
24195
+ VALID_KINDS = ["playbook", "strategy", "reference", "policy"];
24196
+ }
24197
+ });
24198
+
24199
+ // src/cli/commands/om/emit-api-interface.ts
24200
+ function toConstName(systemPath) {
24201
+ return systemPath.split(/[.-]/).map((segment, index) => index === 0 ? segment : segment.charAt(0).toUpperCase() + segment.slice(1)).join("") + "ApiInterface";
24202
+ }
24203
+ function emitApiInterfaceBlock(gap) {
24204
+ const constName = toConstName(gap.systemPath);
24205
+ const resourceIdsLiteral = gap.resourceIds.length === 0 ? "[]" : `[
24206
+ ${gap.resourceIds.map((id) => `'${id}'`).join(",\n ")}
24207
+ ]`;
24208
+ const constFileCode = `// Auto-generated by om:scaffold:fill \u2014 do not edit manually.
24209
+ // Regenerate by running: elevasis-sdk om:scaffold:fill --gaps <path>
24210
+
24211
+ export const ${constName} = {
24212
+ lifecycle: 'active' as const,
24213
+ readinessProfile: 'standard' as const,
24214
+ resourceIds: ${resourceIdsLiteral}
24215
+ }
24216
+ `;
24217
+ const importLine = `import { ${constName} } from './api-interfaces/${gap.systemPath}'`;
24218
+ const fieldLine = ` apiInterface: ${constName},`;
24219
+ const importAnchor = /^\/\/ -{75,}\n\/\/ Feature/m;
24220
+ const escapedId = gap.systemPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24221
+ const fieldAnchor = new RegExp(`id:\\s*['"]${escapedId}['"]`);
24222
+ return {
24223
+ constFileCode,
24224
+ importLine,
24225
+ fieldLine,
24226
+ importAnchor,
24227
+ fieldAnchor
23419
24228
  };
23420
24229
  }
23421
- styles2.visible = {
23422
- get() {
23423
- const builder = createBuilder(this, this[STYLER], true);
23424
- Object.defineProperty(this, "visible", { value: builder });
23425
- return builder;
24230
+ var init_emit_api_interface = __esm({
24231
+ "src/cli/commands/om/emit-api-interface.ts"() {
24232
+ "use strict";
23426
24233
  }
23427
- };
23428
- var getModelAnsi = (model, level, type, ...arguments_) => {
23429
- if (model === "rgb") {
23430
- if (level === "ansi16m") {
23431
- return ansi_styles_default[type].ansi16m(...arguments_);
23432
- }
23433
- if (level === "ansi256") {
23434
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
24234
+ });
24235
+
24236
+ // src/cli/commands/om/scaffold-fill.ts
24237
+ var scaffold_fill_exports = {};
24238
+ __export(scaffold_fill_exports, {
24239
+ conformanceGapTempPath: () => conformanceGapTempPath,
24240
+ default: () => scaffoldFill
24241
+ });
24242
+ function conformanceGapTempPath(orgName) {
24243
+ return (0, import_node_path13.join)(os2.tmpdir(), `elevasis-conformance-${orgName}-${Date.now()}.json`);
24244
+ }
24245
+ function runValidation4(projectDir) {
24246
+ for (const script of ["check-types", "check"]) {
24247
+ const result = (0, import_node_child_process5.spawnSync)("pnpm", ["-C", "operations", "run", script], {
24248
+ cwd: projectDir,
24249
+ encoding: "utf8",
24250
+ shell: true
24251
+ });
24252
+ if (result.status !== 0) {
24253
+ return (result.stderr ?? "") + (result.stdout ?? "");
23435
24254
  }
23436
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
23437
24255
  }
23438
- if (model === "hex") {
23439
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
23440
- }
23441
- return ansi_styles_default[type][model](...arguments_);
23442
- };
23443
- var usedModels = ["rgb", "hex", "ansi256"];
23444
- for (const model of usedModels) {
23445
- styles2[model] = {
23446
- get() {
23447
- const { level } = this;
23448
- return function(...arguments_) {
23449
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
23450
- return createBuilder(this, styler, this[IS_EMPTY]);
23451
- };
23452
- }
23453
- };
23454
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
23455
- styles2[bgModel] = {
23456
- get() {
23457
- const { level } = this;
23458
- return function(...arguments_) {
23459
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
23460
- return createBuilder(this, styler, this[IS_EMPTY]);
23461
- };
23462
- }
23463
- };
24256
+ return null;
23464
24257
  }
23465
- var proto = Object.defineProperties(() => {
23466
- }, {
23467
- ...styles2,
23468
- level: {
23469
- enumerable: true,
23470
- get() {
23471
- return this[GENERATOR].level;
23472
- },
23473
- set(level) {
23474
- this[GENERATOR].level = level;
23475
- }
24258
+ async function scaffoldFill(opts) {
24259
+ const projectDir = getProjectRoot();
24260
+ assertSplitLayout(projectDir);
24261
+ const options = opts;
24262
+ if (!options.gaps) {
24263
+ process.stderr.write(source_default.red("Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.\n"));
24264
+ process.exit(1);
23476
24265
  }
23477
- });
23478
- var createStyler = (open, close, parent) => {
23479
- let openAll;
23480
- let closeAll;
23481
- if (parent === void 0) {
23482
- openAll = open;
23483
- closeAll = close;
23484
- } else {
23485
- openAll = parent.openAll + open;
23486
- closeAll = close + parent.closeAll;
24266
+ if (!(0, import_node_fs10.existsSync)(options.gaps)) {
24267
+ process.stderr.write(
24268
+ source_default.red(
24269
+ `Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.
24270
+ (File not found: ${options.gaps})
24271
+ `
24272
+ )
24273
+ );
24274
+ process.exit(1);
23487
24275
  }
23488
- return {
23489
- open,
23490
- close,
23491
- openAll,
23492
- closeAll,
23493
- parent
23494
- };
23495
- };
23496
- var createBuilder = (self2, _styler, _isEmpty) => {
23497
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
23498
- Object.setPrototypeOf(builder, proto);
23499
- builder[GENERATOR] = self2;
23500
- builder[STYLER] = _styler;
23501
- builder[IS_EMPTY] = _isEmpty;
23502
- return builder;
23503
- };
23504
- var applyStyle = (self2, string4) => {
23505
- if (self2.level <= 0 || !string4) {
23506
- return self2[IS_EMPTY] ? "" : string4;
24276
+ let payload;
24277
+ try {
24278
+ const raw = (0, import_node_fs10.readFileSync)(options.gaps, "utf8");
24279
+ payload = JSON.parse(raw);
24280
+ } catch {
24281
+ process.stderr.write(
24282
+ source_default.red(
24283
+ `Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.
24284
+ (File exists but could not be parsed as JSON: ${options.gaps})
24285
+ `
24286
+ )
24287
+ );
24288
+ process.exit(1);
23507
24289
  }
23508
- let styler = self2[STYLER];
23509
- if (styler === void 0) {
23510
- return string4;
24290
+ if (!payload || typeof payload !== "object" || payload.version !== 1 || !Array.isArray(payload.gaps)) {
24291
+ process.stderr.write(
24292
+ source_default.red(
24293
+ `Missing gaps file. Pass --gaps <path> pointing to a conformance gap JSON file.
24294
+ (File does not match expected schema \u2014 must have version:1 and a gaps array)
24295
+ `
24296
+ )
24297
+ );
24298
+ process.exit(1);
23511
24299
  }
23512
- const { openAll, closeAll } = styler;
23513
- if (string4.includes("\x1B")) {
23514
- while (styler !== void 0) {
23515
- string4 = stringReplaceAll(string4, styler.close, styler.open);
23516
- styler = styler.parent;
24300
+ const systemPath = payload.systemPath;
24301
+ const skippedGaps = [];
24302
+ const appliedGaps = [];
24303
+ const systemsFilePath = (0, import_node_path13.join)(projectDir, "core", "config", "organization-model", "systems.ts");
24304
+ const touchedFiles = [systemsFilePath];
24305
+ const emitResults = [];
24306
+ for (const gap of payload.gaps) {
24307
+ if (gap.field === "apiInterface") {
24308
+ const resourceIds = (
24309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24310
+ Array.isArray(gap.resourceIds) ? (
24311
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24312
+ gap.resourceIds
24313
+ ) : gap.resourceId ? [gap.resourceId] : []
24314
+ );
24315
+ const emitResult = emitApiInterfaceBlock({
24316
+ systemPath,
24317
+ resourceIds,
24318
+ message: gap.reason
24319
+ });
24320
+ const constFilePath = (0, import_node_path13.join)(
24321
+ projectDir,
24322
+ "core",
24323
+ "config",
24324
+ "organization-model",
24325
+ "api-interfaces",
24326
+ `${systemPath}.ts`
24327
+ );
24328
+ touchedFiles.push(constFilePath);
24329
+ emitResults.push(emitResult);
24330
+ appliedGaps.push(gap);
24331
+ } else {
24332
+ skippedGaps.push({
24333
+ field: gap.field,
24334
+ resourceId: gap.resourceId,
24335
+ reason: gap.reason
24336
+ });
24337
+ }
24338
+ }
24339
+ if (options.dryRun) {
24340
+ console.log(source_default.cyan("Dry-run mode \u2014 no files written.\n"));
24341
+ for (let i = 0; i < emitResults.length; i++) {
24342
+ const result = emitResults[i];
24343
+ const gap = appliedGaps[i];
24344
+ const constFilePath = `core/config/organization-model/api-interfaces/${systemPath}.ts`;
24345
+ console.log(source_default.gray(`Gap: ${gap.field} \u2014 would write ${constFilePath}`));
24346
+ console.log(result.constFileCode);
24347
+ console.log(source_default.gray(`Import line for systems.ts:`));
24348
+ console.log(result.importLine);
24349
+ console.log(source_default.gray(`Field line for systems.ts entry:`));
24350
+ console.log(result.fieldLine);
24351
+ console.log();
24352
+ }
24353
+ if (skippedGaps.length > 0) {
24354
+ console.log(source_default.yellow(`Would skip ${skippedGaps.length} gap(s) requiring manual input:`));
24355
+ for (const sg of skippedGaps) {
24356
+ console.log(
24357
+ source_default.yellow(` - ${sg.field}${sg.resourceId ? ` (resource: ${sg.resourceId})` : ""}: ${sg.reason}`)
24358
+ );
24359
+ }
24360
+ }
24361
+ return;
24362
+ }
24363
+ if (appliedGaps.length > 0) {
24364
+ try {
24365
+ await withSnapshotRollback(touchedFiles, async () => {
24366
+ for (let i = 0; i < emitResults.length; i++) {
24367
+ const result = emitResults[i];
24368
+ const constFilePath = (0, import_node_path13.join)(
24369
+ projectDir,
24370
+ "core",
24371
+ "config",
24372
+ "organization-model",
24373
+ "api-interfaces",
24374
+ `${systemPath}.ts`
24375
+ );
24376
+ await applyConstImport(
24377
+ systemsFilePath,
24378
+ result.importLine,
24379
+ result.fieldLine,
24380
+ result.importAnchor,
24381
+ result.fieldAnchor,
24382
+ constFilePath,
24383
+ result.constFileCode
24384
+ );
24385
+ }
24386
+ const validationError = runValidation4(projectDir);
24387
+ if (validationError !== null) {
24388
+ throw new Error(validationError);
24389
+ }
24390
+ });
24391
+ } catch (err) {
24392
+ const raw = err instanceof Error ? err.message : String(err);
24393
+ process.stderr.write(source_default.red(mapValidationError(raw)) + "\n");
24394
+ process.exit(1);
23517
24395
  }
23518
24396
  }
23519
- const lfIndex = string4.indexOf("\n");
23520
- if (lfIndex !== -1) {
23521
- string4 = stringEncaseCRLFWithFirstIndex(string4, closeAll, openAll, lfIndex);
24397
+ if (skippedGaps.length > 0) {
24398
+ const skippedPath = options.skipped ?? (0, import_node_path13.join)(os2.tmpdir(), `elevasis-fill-skipped-${systemPath}-${Date.now()}.json`);
24399
+ (0, import_node_fs10.writeFileSync)(skippedPath, JSON.stringify({ systemPath, skipped: skippedGaps }, null, 2), "utf8");
24400
+ console.log(
24401
+ source_default.yellow(
24402
+ `Partial fill: ${appliedGaps.length} gap(s) applied, ${skippedGaps.length} skipped \u2014 see \`${skippedPath}\` for fields requiring manual input.`
24403
+ )
24404
+ );
24405
+ process.exit(2);
23522
24406
  }
23523
- return openAll + string4 + closeAll;
23524
- };
23525
- Object.defineProperties(createChalk.prototype, styles2);
23526
- var chalk = createChalk();
23527
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
23528
- var source_default = chalk;
24407
+ console.log(
24408
+ source_default.green(
24409
+ `Fill complete: ${appliedGaps.length} gap(s) resolved in \`core/config/organization-model/systems.ts\`.`
24410
+ )
24411
+ );
24412
+ }
24413
+ var import_node_path13, os2, import_node_fs10, import_node_child_process5;
24414
+ var init_scaffold_fill = __esm({
24415
+ "src/cli/commands/om/scaffold-fill.ts"() {
24416
+ "use strict";
24417
+ import_node_path13 = require("node:path");
24418
+ os2 = __toESM(require("node:os"), 1);
24419
+ import_node_fs10 = require("node:fs");
24420
+ import_node_child_process5 = require("node:child_process");
24421
+ init_source();
24422
+ init_config();
24423
+ init_project_layout();
24424
+ init_error_map();
24425
+ init_emit_api_interface();
24426
+ init_splice();
24427
+ }
24428
+ });
24429
+
24430
+ // src/cli/index.ts
24431
+ var index_exports = {};
24432
+ __export(index_exports, {
24433
+ getProjectRoot: () => getProjectRoot
24434
+ });
24435
+ module.exports = __toCommonJS(index_exports);
24436
+ var import_dotenv = __toESM(require_main(), 1);
24437
+ var import_fs4 = require("fs");
24438
+ var import_path4 = require("path");
24439
+
24440
+ // ../../node_modules/.pnpm/commander@11.1.0/node_modules/commander/esm.mjs
24441
+ var import_index = __toESM(require_commander(), 1);
24442
+ var {
24443
+ program,
24444
+ createCommand,
24445
+ createArgument,
24446
+ createOption,
24447
+ CommanderError,
24448
+ InvalidArgumentError,
24449
+ InvalidOptionArgumentError,
24450
+ // deprecated old name
24451
+ Command,
24452
+ Argument,
24453
+ Option,
24454
+ Help
24455
+ } = import_index.default;
24456
+
24457
+ // src/cli/index.ts
24458
+ init_source();
24459
+
24460
+ // src/cli/commands/check.ts
24461
+ init_source();
23529
24462
 
23530
24463
  // ../../node_modules/.pnpm/ora@7.0.1/node_modules/ora/index.js
23531
24464
  var import_node_process6 = __toESM(require("node:process"), 1);
24465
+ init_source();
23532
24466
 
23533
24467
  // ../../node_modules/.pnpm/cli-cursor@4.0.0/node_modules/cli-cursor/index.js
23534
24468
  var import_node_process3 = __toESM(require("node:process"), 1);
@@ -23577,6 +24511,9 @@ var cli_cursor_default = cliCursor;
23577
24511
  // ../../node_modules/.pnpm/ora@7.0.1/node_modules/ora/index.js
23578
24512
  var import_cli_spinners = __toESM(require_cli_spinners(), 1);
23579
24513
 
24514
+ // ../../node_modules/.pnpm/log-symbols@5.1.0/node_modules/log-symbols/index.js
24515
+ init_source();
24516
+
23580
24517
  // ../../node_modules/.pnpm/is-unicode-supported@1.3.0/node_modules/is-unicode-supported/index.js
23581
24518
  var import_node_process4 = __toESM(require("node:process"), 1);
23582
24519
  function isUnicodeSupported() {
@@ -24040,6 +24977,7 @@ function ora(options) {
24040
24977
  var import_path2 = require("path");
24041
24978
  var import_promises = require("fs/promises");
24042
24979
  var import_fs2 = require("fs");
24980
+ init_source();
24043
24981
 
24044
24982
  // ../../node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/external.js
24045
24983
  var external_exports = {};
@@ -37105,6 +38043,7 @@ var ORGANIZATION_MODEL_ICON_TOKENS = [
37105
38043
  "view",
37106
38044
  "launch",
37107
38045
  "message",
38046
+ "message-plus",
37108
38047
  "escalate",
37109
38048
  "promote",
37110
38049
  "submit",
@@ -37291,9 +38230,22 @@ var SidebarNavigationSchema = external_exports.object({
37291
38230
  primary: SidebarSectionSchema,
37292
38231
  bottom: SidebarSectionSchema
37293
38232
  }).default({ primary: {}, bottom: {} });
38233
+ var TopbarActionNodeSchema = external_exports.object({
38234
+ id: ModelIdSchema,
38235
+ label: LabelSchema,
38236
+ tooltip: DescriptionSchema.optional(),
38237
+ icon: IconNameSchema.optional(),
38238
+ order: external_exports.number().int().optional(),
38239
+ enabled: external_exports.boolean().default(true),
38240
+ devOnly: external_exports.boolean().optional(),
38241
+ requiresAdmin: external_exports.boolean().optional(),
38242
+ targets: SidebarSurfaceTargetsSchema.optional()
38243
+ });
38244
+ var TopbarSectionSchema = external_exports.record(external_exports.string(), TopbarActionNodeSchema).default({});
37294
38245
  var OrganizationModelNavigationSchema = external_exports.object({
37295
- sidebar: SidebarNavigationSchema
37296
- }).default({ sidebar: { primary: {}, bottom: {} } });
38246
+ sidebar: SidebarNavigationSchema,
38247
+ topbar: TopbarSectionSchema
38248
+ }).default({ sidebar: { primary: {}, bottom: {} }, topbar: {} });
37297
38249
  var NavigationGroupSchema = external_exports.object({
37298
38250
  id: ModelIdSchema,
37299
38251
  label: LabelSchema,
@@ -37596,10 +38548,27 @@ var SystemUiSchema = external_exports.object({
37596
38548
  });
37597
38549
  var SystemInterfaceKeySchema = ModelIdSchema;
37598
38550
  var SystemInterfaceLifecycleSchema = external_exports.enum(["draft", "active", "disabled", "deprecated", "archived"]).meta({ label: "System interface lifecycle", color: "teal" });
37599
- var SystemInterfaceReadinessProfileSchema = external_exports.string().trim().min(1).max(200).regex(
37600
- /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*(?:\.[a-z0-9][a-z0-9-]*)?$/,
37601
- 'Readiness profiles must use dotted lowercase identifiers (e.g. "sales.lead-gen.api")'
38551
+ var SYSTEM_INTERFACE_PROFILES = [
38552
+ {
38553
+ systemPath: "sales.lead-gen",
38554
+ interfaceKey: "api",
38555
+ readinessProfile: "sales.lead-gen.api"
38556
+ },
38557
+ {
38558
+ systemPath: "sales.crm",
38559
+ interfaceKey: "api",
38560
+ readinessProfile: "sales.crm.api"
38561
+ },
38562
+ {
38563
+ systemPath: "sales.lead-gen",
38564
+ interfaceKey: "crm-handoff",
38565
+ readinessProfile: "sales.lead-gen.crm-handoff"
38566
+ }
38567
+ ];
38568
+ var SYSTEM_INTERFACE_READINESS_PROFILES = SYSTEM_INTERFACE_PROFILES.map(
38569
+ (profile) => profile.readinessProfile
37602
38570
  );
38571
+ var SystemInterfaceReadinessProfileSchema = external_exports.enum(SYSTEM_INTERFACE_READINESS_PROFILES);
37603
38572
  var SystemInterfaceResourceScopeSchema = external_exports.array(ModelIdSchema).default([]);
37604
38573
  var SystemApiInterfaceSchema = external_exports.object({
37605
38574
  lifecycle: SystemInterfaceLifecycleSchema.default("active"),
@@ -38829,7 +39798,8 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
38829
39798
  sidebar: {
38830
39799
  primary: {},
38831
39800
  bottom: {}
38832
- }
39801
+ },
39802
+ topbar: {}
38833
39803
  };
38834
39804
  var DEFAULT_ORGANIZATION_MODEL = {
38835
39805
  version: 1,
@@ -40271,21 +41241,9 @@ function validateModelConfig(config3) {
40271
41241
  }
40272
41242
 
40273
41243
  // ../core/src/business/acquisition/ontology-validation.ts
40274
- var LEAD_GEN_API_INTERFACE = {
40275
- systemPath: "sales.lead-gen",
40276
- interfaceKey: "api",
40277
- readinessProfile: "sales.lead-gen.api"
40278
- };
40279
- var CRM_API_INTERFACE = {
40280
- systemPath: "sales.crm",
40281
- interfaceKey: "api",
40282
- readinessProfile: "sales.crm.api"
40283
- };
40284
- var LEAD_GEN_CRM_HANDOFF_INTERFACE = {
40285
- systemPath: "sales.lead-gen",
40286
- interfaceKey: "crm-handoff",
40287
- readinessProfile: "sales.lead-gen.crm-handoff"
40288
- };
41244
+ var LEAD_GEN_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[0];
41245
+ var CRM_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[1];
41246
+ var LEAD_GEN_CRM_HANDOFF_INTERFACE = SYSTEM_INTERFACE_PROFILES[2];
40289
41247
  var LEAD_GEN_API_READINESS_LABEL = LEAD_GEN_API_INTERFACE.readinessProfile;
40290
41248
  var CRM_API_READINESS_LABEL = CRM_API_INTERFACE.readinessProfile;
40291
41249
  var LEAD_GEN_CRM_HANDOFF_READINESS_LABEL = LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile;
@@ -40366,6 +41324,9 @@ function profileForInterface(systemPath, interfaceKey, readinessProfile) {
40366
41324
  function readinessMarkerPath(context) {
40367
41325
  return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : `systems.${context.systemPath}.derivedCrmHandoffReadiness`;
40368
41326
  }
41327
+ function formatSupportedReadinessProfiles() {
41328
+ return SYSTEM_INTERFACE_READINESS_PROFILES.map((profile) => `"${profile}"`).join(", ");
41329
+ }
40369
41330
  function getActiveScopedResources(model, resourceIds, issues, context) {
40370
41331
  const resources = [];
40371
41332
  for (const [index, resourceId] of resourceIds.entries()) {
@@ -40645,18 +41606,13 @@ function computeInterfaceReadiness(model, request) {
40645
41606
  { path: `${readinessMarkerPath(request)}.lifecycle` }
40646
41607
  );
40647
41608
  }
40648
- const supportedProfiles = [
40649
- LEAD_GEN_API_INTERFACE.readinessProfile,
40650
- CRM_API_INTERFACE.readinessProfile,
40651
- LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile
40652
- ];
40653
- const supportedProfile = readinessProfile !== void 0 && supportedProfiles.some((profile) => profile === readinessProfile);
41609
+ const supportedProfile = readinessProfile !== void 0 && SYSTEM_INTERFACE_PROFILES.some((profile) => profile.readinessProfile === readinessProfile);
40654
41610
  if (!supportedProfile) {
40655
41611
  addReadinessIssue(
40656
41612
  issues,
40657
41613
  "SYSTEM_INTERFACE_INVALID",
40658
41614
  "unknown-readiness-profile",
40659
- `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" references unknown readiness profile "${readinessProfile}".`,
41615
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" references unknown readiness profile "${readinessProfile}". Supported profiles: ${formatSupportedReadinessProfiles()}. Custom Systems should not declare apiInterface; route custom behavior through workflows/operations plus ontology, resources, and topology.`,
40660
41616
  { path: `${readinessMarkerPath(request)}.readinessProfile`, ref: readinessProfile }
40661
41617
  );
40662
41618
  return {
@@ -41071,6 +42027,35 @@ function addSystemInterfaceIssue(issues, orgName, systemPath, interfaceKey, issu
41071
42027
  message: `[${orgName}] ${issue2.family}:${issue2.code}: ${issue2.message}`
41072
42028
  });
41073
42029
  }
42030
+ function detectMissingApiInterfaceDeclarations(orgName, organizationModel) {
42031
+ if (organizationModel === void 0) return [];
42032
+ const apiBoundResourcesBySystemPath = /* @__PURE__ */ new Map();
42033
+ for (const resource of Object.values(organizationModel.resources ?? {})) {
42034
+ const ontology = resource.ontology;
42035
+ if (ontology === void 0) continue;
42036
+ const hasOntologyBindings = ontology.actions !== void 0 && ontology.actions.length > 0 || ontology.writes !== void 0 && ontology.writes.length > 0;
42037
+ if (!hasOntologyBindings) continue;
42038
+ const existing = apiBoundResourcesBySystemPath.get(resource.systemPath);
42039
+ if (existing) {
42040
+ existing.push(resource.id);
42041
+ } else {
42042
+ apiBoundResourcesBySystemPath.set(resource.systemPath, [resource.id]);
42043
+ }
42044
+ }
42045
+ if (apiBoundResourcesBySystemPath.size === 0) return [];
42046
+ const gaps = [];
42047
+ for (const { path: path3, system } of listAllSystems(organizationModel)) {
42048
+ if (system.apiInterface !== void 0) continue;
42049
+ const resourceIds = apiBoundResourcesBySystemPath.get(path3);
42050
+ if (!resourceIds || resourceIds.length === 0) continue;
42051
+ gaps.push({
42052
+ systemPath: path3,
42053
+ resourceIds,
42054
+ message: `[${orgName}] System '${path3}' has ${resourceIds.length} API-backed resource(s) (${resourceIds.join(", ")}) but no apiInterface declaration.`
42055
+ });
42056
+ }
42057
+ return gaps;
42058
+ }
41074
42059
  function validateDeclaredSystemInterfaceReadiness(orgName, organizationModel) {
41075
42060
  const issues = [];
41076
42061
  if (organizationModel === void 0) return { valid: true, issues };
@@ -44518,105 +45503,11 @@ var ResourceRegistry = class {
44518
45503
  // src/index.ts
44519
45504
  var ListBuilderStageKeySchema = external_exports.string().min(1);
44520
45505
 
44521
- // src/cli/config.ts
44522
- var import_fs = require("fs");
44523
- var import_path = require("path");
44524
- var DEV_API_URL = "http://localhost:5170";
44525
- var PROD_API_URL = "https://api.elevasis.io";
44526
- function resolveApiUrl(cliOverride, prod) {
44527
- if (cliOverride) return cliOverride;
44528
- if (prod) return PROD_API_URL;
44529
- if (process.env.ELEVASIS_API_URL) return process.env.ELEVASIS_API_URL;
44530
- if (process.env.NODE_ENV === "development") return DEV_API_URL;
44531
- return PROD_API_URL;
44532
- }
44533
- function resolveEnvironment(prod) {
44534
- if (prod) return "production";
44535
- return process.env.NODE_ENV === "development" ? "development" : "production";
44536
- }
44537
- function resolveApiKey(prod) {
44538
- if (!prod && process.env.NODE_ENV === "development") {
44539
- return process.env.ELEVASIS_PLATFORM_KEY_DEV ?? process.env.ELEVASIS_PLATFORM_KEY ?? "";
44540
- }
44541
- return process.env.ELEVASIS_PLATFORM_KEY ?? "";
44542
- }
44543
- function tryFindProjectRoot(startDir) {
44544
- const raw = (0, import_path.resolve)(startDir);
44545
- let dir;
44546
- try {
44547
- dir = (0, import_fs.realpathSync)(raw);
44548
- } catch {
44549
- dir = raw;
44550
- }
44551
- while (true) {
44552
- if ((0, import_fs.existsSync)((0, import_path.join)(dir, ".elevasis"))) return dir;
44553
- const parent = (0, import_path.dirname)(dir);
44554
- if (parent === dir) break;
44555
- dir = parent;
44556
- }
44557
- return null;
44558
- }
44559
- function findProjectRoot(startDir) {
44560
- const root = tryFindProjectRoot(startDir);
44561
- if (root !== null) return root;
44562
- process.stderr.write(
44563
- "Not inside an Elevasis project. Run this command from a project directory (an Elevasis project has a .elevasis file at its root).\n"
44564
- );
44565
- process.exit(1);
44566
- }
44567
- function isHelpOrVersionOnly() {
44568
- const args = process.argv.slice(2);
44569
- return args.length > 0 && args.every((a) => ["--help", "-h", "--version", "-V"].includes(a));
44570
- }
44571
- var _projectRoot;
44572
- function getProjectRoot() {
44573
- if (_projectRoot !== void 0) return _projectRoot;
44574
- _projectRoot = isHelpOrVersionOnly() ? process.cwd() : findProjectRoot(process.cwd());
44575
- return _projectRoot;
44576
- }
44577
- function resolveProjectRelative(relOrAbsPath) {
44578
- if ((0, import_path.isAbsolute)(relOrAbsPath)) return relOrAbsPath;
44579
- return (0, import_path.resolve)(getProjectRoot(), relOrAbsPath);
44580
- }
44581
- function findEnvFile(_startDir) {
44582
- const projectRoot = tryFindProjectRoot(process.cwd());
44583
- if (projectRoot === null) return void 0;
44584
- const candidate = (0, import_path.join)(projectRoot, ".env");
44585
- return (0, import_fs.existsSync)(candidate) ? candidate : void 0;
44586
- }
44587
- function findPackageRoot(startDir) {
44588
- const raw = (0, import_path.resolve)(startDir);
44589
- let dir;
44590
- try {
44591
- dir = (0, import_fs.realpathSync)(raw);
44592
- } catch {
44593
- dir = raw;
44594
- }
44595
- const projectRoot = tryFindProjectRoot(dir);
44596
- while (true) {
44597
- if ((0, import_fs.existsSync)((0, import_path.join)(dir, "package.json"))) return dir;
44598
- const parent = (0, import_path.dirname)(dir);
44599
- if (parent === dir) break;
44600
- if (projectRoot !== null && dir === projectRoot) break;
44601
- dir = parent;
44602
- }
44603
- process.stderr.write(
44604
- "No package.json found between the current directory and the project root.\nRemediation: run this command from inside a package directory (one that contains package.json).\n"
44605
- );
44606
- process.exit(1);
44607
- }
44608
- var _packageRoot;
44609
- function getPackageRoot() {
44610
- if (_packageRoot !== void 0) return _packageRoot;
44611
- _packageRoot = isHelpOrVersionOnly() ? process.cwd() : findPackageRoot(process.cwd());
44612
- return _packageRoot;
44613
- }
44614
- function resolvePackageRelative(relOrAbsPath) {
44615
- if ((0, import_path.isAbsolute)(relOrAbsPath)) return relOrAbsPath;
44616
- return (0, import_path.resolve)(getPackageRoot(), relOrAbsPath);
44617
- }
45506
+ // src/cli/commands/deploy.ts
45507
+ init_config();
44618
45508
 
44619
45509
  // src/cli/api-client.ts
45510
+ init_config();
44620
45511
  function getApiKey(apiUrl) {
44621
45512
  const isProd = !apiUrl.includes("localhost");
44622
45513
  const key = resolveApiKey(isProd);
@@ -44697,6 +45588,7 @@ async function apiDelete(endpoint, apiUrl = resolveApiUrl()) {
44697
45588
  }
44698
45589
 
44699
45590
  // src/cli/wrap-action.ts
45591
+ init_source();
44700
45592
  function wrapAction(commandName, fn) {
44701
45593
  return async (...args) => {
44702
45594
  try {
@@ -44714,7 +45606,7 @@ function wrapAction(commandName, fn) {
44714
45606
  // package.json
44715
45607
  var package_default = {
44716
45608
  name: "@elevasis/sdk",
44717
- version: "1.29.0",
45609
+ version: "1.30.0",
44718
45610
  description: "SDK for building Elevasis organization resources",
44719
45611
  type: "module",
44720
45612
  bin: {
@@ -44966,6 +45858,21 @@ function validateResourceGovernancePreflight(orgName, org, contractRegistry) {
44966
45858
  if (org.organizationModel !== void 0) {
44967
45859
  OrganizationModelSchema.parse(org.organizationModel);
44968
45860
  }
45861
+ const conformanceGaps = detectMissingApiInterfaceDeclarations(
45862
+ orgName,
45863
+ org.organizationModel
45864
+ );
45865
+ if (conformanceGaps.length > 0) {
45866
+ const gapLines = conformanceGaps.map((gap) => ` ${gap.systemPath}: resources [${gap.resourceIds.join(", ")}] missing apiInterface`).join("\n");
45867
+ throw new RegistryValidationError(
45868
+ orgName,
45869
+ null,
45870
+ "organizationModel.apiInterface",
45871
+ `${conformanceGaps.length} system(s) have API-backed resources but no apiInterface declaration:
45872
+ ${gapLines}
45873
+ Run \`pnpm exec elevasis-sdk om:scaffold:fill --gaps <path>\` to scaffold the missing apiInterface declarations.`
45874
+ );
45875
+ }
44969
45876
  validateDeclaredSystemInterfaceReadiness(orgName, org.organizationModel);
44970
45877
  if (process.env.ELEVASIS_RESOURCE_VALIDATOR === "warn-only") return;
44971
45878
  validateResourceGovernance(orgName, org, org.organizationModel, { mode: "strict" });
@@ -45218,6 +46125,7 @@ import { startWorker } from '@elevasis/sdk/worker'
45218
46125
  }
45219
46126
 
45220
46127
  // src/cli/commands/check.ts
46128
+ init_config();
45221
46129
  function registerCheckCommand(program3) {
45222
46130
  program3.command("check").description(
45223
46131
  "Validate project resources against the ResourceRegistry\n Example: elevasis-sdk check --entry ./src/index.ts"
@@ -45295,6 +46203,8 @@ function registerCheckCommand(program3) {
45295
46203
  // src/cli/commands/exec.ts
45296
46204
  var import_node_fs = require("node:fs");
45297
46205
  var import_node_path = require("node:path");
46206
+ init_source();
46207
+ init_config();
45298
46208
  var POLL_INTERVAL_MS = 3e3;
45299
46209
  async function pollForCompletion(resourceId, executionId, apiUrl) {
45300
46210
  const pollSpinner = ora("Waiting for completion...").start();
@@ -45446,6 +46356,8 @@ function registerExecCommand(program3) {
45446
46356
  }
45447
46357
 
45448
46358
  // src/cli/commands/resources.ts
46359
+ init_source();
46360
+ init_config();
45449
46361
  function registerResourcesCommand(program3) {
45450
46362
  program3.command("resources").description("List deployed resources for your organization").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("resources", async (options) => {
45451
46363
  const apiUrl = resolveApiUrl(options.apiUrl);
@@ -45491,6 +46403,8 @@ function registerResourcesCommand(program3) {
45491
46403
  }
45492
46404
 
45493
46405
  // src/cli/commands/executions.ts
46406
+ init_source();
46407
+ init_config();
45494
46408
  function registerExecutionsCommand(program3) {
45495
46409
  program3.command("executions <resourceId>").description("List execution history for a resource\n Example: elevasis-sdk executions my-workflow --limit 10").option("--api-url <url>", "API URL").option("--json", "Output as JSON").option("--limit <number>", "Limit number of results (default: 50)").option("--status <status>", "Filter by status (running|completed|failed)").action(wrapAction("executions", async (resourceId, options) => {
45496
46410
  const apiUrl = resolveApiUrl(options.apiUrl);
@@ -45549,6 +46463,8 @@ function registerExecutionsCommand(program3) {
45549
46463
  }
45550
46464
 
45551
46465
  // src/cli/commands/execution.ts
46466
+ init_source();
46467
+ init_config();
45552
46468
  function registerExecutionCommand(program3) {
45553
46469
  program3.command("execution <resourceId> <executionId>").description("Get detailed information about a specific execution\n Example: elevasis-sdk execution my-workflow abc-123-uuid --logs-only").option("--api-url <url>", "API URL").option("--json", "Output raw JSON response").option("--logs-only", "Show only execution logs").option("--input", "Include input data in output").option("--result", "Include result data in output").action(wrapAction("execution", async (resourceId, executionId, options) => {
45554
46470
  const apiUrl = resolveApiUrl(options.apiUrl);
@@ -45651,6 +46567,8 @@ function displayLog(log) {
45651
46567
  }
45652
46568
 
45653
46569
  // src/cli/commands/deployments.ts
46570
+ init_source();
46571
+ init_config();
45654
46572
  function registerDeploymentsCommand(program3) {
45655
46573
  program3.command("deployments").description("List deployments for your organization").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("deployments", async (options) => {
45656
46574
  const apiUrl = resolveApiUrl(options.apiUrl);
@@ -45711,6 +46629,8 @@ function registerDeploymentsCommand(program3) {
45711
46629
  }
45712
46630
 
45713
46631
  // src/cli/commands/describe.ts
46632
+ init_source();
46633
+ init_config();
45714
46634
  function hasSchemaContent(schema) {
45715
46635
  return Object.keys(schema).some((k) => k !== "$schema");
45716
46636
  }
@@ -45783,7 +46703,11 @@ function registerDescribeCommand(program3) {
45783
46703
  );
45784
46704
  }
45785
46705
 
46706
+ // src/cli/commands/creds/creds.ts
46707
+ init_config();
46708
+
45786
46709
  // src/cli/commands/creds/creds-list.ts
46710
+ init_source();
45787
46711
  async function listCreds(apiUrl, json2) {
45788
46712
  const spinner = ora("Fetching credentials...").start();
45789
46713
  const data = await apiGet("/api/external/credentials", apiUrl);
@@ -45809,6 +46733,7 @@ Credentials (${data.credentials.length}):
45809
46733
  }
45810
46734
 
45811
46735
  // src/cli/commands/creds/creds-create.ts
46736
+ init_source();
45812
46737
  var CREDENTIAL_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
45813
46738
  var VALID_TYPES = ["api-key", "webhook-secret"];
45814
46739
  async function createCreds(apiUrl, name, type, valueJson) {
@@ -45863,6 +46788,7 @@ Credential created successfully!`));
45863
46788
  }
45864
46789
 
45865
46790
  // src/cli/commands/creds/creds-update.ts
46791
+ init_source();
45866
46792
  async function updateCreds(apiUrl, name, valueJson) {
45867
46793
  let value;
45868
46794
  try {
@@ -45896,6 +46822,7 @@ Credential '${name}' updated successfully!`));
45896
46822
  }
45897
46823
 
45898
46824
  // src/cli/commands/creds/creds-rename.ts
46825
+ init_source();
45899
46826
  var CREDENTIAL_NAME_REGEX2 = /^[a-z0-9]+(-[a-z0-9]+)*$/;
45900
46827
  async function renameCreds(apiUrl, name, newName) {
45901
46828
  if (!newName || newName.length < 1 || newName.length > 100) {
@@ -45929,6 +46856,7 @@ Credential renamed successfully!`));
45929
46856
  }
45930
46857
 
45931
46858
  // src/cli/commands/creds/creds-delete.ts
46859
+ init_source();
45932
46860
  var import_readline = require("readline");
45933
46861
  function confirm(message) {
45934
46862
  const rl = (0, import_readline.createInterface)({ input: process.stdin, output: process.stdout });
@@ -45993,7 +46921,11 @@ function registerCredsCommand(program3) {
45993
46921
  }));
45994
46922
  }
45995
46923
 
46924
+ // src/cli/commands/error/error.ts
46925
+ init_config();
46926
+
45996
46927
  // src/cli/commands/error/error-resolve.ts
46928
+ init_source();
45997
46929
  async function resolveError(apiUrl, errorId) {
45998
46930
  const spinner = ora("Resolving error...").start();
45999
46931
  await apiPatch(`/api/external/observability/errors/${errorId}/resolve`, {}, apiUrl);
@@ -46029,6 +46961,8 @@ function registerErrorCommand(program3) {
46029
46961
  }
46030
46962
 
46031
46963
  // src/cli/commands/rename.ts
46964
+ init_source();
46965
+ init_config();
46032
46966
  function registerRenameCommand(program3) {
46033
46967
  program3.command("rename <oldResourceId>").description("Rename a resource ID across all platform tables (dry run by default)").requiredOption("--to <newResourceId>", "New resource ID").option("--execute", "Apply the rename (default: dry run preview only)").option("--prod", "Target production (overrides NODE_ENV=development)").option("--api-url <url>", "API URL").action(
46034
46968
  wrapAction("rename", async (oldResourceId, options) => {
@@ -46066,7 +47000,12 @@ function registerRenameCommand(program3) {
46066
47000
  );
46067
47001
  }
46068
47002
 
47003
+ // src/cli/commands/project/projects.ts
47004
+ init_source();
47005
+ init_config();
47006
+
46069
47007
  // src/cli/commands/project/resolve-project.ts
47008
+ init_config();
46070
47009
  function isUuid(value) {
46071
47010
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
46072
47011
  }
@@ -46303,6 +47242,8 @@ function renderProjectWorkBrief(brief) {
46303
47242
  }
46304
47243
 
46305
47244
  // src/cli/commands/client/client.ts
47245
+ init_source();
47246
+ init_config();
46306
47247
  function isUuid2(value) {
46307
47248
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
46308
47249
  }
@@ -46676,6 +47617,8 @@ Project ${id} deleted.`));
46676
47617
  }
46677
47618
 
46678
47619
  // src/cli/commands/project/milestones.ts
47620
+ init_source();
47621
+ init_config();
46679
47622
  function registerMilestoneList(program3) {
46680
47623
  program3.command("project:milestone:list").description("List milestones for a project\n Example: elevasis-sdk project:milestone:list --project <uuid>").requiredOption("--project <project-id>", "Project ID (UUID)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
46681
47624
  wrapAction("project:milestone:list", async (options) => {
@@ -46795,6 +47738,8 @@ Milestone ${id} deleted.`));
46795
47738
  }
46796
47739
 
46797
47740
  // src/cli/commands/project/tasks.ts
47741
+ init_source();
47742
+ init_config();
46798
47743
  function registerTaskList(program3) {
46799
47744
  program3.command("project:task:list").description(
46800
47745
  "List tasks for a project\n Example: elevasis-sdk project:task:list --project <uuid> --status in_progress"
@@ -47073,6 +48018,9 @@ Resume context saved for task ${id}`));
47073
48018
  );
47074
48019
  }
47075
48020
 
48021
+ // src/cli/commands/project/notes.ts
48022
+ init_source();
48023
+
47076
48024
  // ../core/src/projects/api-schemas.ts
47077
48025
  var ProjectKindSchema = external_exports.enum(["client_engagement", "internal", "research", "other"]);
47078
48026
  var ProjectStatusSchema = external_exports.enum(["active", "on_track", "at_risk", "blocked", "completed", "paused"]);
@@ -47231,6 +48179,7 @@ var UpdateNoteRequestSchema = external_exports.object({
47231
48179
  var NoteIdParamsSchema = external_exports.object({ id: UuidSchema });
47232
48180
 
47233
48181
  // src/cli/commands/project/notes.ts
48182
+ init_config();
47234
48183
  var NOTE_TYPE_HELP = NoteTypeSchema.options.join(" | ");
47235
48184
  function registerNoteList(program3) {
47236
48185
  program3.command("project:note:list").description("List notes for a project\n Example: elevasis-sdk project:note:list --project <uuid>").requiredOption("--project <project-id>", "Project ID (UUID)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
@@ -48090,6 +49039,9 @@ ${appliesLines.join("\n")}` : "";
48090
49039
  return join3([header, effectSection, appliesSection]);
48091
49040
  }
48092
49041
 
49042
+ // src/cli/commands/knowledge/ls.ts
49043
+ init_config();
49044
+
48093
49045
  // src/cli/commands/knowledge/load-org-model.ts
48094
49046
  var import_path3 = require("path");
48095
49047
  var import_fs3 = require("fs");
@@ -48225,6 +49177,7 @@ function registerKnowledgeLs(program3) {
48225
49177
  }
48226
49178
 
48227
49179
  // src/cli/commands/knowledge/cat.ts
49180
+ init_config();
48228
49181
  function registerKnowledgeCat(program3) {
48229
49182
  program3.command("knowledge:cat <id>").alias("om:cat").description(
48230
49183
  "Print the raw MDX body of a knowledge node\n Example: elevasis-sdk om:cat knowledge.outreach-playbook\n Use --json for structured output"
@@ -48248,6 +49201,7 @@ function registerKnowledgeCat(program3) {
48248
49201
  }
48249
49202
 
48250
49203
  // src/cli/commands/knowledge/graph.ts
49204
+ init_config();
48251
49205
  function registerKnowledgeGraph(program3) {
48252
49206
  program3.command("knowledge:graph <id>").alias("om:graph").description(
48253
49207
  "Show outgoing and incoming edges for a knowledge node\n Example: elevasis-sdk om:graph knowledge.outreach-playbook\n Accepts bare OM node id or graph node id (knowledge:<id>)"
@@ -48307,6 +49261,7 @@ function registerKnowledgeGraph(program3) {
48307
49261
  }
48308
49262
 
48309
49263
  // src/cli/commands/knowledge/skills.ts
49264
+ init_config();
48310
49265
  function normalizeKnowledgeId(id) {
48311
49266
  return id.startsWith("knowledge:") ? id.slice("knowledge:".length) : id;
48312
49267
  }
@@ -48783,6 +49738,7 @@ function generateKnowledgeNodes(options) {
48783
49738
  }
48784
49739
 
48785
49740
  // src/cli/commands/knowledge/generate.ts
49741
+ init_config();
48786
49742
  function registerKnowledgeGenerate(program3) {
48787
49743
  program3.command("knowledge:generate").alias("om:generate").description(
48788
49744
  "Generate OrganizationModel knowledge nodes from MDX source files\n Example: elevasis-sdk om:generate"
@@ -48825,6 +49781,7 @@ function registerKnowledgeGenerate(program3) {
48825
49781
  }
48826
49782
 
48827
49783
  // src/cli/commands/knowledge/search.ts
49784
+ init_config();
48828
49785
  var ALL_KINDS = ["system", "resource", "knowledge", "ontology", "role", "policy"];
48829
49786
  function parseLimit(raw) {
48830
49787
  if (raw === void 0) return 10;
@@ -48877,6 +49834,7 @@ function registerKnowledgeSearch(program3) {
48877
49834
  }
48878
49835
 
48879
49836
  // src/cli/commands/knowledge/describe.ts
49837
+ init_config();
48880
49838
  function registerKnowledgeDescribe(program3) {
48881
49839
  program3.command("knowledge:describe <nodeId>").alias("om:describe").description(
48882
49840
  "Show a structured neighborhood view for any OM node id\n (system, resource, knowledge, ontology, role, policy \u2014 auto-detected from id shape)\n Example: elevasis-sdk om:describe sales.lead-gen\n Example: elevasis-sdk om:describe knowledge.outreach-playbook"
@@ -48915,6 +49873,8 @@ function registerKnowledgeCommands(program3) {
48915
49873
  // src/cli/commands/request/request.ts
48916
49874
  var import_node_fs4 = require("node:fs");
48917
49875
  var import_node_path4 = require("node:path");
49876
+ init_source();
49877
+ init_config();
48918
49878
 
48919
49879
  // ../core/src/requests/api-schemas.ts
48920
49880
  var RequestSeverityEnum = external_exports.enum(["critical", "warning", "info"]);
@@ -49071,6 +50031,7 @@ ${rows.length} request${rows.length === 1 ? "" : "s"}`));
49071
50031
  var import_node_child_process = require("node:child_process");
49072
50032
  var import_node_fs5 = __toESM(require("node:fs"), 1);
49073
50033
  var import_node_path5 = __toESM(require("node:path"), 1);
50034
+ init_config();
49074
50035
  function run(command, args, cwd) {
49075
50036
  (0, import_node_child_process.execFileSync)(command, args, {
49076
50037
  cwd,
@@ -49212,6 +50173,8 @@ function registerUiCommands(program3) {
49212
50173
  // src/cli/commands/doctor.ts
49213
50174
  var import_node_fs6 = require("node:fs");
49214
50175
  var import_node_path6 = __toESM(require("node:path"), 1);
50176
+ init_source();
50177
+ init_config();
49215
50178
  function ok(label, detail) {
49216
50179
  console.log(`${source_default.green("[OK]")} ${source_default.bold(label)}: ${detail}`);
49217
50180
  }
@@ -49451,6 +50414,8 @@ function registerCliCatalogCommand(program3) {
49451
50414
  }
49452
50415
 
49453
50416
  // src/cli/commands/acquisition/deals.ts
50417
+ init_source();
50418
+ init_config();
49454
50419
  function appendQuery2(params, key, value) {
49455
50420
  if (value === void 0 || value === null || value === "") return;
49456
50421
  params.set(key, String(value));
@@ -49560,6 +50525,8 @@ function registerAcquisitionDealStatus(program3) {
49560
50525
  }
49561
50526
 
49562
50527
  // src/cli/commands/acquisition/lists.ts
50528
+ init_source();
50529
+ init_config();
49563
50530
  function appendQuery3(params, key, value) {
49564
50531
  if (value === void 0 || value === null || value === "") return;
49565
50532
  params.set(key, String(value));
@@ -49677,6 +50644,8 @@ function registerAcquisitionCommands(program3) {
49677
50644
  }
49678
50645
 
49679
50646
  // src/cli/commands/client/client-write.ts
50647
+ init_source();
50648
+ init_config();
49680
50649
  function registerClientCreate(program3) {
49681
50650
  program3.command("client:create").description('Create a new client\n Example: elevasis-sdk client:create --name "Acme Corp"').requiredOption("--name <name>", "Client name").option("--status <status>", "Client status: active | onboarding | paused | completed | churned").option("--source-deal-id <uuid>", "UUID of the source deal").option("--primary-company-id <uuid>", "UUID of the primary company").option("--primary-contact-id <uuid>", "UUID of the primary contact").option("--metadata <json>", "Arbitrary metadata (JSON string)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
49682
50651
  wrapAction(
@@ -49808,6 +50777,8 @@ function registerClientCommands(program3) {
49808
50777
  }
49809
50778
 
49810
50779
  // src/cli/commands/queue/queue.ts
50780
+ init_source();
50781
+ init_config();
49811
50782
  function printJson4(value) {
49812
50783
  console.log(JSON.stringify(value, null, 2));
49813
50784
  }
@@ -49993,6 +50964,8 @@ function registerQueueCommands(program3) {
49993
50964
  }
49994
50965
 
49995
50966
  // src/cli/commands/schedule/schedule.ts
50967
+ init_source();
50968
+ init_config();
49996
50969
  function printJson5(value) {
49997
50970
  console.log(JSON.stringify(value, null, 2));
49998
50971
  }
@@ -50221,6 +51194,8 @@ function registerScheduleCommands(program3) {
50221
51194
  }
50222
51195
 
50223
51196
  // src/cli/commands/notes.ts
51197
+ init_source();
51198
+ init_config();
50224
51199
  var PRIORITY_HELP = "low | normal | high | urgent";
50225
51200
  function registerNoteCreate2(program3) {
50226
51201
  program3.command("note:create").description(
@@ -50297,6 +51272,8 @@ function registerNoteCommands(program3) {
50297
51272
  }
50298
51273
 
50299
51274
  // src/cli/commands/agent/agent.ts
51275
+ init_source();
51276
+ init_config();
50300
51277
  function printJson6(value) {
50301
51278
  console.log(JSON.stringify(value, null, 2));
50302
51279
  }
@@ -50358,6 +51335,8 @@ function registerAgentCommands(program3) {
50358
51335
  }
50359
51336
 
50360
51337
  // src/cli/commands/session/session.ts
51338
+ init_source();
51339
+ init_config();
50361
51340
  function printJson7(value) {
50362
51341
  console.log(JSON.stringify(value, null, 2));
50363
51342
  }
@@ -50441,10 +51420,44 @@ function registerSessionCommands(program3) {
50441
51420
  registerSessionEnd(program3);
50442
51421
  }
50443
51422
 
51423
+ // src/cli/commands/om/index.ts
51424
+ function registerOmScaffoldCommands(program3) {
51425
+ program3.command("om:scaffold:system").description("Guide creation of a new system entry in core/config/organization-model/systems.ts").option("--id <path>", "dot-notated system path, e.g. sales.crm (prompted if absent)").option("--title <title>", "display title (prompted if absent)").option("--kind <kind>", "system kind: operational | analytical | support (prompted if absent)").option("--api-backed", "emit apiInterface block and remind to add resource IDs").option("--dry-run", "print proposed TypeScript block without writing").action(async (opts) => {
51426
+ const mod = await Promise.resolve().then(() => (init_scaffold_system(), scaffold_system_exports));
51427
+ await mod.default(opts);
51428
+ });
51429
+ program3.command("om:scaffold:resource").description("Add a new workflow resource descriptor to core/config/organization-model/systems.ts").option("--id <id>", "resource id, e.g. lead-discovery-workflow (prompted if absent)").option("--system-path <path>", "systemPath to attach to (prompted if absent)").option("--title <title>", "resource display title (prompted if absent)").option("--primary-action <action>", "ontology primary action id (prompted; can be skipped)").option("--dry-run", "print proposed TypeScript block without writing").action(async (opts) => {
51430
+ const mod = await Promise.resolve().then(() => (init_scaffold_resource(), scaffold_resource_exports));
51431
+ await mod.default(opts);
51432
+ });
51433
+ program3.command("om:scaffold:role").description("Add a new role to core/config/organization-model/profile.ts").option("--id <id>", "role id, e.g. ops-lead (prompted if absent)").option("--title <title>", "display label (prompted if absent)").option("--description <desc>", "short description (prompted if absent)").option("--dry-run", "print proposed TypeScript block without writing").action(async (opts) => {
51434
+ const mod = await Promise.resolve().then(() => (init_scaffold_role(), scaffold_role_exports));
51435
+ await mod.default(opts);
51436
+ });
51437
+ program3.command("om:scaffold:knowledge").description("Create a new MDX knowledge node file in core/config/knowledge/nodes/").option("--id <id>", "knowledge node id, e.g. outreach-playbook (prompted if absent)").option("--kind <kind>", "node kind: playbook | strategy | reference | policy (prompted if absent)").option("--system-path <path>", "governing system path for mount (prompted; can be blank for global)").option("--dry-run", "print proposed MDX without writing").action(async (opts) => {
51438
+ const mod = await Promise.resolve().then(() => (init_scaffold_knowledge(), scaffold_knowledge_exports));
51439
+ await mod.default(opts);
51440
+ });
51441
+ program3.command("om:scaffold:fill").description("Non-interactive fill-mode: apply conformance gap JSON written by Agent 2a conformance gate").option("--gaps <path>", "path to conformance gap JSON file (required)").option("--skipped <path>", "output path for gaps that require manual input").option("--dry-run", "print proposed changes without writing").action(async (opts) => {
51442
+ const mod = await Promise.resolve().then(() => (init_scaffold_fill(), scaffold_fill_exports));
51443
+ await mod.default(opts);
51444
+ });
51445
+ }
51446
+
50444
51447
  // src/cli/index.ts
51448
+ init_config();
50445
51449
  var PREFLIGHT_SKIP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-V"]);
50446
51450
  var PREFLIGHT_SKIP_COMMANDS = /* @__PURE__ */ new Set(["cli"]);
50447
- var LOCAL_PROJECT_COMMANDS = /* @__PURE__ */ new Set(["ui:use-local", "ui:use-published", "knowledge:generate"]);
51451
+ var LOCAL_PROJECT_COMMANDS = /* @__PURE__ */ new Set([
51452
+ "ui:use-local",
51453
+ "ui:use-published",
51454
+ "knowledge:generate",
51455
+ "om:scaffold:system",
51456
+ "om:scaffold:resource",
51457
+ "om:scaffold:role",
51458
+ "om:scaffold:knowledge",
51459
+ "om:scaffold:fill"
51460
+ ]);
50448
51461
  function shouldSkipPreflight() {
50449
51462
  const args = process.argv.slice(2);
50450
51463
  if (args.length === 0) return true;
@@ -50563,6 +51576,7 @@ registerNoteCommands(program2);
50563
51576
  registerUiCommands(program2);
50564
51577
  registerDoctorCommand(program2);
50565
51578
  registerCliCatalogCommand(program2);
51579
+ registerOmScaffoldCommands(program2);
50566
51580
  program2.parse();
50567
51581
  // Annotate the CommonJS export names for ESM import in node:
50568
51582
  0 && (module.exports = {