@stream44.studio/t44 0.4.0-rc.24

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 (99) hide show
  1. package/.dco-signatures +9 -0
  2. package/.github/workflows/dco.yaml +12 -0
  3. package/.github/workflows/gordian-open-integrity.yaml +13 -0
  4. package/.github/workflows/test.yaml +31 -0
  5. package/.o/GordianOpenIntegrity-CurrentLifehash.svg +1026 -0
  6. package/.o/GordianOpenIntegrity-InceptionLifehash.svg +1026 -0
  7. package/.o/GordianOpenIntegrity.yaml +21 -0
  8. package/.o/assets/Hero-Terminal44-v0.jpeg +0 -0
  9. package/.o/stream44.studio/assets/Icon-v1.svg +1170 -0
  10. package/.repo-identifier +1 -0
  11. package/DCO.md +34 -0
  12. package/LICENSE.txt +186 -0
  13. package/README.md +189 -0
  14. package/bin/activate +36 -0
  15. package/bin/activate.ts +30 -0
  16. package/bin/postinstall.sh +19 -0
  17. package/bin/shell +27 -0
  18. package/bin/t44 +27 -0
  19. package/caps/ConfigSchemaStruct.ts +55 -0
  20. package/caps/Home.ts +57 -0
  21. package/caps/HomeRegistry.ts +319 -0
  22. package/caps/HomeRegistryFile.ts +144 -0
  23. package/caps/JsonSchemas.ts +220 -0
  24. package/caps/OpenApiSchema.ts +67 -0
  25. package/caps/PackageDescriptor.ts +88 -0
  26. package/caps/ProjectCatalogs.ts +153 -0
  27. package/caps/ProjectDeployment.ts +426 -0
  28. package/caps/ProjectDevelopment.ts +257 -0
  29. package/caps/ProjectPublishing.ts +654 -0
  30. package/caps/ProjectPulling.ts +234 -0
  31. package/caps/ProjectRack.ts +155 -0
  32. package/caps/ProjectRepository.ts +332 -0
  33. package/caps/ProjectTest.ts +251 -0
  34. package/caps/ProjectTestLib.ts +257 -0
  35. package/caps/RootKey.ts +219 -0
  36. package/caps/SigningKey.ts +243 -0
  37. package/caps/TaskWorkflow.ts +192 -0
  38. package/caps/WorkspaceCli.ts +448 -0
  39. package/caps/WorkspaceConfig.ts +268 -0
  40. package/caps/WorkspaceConfig.yaml +87 -0
  41. package/caps/WorkspaceConfigFile.ts +902 -0
  42. package/caps/WorkspaceConnection.ts +329 -0
  43. package/caps/WorkspaceEntityConfig.ts +78 -0
  44. package/caps/WorkspaceEntityConfig.v0.ts +77 -0
  45. package/caps/WorkspaceEntityFact.ts +218 -0
  46. package/caps/WorkspaceInfo.ts +619 -0
  47. package/caps/WorkspaceInit.ts +30 -0
  48. package/caps/WorkspaceKey.ts +338 -0
  49. package/caps/WorkspaceModel.ts +373 -0
  50. package/caps/WorkspaceProjects.ts +636 -0
  51. package/caps/WorkspacePrompt.ts +430 -0
  52. package/caps/WorkspaceShell.sh +39 -0
  53. package/caps/WorkspaceShell.ts +104 -0
  54. package/caps/WorkspaceShell.yaml +64 -0
  55. package/caps/WorkspaceShellCli.ts +109 -0
  56. package/caps/patterns/README.md +2 -0
  57. package/caps/patterns/git-scm.com/ProjectPublishing.ts +507 -0
  58. package/caps/patterns/semver.org/ProjectPublishing.ts +458 -0
  59. package/docs/Overview.drawio +248 -0
  60. package/docs/Overview.svg +4 -0
  61. package/examples/01-Lifecycle/main.test.ts +223 -0
  62. package/lib/crypto.ts +53 -0
  63. package/lib/key.ts +381 -0
  64. package/lib/schema-console-renderer.ts +181 -0
  65. package/lib/schema-resolver.ts +349 -0
  66. package/lib/ucan.ts +137 -0
  67. package/package.json +91 -0
  68. package/standalone-rt.test.ts +150 -0
  69. package/standalone-rt.ts +140 -0
  70. package/structs/HomeRegistry.ts +55 -0
  71. package/structs/HomeRegistryConfig.ts +60 -0
  72. package/structs/ProjectCatalogsConfig.ts +53 -0
  73. package/structs/ProjectDeploymentConfig.ts +56 -0
  74. package/structs/ProjectDeploymentFact.ts +106 -0
  75. package/structs/ProjectPublishingConfig.ts +78 -0
  76. package/structs/ProjectPublishingFact.ts +68 -0
  77. package/structs/ProjectPullingConfig.ts +52 -0
  78. package/structs/ProjectRack.ts +51 -0
  79. package/structs/ProjectRackConfig.ts +56 -0
  80. package/structs/RepositoryOriginDescriptor.ts +51 -0
  81. package/structs/RootKeyConfig.ts +64 -0
  82. package/structs/SigningKeyConfig.ts +64 -0
  83. package/structs/Workspace.ts +56 -0
  84. package/structs/WorkspaceCatalogs.ts +56 -0
  85. package/structs/WorkspaceCliConfig.ts +53 -0
  86. package/structs/WorkspaceConfig.ts +64 -0
  87. package/structs/WorkspaceConfigFile.ts +50 -0
  88. package/structs/WorkspaceConfigFileMeta.ts +70 -0
  89. package/structs/WorkspaceKey.ts +55 -0
  90. package/structs/WorkspaceKeyConfig.ts +56 -0
  91. package/structs/WorkspaceMappingsConfig.ts +56 -0
  92. package/structs/WorkspaceProject.ts +104 -0
  93. package/structs/WorkspaceProjectsConfig.ts +67 -0
  94. package/structs/WorkspaceShellConfig.ts +83 -0
  95. package/structs/patterns/README.md +2 -0
  96. package/structs/patterns/git-scm.com/ProjectPublishingFact.ts +46 -0
  97. package/tsconfig.json +33 -0
  98. package/workspace-rt.ts +152 -0
  99. package/workspace.yaml +3 -0
@@ -0,0 +1,83 @@
1
+
2
+ export async function capsule({
3
+ encapsulate,
4
+ CapsulePropertyTypes,
5
+ makeImportStack
6
+ }: any) {
7
+ return encapsulate({
8
+ '#@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0': {
9
+ '#@stream44.studio/t44/caps/ConfigSchemaStruct': {
10
+ as: 'schema',
11
+ options: {
12
+ '#': {
13
+ schema: {
14
+ type: 'object',
15
+ properties: {
16
+ env: {
17
+ type: 'object',
18
+ properties: {
19
+ default: {
20
+ type: 'object',
21
+ additionalProperties: { type: 'string' },
22
+ description: 'Default environment variables.'
23
+ },
24
+ force: {
25
+ type: 'object',
26
+ additionalProperties: { type: 'string' },
27
+ description: 'Forced environment variables that override defaults.'
28
+ }
29
+ },
30
+ additionalProperties: true,
31
+ description: 'Shell environment variable configuration.'
32
+ },
33
+ createdAt: {
34
+ type: 'string',
35
+ format: 'date-time',
36
+ description: 'ISO 8601 timestamp of when the entity config was created.'
37
+ },
38
+ updatedAt: {
39
+ type: 'string',
40
+ format: 'date-time',
41
+ description: 'ISO 8601 timestamp of when the entity config was last updated.'
42
+ }
43
+ },
44
+ required: ['createdAt', 'updatedAt'],
45
+ additionalProperties: true,
46
+ description: 'Workspace shell configuration with environment variables.'
47
+ }
48
+ }
49
+ }
50
+ },
51
+ '#': {
52
+ capsuleName: {
53
+ type: CapsulePropertyTypes.Literal,
54
+ value: capsule['#']
55
+ },
56
+ env: {
57
+ type: CapsulePropertyTypes.GetterFunction,
58
+ value: async function (this: any): Promise<object> {
59
+ const shellConfig = await this.config
60
+
61
+ if (!shellConfig?.env) {
62
+ return {}
63
+ }
64
+
65
+ const defaultEnv = shellConfig.env.default || {}
66
+ const forceEnv = shellConfig.env.force || {}
67
+
68
+ return {
69
+ ...defaultEnv,
70
+ ...forceEnv
71
+ }
72
+ }
73
+ },
74
+ }
75
+ }
76
+ }, {
77
+ extendsCapsule: '@stream44.studio/t44/caps/WorkspaceEntityConfig',
78
+ importMeta: import.meta,
79
+ importStack: makeImportStack(),
80
+ capsuleName: capsule['#'],
81
+ })
82
+ }
83
+ capsule['#'] = '@stream44.studio/t44/structs/WorkspaceShellConfig'
@@ -0,0 +1,2 @@
1
+
2
+ **NOTE: Code in this directory will be relocated under MIT License to a different project in future.**
@@ -0,0 +1,46 @@
1
+
2
+ export async function capsule({
3
+ encapsulate,
4
+ CapsulePropertyTypes,
5
+ makeImportStack
6
+ }: any) {
7
+ return encapsulate({
8
+ '#@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0': {
9
+ '#@stream44.studio/t44/caps/ConfigSchemaStruct': {
10
+ as: 'schema',
11
+ options: {
12
+ '#': {
13
+ schema: {
14
+ type: 'object',
15
+ properties: {
16
+ createdAt: {
17
+ type: 'string',
18
+ format: 'date-time',
19
+ description: 'ISO 8601 timestamp when the project publishing fact was created'
20
+ },
21
+ updatedAt: {
22
+ type: 'string',
23
+ format: 'date-time',
24
+ description: 'ISO 8601 timestamp when the project publishing fact was last updated'
25
+ }
26
+ },
27
+ additionalProperties: true
28
+ }
29
+ }
30
+ }
31
+ },
32
+ '#': {
33
+ capsuleName: {
34
+ type: CapsulePropertyTypes.Literal,
35
+ value: capsule['#']
36
+ },
37
+ }
38
+ }
39
+ }, {
40
+ extendsCapsule: '@stream44.studio/t44/caps/WorkspaceEntityFact',
41
+ importMeta: import.meta,
42
+ importStack: makeImportStack(),
43
+ capsuleName: capsule['#'],
44
+ })
45
+ }
46
+ capsule['#'] = '@stream44.studio/t44/structs/patterns/git-scm.com/ProjectPublishingFact'
package/tsconfig.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2021",
4
+ "module": "esnext",
5
+ "lib": [
6
+ "ES2021",
7
+ "DOM"
8
+ ],
9
+ "types": [
10
+ "bun",
11
+ "node"
12
+ ],
13
+ "moduleResolution": "bundler",
14
+ "strict": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "resolveJsonModule": true,
19
+ "allowSyntheticDefaultImports": true,
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "@stream44.studio/t44/*": [
23
+ "./*"
24
+ ]
25
+ }
26
+ },
27
+ "include": [
28
+ "**/*.ts"
29
+ ],
30
+ "exclude": [
31
+ "node_modules"
32
+ ]
33
+ }
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env bun
2
+ /// <reference types="bun" />
3
+ /// <reference types="node" />
4
+
5
+ const startTime = Date.now()
6
+
7
+ import { join, resolve } from 'path'
8
+ import { access } from 'fs/promises'
9
+ import chalk from 'chalk'
10
+ import { CapsuleSpineFactory } from "@stream44.studio/encapsulate/spine-factories/CapsuleSpineFactory.v0"
11
+ import { CapsuleSpineContract } from "@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0/Membrane.v0"
12
+ import { TimingObserver } from "@stream44.studio/encapsulate/spine-factories/TimingObserver"
13
+
14
+ async function findWorkspaceRoot(): Promise<string> {
15
+ const isInitCommand = process.argv.includes('init')
16
+ if (isInitCommand) {
17
+ const { mkdir, writeFile } = await import('fs/promises')
18
+ const workspaceDir = join(process.cwd(), '.workspace')
19
+ const workspaceConfigPath = join(workspaceDir, 'workspace.yaml')
20
+
21
+ await mkdir(workspaceDir, { recursive: true })
22
+ const workspaceYaml = `extends:\n - '@stream44.studio/t44/workspace.yaml'\n`
23
+ await writeFile(workspaceConfigPath, workspaceYaml)
24
+
25
+ return process.cwd()
26
+ }
27
+
28
+ let currentDir = resolve(process.cwd())
29
+
30
+ while (true) {
31
+ const workspaceConfigPath = join(currentDir, '.workspace', 'workspace.yaml')
32
+ try {
33
+ await access(workspaceConfigPath)
34
+ return currentDir
35
+ } catch {
36
+ // File doesn't exist, continue traversing
37
+ }
38
+
39
+ const parentDir = resolve(currentDir, '..')
40
+ if (parentDir === currentDir) {
41
+ throw new Error(
42
+ `Could not find workspace root. Please run this command from within a workspace directory ` +
43
+ `(a directory containing .workspace/workspace.yaml).`
44
+ )
45
+ }
46
+ currentDir = parentDir
47
+ }
48
+ }
49
+
50
+ export async function run(encapsulateHandler: any, runHandler: any, options?: { importMeta?: { dir: string } }) {
51
+
52
+ const timing = process.argv.includes('--trace') ? TimingObserver({ startTime }) : undefined
53
+
54
+ timing?.recordMajor('INIT SPINE')
55
+
56
+ const eventsByKey = new Map<string, any>()
57
+
58
+ const workspaceRootDir = await findWorkspaceRoot()
59
+
60
+ const { encapsulate, freeze, CapsulePropertyTypes, makeImportStack, hoistSnapshot } = await CapsuleSpineFactory({
61
+ spineFilesystemRoot: workspaceRootDir,
62
+ capsuleModuleProjectionRoot: (import.meta as any).dir,
63
+ enableCallerStackInference: true,
64
+ spineContracts: {
65
+ ['#' + CapsuleSpineContract['#']]: CapsuleSpineContract
66
+ },
67
+ timing,
68
+ onMembraneEvent: timing ? (event: any) => {
69
+ const instanceId = event.target?.spineContractCapsuleInstanceId
70
+ const eventIndex = event.eventIndex
71
+
72
+ // Store event by composite key (instance ID + event index)
73
+ const key = `${eventIndex}`
74
+ eventsByKey.set(key, event)
75
+
76
+ let capsuleRef = event.target?.capsuleSourceLineRef
77
+ let prop = event.target?.prop
78
+ let callerLocation = event.caller ? `${event.caller.filepath}:${event.caller.line}` : 'unknown'
79
+ const eventType = event.event
80
+
81
+ // For call-result events, look up the original call event to get all info
82
+ if (eventType === 'call-result') {
83
+ const callKey = `${event.callEventIndex}`
84
+ const callEvent = eventsByKey.get(callKey)
85
+ if (callEvent) {
86
+ capsuleRef = callEvent.target?.capsuleSourceLineRef || capsuleRef
87
+ prop = callEvent.target?.prop || prop
88
+ if (callEvent.caller) {
89
+ callerLocation = `${callEvent.caller.filepath}:${callEvent.caller.line}`
90
+ }
91
+ }
92
+ }
93
+
94
+ console.error(
95
+ chalk.gray(`[${eventIndex}]`),
96
+ chalk.cyan(eventType.padEnd(12)),
97
+ chalk.yellow(capsuleRef),
98
+ chalk.magenta(`.${prop}`),
99
+ chalk.dim(`from ${callerLocation}`)
100
+ )
101
+ } : undefined
102
+ })
103
+
104
+ timing?.recordMajor('ENCAPSULATE')
105
+
106
+ const exportedApi = await encapsulateHandler({
107
+ encapsulate,
108
+ CapsulePropertyTypes,
109
+ makeImportStack
110
+ })
111
+
112
+ timing?.recordMajor('FREEZE')
113
+
114
+ const snapshot = await freeze()
115
+
116
+ timing?.recordMajor('HOIST SNAPSHOT')
117
+
118
+ const { run } = await hoistSnapshot({
119
+ snapshot
120
+ })
121
+
122
+ timing?.recordMajor('RUN')
123
+
124
+ const result = await run({
125
+ overrides: {
126
+ ['@stream44.studio/t44/caps/WorkspaceConfig']: {
127
+ '#': {
128
+ workspaceRootDir
129
+ }
130
+ },
131
+ ['@stream44.studio/t44/caps/ProjectTest']: {
132
+ '#': {
133
+ testRootDir: options?.importMeta?.dir
134
+ }
135
+ },
136
+ ['@stream44.studio/t44-ipfs.tech/caps/IpfsWorkbench']: {
137
+ '#': {
138
+ cacheDir: join(workspaceRootDir, '.~o/workspace.foundation', '@t44.sh~t44-ipfs.tech~caps~IpfsWorkbench', 'daemons')
139
+ }
140
+ }
141
+ }
142
+ }, async (opts) => {
143
+ return runHandler({
144
+ ...opts,
145
+ ...(exportedApi || {})
146
+ })
147
+ })
148
+
149
+ timing?.recordMajor('DONE')
150
+
151
+ return result
152
+ }
package/workspace.yaml ADDED
@@ -0,0 +1,3 @@
1
+ $schema: ../../../.~o/workspace.foundation/@t44.sh~t44~caps~JsonSchemas/@t44.sh~t44~structs~WorkspaceConfigFile.json
2
+ extends:
3
+ - ./caps/WorkspaceConfig.yaml