@astrale-os/cli 0.8.1-alpha.6 → 1.0.0-beta.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 (98) hide show
  1. package/README.md +18 -5
  2. package/dist/astrale.js +2661 -2714
  3. package/dist/public/connect-core.js +2019 -3050
  4. package/dist/public/keys/index.js +1851 -2885
  5. package/dist/public/paths/index.js +1830 -2872
  6. package/dist/types/connection/auth.d.ts +3 -0
  7. package/dist/types/lib/instance.d.ts +10 -0
  8. package/package.json +9 -9
  9. package/src/commands/__tests__/domain-install-operation.test.ts +121 -0
  10. package/src/commands/__tests__/domain-install-owned.test.ts +66 -0
  11. package/src/commands/__tests__/domain-uninstall.test.ts +53 -0
  12. package/src/commands/__tests__/install-direct.test.ts +3 -2
  13. package/src/commands/__tests__/install-identity-override.test.ts +14 -3
  14. package/src/commands/__tests__/instance-bookmark.test.ts +66 -1
  15. package/src/commands/__tests__/instance-list-rows.test.ts +1 -0
  16. package/src/commands/__tests__/instance-use.test.ts +67 -0
  17. package/src/commands/__tests__/view-build.test.ts +58 -0
  18. package/src/commands/domain/install.ts +84 -20
  19. package/src/commands/domain/uninstall.ts +128 -0
  20. package/src/commands/instance/active.ts +13 -1
  21. package/src/commands/instance/bookmark.ts +26 -3
  22. package/src/commands/instance/list.ts +18 -4
  23. package/src/commands/instance/use.ts +54 -7
  24. package/src/commands/view.ts +28 -16
  25. package/src/connection/.spec/architecture.md +5 -0
  26. package/src/connection/.spec/laws/connection.ts +20 -0
  27. package/src/connection/.spec/layout.ts +1 -0
  28. package/src/connection/__tests__/auth.test.ts +27 -1
  29. package/src/connection/__tests__/ca-fetch.test.ts +8 -1
  30. package/src/connection/__tests__/errors.test.ts +483 -33
  31. package/src/connection/__tests__/exchange.test.ts +46 -5
  32. package/src/connection/__tests__/reasons.test.ts +78 -0
  33. package/src/connection/auth.ts +11 -9
  34. package/src/connection/command.ts +9 -1
  35. package/src/connection/errors.ts +149 -159
  36. package/src/connection/exchange.ts +14 -2
  37. package/src/connection/index.ts +1 -1
  38. package/src/connection/reasons.ts +193 -0
  39. package/src/lib/__tests__/instance.test.ts +51 -1
  40. package/src/lib/__tests__/view-assets.test.ts +33 -1
  41. package/src/lib/__tests__/view-server.test.ts +68 -0
  42. package/src/lib/ca-fetch.ts +9 -3
  43. package/src/lib/instance.ts +31 -0
  44. package/src/lib/view/assets.ts +16 -2
  45. package/src/program/__tests__/program.test.ts +2 -1
  46. package/src/program/build.ts +2 -1
  47. package/studio/client/dist/assets/{elk-api-D0cBetPW.js → elk-api-D2xgMJvi.js} +1 -1
  48. package/studio/client/dist/assets/{index-BQnJ5sgd.css → index-BMdnsIJA.css} +1 -1
  49. package/studio/client/dist/assets/index-D-vRV8w7.js +8 -0
  50. package/studio/client/dist/assets/index-LGSWRrk8.js +81 -0
  51. package/studio/client/dist/index.html +2 -2
  52. package/studio/package.json +8 -9
  53. package/studio/server/agent/prompts/anchors.test.ts +74 -0
  54. package/studio/server/agent/prompts/anchors.ts +85 -15
  55. package/studio/server/agent/prompts/system.test.ts +12 -0
  56. package/studio/server/agent/prompts/system.ts +6 -6
  57. package/studio/server/api.ts +1 -5
  58. package/studio/server/cache.ts +5 -2
  59. package/studio/server/domain.test.ts +67 -0
  60. package/studio/server/domain.ts +29 -6
  61. package/studio/server/index.ts +1 -3
  62. package/studio/server/introspect/anatomy-extras.test.ts +104 -1
  63. package/studio/server/introspect/anatomy-extras.ts +340 -8
  64. package/studio/server/introspect/anatomy.test.ts +33 -0
  65. package/studio/server/introspect/anatomy.ts +22 -7
  66. package/studio/server/introspect/bundle.ts +7 -1
  67. package/studio/server/introspect/canonical-schema.test.ts +395 -0
  68. package/studio/server/introspect/canonical-schema.ts +751 -0
  69. package/studio/server/introspect/core-extractor.ts +30 -10
  70. package/studio/server/introspect/core.ts +4 -2
  71. package/studio/server/introspect/diff.test.ts +124 -0
  72. package/studio/server/introspect/diff.ts +252 -23
  73. package/studio/server/introspect/extractor.ts +46 -14
  74. package/studio/server/introspect/overlay-tsmorph.test.ts +164 -1
  75. package/studio/server/introspect/overlay-tsmorph.ts +381 -106
  76. package/studio/server/introspect/overlay.test.ts +72 -0
  77. package/studio/server/introspect/overlay.ts +16 -6
  78. package/studio/server/introspect/runtime.test.ts +217 -0
  79. package/studio/server/introspect/runtime.ts +18 -6
  80. package/studio/server/introspect/schema-refs.test.ts +100 -0
  81. package/studio/server/introspect/schema-refs.ts +23 -2
  82. package/studio/server/state/baseline.test.ts +51 -0
  83. package/studio/server/state/baseline.ts +31 -2
  84. package/studio/server/state/create.test.ts +37 -0
  85. package/studio/server/state/create.ts +21 -15
  86. package/studio/server/state/instance.test.ts +63 -0
  87. package/studio/server/state/instance.ts +65 -29
  88. package/studio/server/state/views.test.ts +209 -9
  89. package/studio/server/state/views.ts +176 -69
  90. package/studio/server/watch.test.ts +36 -0
  91. package/studio/server/watch.ts +24 -16
  92. package/studio/server/workspace-watch.ts +8 -3
  93. package/studio/shared/types.ts +164 -33
  94. package/viewer/dist/main.js +57 -57
  95. package/studio/client/dist/assets/index-Dspir4w7.js +0 -81
  96. package/studio/client/dist/assets/index-bVD2KJgz.js +0 -8
  97. package/studio/server/view-dev-server.test.ts +0 -111
  98. package/studio/server/view-dev-server.ts +0 -372
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
3
3
  import { tmpdir } from 'node:os'
4
4
  import { join } from 'node:path'
5
5
 
6
- import { buildHandlerLinks } from './overlay-tsmorph'
6
+ import { buildHandlerLinks, buildSchemaAnnotations, buildSourceSpans } from './overlay-tsmorph'
7
7
 
8
8
  test('resolves authorization hooks from imported remote method definitions', () => {
9
9
  const root = mkdtempSync(join(tmpdir(), 'astrale-studio-handler-links-'))
@@ -102,3 +102,166 @@ test('resolves authorization hooks from imported remote method definitions', ()
102
102
  rmSync(root, { recursive: true, force: true })
103
103
  }
104
104
  })
105
+
106
+ test('links current implementation handlers and current edge source spans', () => {
107
+ const root = mkdtempSync(join(tmpdir(), 'astrale-studio-current-overlay-'))
108
+ const schemaDir = join(root, 'schema')
109
+ const actionsDir = join(root, 'actions')
110
+ mkdirSync(schemaDir)
111
+ mkdirSync(actionsDir)
112
+ writeFileSync(
113
+ join(root, 'package.json'),
114
+ JSON.stringify({ imports: { '#actions/*': './actions/*.ts' } }),
115
+ )
116
+
117
+ writeFileSync(
118
+ join(root, 'implementation.ts'),
119
+ `
120
+ import { rename } from '#actions/rename'
121
+ import { createIssue } from '#actions/create-issue'
122
+ export const domain = defineDomain.public({
123
+ schema,
124
+ handlers: {
125
+ functions: { createIssue },
126
+ classes: { Issue: { rename } },
127
+ interfaces: {},
128
+ },
129
+ })
130
+ `,
131
+ )
132
+ writeFileSync(
133
+ join(actionsDir, 'rename.ts'),
134
+ `
135
+ export function rename({ input }) {
136
+ return graph.update(input)
137
+ }
138
+ `,
139
+ )
140
+ writeFileSync(
141
+ join(actionsDir, 'create-issue.ts'),
142
+ `export const createIssue = ({ input }) => graph.create(input)`,
143
+ )
144
+ writeFileSync(
145
+ join(schemaDir, 'members.ts'),
146
+ `
147
+ export const iIssue = nodeInterface({
148
+ properties: { title: property({ type: 'string' }) },
149
+ })
150
+ export const Issue = nodeClass({
151
+ properties: { title: property({ type: 'string' }) },
152
+ methods: { rename },
153
+ })
154
+ export const assigned_to = edgeClass.directed({
155
+ source: { as: 'issue', accepts: [Issue], outgoing: '0..*' },
156
+ target: { as: 'owner', accepts: [Issue], incoming: '0..1' },
157
+ properties: { note: property({ type: 'string' }) },
158
+ })
159
+ export const createIssue = fn({ auth: 'anonymous', input, output })
160
+ `,
161
+ )
162
+ writeFileSync(
163
+ join(schemaDir, 'index.ts'),
164
+ `
165
+ import { Issue, assigned_to, createIssue, iIssue as issueInterface } from './members.js'
166
+ const schemaInput = {
167
+ interfaces: { Issue: issueInterface },
168
+ classes: { Issue, assigned_to },
169
+ functions: { createIssue },
170
+ } as const
171
+ export const schema = defineSchema('issues.example', schemaInput)
172
+ `,
173
+ )
174
+
175
+ try {
176
+ const links = buildHandlerLinks({
177
+ ir: {
178
+ version: 'v1',
179
+ domain: 'issues.example',
180
+ types: {},
181
+ interfaces: {},
182
+ classes: {
183
+ Issue: {
184
+ type: 'node',
185
+ name: 'Issue',
186
+ properties: {},
187
+ methods: {
188
+ rename: {
189
+ name: 'rename',
190
+ params: {},
191
+ returns: {},
192
+ static: false,
193
+ inheritance: 'default',
194
+ auth: 'authorized',
195
+ } as any,
196
+ },
197
+ },
198
+ },
199
+ imports: {},
200
+ functions: {
201
+ createIssue: {
202
+ name: 'createIssue',
203
+ input: {},
204
+ params: {},
205
+ output: { mode: 'value', schema: {} },
206
+ returns: {},
207
+ static: true,
208
+ inheritance: 'default',
209
+ auth: 'anonymous',
210
+ },
211
+ },
212
+ },
213
+ domainRoot: root,
214
+ })
215
+ expect(links).toHaveLength(2)
216
+ expect(links.find((link) => link.ownerKind === 'class')).toMatchObject({
217
+ owner: 'Issue',
218
+ ownerKind: 'class',
219
+ method: 'rename',
220
+ wiringFile: 'implementation.ts',
221
+ handlerFile: 'actions/rename.ts',
222
+ implemented: true,
223
+ auth: 'required',
224
+ callableAuth: 'authorized',
225
+ authorize: 'custom',
226
+ kernelCalls: ['graph.update'],
227
+ })
228
+ expect(links.find((link) => link.ownerKind === 'function')).toMatchObject({
229
+ owner: 'issues.example',
230
+ method: 'createIssue',
231
+ wiringFile: 'implementation.ts',
232
+ handlerFile: 'actions/create-issue.ts',
233
+ implemented: true,
234
+ static: true,
235
+ auth: 'public',
236
+ callableAuth: 'anonymous',
237
+ kernelCalls: ['graph.create'],
238
+ })
239
+
240
+ const spans = buildSourceSpans({ ir: null, schemaDir })
241
+ expect(spans['interface.Issue.property.title']?.file).toBe('schema/members.ts')
242
+ expect(spans['class.Issue.property.title']?.file).toBe('schema/members.ts')
243
+ expect(spans['edge.assigned_to.endpoint.issue']?.file).toBe('schema/members.ts')
244
+ expect(spans['edge.assigned_to.endpoint.owner']?.file).toBe('schema/members.ts')
245
+ expect(spans['edge.assigned_to.property.note']?.file).toBe('schema/members.ts')
246
+ expect(spans['function.createIssue']?.file).toBe('schema/members.ts')
247
+ } finally {
248
+ rmSync(root, { recursive: true, force: true })
249
+ }
250
+ })
251
+
252
+ test('does not emit the obsolete enum update warning', () => {
253
+ expect(
254
+ buildSchemaAnnotations({
255
+ ir: {
256
+ classes: {
257
+ Issue: {
258
+ type: 'node',
259
+ name: 'Issue',
260
+ properties: { status: { type: 'string', enum: ['open', 'closed'] } },
261
+ methods: {},
262
+ },
263
+ },
264
+ } as any,
265
+ }),
266
+ ).toEqual([])
267
+ })