@elevasis/core 0.24.1 → 0.26.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 (82) hide show
  1. package/dist/index.d.ts +239 -86
  2. package/dist/index.js +474 -1346
  3. package/dist/knowledge/index.d.ts +57 -39
  4. package/dist/knowledge/index.js +1 -1
  5. package/dist/organization-model/index.d.ts +239 -86
  6. package/dist/organization-model/index.js +474 -1346
  7. package/dist/test-utils/index.d.ts +24 -31
  8. package/dist/test-utils/index.js +76 -1238
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +108 -96
  11. package/src/business/acquisition/api-schemas.test.ts +70 -77
  12. package/src/business/acquisition/api-schemas.ts +21 -42
  13. package/src/business/acquisition/derive-actions.test.ts +11 -21
  14. package/src/business/acquisition/derive-actions.ts +61 -14
  15. package/src/business/acquisition/ontology-validation.ts +4 -4
  16. package/src/business/acquisition/types.ts +7 -8
  17. package/src/execution/engine/llm/adapters/__tests__/openrouter.integration.test.ts +10 -10
  18. package/src/knowledge/__tests__/queries.test.ts +960 -546
  19. package/src/knowledge/format.ts +322 -100
  20. package/src/knowledge/index.ts +18 -5
  21. package/src/knowledge/queries.ts +1004 -240
  22. package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
  23. package/src/organization-model/__tests__/defaults.test.ts +4 -4
  24. package/src/organization-model/__tests__/deprecate-helpers.test.ts +71 -0
  25. package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
  26. package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
  27. package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
  28. package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
  29. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
  30. package/src/organization-model/__tests__/foundation.test.ts +81 -14
  31. package/src/organization-model/__tests__/graph.test.ts +662 -694
  32. package/src/organization-model/__tests__/knowledge.test.ts +31 -17
  33. package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
  34. package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
  35. package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
  36. package/src/organization-model/__tests__/published-zero-leak.test.ts +17 -0
  37. package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
  38. package/src/organization-model/__tests__/resolve.test.ts +88 -49
  39. package/src/organization-model/__tests__/scaffolders.test.ts +93 -0
  40. package/src/organization-model/__tests__/schema.test.ts +65 -56
  41. package/src/organization-model/catalogs/lead-gen.ts +0 -103
  42. package/src/organization-model/defaults.ts +17 -702
  43. package/src/organization-model/domains/actions.ts +116 -333
  44. package/src/organization-model/domains/knowledge.ts +15 -7
  45. package/src/organization-model/domains/projects.ts +4 -4
  46. package/src/organization-model/domains/prospecting.ts +405 -395
  47. package/src/organization-model/domains/resources.ts +206 -135
  48. package/src/organization-model/domains/sales.ts +5 -5
  49. package/src/organization-model/domains/systems.ts +8 -23
  50. package/src/organization-model/graph/build.ts +223 -294
  51. package/src/organization-model/graph/schema.ts +2 -3
  52. package/src/organization-model/graph/types.ts +12 -14
  53. package/src/organization-model/helpers.ts +120 -141
  54. package/src/organization-model/icons.ts +1 -0
  55. package/src/organization-model/index.ts +107 -126
  56. package/src/organization-model/migration-helpers.ts +211 -249
  57. package/src/organization-model/ontology.ts +0 -60
  58. package/src/organization-model/organization-graph.mdx +4 -5
  59. package/src/organization-model/organization-model.mdx +1 -1
  60. package/src/organization-model/published.ts +251 -228
  61. package/src/organization-model/resolve.ts +4 -5
  62. package/src/organization-model/scaffolders/helpers.ts +84 -0
  63. package/src/organization-model/scaffolders/index.ts +19 -0
  64. package/src/organization-model/scaffolders/scaffoldKnowledgeNode.ts +48 -0
  65. package/src/organization-model/scaffolders/scaffoldOntologyRecord.ts +38 -0
  66. package/src/organization-model/scaffolders/scaffoldResource.ts +59 -0
  67. package/src/organization-model/scaffolders/scaffoldSystem.ts +110 -0
  68. package/src/organization-model/scaffolders/types.ts +81 -0
  69. package/src/organization-model/schema.ts +610 -704
  70. package/src/organization-model/types.ts +167 -161
  71. package/src/platform/constants/versions.ts +1 -1
  72. package/src/platform/registry/__tests__/validation.test.ts +23 -0
  73. package/src/platform/registry/validation.ts +13 -2
  74. package/src/reference/_generated/contracts.md +108 -96
  75. package/src/reference/glossary.md +71 -69
  76. package/src/organization-model/content-kinds/config.ts +0 -36
  77. package/src/organization-model/content-kinds/index.ts +0 -78
  78. package/src/organization-model/content-kinds/pipeline.ts +0 -68
  79. package/src/organization-model/content-kinds/registry.ts +0 -44
  80. package/src/organization-model/content-kinds/status.ts +0 -71
  81. package/src/organization-model/content-kinds/template.ts +0 -83
  82. package/src/organization-model/content-kinds/types.ts +0 -117
@@ -0,0 +1,48 @@
1
+ import type { OrganizationModel } from '..'
2
+ import { assertSystemExists, slugify, titleize } from './helpers'
3
+ import type { KnowledgeNodeScaffoldSpec, OmScaffoldPlan } from './types'
4
+
5
+ export function scaffoldKnowledgeNode(model: OrganizationModel, spec: KnowledgeNodeScaffoldSpec): OmScaffoldPlan {
6
+ if (spec.systemPath !== undefined) assertSystemExists(model, spec.systemPath)
7
+ if (model.knowledge?.[spec.id] !== undefined) {
8
+ throw new Error(`knowledge node already exists: ${spec.id}`)
9
+ }
10
+
11
+ const title = spec.label ?? titleize(spec.id.replace(/^knowledge\./, ''))
12
+ const slug = slugify(spec.id.replace(/^knowledge\./, ''))
13
+ const kind = spec.kind ?? 'reference'
14
+ const links = spec.systemPath === undefined ? '' : `links:\n - system:${spec.systemPath}\n`
15
+ const ownerIds = spec.ownerRoleId === undefined ? '' : `ownerIds:\n - ${spec.ownerRoleId}\n`
16
+
17
+ return {
18
+ intent: 'knowledge',
19
+ id: spec.id,
20
+ summary: `Scaffold ${kind} knowledge node "${spec.id}".`,
21
+ writes: [
22
+ {
23
+ path: `packages/elevasis-core/src/knowledge/nodes/${slug}.mdx.stub`,
24
+ mode: 'create',
25
+ description: 'Knowledge node MDX skeleton.',
26
+ content: `---\nid: ${spec.id}\nkind: ${kind}\ntitle: ${JSON.stringify(title)}\nsummary: ${JSON.stringify(spec.description ?? `${title} knowledge node.`)}\n${links}${ownerIds}updatedAt: 2026-05-15\n---\n\n## Overview\n\nCapture the durable operating knowledge here.\n`
27
+ }
28
+ ],
29
+ edits: [
30
+ {
31
+ path: 'packages/elevasis-core/src/organization-model/knowledge.ts',
32
+ description: 'Register this generated node after replacing the .stub suffix.',
33
+ snippet: `${JSON.stringify(spec.id)}`
34
+ }
35
+ ],
36
+ warnings: [],
37
+ nextSteps: [
38
+ 'Replace the .stub suffix after the node is ready to become canonical.',
39
+ spec.systemPath === undefined
40
+ ? 'Add links to the OM nodes this knowledge governs.'
41
+ : `Run pnpm exec elevasis om:verify --scope ${spec.systemPath}.`
42
+ ],
43
+ projectCommand:
44
+ spec.withProject && spec.systemPath !== undefined
45
+ ? `pnpm exec elevasis project:create --link-om ${spec.systemPath} --title "Add ${title} knowledge" --kind om-change`
46
+ : undefined
47
+ }
48
+ }
@@ -0,0 +1,38 @@
1
+ import type { OrganizationModel } from '..'
2
+ import { assertSystemExists, makeOntologyId, ontologyMapName, titleize } from './helpers'
3
+ import type { OmScaffoldPlan, OntologyRecordScaffoldSpec } from './types'
4
+
5
+ export function scaffoldOntologyRecord(model: OrganizationModel, spec: OntologyRecordScaffoldSpec): OmScaffoldPlan {
6
+ assertSystemExists(model, spec.systemPath)
7
+ const localId = spec.localId ?? spec.id
8
+ const ontologyId = makeOntologyId(spec.systemPath, spec.kind, localId)
9
+ const label = spec.label ?? titleize(localId)
10
+ const mapName = ontologyMapName(spec.kind)
11
+
12
+ return {
13
+ intent: 'ontology',
14
+ id: ontologyId,
15
+ summary: `Scaffold ${spec.kind} ontology record "${ontologyId}".`,
16
+ writes: [],
17
+ edits: [
18
+ {
19
+ path: 'packages/elevasis-core/src/organization-model/systems.ts',
20
+ description: `Add this record under ${spec.systemPath}.ontology.${mapName}.`,
21
+ snippet: `${JSON.stringify(ontologyId)}: {
22
+ id: ${JSON.stringify(ontologyId)},
23
+ label: ${JSON.stringify(label)},
24
+ ownerSystemId: ${JSON.stringify(spec.systemPath)}${spec.description === undefined ? '' : `,
25
+ description: ${JSON.stringify(spec.description)}`}
26
+ }`
27
+ }
28
+ ],
29
+ warnings: [],
30
+ nextSteps: [
31
+ 'Wire any cross-references using canonical ontology IDs.',
32
+ `Run pnpm exec elevasis om:verify --scope ${spec.systemPath}.`
33
+ ],
34
+ projectCommand: spec.withProject
35
+ ? `pnpm exec elevasis project:create --link-om ${spec.systemPath} --title "Add ${label} ontology" --kind om-change`
36
+ : undefined
37
+ }
38
+ }
@@ -0,0 +1,59 @@
1
+ import type { OrganizationModel } from '..'
2
+ import { assertSystemExists, slugify, titleize } from './helpers'
3
+ import type { OmScaffoldPlan, ResourceScaffoldSpec } from './types'
4
+
5
+ export function scaffoldResource(model: OrganizationModel, spec: ResourceScaffoldSpec): OmScaffoldPlan {
6
+ assertSystemExists(model, spec.systemPath)
7
+ if (model.resources?.[spec.id] !== undefined) {
8
+ throw new Error(`resource already exists: ${spec.id}`)
9
+ }
10
+
11
+ const label = spec.label ?? titleize(spec.id)
12
+ const kind = spec.kind ?? 'workflow'
13
+ const slug = slugify(spec.id)
14
+ const writes = spec.withStubWorkflow
15
+ ? [
16
+ {
17
+ path: `packages/elevasis-core/src/workflows/${slug}.stub.ts`,
18
+ mode: 'create' as const,
19
+ description: 'Optional workflow implementation stub. Runtime wiring remains manual.',
20
+ content: `// Stub only. Replace with a real workflow implementation before registering the resource.\nexport const ${slug.replaceAll('-', '_')}Workflow = {\n id: ${JSON.stringify(spec.id)}\n}\n`
21
+ }
22
+ ]
23
+ : []
24
+
25
+ return {
26
+ intent: 'resource',
27
+ id: spec.id,
28
+ summary: `Scaffold ${kind} Resource "${spec.id}" for System "${spec.systemPath}".`,
29
+ writes,
30
+ edits: [
31
+ {
32
+ path: 'packages/elevasis-core/src/organization-model/resources.ts',
33
+ description: 'Add this descriptor to platformResources/platformResourceDescriptors.',
34
+ snippet: `${JSON.stringify(spec.id)}: {
35
+ id: ${JSON.stringify(spec.id)},
36
+ order: 0,
37
+ kind: ${JSON.stringify(kind)},
38
+ systemPath: ${JSON.stringify(spec.systemPath)},
39
+ title: ${JSON.stringify(label)},
40
+ ${spec.description === undefined ? '' : `description: ${JSON.stringify(spec.description)},\n `}${spec.ownerRoleId === undefined ? '' : `ownerRoleId: ${JSON.stringify(spec.ownerRoleId)},\n `}status: 'active',
41
+ codeRefs: []
42
+ }`
43
+ },
44
+ {
45
+ path: 'packages/elevasis-core/src/organization-model/topology.ts',
46
+ description: 'Add topology relationships only when this resource triggers, uses, or requires approval from another OM node.',
47
+ snippet: `// topologyRelationship({ from: topologyRef('resource', ${JSON.stringify(spec.id)}), kind: 'uses', to: ... })`
48
+ }
49
+ ],
50
+ warnings: ['Resource ontology bindings are intentionally omitted until action/read/write contracts are known.'],
51
+ nextSteps: [
52
+ 'Bind resource.ontology.actions/reads/writes after the ontology records exist.',
53
+ `Run pnpm exec elevasis om:verify --scope ${spec.systemPath}.`
54
+ ],
55
+ projectCommand: spec.withProject
56
+ ? `pnpm exec elevasis project:create --link-om ${spec.systemPath} --title "Add ${label} resource" --kind om-change`
57
+ : undefined
58
+ }
59
+ }
@@ -0,0 +1,110 @@
1
+ import type { OrganizationModel } from '..'
2
+ import {
3
+ addProjectNextStep,
4
+ assertSystemPathAvailable,
5
+ localIdOf,
6
+ nextSystemOrder,
7
+ parentPathOf,
8
+ slugify,
9
+ titleize
10
+ } from './helpers'
11
+ import type { OmScaffoldPlan, SystemScaffoldSpec } from './types'
12
+
13
+ export function scaffoldSystem(model: OrganizationModel, spec: SystemScaffoldSpec): OmScaffoldPlan {
14
+ const systemPath = spec.parent !== undefined && !spec.id.includes('.') ? `${spec.parent}.${spec.id}` : spec.id
15
+ assertSystemPathAvailable(model, systemPath)
16
+
17
+ const parentPath = parentPathOf(systemPath)
18
+ const localId = localIdOf(systemPath)
19
+ const label = spec.label ?? titleize(localId)
20
+ const roleId = spec.role ?? 'role.ops-lead'
21
+ const uiPath = spec.uiPath ?? `/${localId}`
22
+ const featureSlug = slugify(systemPath.replaceAll('.', '-'))
23
+ const knowledgeId = `knowledge.${featureSlug}-system-overview`
24
+ const order = nextSystemOrder(model, parentPath)
25
+ const withProject = spec.withProject ?? !spec.noProject
26
+
27
+ const systemEntry = ` ${JSON.stringify(localId)}: {
28
+ id: ${JSON.stringify(systemPath)},
29
+ order: ${order},
30
+ label: ${JSON.stringify(label)},
31
+ description: ${JSON.stringify(spec.description ?? `${label} bounded context.`)},
32
+ kind: ${JSON.stringify(spec.kind ?? 'operational')},
33
+ ${parentPath === undefined ? '' : `parentSystemId: ${JSON.stringify(parentPath)},\n `}responsibleRoleId: ${JSON.stringify(roleId)},
34
+ governedByKnowledge: [${JSON.stringify(knowledgeId)}],
35
+ drivesGoals: [],
36
+ lifecycle: 'draft',
37
+ ui: {
38
+ path: ${JSON.stringify(uiPath)},
39
+ surfaces: [],
40
+ ${spec.icon === undefined ? '' : `icon: ${JSON.stringify(spec.icon)},`}
41
+ }${spec.withOntology ? `,
42
+ ontology: {
43
+ objectTypes: {}
44
+ }` : ''}
45
+ }`
46
+
47
+ const plan: OmScaffoldPlan = {
48
+ intent: 'system',
49
+ id: systemPath,
50
+ summary: `Scaffold System "${systemPath}" with nav, role wiring, governing knowledge, and a UI manifest stub.`,
51
+ writes: [
52
+ {
53
+ path: `packages/ui/src/features/${featureSlug}/manifest.stub.ts`,
54
+ mode: 'create',
55
+ description: 'SystemModule manifest stub. Route files are intentionally not generated.',
56
+ content: `import type { SystemModule } from '@repo/ui'\n\nexport const ${featureSlug.replaceAll('-', '_')}Manifest: SystemModule = {\n systemId: ${JSON.stringify(systemPath)},\n label: ${JSON.stringify(label)},\n routes: []\n}\n`
57
+ },
58
+ {
59
+ path: `packages/elevasis-core/src/knowledge/nodes/${featureSlug}-system-overview.mdx.stub`,
60
+ mode: 'create',
61
+ description: 'Governing knowledge skeleton for the new System.',
62
+ content: `---\nid: ${knowledgeId}\nkind: reference\ntitle: ${JSON.stringify(`${label} System Overview`)}\nsummary: ${JSON.stringify(`Governing context for the ${label} System.`)}\nlinks:\n - system:${systemPath}\nownerIds:\n - ${roleId}\nupdatedAt: 2026-05-15\n---\n\n## Purpose\n\nDocument the operating boundaries, decisions, and ownership for ${label}.\n`
63
+ }
64
+ ],
65
+ edits: [
66
+ {
67
+ path: 'packages/elevasis-core/src/organization-model/systems.ts',
68
+ description:
69
+ parentPath === undefined
70
+ ? 'Add this entry to platformSystems.'
71
+ : `Add this entry under platformSystems ${parentPath}.systems.`,
72
+ snippet: systemEntry
73
+ },
74
+ {
75
+ path: 'packages/elevasis-core/src/organization-model/navigation.ts',
76
+ description: 'Confirm sidebar placement derives from ui.path or add explicit surface targeting if needed.',
77
+ snippet: `// System "${systemPath}" declares ui.path ${JSON.stringify(uiPath)}. Do not add route files in /om create.`
78
+ },
79
+ {
80
+ path: 'packages/elevasis-core/src/organization-model/roles.ts',
81
+ description: `Confirm ${roleId} exists or add the owning role before merging.`,
82
+ snippet: `// responsibleRoleId: ${JSON.stringify(roleId)}`
83
+ },
84
+ {
85
+ path: 'packages/elevasis-core/src/organization-model/assembly.ts',
86
+ description: 'Confirm roleFor()/owner routing covers the new System.',
87
+ snippet: `case ${JSON.stringify(systemPath)}:\n return ${JSON.stringify(roleId)}`
88
+ },
89
+ {
90
+ path: 'packages/elevasis-core/src/organization-model/knowledge.ts',
91
+ description: 'Register the generated governing knowledge node after replacing the .stub suffix.',
92
+ snippet: `${JSON.stringify(knowledgeId)}`
93
+ }
94
+ ],
95
+ warnings: spec.withOntology
96
+ ? ['Ontology was requested; the default objectTypes block is intentionally empty until the domain language is known.']
97
+ : ['Ontology is opt-in. Re-run with --with-ontology when the object/action/catalog language is known.'],
98
+ nextSteps: [
99
+ 'Review the planned OM edits and apply them in the listed source files.',
100
+ 'Replace .stub suffixes only after the System entry is merged.',
101
+ `Run pnpm exec elevasis om:verify --scope ${systemPath}.`
102
+ ]
103
+ }
104
+
105
+ return addProjectNextStep(
106
+ plan,
107
+ withProject,
108
+ `pnpm exec elevasis project:create --link-om ${systemPath} --title "Build ${label} System" --kind system-build`
109
+ )
110
+ }
@@ -0,0 +1,81 @@
1
+ import type {
2
+ OrganizationModelIconToken,
3
+ OrganizationModelResourceKind,
4
+ OrganizationModelSystemKind
5
+ } from '../types'
6
+ import type { OntologyKind } from '../ontology'
7
+
8
+ export type OmScaffoldIntent = 'system' | 'ontology' | 'resource' | 'knowledge'
9
+
10
+ export interface OmScaffoldWrite {
11
+ path: string
12
+ content: string
13
+ description: string
14
+ mode: 'create'
15
+ }
16
+
17
+ export interface OmScaffoldEdit {
18
+ path: string
19
+ description: string
20
+ snippet: string
21
+ }
22
+
23
+ export interface OmScaffoldPlan {
24
+ intent: OmScaffoldIntent
25
+ id: string
26
+ summary: string
27
+ writes: OmScaffoldWrite[]
28
+ edits: OmScaffoldEdit[]
29
+ warnings: string[]
30
+ nextSteps: string[]
31
+ projectCommand?: string
32
+ }
33
+
34
+ export interface BaseOmScaffoldSpec {
35
+ id: string
36
+ label?: string
37
+ description?: string
38
+ }
39
+
40
+ export interface SystemScaffoldSpec extends BaseOmScaffoldSpec {
41
+ intent: 'system'
42
+ parent?: string
43
+ kind?: OrganizationModelSystemKind
44
+ uiPath?: string
45
+ icon?: OrganizationModelIconToken
46
+ role?: string
47
+ withOntology?: boolean
48
+ noProject?: boolean
49
+ withProject?: boolean
50
+ }
51
+
52
+ export interface OntologyRecordScaffoldSpec extends BaseOmScaffoldSpec {
53
+ intent: 'ontology'
54
+ systemPath: string
55
+ kind: OntologyKind
56
+ localId?: string
57
+ withProject?: boolean
58
+ }
59
+
60
+ export interface ResourceScaffoldSpec extends BaseOmScaffoldSpec {
61
+ intent: 'resource'
62
+ systemPath: string
63
+ kind?: OrganizationModelResourceKind
64
+ ownerRoleId?: string
65
+ withStubWorkflow?: boolean
66
+ withProject?: boolean
67
+ }
68
+
69
+ export interface KnowledgeNodeScaffoldSpec extends BaseOmScaffoldSpec {
70
+ intent: 'knowledge'
71
+ systemPath?: string
72
+ kind?: 'playbook' | 'strategy' | 'reference'
73
+ ownerRoleId?: string
74
+ withProject?: boolean
75
+ }
76
+
77
+ export type OmScaffoldSpec =
78
+ | SystemScaffoldSpec
79
+ | OntologyRecordScaffoldSpec
80
+ | ResourceScaffoldSpec
81
+ | KnowledgeNodeScaffoldSpec