@aifabrix/builder 2.51.1 → 2.52.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 (69) hide show
  1. package/lib/app/run-container-start.js +4 -0
  2. package/lib/app/run-deploy-job.js +135 -27
  3. package/lib/app/run-env-compose.js +32 -0
  4. package/lib/app/run-env-recovery.js +35 -0
  5. package/lib/app/run-helpers.js +5 -6
  6. package/lib/app/run.js +11 -3
  7. package/lib/channels/approval-guides/chatgpt.js +12 -9
  8. package/lib/channels/channel-targets.js +18 -1
  9. package/lib/channels/chatgpt-runtime-contract.js +1 -1
  10. package/lib/cli/infra-guided-footers.js +1 -1
  11. package/lib/cli/infra-guided-public-url-warn.js +55 -0
  12. package/lib/cli/infra-guided.js +65 -56
  13. package/lib/cli/setup-app.help.js +4 -0
  14. package/lib/cli/setup-app.test-commands.js +59 -28
  15. package/lib/cli/setup-external-system.js +50 -12
  16. package/lib/commands/channel-add-setup.js +8 -2
  17. package/lib/commands/channel.js +16 -5
  18. package/lib/commands/deploy-gate-orchestrator.js +3 -2
  19. package/lib/commands/governance-verify-external.js +2 -5
  20. package/lib/commands/lifecycle-external.js +14 -7
  21. package/lib/commands/role-assistant.js +66 -8
  22. package/lib/commands/test-governance-external.js +2 -5
  23. package/lib/commands/up-miso.js +61 -24
  24. package/lib/commands/upload-data-sync-finalize.js +20 -3
  25. package/lib/commands/verify-governance-external.js +2 -5
  26. package/lib/commands/verify-operations-external.js +2 -5
  27. package/lib/commands/verify-operations-step-plan.js +31 -0
  28. package/lib/commands/verify-trust-command-action.js +2 -5
  29. package/lib/datasource/datasource-identifier.js +4 -3
  30. package/lib/datasource/integration-context.js +3 -3
  31. package/lib/datasource/resolve-app.js +90 -8
  32. package/lib/datasource/test-e2e.js +2 -2
  33. package/lib/datasource/unified-validation-run-body.js +15 -1
  34. package/lib/datasource/unified-validation-run-resolve.js +2 -2
  35. package/lib/external-system/deploy-helpers.js +9 -5
  36. package/lib/external-system/deploy.js +2 -1
  37. package/lib/external-system/test-system-level.js +21 -3
  38. package/lib/external-system/test.js +4 -4
  39. package/lib/generator/builders.js +9 -15
  40. package/lib/role-assistant/knowledge-markdown-frontmatter.js +75 -0
  41. package/lib/role-assistant/knowledge-sync.js +25 -5
  42. package/lib/role-assistant/test-runner-workhub-answers.js +44 -26
  43. package/lib/role-assistant/test-runner-workhub.js +21 -7
  44. package/lib/schema/application-schema.json +10 -28
  45. package/lib/schema/infra.parameter.yaml +0 -20
  46. package/lib/utils/certify-external-workspace.js +40 -0
  47. package/lib/utils/docker-run-ephemeral.js +77 -17
  48. package/lib/utils/health-check-public-warn.js +31 -13
  49. package/lib/utils/health-check.js +11 -1
  50. package/lib/utils/paths.js +13 -15
  51. package/lib/utils/role-assistant-paths.js +76 -14
  52. package/lib/utils/upload-sync-options.js +7 -4
  53. package/lib/validation/reserved-system-key-prefixes.js +56 -0
  54. package/lib/validation/validate.js +54 -19
  55. package/package.json +1 -1
  56. package/templates/applications/builder-api/application.yaml +3 -3
  57. package/templates/applications/dataplane/application.yaml +3 -4
  58. package/templates/applications/dataplane/env.template +2 -2
  59. package/templates/applications/dataplane/rbac.yaml +10 -10
  60. package/templates/applications/keycloak/application.yaml +2 -2
  61. package/templates/applications/keycloak/env.template +5 -2
  62. package/templates/applications/miso-controller/application.yaml +3 -3
  63. package/templates/applications/miso-controller/env.template +16 -3
  64. package/templates/channels/chatgpt/install.template.md.hbs +75 -37
  65. package/templates/channels/chatgpt/integration/README.md +3 -2
  66. package/templates/channels/chatgpt/manifest.template.json.hbs +3 -3
  67. package/templates/channels/slack/install.template.md.hbs +6 -1
  68. package/templates/python/docker-compose.hbs +10 -0
  69. package/templates/typescript/docker-compose.hbs +10 -0
@@ -8,8 +8,6 @@ const chalk = require('chalk');
8
8
  const logger = require('../utils/logger');
9
9
  const config = require('../core/config');
10
10
  const devConfig = require('../utils/dev-config');
11
- const pathsUtil = require('../utils/paths');
12
- const { loadConfigFile } = require('../utils/config-format');
13
11
  const { withMutedLogger } = require('../utils/with-muted-logger');
14
12
  const infra = require('../infrastructure');
15
13
  const { execWithDockerEnv } = require('../utils/docker-exec');
@@ -41,12 +39,72 @@ const {
41
39
  logUpPlatformForceCleanSummary,
42
40
  logStoppedServices
43
41
  } = require('./infra-guided-footers');
44
- const healthCheck = require('../utils/health-check');
45
42
  const { prepareUrlsLocalRegistryForUpPlatform } = require('../commands/up-common');
46
43
  const { assertDevInfraUp } = require('../commands/dev-infra-gate');
47
44
  const {
48
45
  emitSystemBuilderAppManifestLineIfTTY
49
46
  } = require('../utils/manifest-source-emit');
47
+ const { flushDeferredPublicUrlWarnings } = require('./infra-guided-public-url-warn');
48
+
49
+ /**
50
+ * Guided Keycloak → Miso Controller start with one spinner per app (no second health wait).
51
+ * @param {Object} options
52
+ * @param {Function} handleUpMiso
53
+ * @returns {Promise<string[]>} Deferred public-URL warning messages
54
+ */
55
+ async function runGuidedKeycloakAndMisoControllerPhase(options, handleUpMiso) {
56
+ const deferredWarnings = [];
57
+ const misoSpinnerRef = { current: null };
58
+ emitSystemBuilderAppManifestLineIfTTY(logger, 'keycloak');
59
+ const kcSpin = startSpinner('Starting Keycloak...');
60
+ // Fully mute inner run logs — any newline (✔ / Manifest / blank) splits the ora line.
61
+ await withMutedLogger(
62
+ () =>
63
+ handleUpMiso({
64
+ ...options,
65
+ platformInstall: true,
66
+ onAfterKeycloak: () => {
67
+ stopSpinnerSuccess(kcSpin, 'Keycloak ready');
68
+ logger.log('');
69
+ emitSystemBuilderAppManifestLineIfTTY(logger, 'miso-controller');
70
+ misoSpinnerRef.current = startSpinner('Starting Miso Controller...');
71
+ },
72
+ onMisoPollText: (text) => {
73
+ const spin = misoSpinnerRef.current;
74
+ if (spin) {
75
+ // Keep app name; append health progress so the spinner does not look like a new step.
76
+ spin.text = `Starting Miso Controller… ${stripHealthPrefix(text)}`;
77
+ return;
78
+ }
79
+ logger.log(text);
80
+ },
81
+ onDeferredPublicUrlWarning: (message) => deferredWarnings.push(message)
82
+ }),
83
+ { allow: () => false }
84
+ );
85
+ if (misoSpinnerRef.current) {
86
+ stopSpinnerSuccess(misoSpinnerRef.current, 'Miso Controller ready');
87
+ } else {
88
+ stopSpinnerSuccess(kcSpin, 'Keycloak ready');
89
+ }
90
+ flushDeferredPublicUrlWarnings(deferredWarnings);
91
+ logger.log('');
92
+ return deferredWarnings;
93
+ }
94
+
95
+ /** ESC + CSI SGR — built without a control-char regex literal (no-control-regex). */
96
+ const ANSI_SGR_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, 'g');
97
+
98
+ /**
99
+ * Turn "Waiting for health check… (4/45)" into "(4/45)" for nested spinner text.
100
+ * @param {string} text
101
+ * @returns {string}
102
+ */
103
+ function stripHealthPrefix(text) {
104
+ const raw = String(text || '');
105
+ const match = raw.match(/\((\d+\/\d+)\)/);
106
+ return match ? `(${match[1]})` : raw.replace(ANSI_SGR_RE, '').trim();
107
+ }
50
108
 
51
109
  async function getRunningContainerNameForApp(appName) {
52
110
  const apps = await infra.getAppStatus();
@@ -86,31 +144,6 @@ async function validateAppErrorLogs(appNames) {
86
144
  logger.log('');
87
145
  }
88
146
 
89
- async function waitForAppReady(appName, opts = {}) {
90
- const timeoutSeconds = Number.isFinite(opts.timeoutSeconds) ? opts.timeoutSeconds : 90;
91
- const builderPath = pathsUtil.getBuilderPath(appName);
92
- const configPath = pathsUtil.resolveApplicationConfigPath(builderPath);
93
- const appConfig = loadConfigFile(configPath) || {};
94
-
95
- const apps = await infra.getAppStatus();
96
- const hit = (apps || []).find(a => a && a.name === appName && typeof a.url === 'string');
97
- const portMatch = hit && hit.url ? hit.url.match(/:(\d+)$/) : null;
98
- const hostPort = portMatch ? parseInt(portMatch[1], 10) : null;
99
- if (!hostPort) {
100
- throw new Error(`Could not determine host port for ${appName}`);
101
- }
102
-
103
- const userCfg = await config.getConfig();
104
- const healthRunOpts = { profile: 'docker' };
105
- if (userCfg && userCfg.traefik === true) {
106
- healthRunOpts.traefikEnabled = true;
107
- }
108
- if (typeof opts.onPollText === 'function') {
109
- healthRunOpts.onPollText = opts.onPollText;
110
- }
111
- await healthCheck.waitForHealthCheck(appName, timeoutSeconds, hostPort, appConfig, false, healthRunOpts);
112
- }
113
-
114
147
  function resolveInfraHost(remoteServer) {
115
148
  const raw = String(remoteServer || '').trim().replace(/\/+$/, '');
116
149
  if (!raw) return 'localhost';
@@ -179,16 +212,7 @@ async function runGuidedUpMiso(options, handleUpMiso) {
179
212
  logger.log('');
180
213
  logPlatformSetupDurationHint('platform');
181
214
  logger.log('');
182
- const kcSpin = startSpinner('Starting Keycloak...');
183
- await withMutedLogger(() => handleUpMiso({ ...options, platformInstall: true }));
184
- stopSpinnerSuccess(kcSpin, 'Keycloak ready');
185
- logger.log('');
186
- const mcSpin = startSpinner('Starting Miso Controller...');
187
- await waitForAppReady('miso-controller', {
188
- timeoutSeconds: 120,
189
- onPollText: createSpinnerTextUpdater(mcSpin)
190
- });
191
- stopSpinnerSuccess(mcSpin, 'Miso Controller ready');
215
+ await runGuidedKeycloakAndMisoControllerPhase(options, handleUpMiso);
192
216
  await logMisoReadyFooter();
193
217
  await validateAppErrorLogs(['miso-controller']);
194
218
  }
@@ -241,22 +265,6 @@ async function refreshDataplaneVersionAfterPlatformInstall() {
241
265
  }
242
266
  }
243
267
 
244
- async function runGuidedKeycloakAndMisoControllerPhase(options, handleUpMiso) {
245
- emitSystemBuilderAppManifestLineIfTTY(logger, 'keycloak');
246
- const kcSpin = startSpinner('Starting Keycloak...');
247
- await withMutedLogger(() => handleUpMiso({ ...options, platformInstall: true }));
248
- stopSpinnerSuccess(kcSpin, 'Keycloak ready');
249
- logger.log('');
250
- emitSystemBuilderAppManifestLineIfTTY(logger, 'miso-controller');
251
- const mcSpin = startSpinner('Starting Miso Controller...');
252
- await waitForAppReady('miso-controller', {
253
- timeoutSeconds: 120,
254
- onPollText: createSpinnerTextUpdater(mcSpin)
255
- });
256
- stopSpinnerSuccess(mcSpin, 'Miso Controller ready');
257
- logger.log('');
258
- }
259
-
260
268
  async function runGuidedDataplaneInstallPhase(options, handleUpDataplane, handleLoginFn, controllerUrl) {
261
269
  logger.log('');
262
270
  emitSystemBuilderAppManifestLineIfTTY(logger, 'dataplane');
@@ -310,7 +318,7 @@ async function runGuidedUpPlatform(options, handleUpMiso, handleUpDataplane, han
310
318
  await runGuidedAuthStep(handleLogin, authOpts, { startSpinner, stopSpinnerSuccess });
311
319
  const controllerUrl = await resolveGuidedAuthControllerUrl(authOpts);
312
320
  await runGuidedDataplaneInstallPhase(options, handleUpDataplane, handleLogin, controllerUrl);
313
- const baSpin = startSpinner('Starting builder-api...');
321
+ const baSpin = startSpinner('Starting Builder API...');
314
322
  await withMutedLogger(() => handleUpBuilderApi({ ...options, platformInstall: true }));
315
323
  stopSpinnerSuccess(baSpin, 'Builder API ready');
316
324
  await validateAppErrorLogs(['miso-controller', 'dataplane', 'builder-api']);
@@ -353,5 +361,6 @@ module.exports = {
353
361
  runGuidedUpMiso,
354
362
  runGuidedUpDataplane,
355
363
  runGuidedUpPlatform,
356
- runGuidedDownInfra
364
+ runGuidedDownInfra,
365
+ stripHealthPrefix
357
366
  };
@@ -11,6 +11,10 @@ Examples:
11
11
  $ aifabrix test hubspot -v
12
12
  $ aifabrix test hubspot -d
13
13
 
14
+ # Role Assistant (role-assistant/ra-<roleKey>/) — lifecycle checks
15
+ $ aifabrix test ra-business-transformation
16
+ $ aifabrix role-assistant test business-transformation
17
+
14
18
  # Builder app (builder/<app>/) — runs in container
15
19
  $ aifabrix test myapp -e dev
16
20
  $ aifabrix test myapp -e tst
@@ -12,9 +12,56 @@ const {
12
12
  TEST_E2E_HELP_AFTER
13
13
  } = require('./setup-app.help');
14
14
 
15
+ /** External packages that use local unit validation (not builder container tests). */
16
+ function isExternalUnitTestWorkspace(baseDir) {
17
+ return baseDir === 'integration' || baseDir === 'enterprise-knowledge';
18
+ }
19
+
20
+ /**
21
+ * Dispatch aifabrix test by detected workspace (builder / integration / role-assistant).
22
+ * @param {string} appName
23
+ * @param {Object} options
24
+ * @param {Object} cmd
25
+ * @returns {Promise<void>}
26
+ */
27
+ async function runTestCommandAction(appName, options, cmd) {
28
+ const rawArgs = Array.isArray(cmd?.rawArgs) ? cmd.rawArgs : [];
29
+ const envExplicit = rawArgs.includes('-e') || rawArgs.includes('--env');
30
+ const pathsUtil = require('../utils/paths');
31
+ const appType = await pathsUtil.detectAppType(appName).catch(() => null);
32
+ if (options.sync === true) {
33
+ throw new Error(
34
+ 'Option --sync is not supported for aifabrix test (local or container runs do not publish to the dataplane). ' +
35
+ 'Use: aifabrix upload <systemKey>, then aifabrix test-integration <systemKey> --sync or aifabrix datasource test-integration <datasourceKey> --sync.'
36
+ );
37
+ }
38
+ if (appType && appType.baseDir === 'role-assistant') {
39
+ const { runRoleAssistantTestAction } = require('../commands/role-assistant');
40
+ await runRoleAssistantTestAction(appName, options, cmd);
41
+ return;
42
+ }
43
+ if (appType && isExternalUnitTestWorkspace(appType.baseDir)) {
44
+ const test = require('../external-system/test');
45
+ const externalOpts = {
46
+ ...options,
47
+ // Keep help default but don't override auth/env behavior unless user explicitly set it.
48
+ env: envExplicit ? options.env : undefined
49
+ };
50
+ const results = await test.testExternalSystem(appName, externalOpts);
51
+ test.displayTestResults(results, options.verbose, appName);
52
+ if (!results.valid) process.exit(1);
53
+ return;
54
+ }
55
+ const { runAppTest } = require('../commands/app-test');
56
+ await runAppTest(appName, { env: options.env });
57
+ }
58
+
15
59
  function setupTestCommand(program) {
16
60
  program.command('test <appKey|systemKey>')
17
- .description('Tests: builder appKey in container; external systemKey = local validation')
61
+ .description(
62
+ 'Tests: builder appKey in container; integration/EK = local validation; ' +
63
+ 'role-assistant = lifecycle (same as role-assistant test)'
64
+ )
18
65
  .option('-e, --env <env>', 'For builder app: dev (running container) or tst (ephemeral)', 'dev')
19
66
  .option('-v, --verbose', 'Verbose output')
20
67
  .option('-d, --debug', 'Certification debug + log to integration/<systemKey>/logs/ (external only)')
@@ -25,30 +72,7 @@ function setupTestCommand(program) {
25
72
  .addHelpText('after', TEST_HELP_AFTER)
26
73
  .action(async(appName, options, cmd) => {
27
74
  try {
28
- const rawArgs = Array.isArray(cmd?.rawArgs) ? cmd.rawArgs : [];
29
- const envExplicit = rawArgs.includes('-e') || rawArgs.includes('--env');
30
- const pathsUtil = require('../utils/paths');
31
- const appType = await pathsUtil.detectAppType(appName).catch(() => null);
32
- if (options.sync === true) {
33
- throw new Error(
34
- 'Option --sync is not supported for aifabrix test (local or container runs do not publish to the dataplane). ' +
35
- 'Use: aifabrix upload <systemKey>, then aifabrix test-integration <systemKey> --sync or aifabrix datasource test-integration <datasourceKey> --sync.'
36
- );
37
- }
38
- if (appType && appType.baseDir === 'integration') {
39
- const test = require('../external-system/test');
40
- const externalOpts = {
41
- ...options,
42
- // Keep help default but don't override auth/env behavior unless user explicitly set it.
43
- env: envExplicit ? options.env : undefined
44
- };
45
- const results = await test.testExternalSystem(appName, externalOpts);
46
- test.displayTestResults(results, options.verbose, appName);
47
- if (!results.valid) process.exit(1);
48
- return;
49
- }
50
- const { runAppTest } = require('../commands/app-test');
51
- await runAppTest(appName, { env: options.env });
75
+ await runTestCommandAction(appName, options, cmd);
52
76
  } catch (error) {
53
77
  handleCommandError(error, 'test');
54
78
  process.exit(1);
@@ -106,7 +130,14 @@ async function runTestE2ECommand(appName, options, cmd) {
106
130
  'Remove --no-publish for builder app E2E.'
107
131
  );
108
132
  }
109
- if (appType && appType.baseDir === 'integration') {
133
+ if (appType && appType.baseDir === 'role-assistant') {
134
+ throw new Error(
135
+ `'${appName}' is a Role Assistant under role-assistant/. ` +
136
+ 'Datasource E2E does not apply. Use: aifabrix role-assistant test <roleKey> ' +
137
+ '(or: aifabrix test <roleKey>).'
138
+ );
139
+ }
140
+ if (appType && isExternalUnitTestWorkspace(appType.baseDir)) {
110
141
  await runExternalIntegrationE2EAndExit(appName, options, cmd);
111
142
  return;
112
143
  }
@@ -122,7 +153,7 @@ function setupInstallCommand(program) {
122
153
  try {
123
154
  const pathsUtil = require('../utils/paths');
124
155
  const appType = await pathsUtil.detectAppType(appName).catch(() => null);
125
- if (appType && appType.baseDir === 'integration') {
156
+ if (appType && (isExternalUnitTestWorkspace(appType.baseDir) || appType.baseDir === 'role-assistant')) {
126
157
  logger.log(
127
158
  chalk.gray('Install is for builder appKey only. Use aifabrix shell <appKey> for builder apps or External Systems commands for integrations.')
128
159
  );
@@ -186,7 +217,7 @@ function setupLintCommand(program) {
186
217
  try {
187
218
  const pathsUtil = require('../utils/paths');
188
219
  const appType = await pathsUtil.detectAppType(appName).catch(() => null);
189
- if (appType && appType.baseDir === 'integration') {
220
+ if (appType && (isExternalUnitTestWorkspace(appType.baseDir) || appType.baseDir === 'role-assistant')) {
190
221
  logger.log(chalk.gray('lint is for builder appKey only. Use aifabrix shell <appKey> then make lint or pnpm lint.'));
191
222
  return;
192
223
  }
@@ -159,10 +159,44 @@ function setupDeleteCommand(program) {
159
159
  * @param {Object} options - CLI options
160
160
  * @returns {Promise<boolean>} True if builder test was run, false otherwise
161
161
  */
162
- async function tryBuilderTestIntegration(appName, options) {
162
+ /**
163
+ * @param {string} appName
164
+ * @param {Object} options
165
+ * @returns {Promise<boolean>} True if a builder-app integration test was started
166
+ */
167
+ async function tryRunBuilderAppIntegration(appName, options) {
163
168
  const fsSync = require('fs');
169
+ const { getBuilderPath } = require('../utils/paths');
170
+ const { resolveApplicationConfigPath } = require('../utils/app-config-resolver');
171
+ const builderPath = getBuilderPath(appName);
172
+ if (!fsSync.existsSync(builderPath)) {
173
+ return false;
174
+ }
175
+ let builderConfigPath;
176
+ try {
177
+ builderConfigPath = resolveApplicationConfigPath(builderPath);
178
+ } catch {
179
+ return false;
180
+ }
181
+ if (!fsSync.existsSync(builderConfigPath)) {
182
+ return false;
183
+ }
184
+ const { runAppTestIntegration } = require('../commands/app-test');
185
+ await runAppTestIntegration(appName, {
186
+ env: options.env || options.environment || 'dev'
187
+ });
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Prefer builder-app container tests when no externalIntegration folder exists.
193
+ * @param {string} appName - App or system key
194
+ * @param {Object} options - CLI options
195
+ * @returns {Promise<boolean>} True if builder test was run, false otherwise
196
+ */
197
+ async function tryBuilderTestIntegration(appName, options) {
164
198
  const pathsUtil = require('../utils/paths');
165
- const { getIntegrationPath, getBuilderPath } = pathsUtil;
199
+ const { getIntegrationPath } = pathsUtil;
166
200
  const { resolveApplicationConfigPath } = require('../utils/app-config-resolver');
167
201
  const { loadConfigFile } = require('../utils/config-format');
168
202
  const integrationPath = getIntegrationPath(appName);
@@ -173,17 +207,10 @@ async function tryBuilderTestIntegration(appName, options) {
173
207
  } catch {
174
208
  // integration path or config missing
175
209
  }
176
- if (!hasExternalIntegration) {
177
- const builderPath = getBuilderPath(appName);
178
- const builderConfigPath = resolveApplicationConfigPath(builderPath);
179
- if (fsSync.existsSync(builderPath) && fsSync.existsSync(builderConfigPath)) {
180
- const { runAppTestIntegration } = require('../commands/app-test');
181
- const opts = { env: options.env || options.environment || 'dev' };
182
- await runAppTestIntegration(appName, opts);
183
- return true;
184
- }
210
+ if (hasExternalIntegration) {
211
+ return false;
185
212
  }
186
- return false;
213
+ return tryRunBuilderAppIntegration(appName, options);
187
214
  }
188
215
 
189
216
  /**
@@ -233,6 +260,17 @@ async function runTestIntegrationCommand(appName, options) {
233
260
  await runAppTestIntegration(appName, opts);
234
261
  return;
235
262
  }
263
+ // Role Assistant / EK / integration packages must use the dataplane path — do not
264
+ // probe builder/<app> (resolveApplicationConfigPath throws when the folder is absent).
265
+ if (
266
+ appType &&
267
+ (appType.baseDir === 'role-assistant' ||
268
+ appType.baseDir === 'enterprise-knowledge' ||
269
+ appType.baseDir === 'integration')
270
+ ) {
271
+ await runExternalSystemTestIntegration(appName, options);
272
+ return;
273
+ }
236
274
  const ranBuilder = await tryBuilderTestIntegration(appName, options);
237
275
  if (ranBuilder) {
238
276
  if (options.sync === true) {
@@ -9,15 +9,21 @@
9
9
  const chalk = require('chalk');
10
10
  const logger = require('../utils/logger');
11
11
  const { formatBlockingError } = require('../utils/cli-test-layout-chalk');
12
- const { isChannelTargetKey } = require('../channels/channel-targets');
12
+ const {
13
+ formatSupportedChannelTargetsHelp,
14
+ isChannelTargetKey
15
+ } = require('../channels/channel-targets');
13
16
  const { addChannelCommand } = require('../channels/add-channel');
14
17
 
15
18
  const CHANNEL_ADD_HELP_AFTER = `
19
+ ${formatSupportedChannelTargetsHelp()}
16
20
 
17
21
  Examples:
18
22
  # After upload/deploy of the communication external system
19
23
  $ aifabrix channel add slack --name "Elsa"
20
24
  $ aifabrix channel add teams-bot --name "Elsa" --description "Enterprise AI assistant for employees"
25
+ $ aifabrix channel add chatgpt --name "Your Assistant"
26
+ $ aifabrix channel add microsoft-copilot --name "Your Assistant"
21
27
 
22
28
  # Slack slash-command prefix (registers /{prefix}-help in manifest)
23
29
  $ aifabrix channel add slack --name "Elsa" --command-prefix af
@@ -49,7 +55,7 @@ async function runChannelAddAction(channelTarget, options, meta = {}) {
49
55
  }
50
56
  if (!isChannelTargetKey(channelTarget)) {
51
57
  throw new Error(
52
- `Unknown channel target "${channelTarget}". Use teams-bot, slack, microsoft-copilot, or chatgpt.`
58
+ `Unknown channel target "${channelTarget}". ${formatSupportedChannelTargetsHelp()}`
53
59
  );
54
60
  }
55
61
  await addChannelCommand(channelTarget, {
@@ -16,7 +16,10 @@ const {
16
16
  sectionTitle,
17
17
  metadata
18
18
  } = require('../utils/cli-test-layout-chalk');
19
- const { CHANNEL_TARGET_KEYS, isChannelTargetKey } = require('../channels/channel-targets');
19
+ const {
20
+ formatSupportedChannelTargetsHelp,
21
+ isChannelTargetKey
22
+ } = require('../channels/channel-targets');
20
23
  const { scaffoldChannelIntegration } = require('../channels/channel-integration-generator');
21
24
  const { registerChannelAddCommand } = require('./channel-add-setup');
22
25
 
@@ -25,9 +28,7 @@ Subcommands:
25
28
  scaffold <target> Create integration/<target>/ files locally (step 1)
26
29
  add <target> Channel install guide + manifest/credential patch (step 3)
27
30
 
28
- Targets:
29
- teams-bot, slack, microsoft-copilot, chatgpt
30
- web-embed (experimental — scaffold with --allow-experimental)
31
+ ${formatSupportedChannelTargetsHelp()}
31
32
 
32
33
  Typical flow (channels are connected systems, not controller apps):
33
34
  aifabrix channel scaffold slack
@@ -39,6 +40,15 @@ Controller pipeline apps only: aifabrix app register · aifabrix app list
39
40
  Requires: aifabrix login (for add)
40
41
  `;
41
42
 
43
+ const CHANNEL_SCAFFOLD_HELP_AFTER = `
44
+ ${formatSupportedChannelTargetsHelp()}
45
+
46
+ Typical flow:
47
+ aifabrix channel scaffold slack
48
+ aifabrix upload slack --force
49
+ aifabrix channel add slack --name "Your Assistant" --probe
50
+ `;
51
+
42
52
  /**
43
53
  * @param {import('commander').Command} program
44
54
  */
@@ -57,11 +67,12 @@ function setupChannelCommands(program) {
57
67
  )
58
68
  .option('--force', 'Overwrite generated scaffold files when folder exists')
59
69
  .option('--allow-experimental', 'Allow web-embed scaffold')
70
+ .addHelpText('after', CHANNEL_SCAFFOLD_HELP_AFTER)
60
71
  .action(async(channelTarget, options) => {
61
72
  try {
62
73
  if (!isChannelTargetKey(channelTarget)) {
63
74
  throw new Error(
64
- `Unknown channel target "${channelTarget}". Expected: ${CHANNEL_TARGET_KEYS.join(', ')}`
75
+ `Unknown channel target "${channelTarget}". ${formatSupportedChannelTargetsHelp()}`
65
76
  );
66
77
  }
67
78
  const result = await scaffoldChannelIntegration(channelTarget, {
@@ -142,7 +142,6 @@ async function runDeployBaselineSteps(systemKey, options) {
142
142
  uploadStatus: 'published',
143
143
  minimal: true,
144
144
  suppressSummary: true,
145
- suppressPipelineSpinner: true,
146
145
  uploadContext: 'deploy-preflight'
147
146
  });
148
147
  stepOptions = mergeUploadAuthOptions({ ...options, uploadStatus: 'published' }, uploadCtx);
@@ -322,7 +321,9 @@ function inferGatePillarFromLabel(label) {
322
321
  * @returns {Promise<{ baseline: { unitPassed: boolean, integrationPassed: boolean }, gates: Object[] }>}
323
322
  */
324
323
  async function runDeployGateOrchestrator(systemKey, options = {}) {
325
- const quiet = options.quietDeployUi === true || options.verbose !== true;
324
+ // Default: show unit/integration/publish progress (parity with upload).
325
+ // Only hush when caller opts in (json / explicit quietDeployUi).
326
+ const quiet = options.quietDeployUi === true;
326
327
  if (!quiet) {
327
328
  logger.log('');
328
329
  logger.log(sectionTitle('Deploy preflight'));
@@ -20,12 +20,9 @@ const { VERDICT, verdictFromPassed } = require('../lifecycle/product-model');
20
20
  */
21
21
  async function runGovernanceVerifyForExternalSystem(systemKey, options = {}) {
22
22
  const pathsUtil = require('../utils/paths');
23
+ const { assertCertifyExternalWorkspace } = require('../utils/certify-external-workspace');
23
24
  const appType = await pathsUtil.detectAppType(systemKey).catch(() => null);
24
- if (!appType || appType.baseDir !== 'integration') {
25
- throw new Error(
26
- 'governance verify applies to external integration folders only (integration/<systemKey>/).'
27
- );
28
- }
25
+ assertCertifyExternalWorkspace(appType && appType.baseDir, 'governance verify');
29
26
 
30
27
  if (options.pack) {
31
28
  const { runTestGovernanceForExternalSystem } = require('./test-governance-external');
@@ -247,23 +247,30 @@ async function executeLifecycleWork(systemKey, options = {}) {
247
247
  */
248
248
  async function runLifecycleForExternalSystem(systemKey, options = {}) {
249
249
  const pathsUtil = require('../utils/paths');
250
+ const { assertCertifyExternalWorkspace } = require('../utils/certify-external-workspace');
250
251
  const appType = await pathsUtil.detectAppType(systemKey).catch(() => null);
251
- const allowedRoots = new Set(['integration', 'role-assistant']);
252
- if (!appType || !allowedRoots.has(appType.baseDir)) {
253
- throw new Error(
254
- 'lifecycle applies to external authoring folders only (integration/<systemKey>/ or role-assistant/<roleKey>/).'
255
- );
252
+ assertCertifyExternalWorkspace(appType && appType.baseDir, 'lifecycle');
253
+
254
+ let resolvedKey = systemKey;
255
+ if (appType.baseDir === 'role-assistant') {
256
+ const { resolveExternalIntegrationContext } = require('./test-e2e-external');
257
+ const { roleAssistantSystemKey } = require('../utils/role-assistant-paths');
258
+ try {
259
+ resolvedKey = resolveExternalIntegrationContext(systemKey).systemKey;
260
+ } catch {
261
+ resolvedKey = roleAssistantSystemKey(systemKey);
262
+ }
256
263
  }
257
264
 
258
265
  if (options.run === true) {
259
266
  return runWithVerifyStepProgress(
260
267
  'Processing',
261
- async(progress) => executeLifecycleWork(systemKey, { ...options, lifecycleProgress: progress }),
268
+ async(progress) => executeLifecycleWork(resolvedKey, { ...options, lifecycleProgress: progress }),
262
269
  { json: options.json === true }
263
270
  );
264
271
  }
265
272
 
266
- return executeLifecycleWork(systemKey, options);
273
+ return executeLifecycleWork(resolvedKey, options);
267
274
  }
268
275
 
269
276
  module.exports = {
@@ -38,6 +38,61 @@ const {
38
38
  formatBlockingError,
39
39
  metadata
40
40
  } = require('../utils/cli-test-layout-chalk');
41
+ const {
42
+ bareRoleKey,
43
+ roleAssistantSystemKey
44
+ } = require('../utils/role-assistant-paths');
45
+
46
+ /**
47
+ * Bucket a lifecycle step status into ok | failed | skipped | other.
48
+ * @param {string} status
49
+ * @returns {'ok'|'failed'|'skipped'|'other'}
50
+ */
51
+ function bucketStepStatus(status) {
52
+ const normalized = String(status || 'ok').toLowerCase();
53
+ if (normalized === 'ok' || normalized === 'verified' || normalized === 'passed') {
54
+ return 'ok';
55
+ }
56
+ if (normalized === 'failed' || normalized === 'error') {
57
+ return 'failed';
58
+ }
59
+ if (normalized === 'skipped' || normalized === 'n/a' || normalized === 'not_applicable') {
60
+ return 'skipped';
61
+ }
62
+ return 'other';
63
+ }
64
+
65
+ /**
66
+ * Summarize lifecycle stepsRun rows (API uses step/status/datasourceKey, not pillar).
67
+ * @param {Array<Object|string>} steps
68
+ * @returns {string}
69
+ */
70
+ function formatStepsRunSummary(steps) {
71
+ const byStep = Object.create(null);
72
+ for (const row of steps) {
73
+ if (!row || typeof row !== 'object') {
74
+ const label = String(row);
75
+ byStep[label] = byStep[label] || { ok: 0, failed: 0, skipped: 0, other: 0 };
76
+ byStep[label].other += 1;
77
+ continue;
78
+ }
79
+ const stepName = String(row.step || row.pillar || row.name || 'step').trim() || 'step';
80
+ const status = row.status || (row.success === false ? 'failed' : 'ok');
81
+ byStep[stepName] = byStep[stepName] || { ok: 0, failed: 0, skipped: 0, other: 0 };
82
+ byStep[stepName][bucketStepStatus(status)] += 1;
83
+ }
84
+ return Object.keys(byStep)
85
+ .map((stepName) => {
86
+ const counts = byStep[stepName];
87
+ const parts = [];
88
+ if (counts.ok) parts.push(`${counts.ok} ok`);
89
+ if (counts.failed) parts.push(`${counts.failed} failed`);
90
+ if (counts.skipped) parts.push(`${counts.skipped} skipped`);
91
+ if (counts.other) parts.push(`${counts.other} other`);
92
+ return parts.length > 0 ? `${stepName} (${parts.join(', ')})` : stepName;
93
+ })
94
+ .join('; ');
95
+ }
41
96
 
42
97
  function roleAssistantHelpAfter() {
43
98
  return `
@@ -178,8 +233,7 @@ function displayRoleAssistantTestSummary(roleKey, verdict, portalUrl, result, ca
178
233
  }
179
234
  const steps = Array.isArray(result.stepsRun) ? result.stepsRun : [];
180
235
  if (steps.length > 0) {
181
- const labels = steps.map((row) => (row && row.pillar ? row.pillar : String(row)));
182
- logger.log(metadata(`Steps run: ${labels.join(', ')}`));
236
+ logger.log(metadata(`Steps run: ${formatStepsRunSummary(steps)}`));
183
237
  }
184
238
  displayCaseResultSummary(caseResult);
185
239
  }
@@ -230,21 +284,24 @@ function computeRoleAssistantExitCode(verdict, caseResult) {
230
284
 
231
285
  async function runRoleAssistantTestAction(roleKey, options, cmd) {
232
286
  const opts = normalizeRoleAssistantTestOptions(options, cmd);
233
- const result = await runLifecycleForExternalSystem(roleKey, opts);
287
+ // Dataplane ExternalSystem key is always ra-{roleKey}; bare roleKey is display/settings only.
288
+ const systemKey = roleAssistantSystemKey(roleKey);
289
+ const displayKey = bareRoleKey(roleKey);
290
+ const result = await runLifecycleForExternalSystem(systemKey, opts);
234
291
  const verdict = lifecycleVerdictFromReport(result.report || {});
235
- const portalUrl = buildExternalSystemUiUrl(result.dataplaneUiBaseUrl, roleKey);
236
- const caseResult = await resolveRoleAssistantCaseResult(roleKey, opts, result, verdict, portalUrl);
292
+ const portalUrl = buildExternalSystemUiUrl(result.dataplaneUiBaseUrl, systemKey);
293
+ const caseResult = await resolveRoleAssistantCaseResult(systemKey, opts, result, verdict, portalUrl);
237
294
 
238
295
  if (opts.json) {
239
296
  logger.log(
240
297
  JSON.stringify(
241
- buildRoleAssistantTestEnvelope(roleKey, verdict, portalUrl, result, opts, caseResult),
298
+ buildRoleAssistantTestEnvelope(displayKey, verdict, portalUrl, result, opts, caseResult),
242
299
  null,
243
300
  2
244
301
  )
245
302
  );
246
303
  } else {
247
- displayRoleAssistantTestSummary(roleKey, verdict, portalUrl, result, caseResult);
304
+ displayRoleAssistantTestSummary(displayKey, verdict, portalUrl, result, caseResult);
248
305
  }
249
306
 
250
307
  const exitCode = computeRoleAssistantExitCode(verdict, caseResult);
@@ -309,5 +366,6 @@ module.exports = {
309
366
  normalizeRoleAssistantTestOptions,
310
367
  buildRoleAssistantTestEnvelope,
311
368
  computeRoleAssistantExitCode,
312
- resolveRoleAssistantCaseResult
369
+ resolveRoleAssistantCaseResult,
370
+ formatStepsRunSummary
313
371
  };