@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.
- package/dist/astrale.js +66254 -64461
- package/dist/public/connect-core.js +14895 -33867
- package/dist/public/keys/index.js +1246 -34250
- package/dist/public/paths/index.js +866 -33833
- package/dist/types/admin/instance/model.d.ts +3 -4
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/lib/instance-target.d.ts +1 -1
- package/dist/types/lib/log.d.ts +2 -2
- package/package.json +4 -9
- package/src/__tests__/fixtures/publication.ts +20 -0
- package/src/admin/__tests__/binding.test.ts +12 -19
- package/src/admin/__tests__/fixture.ts +101 -0
- package/src/admin/binding.ts +83 -3
- package/src/admin/catalog/.spec/api.d.ts +1 -1
- package/src/admin/catalog/__tests__/client.test.ts +20 -49
- package/src/admin/catalog/client.ts +35 -26
- package/src/admin/catalog/model.ts +3 -4
- package/src/admin/graph/.spec/api.d.ts +4 -10
- package/src/admin/graph/nodes.ts +1 -1
- package/src/admin/instance/.spec/api.d.ts +1 -1
- package/src/admin/instance/__tests__/client.test.ts +58 -83
- package/src/admin/instance/client.ts +49 -39
- package/src/admin/instance/model.ts +9 -8
- package/src/commands/__tests__/call-describe.test.ts +46 -33
- package/src/commands/__tests__/domain-install-operation.test.ts +3 -14
- package/src/commands/__tests__/domain-install-owned.test.ts +1 -1
- package/src/commands/__tests__/domain-list.test.ts +5 -25
- package/src/commands/__tests__/install-identity-override.test.ts +3 -14
- package/src/commands/__tests__/read-commands.test.ts +35 -10
- package/src/commands/call-describe.ts +59 -67
- package/src/commands/call.ts +41 -54
- package/src/commands/domain/install.ts +2 -2
- package/src/commands/domain/uninstall.ts +2 -2
- package/src/commands/get.ts +13 -14
- package/src/commands/identity/__tests__/register.test.ts +3 -3
- package/src/commands/identity/register.ts +5 -4
- package/src/commands/instance/delete.ts +5 -3
- package/src/commands/instance/status.ts +1 -9
- package/src/commands/introspect.ts +4 -11
- package/src/commands/logs.ts +24 -25
- package/src/commands/mutate.ts +6 -5
- package/src/commands/query.ts +27 -30
- package/src/commands/token.ts +8 -7
- package/src/commands/view.ts +4 -3
- package/src/connection/.spec/api.d.ts +7 -8
- package/src/connection/.spec/architecture.md +5 -4
- package/src/connection/.spec/flows/session.ts +2 -2
- package/src/connection/.spec/laws/connection.ts +6 -2
- package/src/connection/.spec/layout.ts +1 -0
- package/src/connection/__tests__/credential.test.ts +1 -1
- package/src/connection/__tests__/errors.test.ts +27 -20
- package/src/connection/__tests__/exchange.test.ts +30 -1
- package/src/connection/__tests__/failure-fixtures.ts +39 -0
- package/src/connection/__tests__/failure-safety.test.ts +75 -0
- package/src/connection/__tests__/self.test.ts +31 -11
- package/src/connection/__tests__/session.test.ts +3 -3
- package/src/connection/call.ts +1 -1
- package/src/connection/credential.ts +2 -2
- package/src/connection/errors.ts +1 -355
- package/src/connection/exchange.ts +47 -23
- package/src/connection/failure/classify.ts +110 -0
- package/src/connection/failure/debug.ts +26 -0
- package/src/connection/failure/index.ts +18 -0
- package/src/connection/failure/model.ts +28 -0
- package/src/connection/failure/render.ts +116 -0
- package/src/connection/reasons.ts +16 -0
- package/src/connection/self.ts +39 -21
- package/src/connection/session.ts +8 -8
- package/src/errors.ts +3 -2
- package/src/graph/.spec/api.d.ts +12 -5
- package/src/graph/.spec/layout.ts +9 -1
- package/src/graph/__tests__/mutation.test.ts +2 -2
- package/src/graph/__tests__/query.test.ts +25 -6
- package/src/graph/class.ts +30 -0
- package/src/graph/index.ts +1 -0
- package/src/graph/query.ts +21 -32
- package/src/identity/.spec/api.d.ts +2 -2
- package/src/identity/__tests__/registration.test.ts +1 -1
- package/src/identity/registration.ts +3 -3
- package/src/lib/__tests__/domain-publication.test.ts +4 -15
- package/src/lib/__tests__/instance-target.test.ts +6 -39
- package/src/lib/__tests__/log-errors.test.ts +53 -0
- package/src/lib/__tests__/studio-server-deps.test.ts +1 -1
- package/src/lib/command-dx.ts +1 -4
- package/src/lib/domain-publication.ts +1 -1
- package/src/lib/instance-target.ts +3 -14
- package/src/lib/log.ts +11 -6
- package/src/lib/validation.ts +2 -2
- package/src/lib/view/resolve.ts +1 -1
- package/src/program/__tests__/program.test.ts +1 -1
- package/studio/client/dist/assets/{elk-api-YEDvaNU-.js → elk-api-Di4OXGNH.js} +1 -1
- package/studio/client/dist/assets/index-BLm6J11H.js +81 -0
- package/studio/client/dist/assets/index-BiGR8Oo9.css +1 -0
- package/studio/client/dist/assets/index-DTjvkOUX.js +8 -0
- package/studio/client/dist/index.html +2 -2
- package/studio/package.json +2 -7
- package/studio/server/agent/ask.test.ts +1 -1
- package/studio/server/agent/bridge/grant.test.ts +1 -1
- package/studio/server/agent/bridge/routes.test.ts +1 -1
- package/studio/server/agent/harness/claude/adapter.test.ts +15 -5
- package/studio/server/agent/prompts/anchors.test.ts +32 -36
- package/studio/server/agent/prompts/anchors.ts +20 -49
- package/studio/server/agent/prompts/system.test.ts +3 -2
- package/studio/server/agent/prompts/system.ts +3 -3
- package/studio/server/agent/routes.test.ts +1 -1
- package/studio/server/agent/run/coordinator.test.ts +1 -1
- package/studio/server/api/canvas.ts +0 -1
- package/studio/server/api-agent-loadout.test.ts +1 -1
- package/studio/server/api.test.ts +1 -1
- package/studio/server/cache.test.ts +23 -12
- package/studio/server/cache.ts +12 -15
- package/studio/server/domain.test.ts +50 -68
- package/studio/server/domain.ts +82 -63
- package/studio/server/handoff/copy.ts +1 -1
- package/studio/server/index.ts +1 -1
- package/studio/server/instances/probe.test.ts +1 -1
- package/studio/server/introspect/anatomy/views/routes.ts +46 -37
- package/studio/server/introspect/anatomy/views.ts +9 -14
- package/studio/server/introspect/anatomy-extras.test.ts +26 -42
- package/studio/server/introspect/anatomy.test.ts +22 -14
- package/studio/server/introspect/anatomy.ts +6 -9
- package/studio/server/introspect/bundle.ts +0 -3
- package/studio/server/introspect/canonical-schema.test.ts +94 -389
- package/studio/server/introspect/canonical-schema.ts +227 -457
- package/studio/server/introspect/core-extractor.ts +18 -127
- package/studio/server/introspect/core.ts +1 -2
- package/studio/server/introspect/diff.test.ts +11 -7
- package/studio/server/introspect/diff.ts +18 -55
- package/studio/server/introspect/extractor.ts +22 -117
- package/studio/server/introspect/overlay-tsmorph.test.ts +119 -240
- package/studio/server/introspect/overlay.test.ts +26 -54
- package/studio/server/introspect/overlay.ts +10 -37
- package/studio/server/introspect/revision.test.ts +1 -1
- package/studio/server/introspect/revision.ts +1 -1
- package/studio/server/introspect/runtime.test.ts +65 -183
- package/studio/server/introspect/runtime.ts +8 -25
- package/studio/server/introspect/schema-ir-json.test.ts +70 -0
- package/studio/server/introspect/schema-ir-json.ts +38 -68
- package/studio/server/introspect/schema-refs.test.ts +43 -88
- package/studio/server/introspect/schema-refs.ts +14 -49
- package/studio/server/introspect/source-overlay/handlers.ts +116 -636
- package/studio/server/introspect/source-overlay/kernel-calls.ts +0 -3
- package/studio/server/introspect/source-overlay/spans.ts +15 -45
- package/studio/server/state/baseline.test.ts +14 -9
- package/studio/server/state/baseline.ts +3 -5
- package/studio/server/state/visibility.ts +1 -5
- package/studio/server/views/model.ts +3 -3
- package/studio/server/views/target.test.ts +17 -74
- package/studio/server/views/target.ts +24 -50
- package/studio/server/watch.test.ts +11 -11
- package/studio/server/watch.ts +8 -4
- package/studio/server/workspace-watch.ts +2 -2
- package/studio/shared/contracts/schema.ts +38 -107
- package/studio/shared/contracts/surface.test.ts +12 -15
- package/studio/shared/contracts/workspace.ts +2 -11
- package/studio/shared/schema/identity.test.ts +20 -44
- package/studio/shared/schema/identity.ts +9 -23
- package/viewer/dist/main.js +41 -38
- package/studio/client/dist/assets/index-C-PvAXV4.js +0 -81
- package/studio/client/dist/assets/index-C4aNQ6dz.css +0 -1
- package/studio/client/dist/assets/index-CzpmJD0j.js +0 -8
- 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 ─────────────────────────────
|