@arcforge/platform 2.0.206 → 2.0.208
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/package.json +10 -10
- package/src/build/blueprint/blueprint.ts +21 -5
- package/src/build/blueprint/scan/scripts.ts +5 -2
- package/src/build/project/project.ts +1 -1
- package/src/build/project/projects.ts +5 -3
- package/src/build/project/typegen/index.ts +14 -0
- package/src/build/project/typegen/workspace-scripts.ts +112 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcforge/platform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.208",
|
|
4
4
|
"description": "The Axon developer platform — headless project discovery, blueprint scanning, typegen, agent lifecycle, registry, benches and tests. Shared by the CLI/TUI and the Fleet extension.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"deploy": "echo \"This package is published ONLY by apps/tui/scripts/release.ts, which pins workspace:* deps to concrete versions first. Publishing it directly ships an unresolvable dependency.\" && exit 1"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@arcforge/session": "2.0.
|
|
48
|
-
"@arcforge/engines": "2.0.
|
|
49
|
-
"@arcforge/err": "2.0.
|
|
50
|
-
"@arcforge/types": "2.0.
|
|
51
|
-
"@arcforge/cloud": "2.0.
|
|
52
|
-
"@arcforge/capsule": "2.0.
|
|
53
|
-
"@arcforge/core": "2.0.
|
|
54
|
-
"@arcforge/vstr": "2.0.
|
|
47
|
+
"@arcforge/session": "2.0.208",
|
|
48
|
+
"@arcforge/engines": "2.0.208",
|
|
49
|
+
"@arcforge/err": "2.0.208",
|
|
50
|
+
"@arcforge/types": "2.0.208",
|
|
51
|
+
"@arcforge/cloud": "2.0.208",
|
|
52
|
+
"@arcforge/capsule": "2.0.208",
|
|
53
|
+
"@arcforge/core": "2.0.208",
|
|
54
|
+
"@arcforge/vstr": "2.0.208",
|
|
55
55
|
"fft.js": "^4.0.4",
|
|
56
56
|
"h3": "^1.15.11",
|
|
57
57
|
"semver": "^7.7.4",
|
|
58
58
|
"sharp": "^0.35.3",
|
|
59
59
|
"typescript": "5.9.2",
|
|
60
|
-
"@arcforge/link": "2.0.
|
|
60
|
+
"@arcforge/link": "2.0.208"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@arcforge/air": "2.0.187",
|
|
@@ -123,6 +123,9 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
123
123
|
|
|
124
124
|
// Authored truth — a broken config is no agent. Throws.
|
|
125
125
|
const config = await Config(root)
|
|
126
|
+
// Workspace integration is opt-out for both prompts and scripts.
|
|
127
|
+
// Resolve it once so the two repository-owned surfaces cannot drift.
|
|
128
|
+
const workspaceEnabled = config.value.workspace !== false
|
|
126
129
|
|
|
127
130
|
// `engine:` is READ BY NOTHING, and now REFUSED.
|
|
128
131
|
//
|
|
@@ -148,8 +151,8 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
148
151
|
// what this writes.
|
|
149
152
|
if (loadOpts.compile) await cognet.compile(cognetSourceOf(config))
|
|
150
153
|
|
|
151
|
-
// Agent surfaces + modules, plus workspace prompts when available.
|
|
152
|
-
const [prompts, scripts, tools, routes, plugins, middleware, knowledge, boot, modules, brain, workspacePrompts] = await Promise.all([
|
|
154
|
+
// Agent surfaces + modules, plus workspace prompts/scripts when available.
|
|
155
|
+
const [prompts, scripts, tools, routes, plugins, middleware, knowledge, boot, modules, brain, workspacePrompts, workspaceScripts] = await Promise.all([
|
|
153
156
|
Prompts(root),
|
|
154
157
|
|
|
155
158
|
Scripts(root),
|
|
@@ -161,7 +164,7 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
161
164
|
Boot(root),
|
|
162
165
|
Modules({ root, declared: config.modules, modulePaths: config.modulePaths }),
|
|
163
166
|
cognet.read(),
|
|
164
|
-
!workspace
|
|
167
|
+
!workspace || !workspaceEnabled
|
|
165
168
|
? Promise.resolve({ entries: [], warnings: [] })
|
|
166
169
|
: Prompts(workspace, { prefix: "workspace", dir: "prompts" }).then(async scanned => ({
|
|
167
170
|
entries: await Promise.all(scanned.entries.map(async entry => ({
|
|
@@ -170,8 +173,14 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
170
173
|
}))),
|
|
171
174
|
warnings: scanned.warnings,
|
|
172
175
|
})),
|
|
176
|
+
!workspace || !workspaceEnabled
|
|
177
|
+
? Promise.resolve({ entries: [], warnings: [] })
|
|
178
|
+
// Workspace scripts are trusted repository orchestration.
|
|
179
|
+
// They remain namespaced so a repo cannot silently replace
|
|
180
|
+
// an agent-owned script with the same filename.
|
|
181
|
+
: Scripts(workspace, { prefix: "workspace", dir: "scripts", required: false }),
|
|
173
182
|
])
|
|
174
|
-
for (const scanned of [prompts, scripts, tools, routes, plugins, middleware, knowledge, workspacePrompts]) warnings.push(...scanned.warnings)
|
|
183
|
+
for (const scanned of [prompts, scripts, tools, routes, plugins, middleware, knowledge, workspacePrompts, workspaceScripts]) warnings.push(...scanned.warnings)
|
|
175
184
|
warnings.push(...boot.warnings, ...modules.warnings, ...brain.warnings)
|
|
176
185
|
|
|
177
186
|
// Merge module surfaces under agent-wins precedence.
|
|
@@ -184,7 +193,14 @@ export function Blueprint(opts: BlueprintOpts) {
|
|
|
184
193
|
...(workspacePrompts.entries.length ? [{ owner: "workspace", entries: workspacePrompts.entries }] : []),
|
|
185
194
|
],
|
|
186
195
|
)
|
|
187
|
-
const mergedScripts = merge(
|
|
196
|
+
const mergedScripts = merge(
|
|
197
|
+
"scripts",
|
|
198
|
+
scripts.entries,
|
|
199
|
+
[
|
|
200
|
+
...groups.map(g => ({ owner: g.owner, entries: g.entries.scripts })),
|
|
201
|
+
...(workspaceScripts.entries.length ? [{ owner: "workspace", entries: workspaceScripts.entries }] : []),
|
|
202
|
+
],
|
|
203
|
+
)
|
|
188
204
|
const mergedTools = merge("tools", tools.entries, groups.map(g => ({ owner: g.owner, entries: g.entries.tools })))
|
|
189
205
|
warnings.push(...mergedPrompts.warnings, ...mergedScripts.warnings, ...mergedTools.warnings)
|
|
190
206
|
|
|
@@ -49,8 +49,11 @@ function loadToolchain() {
|
|
|
49
49
|
* Defaults to true: a caller that has not thought about it gets the strict
|
|
50
50
|
* behaviour, and only the module scanner opts out.
|
|
51
51
|
*/
|
|
52
|
-
export async function Scripts(root: string, opts: { prefix?: string; required?: boolean } = {}): Promise<Scanned<AxonScript>> {
|
|
53
|
-
|
|
52
|
+
export async function Scripts(root: string, opts: { prefix?: string; dir?: string; required?: boolean } = {}): Promise<Scanned<AxonScript>> {
|
|
53
|
+
// Agent/module scripts live under src/scripts; a repository workspace owns
|
|
54
|
+
// its scripts directly under .agents/scripts. Sharing this scanner keeps
|
|
55
|
+
// metadata extraction and failure semantics identical across both surfaces.
|
|
56
|
+
const scriptsDir = opts.dir ? join(root, opts.dir) : join(root, "src", "scripts")
|
|
54
57
|
const entries: AxonScript[] = []
|
|
55
58
|
const warnings: Scanned<AxonScript>["warnings"] = []
|
|
56
59
|
|
|
@@ -95,7 +95,7 @@ export function Project(opts: ProjectOpts) {
|
|
|
95
95
|
tree: tree,
|
|
96
96
|
during: (fn, options) => during(fn, options),
|
|
97
97
|
})
|
|
98
|
-
const typegen = Typegen({ root: root, kind: kind })
|
|
98
|
+
const typegen = Typegen({ root: root, kind: kind, ...(opts.cwd ? { cwd: opts.cwd } : {}) })
|
|
99
99
|
// `prepare` is a getter: Prepare() is built below and bundling needs it.
|
|
100
100
|
const bundle = Bundle({ root: root, manifest: manifest, modules: modules, prepare: () => prepare })
|
|
101
101
|
|
|
@@ -42,7 +42,7 @@ type ProjectsOpts = {
|
|
|
42
42
|
* cloud client and fails loudly at the call site when logged out.
|
|
43
43
|
*/
|
|
44
44
|
export function Projects(opts: ProjectsOpts) {
|
|
45
|
-
async function open(root: string): Promise<ProjectT> {
|
|
45
|
+
async function open(root: string, cwd = opts.cwd): Promise<ProjectT> {
|
|
46
46
|
const absolute = resolve(root)
|
|
47
47
|
const kind = detectKind(absolute)
|
|
48
48
|
|
|
@@ -56,7 +56,7 @@ export function Projects(opts: ProjectsOpts) {
|
|
|
56
56
|
name: await projectName(absolute),
|
|
57
57
|
cloud: opts.cloud,
|
|
58
58
|
frameworkVersion: opts.frameworkVersion,
|
|
59
|
-
...(
|
|
59
|
+
...(cwd ? { cwd } : {}),
|
|
60
60
|
...(opts.frameworkSource ? { frameworkSource: opts.frameworkSource } : {}),
|
|
61
61
|
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
|
|
62
62
|
bench: opts.bench,
|
|
@@ -73,7 +73,9 @@ export function Projects(opts: ProjectsOpts) {
|
|
|
73
73
|
context: { path: cwd, kind },
|
|
74
74
|
})
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
// Workspace discovery belongs to this invocation, not the long-lived
|
|
77
|
+
// terminal process that happened to create the platform.
|
|
78
|
+
const project = await open(root, cwd)
|
|
77
79
|
if (project.kind !== kind) {
|
|
78
80
|
throw err("PROJECT_WRONG_KIND", {
|
|
79
81
|
detail: `${project.root} is a ${project.kind} project, not a ${kind}`,
|
|
@@ -4,6 +4,9 @@ import { Generators } from "./generators"
|
|
|
4
4
|
import type { BuiltinRegistry } from "./registry-dts"
|
|
5
5
|
import { Tools } from "../../blueprint/scan/tools"
|
|
6
6
|
import { KINDS, type ProjectKind } from "../kinds"
|
|
7
|
+
import { generateWorkspaceScriptFrame } from "./workspace-scripts"
|
|
8
|
+
import { workspaceRoot } from "../../blueprint/workspace"
|
|
9
|
+
import { dirname, relative, resolve } from "node:path"
|
|
7
10
|
|
|
8
11
|
export type TypegenResult = {
|
|
9
12
|
toolGlobals: number
|
|
@@ -37,6 +40,8 @@ type TypegenOpts = {
|
|
|
37
40
|
* serves. The names are data — the platform only writes them down.
|
|
38
41
|
*/
|
|
39
42
|
builtins?: BuiltinRegistry
|
|
43
|
+
/** Invocation directory used to discover a repository workspace. */
|
|
44
|
+
cwd?: string
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
/**
|
|
@@ -63,6 +68,12 @@ type TypegenOpts = {
|
|
|
63
68
|
export function Typegen(opts: TypegenOpts) {
|
|
64
69
|
const { kind, root } = opts
|
|
65
70
|
const generate = Generators(opts)
|
|
71
|
+
const discoveredWorkspace = opts.cwd ? workspaceRoot(opts.cwd) : null
|
|
72
|
+
const workspace = discoveredWorkspace && (() => {
|
|
73
|
+
const repoRoot = dirname(discoveredWorkspace)
|
|
74
|
+
const rel = relative(resolve(repoRoot), resolve(root))
|
|
75
|
+
return rel === "" || (!rel.startsWith(".." + "/") && rel !== "..") ? discoveredWorkspace : null
|
|
76
|
+
})()
|
|
66
77
|
|
|
67
78
|
return {
|
|
68
79
|
/** Per-domain generators — regenerate one file when one domain changed. */
|
|
@@ -129,6 +140,9 @@ export function Typegen(opts: TypegenOpts) {
|
|
|
129
140
|
scripts: generate.scripts(blueprint.scripts ?? []),
|
|
130
141
|
components: await generate.components(blueprint.modules ?? []),
|
|
131
142
|
env: generate.env(),
|
|
143
|
+
...(workspace && blueprint.config?.workspace !== false
|
|
144
|
+
? (generateWorkspaceScriptFrame(workspace, root, blueprint.scripts ?? [], blueprint.prompts ?? []), {})
|
|
145
|
+
: {}),
|
|
132
146
|
}
|
|
133
147
|
},
|
|
134
148
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { join, relative } from "node:path"
|
|
3
|
+
import type { AxonPrompt, AxonScript } from "@arcforge/types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Give repository-authored workspace scripts the same ambient frame as the
|
|
7
|
+
* linked agent that will execute them. The config is authored once; .axon/
|
|
8
|
+
* is derived from the currently prepared agent and deliberately disposable.
|
|
9
|
+
*/
|
|
10
|
+
export function generateWorkspaceScriptFrame(
|
|
11
|
+
workspace: string,
|
|
12
|
+
agentRoot: string,
|
|
13
|
+
scripts: AxonScript[],
|
|
14
|
+
prompts: AxonPrompt[],
|
|
15
|
+
): void {
|
|
16
|
+
const scriptsDir = join(workspace, "scripts")
|
|
17
|
+
if (!existsSync(scriptsDir)) return
|
|
18
|
+
|
|
19
|
+
const output = join(workspace, ".axon")
|
|
20
|
+
mkdirSync(output, { recursive: true })
|
|
21
|
+
|
|
22
|
+
const config = join(workspace, "tsconfig.json")
|
|
23
|
+
// The initial workspace frame used an extends-only config. Upgrade that
|
|
24
|
+
// exact generated shape, but never overwrite a workspace author's config.
|
|
25
|
+
const legacyConfig = existsSync(config) && (() => {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(readFileSync(config, "utf-8")) as { extends?: string }
|
|
28
|
+
return parsed.extends === "@arcforge/types/tsconfig.base.json"
|
|
29
|
+
} catch {
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
})()
|
|
33
|
+
if (!existsSync(config) || legacyConfig) {
|
|
34
|
+
writeFileSync(config, JSON.stringify({
|
|
35
|
+
compilerOptions: {
|
|
36
|
+
// Workspace scripts are Bun modules even when a script has no
|
|
37
|
+
// imports/exports. This makes top-level await valid without
|
|
38
|
+
// requiring authors to add a meaningless module marker.
|
|
39
|
+
target: "ESNext",
|
|
40
|
+
module: "ESNext",
|
|
41
|
+
moduleResolution: "bundler",
|
|
42
|
+
moduleDetection: "force",
|
|
43
|
+
lib: ["ESNext"],
|
|
44
|
+
types: ["bun-types"],
|
|
45
|
+
strict: true,
|
|
46
|
+
skipLibCheck: true,
|
|
47
|
+
noEmit: true,
|
|
48
|
+
allowImportingTsExtensions: true,
|
|
49
|
+
},
|
|
50
|
+
include: ["scripts/**/*.ts", ".axon/**/*.d.ts"],
|
|
51
|
+
}, null, 2) + "\n", "utf-8")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const toolGlobals = join(agentRoot, ".agent", "types", "tool-globals.d.ts")
|
|
55
|
+
const references = existsSync(toolGlobals)
|
|
56
|
+
? [`/// <reference path="${relative(output, toolGlobals).replace(/\\\\/g, "/")}" />`]
|
|
57
|
+
: []
|
|
58
|
+
|
|
59
|
+
// This is intentionally a small stable script contract rather than a
|
|
60
|
+
// reference to the agent's complete axon.d.ts. Referencing that declaration
|
|
61
|
+
// pulls the agent's provider graph into repository typechecking; a workspace
|
|
62
|
+
// script needs its runtime entrypoints and the selected agent's tool globals.
|
|
63
|
+
const workspacePrompts = prompts.filter(prompt => prompt.name.startsWith("workspace:"))
|
|
64
|
+
const propsType = (props: NonNullable<AxonPrompt["props"]>): string =>
|
|
65
|
+
props.length === 0
|
|
66
|
+
? "Record<string, never>"
|
|
67
|
+
: `{ ${props.map(prop => `${prop.name}${prop.required ? "" : "?"}: ${prop.type}`).join("; ")} }`
|
|
68
|
+
const promptTypes = workspacePrompts.map(prompt =>
|
|
69
|
+
` interface WorkspacePromptMap { "${prompt.name}": ${propsType(prompt.props ?? [])} }`,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const scriptGlobals = [
|
|
73
|
+
"declare global {",
|
|
74
|
+
" interface WorkspacePromptMap {}",
|
|
75
|
+
...promptTypes,
|
|
76
|
+
" type WorkspacePromptName = keyof WorkspacePromptMap",
|
|
77
|
+
" type WorkspacePromptArgs<K extends WorkspacePromptName> = keyof WorkspacePromptMap[K] extends never",
|
|
78
|
+
" ? [props?: WorkspacePromptMap[K]]",
|
|
79
|
+
" : [props: WorkspacePromptMap[K]]",
|
|
80
|
+
" const axon: {",
|
|
81
|
+
" request(input: string | { prompt: string }): Promise<unknown>",
|
|
82
|
+
" prompt<K extends string>(name: K & (K extends WorkspacePromptName ? K : K extends `workspace:${string}` ? never : K), ...args: K extends WorkspacePromptName ? WorkspacePromptArgs<K> : [props?: Record<string, unknown>]): Promise<string>",
|
|
83
|
+
" scripts: { request(name: string, args?: Record<string, unknown>): Promise<unknown> }",
|
|
84
|
+
" }",
|
|
85
|
+
" const args: Record<string, unknown>",
|
|
86
|
+
" function defineArgs<T extends Record<string, unknown>>(): T",
|
|
87
|
+
"}",
|
|
88
|
+
]
|
|
89
|
+
// Keep a workspace-only inventory too: it names the files this workspace
|
|
90
|
+
// owns even when the selected agent has other script surfaces.
|
|
91
|
+
const workspaceNames = scripts
|
|
92
|
+
.filter(script => script.name.startsWith("workspace:"))
|
|
93
|
+
.map(script => script.name)
|
|
94
|
+
|
|
95
|
+
writeFileSync(join(output, "globals.d.ts"), [
|
|
96
|
+
"// .agents/.axon/globals.d.ts — generated by axon prepare, do not edit",
|
|
97
|
+
"// The selected agent supplies the runtime globals and tool surface.",
|
|
98
|
+
...references,
|
|
99
|
+
...scriptGlobals,
|
|
100
|
+
"",
|
|
101
|
+
"export {}",
|
|
102
|
+
"",
|
|
103
|
+
].join("\n"), "utf-8")
|
|
104
|
+
|
|
105
|
+
writeFileSync(join(output, "scripts.d.ts"), [
|
|
106
|
+
"// .agents/.axon/scripts.d.ts — generated by axon prepare, do not edit",
|
|
107
|
+
`// Workspace scripts: ${workspaceNames.join(", ") || "none"}`,
|
|
108
|
+
"",
|
|
109
|
+
"export {}",
|
|
110
|
+
"",
|
|
111
|
+
].join("\n"), "utf-8")
|
|
112
|
+
}
|