@astrale-os/cli 1.0.0-beta.5 → 1.0.0-beta.6

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 (162) hide show
  1. package/dist/astrale.js +66254 -64461
  2. package/dist/public/connect-core.js +14895 -33867
  3. package/dist/public/keys/index.js +1246 -34250
  4. package/dist/public/paths/index.js +866 -33833
  5. package/dist/types/admin/instance/model.d.ts +3 -4
  6. package/dist/types/errors.d.ts +1 -1
  7. package/dist/types/lib/instance-target.d.ts +1 -1
  8. package/dist/types/lib/log.d.ts +2 -2
  9. package/package.json +4 -9
  10. package/src/__tests__/fixtures/publication.ts +20 -0
  11. package/src/admin/__tests__/binding.test.ts +12 -19
  12. package/src/admin/__tests__/fixture.ts +101 -0
  13. package/src/admin/binding.ts +83 -3
  14. package/src/admin/catalog/.spec/api.d.ts +1 -1
  15. package/src/admin/catalog/__tests__/client.test.ts +20 -49
  16. package/src/admin/catalog/client.ts +35 -26
  17. package/src/admin/catalog/model.ts +3 -4
  18. package/src/admin/graph/.spec/api.d.ts +4 -10
  19. package/src/admin/graph/nodes.ts +1 -1
  20. package/src/admin/instance/.spec/api.d.ts +1 -1
  21. package/src/admin/instance/__tests__/client.test.ts +58 -83
  22. package/src/admin/instance/client.ts +49 -39
  23. package/src/admin/instance/model.ts +9 -8
  24. package/src/commands/__tests__/call-describe.test.ts +46 -33
  25. package/src/commands/__tests__/domain-install-operation.test.ts +3 -14
  26. package/src/commands/__tests__/domain-install-owned.test.ts +1 -1
  27. package/src/commands/__tests__/domain-list.test.ts +5 -25
  28. package/src/commands/__tests__/install-identity-override.test.ts +3 -14
  29. package/src/commands/__tests__/read-commands.test.ts +35 -10
  30. package/src/commands/call-describe.ts +59 -67
  31. package/src/commands/call.ts +41 -54
  32. package/src/commands/domain/install.ts +2 -2
  33. package/src/commands/domain/uninstall.ts +2 -2
  34. package/src/commands/get.ts +13 -14
  35. package/src/commands/identity/__tests__/register.test.ts +3 -3
  36. package/src/commands/identity/register.ts +5 -4
  37. package/src/commands/instance/delete.ts +5 -3
  38. package/src/commands/instance/status.ts +1 -9
  39. package/src/commands/introspect.ts +4 -11
  40. package/src/commands/logs.ts +24 -25
  41. package/src/commands/mutate.ts +6 -5
  42. package/src/commands/query.ts +27 -30
  43. package/src/commands/token.ts +8 -7
  44. package/src/commands/view.ts +4 -3
  45. package/src/connection/.spec/api.d.ts +7 -8
  46. package/src/connection/.spec/architecture.md +5 -4
  47. package/src/connection/.spec/flows/session.ts +2 -2
  48. package/src/connection/.spec/laws/connection.ts +6 -2
  49. package/src/connection/.spec/layout.ts +1 -0
  50. package/src/connection/__tests__/credential.test.ts +1 -1
  51. package/src/connection/__tests__/errors.test.ts +27 -20
  52. package/src/connection/__tests__/exchange.test.ts +30 -1
  53. package/src/connection/__tests__/failure-fixtures.ts +39 -0
  54. package/src/connection/__tests__/failure-safety.test.ts +75 -0
  55. package/src/connection/__tests__/self.test.ts +31 -11
  56. package/src/connection/__tests__/session.test.ts +3 -3
  57. package/src/connection/call.ts +1 -1
  58. package/src/connection/credential.ts +2 -2
  59. package/src/connection/errors.ts +1 -355
  60. package/src/connection/exchange.ts +47 -23
  61. package/src/connection/failure/classify.ts +110 -0
  62. package/src/connection/failure/debug.ts +26 -0
  63. package/src/connection/failure/index.ts +18 -0
  64. package/src/connection/failure/model.ts +28 -0
  65. package/src/connection/failure/render.ts +116 -0
  66. package/src/connection/reasons.ts +16 -0
  67. package/src/connection/self.ts +39 -21
  68. package/src/connection/session.ts +8 -8
  69. package/src/errors.ts +3 -2
  70. package/src/graph/.spec/api.d.ts +12 -5
  71. package/src/graph/.spec/layout.ts +9 -1
  72. package/src/graph/__tests__/mutation.test.ts +2 -2
  73. package/src/graph/__tests__/query.test.ts +25 -6
  74. package/src/graph/class.ts +30 -0
  75. package/src/graph/index.ts +1 -0
  76. package/src/graph/query.ts +21 -32
  77. package/src/identity/.spec/api.d.ts +2 -2
  78. package/src/identity/__tests__/registration.test.ts +1 -1
  79. package/src/identity/registration.ts +3 -3
  80. package/src/lib/__tests__/domain-publication.test.ts +4 -15
  81. package/src/lib/__tests__/instance-target.test.ts +6 -39
  82. package/src/lib/__tests__/log-errors.test.ts +53 -0
  83. package/src/lib/__tests__/studio-server-deps.test.ts +1 -1
  84. package/src/lib/command-dx.ts +1 -4
  85. package/src/lib/domain-publication.ts +1 -1
  86. package/src/lib/instance-target.ts +3 -14
  87. package/src/lib/log.ts +11 -6
  88. package/src/lib/validation.ts +2 -2
  89. package/src/lib/view/resolve.ts +1 -1
  90. package/src/program/__tests__/program.test.ts +1 -1
  91. package/studio/client/dist/assets/{elk-api-YEDvaNU-.js → elk-api-Di4OXGNH.js} +1 -1
  92. package/studio/client/dist/assets/index-BLm6J11H.js +81 -0
  93. package/studio/client/dist/assets/index-BiGR8Oo9.css +1 -0
  94. package/studio/client/dist/assets/index-DTjvkOUX.js +8 -0
  95. package/studio/client/dist/index.html +2 -2
  96. package/studio/package.json +2 -7
  97. package/studio/server/agent/ask.test.ts +1 -1
  98. package/studio/server/agent/bridge/grant.test.ts +1 -1
  99. package/studio/server/agent/bridge/routes.test.ts +1 -1
  100. package/studio/server/agent/harness/claude/adapter.test.ts +15 -5
  101. package/studio/server/agent/prompts/anchors.test.ts +32 -36
  102. package/studio/server/agent/prompts/anchors.ts +20 -49
  103. package/studio/server/agent/prompts/system.test.ts +3 -2
  104. package/studio/server/agent/prompts/system.ts +3 -3
  105. package/studio/server/agent/routes.test.ts +1 -1
  106. package/studio/server/agent/run/coordinator.test.ts +1 -1
  107. package/studio/server/api/canvas.ts +0 -1
  108. package/studio/server/api-agent-loadout.test.ts +1 -1
  109. package/studio/server/api.test.ts +1 -1
  110. package/studio/server/cache.test.ts +23 -12
  111. package/studio/server/cache.ts +12 -15
  112. package/studio/server/domain.test.ts +50 -68
  113. package/studio/server/domain.ts +82 -63
  114. package/studio/server/handoff/copy.ts +1 -1
  115. package/studio/server/index.ts +1 -1
  116. package/studio/server/instances/probe.test.ts +1 -1
  117. package/studio/server/introspect/anatomy/views/routes.ts +46 -37
  118. package/studio/server/introspect/anatomy/views.ts +9 -14
  119. package/studio/server/introspect/anatomy-extras.test.ts +26 -42
  120. package/studio/server/introspect/anatomy.test.ts +22 -14
  121. package/studio/server/introspect/anatomy.ts +6 -9
  122. package/studio/server/introspect/bundle.ts +0 -3
  123. package/studio/server/introspect/canonical-schema.test.ts +94 -389
  124. package/studio/server/introspect/canonical-schema.ts +227 -457
  125. package/studio/server/introspect/core-extractor.ts +18 -127
  126. package/studio/server/introspect/core.ts +1 -2
  127. package/studio/server/introspect/diff.test.ts +11 -7
  128. package/studio/server/introspect/diff.ts +18 -55
  129. package/studio/server/introspect/extractor.ts +22 -117
  130. package/studio/server/introspect/overlay-tsmorph.test.ts +119 -240
  131. package/studio/server/introspect/overlay.test.ts +26 -54
  132. package/studio/server/introspect/overlay.ts +10 -37
  133. package/studio/server/introspect/revision.test.ts +1 -1
  134. package/studio/server/introspect/revision.ts +1 -1
  135. package/studio/server/introspect/runtime.test.ts +65 -183
  136. package/studio/server/introspect/runtime.ts +8 -25
  137. package/studio/server/introspect/schema-ir-json.test.ts +70 -0
  138. package/studio/server/introspect/schema-ir-json.ts +38 -68
  139. package/studio/server/introspect/schema-refs.test.ts +43 -88
  140. package/studio/server/introspect/schema-refs.ts +14 -49
  141. package/studio/server/introspect/source-overlay/handlers.ts +116 -636
  142. package/studio/server/introspect/source-overlay/kernel-calls.ts +0 -3
  143. package/studio/server/introspect/source-overlay/spans.ts +15 -45
  144. package/studio/server/state/baseline.test.ts +14 -9
  145. package/studio/server/state/baseline.ts +3 -5
  146. package/studio/server/state/visibility.ts +1 -5
  147. package/studio/server/views/model.ts +3 -3
  148. package/studio/server/views/target.test.ts +17 -74
  149. package/studio/server/views/target.ts +24 -50
  150. package/studio/server/watch.test.ts +11 -11
  151. package/studio/server/watch.ts +8 -4
  152. package/studio/server/workspace-watch.ts +2 -2
  153. package/studio/shared/contracts/schema.ts +38 -107
  154. package/studio/shared/contracts/surface.test.ts +12 -15
  155. package/studio/shared/contracts/workspace.ts +2 -11
  156. package/studio/shared/schema/identity.test.ts +20 -44
  157. package/studio/shared/schema/identity.ts +9 -23
  158. package/viewer/dist/main.js +41 -38
  159. package/studio/client/dist/assets/index-C-PvAXV4.js +0 -81
  160. package/studio/client/dist/assets/index-C4aNQ6dz.css +0 -1
  161. package/studio/client/dist/assets/index-CzpmJD0j.js +0 -8
  162. package/studio/server/introspect/anatomy/views/legacy.ts +0 -232
@@ -1,232 +0,0 @@
1
- import { existsSync, statSync } from 'node:fs'
2
- import { dirname, join, relative } from 'node:path'
3
- import { Node, Project, SyntaxKind } from 'ts-morph'
4
-
5
- import type { ViewInfo } from '../../../../shared/types'
6
-
7
- import { makeProject } from '../source'
8
-
9
- /**
10
- * Resolve the relative `./welcome` / `../foo` import spec used in views/index.ts
11
- * to an on-disk `.ts` file under the views dir. Returns absolute path or null.
12
- */
13
- function resolveLocalModule(fromFile: string, spec: string): string | null {
14
- if (!spec.startsWith('.')) return null
15
- const base = join(dirname(fromFile), spec)
16
- const candidates = [
17
- base,
18
- `${base}.ts`,
19
- `${base}.tsx`,
20
- join(base, 'index.ts'),
21
- join(base, 'index.tsx'),
22
- ]
23
- for (const c of candidates) {
24
- try {
25
- if (existsSync(c) && statSync(c).isFile()) return c
26
- } catch {
27
- /* ignore */
28
- }
29
- }
30
- return null
31
- }
32
-
33
- export function buildLegacyViews(root: string): ViewInfo[] {
34
- const indexFile = join(root, 'views', 'index.ts')
35
- if (!existsSync(indexFile)) return []
36
-
37
- let project: Project
38
- let index
39
- try {
40
- project = makeProject()
41
- index = project.addSourceFileAtPath(indexFile)
42
- } catch {
43
- return []
44
- }
45
-
46
- // Map identifier name → imported module spec (e.g. `welcome` → './welcome').
47
- const importSpecByName = new Map<string, string>()
48
- for (const imp of index.getImportDeclarations()) {
49
- const spec = imp.getModuleSpecifierValue()
50
- for (const named of imp.getNamedImports()) {
51
- importSpecByName.set(named.getAliasNode()?.getText() ?? named.getName(), spec)
52
- }
53
- const def = imp.getDefaultImport()
54
- if (def) importSpecByName.set(def.getText(), spec)
55
- }
56
-
57
- // Find the exported `views` object literal: { welcome, 'ui-status-page': statusPage }.
58
- const viewsDecl =
59
- index.getVariableDeclaration('views') ??
60
- index.getVariableDeclarations().find((d) => d.getName() === 'views')
61
- const init = viewsDecl?.getInitializer()
62
- if (!init || !Node.isObjectLiteralExpression(init)) return []
63
-
64
- const views: ViewInfo[] = []
65
- for (const prop of init.getProperties()) {
66
- let slug: string | undefined
67
- let refName: string | undefined
68
- let inlineArg: Node | undefined // `slug: defineView({...})` declared right here (e.g. mcac)
69
-
70
- if (Node.isShorthandPropertyAssignment(prop)) {
71
- // `welcome,` → slug `welcome`, ref `welcome` (imported view file)
72
- slug = prop.getName()
73
- refName = prop.getName()
74
- } else if (Node.isPropertyAssignment(prop)) {
75
- const nameNode = prop.getNameNode()
76
- slug = Node.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName()
77
- const valueInit = prop.getInitializer()
78
- if (
79
- valueInit &&
80
- Node.isCallExpression(valueInit) &&
81
- valueInit.getExpression().getText() === 'defineView'
82
- ) {
83
- // `'ui-move': defineView({...})` — parsed in place
84
- inlineArg = valueInit.getArguments()[0]
85
- } else if (valueInit && Node.isIdentifier(valueInit)) {
86
- // `'ui-status-page': statusPage` — resolved from an imported file
87
- refName = valueInit.getText()
88
- }
89
- }
90
-
91
- if (!slug) continue
92
-
93
- const info: ViewInfo = { slug, kind: 'unknown', url: undefined }
94
-
95
- if (inlineArg) {
96
- // inline defineView (e.g. mcac) — the declaration lives in views/index.ts itself
97
- info.file = relative(root, indexFile)
98
- applyParsed(info, parseViewObject(inlineArg))
99
- } else {
100
- // A shorthand may reference a defineView declared earlier in this same
101
- // registry file (services), or one imported from another module (ai-gateway).
102
- const localInit = refName
103
- ? index.getVariableDeclaration(refName)?.getInitializer()
104
- : undefined
105
- if (
106
- localInit &&
107
- Node.isCallExpression(localInit) &&
108
- localInit.getExpression().getText() === 'defineView'
109
- ) {
110
- const arg = localInit.getArguments()[0]
111
- if (arg) {
112
- info.file = relative(root, indexFile)
113
- applyParsed(info, parseViewObject(arg))
114
- }
115
- } else {
116
- const spec = refName ? importSpecByName.get(refName) : undefined
117
- const viewFile = spec ? resolveLocalModule(indexFile, spec) : null
118
- if (viewFile) {
119
- info.file = relative(root, viewFile)
120
- try {
121
- applyParsed(info, parseViewFile(project, viewFile))
122
- } catch {
123
- /* keep the unknown-kind stub */
124
- }
125
- }
126
- }
127
- }
128
-
129
- views.push(info)
130
- }
131
-
132
- return views
133
- }
134
-
135
- interface ParsedView {
136
- kind: ViewInfo['kind']
137
- auth?: string
138
- mount?: string
139
- viewFor?: string | string[]
140
- description?: string
141
- }
142
-
143
- /** Copy a ParsedView's set fields onto a ViewInfo. */
144
- function applyParsed(info: ViewInfo, parsed: ParsedView): void {
145
- info.kind = parsed.kind
146
- if (parsed.auth !== undefined) info.auth = parsed.auth
147
- if (parsed.mount !== undefined) info.mount = parsed.mount
148
- if (parsed.viewFor !== undefined) info.viewFor = parsed.viewFor
149
- if (parsed.description !== undefined) info.description = parsed.description
150
- }
151
-
152
- /** Parse a referenced view module: find its defineView({...}) call + parse the literal. */
153
- function parseViewFile(project: Project, file: string): ParsedView {
154
- const sf = project.addSourceFileAtPathIfExists(file) ?? project.addSourceFileAtPath(file)
155
- for (const call of sf.getDescendantsOfKind(SyntaxKind.CallExpression)) {
156
- if (call.getExpression().getText() === 'defineView') {
157
- const arg = call.getArguments()[0]
158
- if (arg) return parseViewObject(arg)
159
- }
160
- }
161
- return { kind: 'unknown' }
162
- }
163
-
164
- /** Parse a `defineView({...})` object-literal argument into a ParsedView. */
165
- function parseViewObject(arg: Node): ParsedView {
166
- const result: ParsedView = { kind: 'unknown' }
167
- if (!Node.isObjectLiteralExpression(arg)) return result
168
-
169
- let hasRender = false
170
- let hasInlineHtml = false
171
- let hasMount = false
172
-
173
- for (const prop of arg.getProperties()) {
174
- if (
175
- !Node.isPropertyAssignment(prop) &&
176
- !Node.isMethodDeclaration(prop) &&
177
- !Node.isShorthandPropertyAssignment(prop)
178
- ) {
179
- continue
180
- }
181
- const key = prop.getName?.()
182
- if (!key) continue
183
-
184
- if (key === 'auth') {
185
- if (Node.isPropertyAssignment(prop)) {
186
- const v = prop.getInitializer()
187
- if (v && Node.isStringLiteral(v)) result.auth = v.getLiteralValue()
188
- else if (v) result.auth = v.getText().replace(/^['"`]|['"`]$/g, '')
189
- }
190
- } else if (key === 'mount') {
191
- hasMount = true
192
- if (Node.isPropertyAssignment(prop)) {
193
- const v = prop.getInitializer()
194
- if (v && Node.isStringLiteral(v)) result.mount = v.getLiteralValue()
195
- else if (v) result.mount = v.getText().replace(/^['"`]|['"`]$/g, '')
196
- }
197
- } else if (key === 'render') {
198
- hasRender = true
199
- // Inline HTML if the render body references c.html(...) or returns an HTML string.
200
- const text = prop.getText()
201
- if (/\bc\s*\.\s*html\s*\(/.test(text) || /<!doctype html>|<html\b/i.test(text)) {
202
- hasInlineHtml = true
203
- }
204
- } else if (key === 'viewFor') {
205
- if (Node.isPropertyAssignment(prop)) {
206
- const v = prop.getInitializer()
207
- if (v) {
208
- // selfOf(A) → 'A' ; [selfOf(A), selfOf(B)] → ['A','B'] ; else best-effort identifier.
209
- const names = [...v.getText().matchAll(/selfOf\s*\(\s*([A-Za-z_$][\w$]*)\s*\)/g)].map(
210
- (m) => m[1],
211
- )
212
- if (names.length > 1) result.viewFor = names
213
- else if (names.length === 1) result.viewFor = names[0]
214
- else if (Node.isIdentifier(v)) result.viewFor = v.getText()
215
- }
216
- }
217
- } else if (key === 'description') {
218
- if (Node.isPropertyAssignment(prop)) {
219
- const v = prop.getInitializer()
220
- if (v && Node.isStringLiteral(v)) result.description = v.getLiteralValue()
221
- }
222
- }
223
- }
224
-
225
- if (hasRender && (hasInlineHtml || !hasMount)) result.kind = 'inline-html'
226
- else if (hasMount) result.kind = 'spa'
227
- else result.kind = 'unknown'
228
-
229
- return result
230
- }
231
-
232
- // ───────────────────────────── 2) client tree ─────────────────────────────