@open-mercato/cli 0.11.1-develop.8942.1.68c12f7f28 → 0.11.1-develop.8950.1.f7e65e5fe1

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 (109) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/agentic/guides/module-facts.json +266 -193
  3. package/dist/agentic/guides/module-facts.v2.json +266 -193
  4. package/dist/agentic/guides/modules/agent_orchestrator/active-extension-bindings.md +1 -1
  5. package/dist/agentic/guides/modules/agent_orchestrator/contribution-resolutions.md +1 -0
  6. package/dist/agentic/guides/modules/agent_orchestrator/exact-override-targets.md +2 -1
  7. package/dist/agentic/guides/modules/agent_orchestrator/index.md +3 -3
  8. package/dist/agentic/guides/modules/agent_orchestrator/umes-contributions.md +1 -0
  9. package/dist/agentic/guides/modules/agent_orchestrator/workers.md +1 -1
  10. package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
  11. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  12. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  13. package/dist/agentic/guides/modules/assisted_selling/index.md +1 -1
  14. package/dist/agentic/guides/modules/attachments/di-registrations-rich.md +4 -4
  15. package/dist/agentic/guides/modules/attachments/di-service-tokens.md +3 -3
  16. package/dist/agentic/guides/modules/attachments/exact-override-targets.md +4 -4
  17. package/dist/agentic/guides/modules/attachments/index.md +1 -1
  18. package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
  19. package/dist/agentic/guides/modules/auth/index.md +1 -1
  20. package/dist/agentic/guides/modules/availability/index.md +1 -1
  21. package/dist/agentic/guides/modules/backups/index.md +1 -1
  22. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  23. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  24. package/dist/agentic/guides/modules/cart/index.md +1 -1
  25. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  26. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  27. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  28. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  29. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  30. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  31. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  32. package/dist/agentic/guides/modules/channel_ms365/index.md +1 -1
  33. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  34. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  35. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  36. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  37. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  38. package/dist/agentic/guides/modules/configs/index.md +1 -1
  39. package/dist/agentic/guides/modules/content/index.md +1 -1
  40. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  41. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  42. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  43. package/dist/agentic/guides/modules/customers/index.md +1 -1
  44. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  45. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  46. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  47. package/dist/agentic/guides/modules/devices/index.md +1 -1
  48. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  49. package/dist/agentic/guides/modules/directory/index.md +1 -1
  50. package/dist/agentic/guides/modules/documents/index.md +1 -1
  51. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  52. package/dist/agentic/guides/modules/entities/index.md +1 -1
  53. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  54. package/dist/agentic/guides/modules/events/index.md +1 -1
  55. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  56. package/dist/agentic/guides/modules/forms/index.md +1 -1
  57. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  58. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  59. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  60. package/dist/agentic/guides/modules/generators/index.md +1 -1
  61. package/dist/agentic/guides/modules/gus_regon/index.md +1 -1
  62. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  63. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  64. package/dist/agentic/guides/modules/ledger/index.md +1 -1
  65. package/dist/agentic/guides/modules/maintenance/index.md +1 -1
  66. package/dist/agentic/guides/modules/messages/index.md +1 -1
  67. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  68. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  69. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  70. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  71. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  72. package/dist/agentic/guides/modules/planner/index.md +1 -1
  73. package/dist/agentic/guides/modules/portal/index.md +1 -1
  74. package/dist/agentic/guides/modules/progress/index.md +1 -1
  75. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  76. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  77. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  78. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  79. package/dist/agentic/guides/modules/resources/index.md +1 -1
  80. package/dist/agentic/guides/modules/sales/index.md +1 -1
  81. package/dist/agentic/guides/modules/sales_invoices_gl_posting/index.md +1 -1
  82. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  83. package/dist/agentic/guides/modules/search/index.md +1 -1
  84. package/dist/agentic/guides/modules/security/index.md +1 -1
  85. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  86. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  87. package/dist/agentic/guides/modules/sso/index.md +1 -1
  88. package/dist/agentic/guides/modules/staff/index.md +1 -1
  89. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  90. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  91. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  92. package/dist/agentic/guides/modules/sync_shopify/index.md +1 -1
  93. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  94. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  95. package/dist/agentic/guides/modules/tenant_boundaries/index.md +1 -1
  96. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  97. package/dist/agentic/guides/modules/translations/index.md +1 -1
  98. package/dist/agentic/guides/modules/upgrade_actions/index.md +1 -1
  99. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  100. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  101. package/dist/agentic/guides/modules/wms/index.md +1 -1
  102. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  103. package/dist/agentic/guides/reference-module-facts.json +1 -1
  104. package/dist/agentic/guides/upstream/manifest.json +1 -1
  105. package/dist/lib/generators/extensions/agent-files.js +49 -0
  106. package/dist/lib/generators/extensions/agent-files.js.map +2 -2
  107. package/package.json +7 -7
  108. package/src/lib/generators/__tests__/agent-files-extension.test.ts +92 -0
  109. package/src/lib/generators/extensions/agent-files.ts +64 -0
@@ -411,6 +411,98 @@ describe('createAgentFilesExtension', () => {
411
411
  ).toThrow(/malformed GOVERNANCE\.json/)
412
412
  })
413
413
 
414
+ it('emits agent rubrics/<key>.json files into the manifest as evalRubrics', () => {
415
+ const fixture = makeRepoFixture()
416
+ repoRoot = fixture.repoRoot
417
+ const rubricsDir = path.join(fixture.appBase, 'agents', 'deals_health_check', 'rubrics')
418
+ fs.mkdirSync(rubricsDir, { recursive: true })
419
+ const rubric = {
420
+ promptTemplate: 'Judge whether the summary names the deal stage.',
421
+ scoring: { kind: 'binary', passDescription: 'Names it.', failDescription: 'Omits it.' },
422
+ }
423
+ fs.writeFileSync(path.join(rubricsDir, 'stage_named.json'), JSON.stringify(rubric), 'utf8')
424
+ fs.writeFileSync(path.join(rubricsDir, 'notes.txt'), 'ignored', 'utf8')
425
+
426
+ const extension = createAgentFilesExtension()
427
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
428
+ extension.generateOutput()
429
+
430
+ const manifest = fs.readFileSync(
431
+ path.join(repoRoot, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
432
+ 'utf8',
433
+ )
434
+ expect(manifest).toContain(`evalRubrics: ${JSON.stringify({ stage_named: rubric })}`)
435
+ expect(manifest).toContain('evalRubrics?: Record<string, Record<string, unknown>>')
436
+ expect(manifest).toContain('"path":"rubrics/stage_named.json"')
437
+ expect(manifest).not.toContain('rubrics/notes.txt')
438
+ })
439
+
440
+ it('emits a sub-agent rubric on the sub-agent descriptor only', () => {
441
+ const fixture = makeRepoFixture()
442
+ repoRoot = fixture.repoRoot
443
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
444
+ const subDir = path.join(agentDir, 'sub-agents', 'company_researcher')
445
+ fs.mkdirSync(path.join(subDir, 'rubrics'), { recursive: true })
446
+ fs.writeFileSync(
447
+ path.join(subDir, 'AGENT.md'),
448
+ ['---', 'id: deals.company_researcher', 'label: Company researcher', 'description: Research a company.', '---', 'You research a company.'].join('\n'),
449
+ 'utf8',
450
+ )
451
+ fs.writeFileSync(
452
+ path.join(subDir, 'OUTCOME.md'),
453
+ ['---', 'kind: research', '---', '```json', JSON.stringify({ type: 'object', properties: { summary: { type: 'string' } } }), '```'].join('\n'),
454
+ 'utf8',
455
+ )
456
+ const rubric = { promptTemplate: 'Judge the research.', scoring: { kind: 'binary', passDescription: 'Good.', failDescription: 'Bad.' } }
457
+ fs.writeFileSync(path.join(subDir, 'rubrics', 'research_depth.json'), JSON.stringify(rubric), 'utf8')
458
+
459
+ const extension = createAgentFilesExtension()
460
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
461
+ extension.generateOutput()
462
+
463
+ const manifest = fs.readFileSync(
464
+ path.join(repoRoot, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
465
+ 'utf8',
466
+ )
467
+ const rendered = `evalRubrics: ${JSON.stringify({ research_depth: rubric })}`
468
+ expect(manifest.split(rendered)).toHaveLength(2)
469
+ expect(manifest.indexOf(rendered)).toBeGreaterThan(manifest.indexOf('subAgentDescriptors: ['))
470
+ expect(manifest).toContain('"path":"sub-agents/company_researcher/rubrics/research_depth.json"')
471
+ })
472
+
473
+ it('omits evalRubrics when the agent has no rubrics directory', () => {
474
+ const fixture = makeRepoFixture()
475
+ repoRoot = fixture.repoRoot
476
+
477
+ const extension = createAgentFilesExtension()
478
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
479
+ extension.generateOutput()
480
+
481
+ const manifest = fs.readFileSync(
482
+ path.join(repoRoot, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
483
+ 'utf8',
484
+ )
485
+ expect(manifest).not.toContain('evalRubrics: {')
486
+ })
487
+
488
+ it.each([
489
+ ['an invalid key', 'bad key!.json', '{"promptTemplate":"x","scoring":{"kind":"binary"}}', /file name is the rubric key/],
490
+ ['invalid JSON', 'broken.json', '{ promptTemplate: ', /malformed rubric file/],
491
+ ['a top-level array', 'listed.json', '[]', /expected a JSON object/],
492
+ ['no scoring', 'no_scoring.json', '{"promptTemplate":"x"}', /"promptTemplate" \(string\) and "scoring" \(object\) are required/],
493
+ ])('fails generation on a rubric file with %s', (_label, fileName, content, message) => {
494
+ const fixture = makeRepoFixture()
495
+ repoRoot = fixture.repoRoot
496
+ const rubricsDir = path.join(fixture.appBase, 'agents', 'deals_health_check', 'rubrics')
497
+ fs.mkdirSync(rubricsDir, { recursive: true })
498
+ fs.writeFileSync(path.join(rubricsDir, fileName), content, 'utf8')
499
+
500
+ const extension = createAgentFilesExtension()
501
+ expect(() =>
502
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase)),
503
+ ).toThrow(message)
504
+ })
505
+
414
506
  it('fails generation on a malformed agent dir (missing OUTCOME.md)', () => {
415
507
  const fixture = makeRepoFixture()
416
508
  repoRoot = fixture.repoRoot
@@ -102,6 +102,8 @@ type DiscoveredAgent = {
102
102
  facts?: DiscoveredFact[]
103
103
  /** Optional `GOVERNANCE.json` declarations, validated in full when the agent loads. */
104
104
  governance?: DiscoveredGovernance
105
+ /** Optional judge rubrics from `rubrics/<key>.json`, validated in full when the agent loads. */
106
+ evalRubrics?: Record<string, Record<string, unknown>>
105
107
  /** Baked token-usage breakdown of the agent's construction files (Phase: token accounting). */
106
108
  tokenUsage: FileAgentTokenUsage
107
109
  /** Baked raw content of every construction file, for the read-only Files tab (#12 files). */
@@ -449,6 +451,9 @@ function discoverFacts(dir: string): DiscoveredFact[] | undefined {
449
451
  }
450
452
 
451
453
  const GOVERNANCE_FILE = 'GOVERNANCE.json'
454
+ const RUBRICS_DIR = 'rubrics'
455
+ /** MIRRORS `RUBRIC_KEY_PATTERN` in agent_orchestrator `lib/eval/rubrics/index.ts`. */
456
+ const RUBRIC_KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}$/
452
457
  const GOVERNANCE_OBJECT_KEYS = ['principal', 'modelSettings'] as const
453
458
  const GOVERNANCE_LIST_KEYS = ['integrity', 'untrustedInputs'] as const
454
459
 
@@ -456,6 +461,50 @@ function isPlainObject(value: unknown): value is Record<string, unknown> {
456
461
  return typeof value === 'object' && value !== null && !Array.isArray(value)
457
462
  }
458
463
 
464
+ /**
465
+ * Read the optional `agents/<id>/rubrics/<key>.json` judge rubrics an
466
+ * `llm_judge` assertion can name with `{ "rubricRef": "<key>" }`. The file name
467
+ * (without `.json`) is the key; the content is a judge rubric object. Only the
468
+ * shape and key are checked here — the CLI cannot import the enterprise rubric
469
+ * schema — and the loader validates each rubric with `parseAgentEvalRubrics`.
470
+ */
471
+ function discoverEvalRubrics(dir: string): Record<string, Record<string, unknown>> | undefined {
472
+ const rubricsDir = path.join(dir, RUBRICS_DIR)
473
+ if (!fs.existsSync(rubricsDir) || !fs.statSync(rubricsDir).isDirectory()) return undefined
474
+ const rubrics: Record<string, Record<string, unknown>> = {}
475
+ const files = fs
476
+ .readdirSync(rubricsDir, { withFileTypes: true })
477
+ .filter((entry) => entry.isFile() && entry.name.endsWith('.json'))
478
+ .map((entry) => entry.name)
479
+ .sort((a, b) => a.localeCompare(b))
480
+ for (const fileName of files) {
481
+ const key = fileName.slice(0, -'.json'.length)
482
+ const where = path.join(rubricsDir, fileName)
483
+ if (!RUBRIC_KEY_PATTERN.test(key)) {
484
+ throw new Error(
485
+ `[internal] malformed rubric file ${where}: the file name is the rubric key and may use letters, digits, "_", ".", ":" or "-" (max 100)`,
486
+ )
487
+ }
488
+ let parsed: unknown
489
+ try {
490
+ parsed = JSON.parse(fs.readFileSync(where, 'utf8'))
491
+ } catch (err) {
492
+ const detail = err instanceof Error ? err.message : String(err)
493
+ throw new Error(`[internal] malformed rubric file ${where}: ${detail}`)
494
+ }
495
+ if (!isPlainObject(parsed)) {
496
+ throw new Error(`[internal] malformed rubric file ${where}: expected a JSON object`)
497
+ }
498
+ if (typeof parsed.promptTemplate !== 'string' || !isPlainObject(parsed.scoring)) {
499
+ throw new Error(
500
+ `[internal] malformed rubric file ${where}: "promptTemplate" (string) and "scoring" (object) are required`,
501
+ )
502
+ }
503
+ rubrics[key] = parsed
504
+ }
505
+ return Object.keys(rubrics).length > 0 ? rubrics : undefined
506
+ }
507
+
459
508
  /**
460
509
  * Read the optional `agents/<id>/GOVERNANCE.json`: the same `principal`,
461
510
  * `integrity`, `untrustedInputs` and `modelSettings` declarations `defineAgent`
@@ -794,6 +843,7 @@ function discoverSubAgents(agentDir: string): DiscoveredAgent[] {
794
843
  sampleInput: discoverSampleInput(dir),
795
844
  facts: discoverFacts(dir),
796
845
  governance: discoverGovernance(dir),
846
+ evalRubrics: discoverEvalRubrics(dir),
797
847
  tokenUsage: discoverAgentTokenUsage(dir),
798
848
  sourceFiles: collectAgentFiles(dir),
799
849
  })
@@ -919,6 +969,9 @@ function collectAgentFiles(agentDir: string, prefix = '', depth = 0): FileAgentS
919
969
  add('AGENT.md', true)
920
970
  add('OUTCOME.md', true)
921
971
  for (const name of AGENT_AUX_FILES) add(name, false)
972
+ for (const name of tokenListFiles(path.join(agentDir, RUBRICS_DIR), ['.json'])) {
973
+ add(path.join(RUBRICS_DIR, name), false)
974
+ }
922
975
  for (const skillId of tokenListDirs(path.join(agentDir, 'skills'))) {
923
976
  const skillRel = path.join('skills', skillId)
924
977
  for (const name of ['SKILL.md', 'TEMPLATE.md']) add(path.join(skillRel, name), true)
@@ -1192,6 +1245,9 @@ function renderDescriptor(agent: DiscoveredAgent, indent: string): string {
1192
1245
  if (agent.governance !== undefined) {
1193
1246
  optional.push(`${indent} governance: ${JSON.stringify(agent.governance)},`)
1194
1247
  }
1248
+ if (agent.evalRubrics !== undefined) {
1249
+ optional.push(`${indent} evalRubrics: ${JSON.stringify(agent.evalRubrics)},`)
1250
+ }
1195
1251
  const skillsContent = agent.skillsContent.map((skill) => ({
1196
1252
  id: skill.id,
1197
1253
  instructions: skill.instructions,
@@ -1367,6 +1423,13 @@ export type FileAgentDescriptor = {
1367
1423
  * validates them with the \`defineAgent\` parsers.
1368
1424
  */
1369
1425
  governance?: FileAgentGovernance
1426
+ /**
1427
+ * Optional judge rubrics read from \`agents/<id>/rubrics/<key>.json\`, keyed by
1428
+ * file name. An \`llm_judge\` assertion names one with \`{ "rubricRef": "<key>" }\`;
1429
+ * it shadows a built-in of the same key. The loader validates them with
1430
+ * \`parseAgentEvalRubrics\`, exactly as \`defineAgent({ evalRubrics })\`.
1431
+ */
1432
+ evalRubrics?: Record<string, Record<string, unknown>>
1370
1433
  }
1371
1434
 
1372
1435
  export const fileAgentDescriptors: FileAgentDescriptor[] = [${
@@ -1471,6 +1534,7 @@ export function createAgentFilesExtension(resolver?: AgentFilesResolver): Genera
1471
1534
  sampleInput: discoverSampleInput(dir),
1472
1535
  facts: discoverFacts(dir),
1473
1536
  governance: discoverGovernance(dir),
1537
+ evalRubrics: discoverEvalRubrics(dir),
1474
1538
  tokenUsage: discoverAgentTokenUsage(dir),
1475
1539
  sourceFiles: collectAgentFiles(dir),
1476
1540
  })