@arcforge/platform 2.0.166
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/README.md +31 -0
- package/package.json +69 -0
- package/src/bin/supervisor.ts +102 -0
- package/src/bin/test-api.ts +30 -0
- package/src/bin/test-preload.ts +308 -0
- package/src/bin/update-helper.ts +32 -0
- package/src/build/bench/CLAUDE.md +106 -0
- package/src/build/bench/SPEC.md +209 -0
- package/src/build/bench/agents.ts +105 -0
- package/src/build/bench/axes.ts +84 -0
- package/src/build/bench/bench.ts +96 -0
- package/src/build/bench/discover.ts +147 -0
- package/src/build/bench/index.ts +7 -0
- package/src/build/bench/log.ts +47 -0
- package/src/build/bench/matrix.ts +23 -0
- package/src/build/bench/preload.ts +440 -0
- package/src/build/bench/prepare.ts +61 -0
- package/src/build/bench/projection.ts +112 -0
- package/src/build/bench/resolve.ts +54 -0
- package/src/build/bench/runner.ts +309 -0
- package/src/build/bench/schema/extract.ts +148 -0
- package/src/build/bench/schema/index.ts +2 -0
- package/src/build/bench/schema/schema.ts +95 -0
- package/src/build/bench/schema/worker.ts +30 -0
- package/src/build/bench/typegen.ts +119 -0
- package/src/build/bench/workspace/files.ts +139 -0
- package/src/build/bench/workspace/handle.ts +133 -0
- package/src/build/bench/workspace/index.ts +11 -0
- package/src/build/bench/workspace/workspace.ts +14 -0
- package/src/build/blueprint/blueprint.ts +398 -0
- package/src/build/blueprint/cognet/abi.ts +207 -0
- package/src/build/blueprint/cognet/bundle-worker.ts +93 -0
- package/src/build/blueprint/cognet/bundle.ts +664 -0
- package/src/build/blueprint/cognet/cognet.ts +249 -0
- package/src/build/blueprint/cognet/index.ts +10 -0
- package/src/build/blueprint/cognet/manifest.ts +38 -0
- package/src/build/blueprint/cognet/resolve.ts +113 -0
- package/src/build/blueprint/collisions.ts +51 -0
- package/src/build/blueprint/index.ts +29 -0
- package/src/build/blueprint/modules/entries.ts +117 -0
- package/src/build/blueprint/modules/index.ts +300 -0
- package/src/build/blueprint/modules/meta.ts +174 -0
- package/src/build/blueprint/scan/boot.ts +34 -0
- package/src/build/blueprint/scan/cognetImports.ts +56 -0
- package/src/build/blueprint/scan/components.ts +45 -0
- package/src/build/blueprint/scan/config.ts +234 -0
- package/src/build/blueprint/scan/configImports.ts +232 -0
- package/src/build/blueprint/scan/declare-worker.ts +61 -0
- package/src/build/blueprint/scan/declare.ts +393 -0
- package/src/build/blueprint/scan/h3-globals.ts +137 -0
- package/src/build/blueprint/scan/knowledge.ts +101 -0
- package/src/build/blueprint/scan/middleware.ts +110 -0
- package/src/build/blueprint/scan/moduleImports.ts +79 -0
- package/src/build/blueprint/scan/plugins.ts +93 -0
- package/src/build/blueprint/scan/promptPackages.ts +45 -0
- package/src/build/blueprint/scan/prompts.ts +164 -0
- package/src/build/blueprint/scan/published.ts +131 -0
- package/src/build/blueprint/scan/resolve.ts +398 -0
- package/src/build/blueprint/scan/routes.ts +109 -0
- package/src/build/blueprint/scan/scripts.ts +119 -0
- package/src/build/blueprint/scan/tool-bundle-worker.ts +69 -0
- package/src/build/blueprint/scan/tools.ts +610 -0
- package/src/build/blueprint/types.ts +28 -0
- package/src/build/extensions/config.ts +261 -0
- package/src/build/extensions/edit.ts +684 -0
- package/src/build/extensions/extensions.ts +731 -0
- package/src/build/extensions/index.ts +10 -0
- package/src/build/extensions/load.ts +350 -0
- package/src/build/extensions/registrations.ts +189 -0
- package/src/build/extensions/store.ts +200 -0
- package/src/build/frame/frame.ts +145 -0
- package/src/build/frame/index.ts +5 -0
- package/src/build/frame/migrate.ts +246 -0
- package/src/build/project/bundle/agent.ts +382 -0
- package/src/build/project/bundle/artifacts.ts +88 -0
- package/src/build/project/bundle/assets.ts +385 -0
- package/src/build/project/bundle/bundle.ts +160 -0
- package/src/build/project/bundle/imports.ts +102 -0
- package/src/build/project/bundle/index.ts +16 -0
- package/src/build/project/bundle/module.ts +130 -0
- package/src/build/project/bundle/source.ts +136 -0
- package/src/build/project/bundle/stage.ts +97 -0
- package/src/build/project/bundle/types.ts +111 -0
- package/src/build/project/cognet.ts +156 -0
- package/src/build/project/create/agent.ts +52 -0
- package/src/build/project/create/bench.ts +81 -0
- package/src/build/project/create/cognet.ts +102 -0
- package/src/build/project/create/extension.ts +63 -0
- package/src/build/project/create/module.ts +43 -0
- package/src/build/project/create/profile.ts +102 -0
- package/src/build/project/create/prompt.ts +68 -0
- package/src/build/project/create/templates.ts +88 -0
- package/src/build/project/deploy.ts +96 -0
- package/src/build/project/index.ts +40 -0
- package/src/build/project/installer.ts +616 -0
- package/src/build/project/kinds.ts +374 -0
- package/src/build/project/links.ts +33 -0
- package/src/build/project/manifest/bunfig.ts +139 -0
- package/src/build/project/manifest/config.ts +246 -0
- package/src/build/project/manifest/env.ts +184 -0
- package/src/build/project/manifest/index.ts +9 -0
- package/src/build/project/manifest/manifest.ts +49 -0
- package/src/build/project/manifest/model.ts +124 -0
- package/src/build/project/manifest/package.ts +386 -0
- package/src/build/project/manifest/text.ts +19 -0
- package/src/build/project/models/fetch.ts +123 -0
- package/src/build/project/models/index.ts +8 -0
- package/src/build/project/models/models.ts +111 -0
- package/src/build/project/models/specifier.ts +106 -0
- package/src/build/project/models/store.ts +202 -0
- package/src/build/project/modules/hash.ts +31 -0
- package/src/build/project/modules/index.ts +5 -0
- package/src/build/project/modules/lock.ts +78 -0
- package/src/build/project/modules/modules.ts +155 -0
- package/src/build/project/prepare.ts +709 -0
- package/src/build/project/project.ts +253 -0
- package/src/build/project/projects.ts +164 -0
- package/src/build/project/propagation.ts +120 -0
- package/src/build/project/publish/verify.ts +312 -0
- package/src/build/project/publish.ts +155 -0
- package/src/build/project/reconcile.ts +93 -0
- package/src/build/project/specifier.ts +42 -0
- package/src/build/project/tree.ts +615 -0
- package/src/build/project/treecache.ts +356 -0
- package/src/build/project/typegen/axon-dts.ts +362 -0
- package/src/build/project/typegen/cognet-dts.ts +91 -0
- package/src/build/project/typegen/components.ts +45 -0
- package/src/build/project/typegen/env.ts +59 -0
- package/src/build/project/typegen/generators.ts +108 -0
- package/src/build/project/typegen/hooks.ts +71 -0
- package/src/build/project/typegen/index.ts +137 -0
- package/src/build/project/typegen/prompt-dts.ts +40 -0
- package/src/build/project/typegen/prompts.ts +36 -0
- package/src/build/project/typegen/registry-dts.ts +109 -0
- package/src/build/project/typegen/scripts.ts +37 -0
- package/src/build/project/typegen/tools.ts +31 -0
- package/src/build/project/typegen/tsconfig.ts +243 -0
- package/src/build/project/typegen/tui-dts.ts +120 -0
- package/src/build/project/typegen/write.ts +40 -0
- package/src/build/project/verify.ts +268 -0
- package/src/build/project/watcher.ts +266 -0
- package/src/build/runtime/agent.ts +550 -0
- package/src/build/runtime/escalations.ts +159 -0
- package/src/build/runtime/index.ts +15 -0
- package/src/build/runtime/instances.ts +604 -0
- package/src/build/runtime/profile.ts +91 -0
- package/src/build/runtime/progress.ts +143 -0
- package/src/build/runtime/requests.ts +167 -0
- package/src/build/runtime/resolve.ts +159 -0
- package/src/build/runtime/runtime.ts +233 -0
- package/src/build/runtime/sessions/index.ts +5 -0
- package/src/build/runtime/sessions/record.ts +145 -0
- package/src/build/runtime/sessions/sessions.ts +240 -0
- package/src/build/runtime/zeno.ts +120 -0
- package/src/index.ts +11 -0
- package/src/link/agent-main.ts +395 -0
- package/src/link/index.ts +70 -0
- package/src/link/services.ts +120 -0
- package/src/platform.ts +293 -0
- package/src/procs/index.ts +15 -0
- package/src/procs/tree.ts +177 -0
- package/src/services/cloud.ts +419 -0
- package/src/services/control/client.ts +126 -0
- package/src/services/control/dispatch.ts +156 -0
- package/src/services/control/index.ts +17 -0
- package/src/services/control/protocol.ts +179 -0
- package/src/services/control/server.ts +241 -0
- package/src/services/deployments.ts +81 -0
- package/src/services/files.ts +329 -0
- package/src/services/index.ts +5 -0
- package/src/services/mic/capture.ts +248 -0
- package/src/services/mic/config.ts +109 -0
- package/src/services/mic/fft.ts +93 -0
- package/src/services/mic/index.ts +139 -0
- package/src/services/mic/visualizer.ts +46 -0
- package/src/services/ollama/catalog.ts +122 -0
- package/src/services/ollama/http.ts +124 -0
- package/src/services/ollama/index.ts +13 -0
- package/src/services/ollama/models.ts +153 -0
- package/src/services/ollama/ollama.ts +89 -0
- package/src/services/ollama/registry.ts +112 -0
- package/src/services/ollama/types.ts +72 -0
- package/src/services/prompts.ts +76 -0
- package/src/services/registry.ts +220 -0
- package/src/services/resources/hardware.ts +125 -0
- package/src/services/resources/index.ts +6 -0
- package/src/services/resources/reservations.ts +162 -0
- package/src/services/resources/resources.ts +156 -0
- package/src/services/running/index.ts +1 -0
- package/src/services/running/running.ts +200 -0
- package/src/services/store/disk.ts +97 -0
- package/src/services/store/index.ts +15 -0
- package/src/services/store/store.ts +729 -0
- package/src/services/store/types.ts +303 -0
- package/src/services/test/child.ts +150 -0
- package/src/services/test/events.ts +102 -0
- package/src/services/test/files.ts +26 -0
- package/src/services/test/frames.ts +39 -0
- package/src/services/test/index.ts +7 -0
- package/src/services/test/runner.ts +122 -0
- package/src/services/test/types.ts +26 -0
- package/src/services/update/contract.ts +77 -0
- package/src/services/update/index.ts +12 -0
- package/src/services/update/installer.ts +139 -0
- package/src/services/update/updates.ts +137 -0
- package/src/utils/fs.ts +148 -0
- package/src/utils/tsast.ts +102 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import type { FrameworkSet, FrameworkSource } from "./manifest/package"
|
|
2
|
+
import { basename, dirname, join } from "node:path"
|
|
3
|
+
import { fsx } from "../../utils/fs"
|
|
4
|
+
import { INLINE_COGNET_DIR } from "../blueprint/cognet"
|
|
5
|
+
import { scaffoldAgent } from "./create/agent"
|
|
6
|
+
import { scaffoldBench } from "./create/bench"
|
|
7
|
+
import { scaffoldCognet } from "./create/cognet"
|
|
8
|
+
import { scaffoldModule } from "./create/module"
|
|
9
|
+
import { scaffoldPrompt } from "./create/prompt"
|
|
10
|
+
import { scaffoldExtension } from "./create/extension"
|
|
11
|
+
import { scaffoldProfile } from "./create/profile"
|
|
12
|
+
|
|
13
|
+
// The kind union and the frame layout are defined one stage down, in
|
|
14
|
+
// build/frame — the lowest layer, which imports nothing so that blueprint/
|
|
15
|
+
// and project/ can both read it without depending on each other. Re-exported
|
|
16
|
+
// here because `kinds.ts` is where callers already look for anything
|
|
17
|
+
// kind-shaped.
|
|
18
|
+
export type { ProjectKind } from "../frame"
|
|
19
|
+
export { Frame, FRAME, type FrameT, type FrameArea } from "../frame"
|
|
20
|
+
|
|
21
|
+
import type { ProjectKind as Kind } from "../frame"
|
|
22
|
+
|
|
23
|
+
/** What a scaffolder receives. Every kind takes the same input. */
|
|
24
|
+
export type ScaffoldOpts = {
|
|
25
|
+
name: string
|
|
26
|
+
dir: string
|
|
27
|
+
/** Pinned into the manifest by kinds that declare framework deps at scaffold time. */
|
|
28
|
+
frameworkVersion: string
|
|
29
|
+
frameworkSource?: FrameworkSource
|
|
30
|
+
repoRoot?: string
|
|
31
|
+
/** Registry URL baked into an agent's bunfig.toml. Agents only; ignored elsewhere. */
|
|
32
|
+
apiBase?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How one project kind differs from the others — and nothing else.
|
|
37
|
+
*
|
|
38
|
+
* Every per-kind decision in this package reads a field here. That is the
|
|
39
|
+
* point: a kind used to be an `if` repeated across projects.ts, prepare.ts,
|
|
40
|
+
* publish.ts, typegen/index.ts, generators.ts and tsconfig.ts, and cognet
|
|
41
|
+
* proved what happens when six branches must agree and one is forgotten —
|
|
42
|
+
* `axon cognet init` wrote its type frame before anything was installed and
|
|
43
|
+
* crashed on its own assert.
|
|
44
|
+
*
|
|
45
|
+
* Adding a sixth kind is adding a row. If something about a kind cannot be
|
|
46
|
+
* expressed as a field, that is the signal to widen the table rather than to
|
|
47
|
+
* reintroduce a branch somewhere.
|
|
48
|
+
*/
|
|
49
|
+
export type KindSpec = {
|
|
50
|
+
/** The file whose presence on disk identifies this kind. */
|
|
51
|
+
config: string
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* tsconfig `include` globs, written relative to the PROJECT ROOT.
|
|
55
|
+
*
|
|
56
|
+
* The generated tsconfig lives at `.<dir>/types/tsconfig.json`, two levels
|
|
57
|
+
* down, so these are rebased by the writer rather than authored with the
|
|
58
|
+
* right number of `../` segments here. Stating them from the root is both
|
|
59
|
+
* what a reader expects and what stops the table from breaking if the
|
|
60
|
+
* frame's interior ever gains another level: the depth is computed in one
|
|
61
|
+
* place (see `rebase()` in typegen/tsconfig.ts), not spelled 30 times.
|
|
62
|
+
*
|
|
63
|
+
* `./**` paths are the exception and stay frame-relative — they name the
|
|
64
|
+
* generated .d.ts files sitting beside the tsconfig itself.
|
|
65
|
+
*
|
|
66
|
+
* Empty when the kind has no frame.
|
|
67
|
+
*/
|
|
68
|
+
include: string[]
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Which ambient declaration file the frame carries. "axon" is the
|
|
72
|
+
* framework globals every agent-shaped project sees; "cognet" is the
|
|
73
|
+
* narrower authoring surface (loop, kernel, phase, system); "prompt" is
|
|
74
|
+
* the narrowest of all — definePrompt and nothing else; "tui" is the
|
|
75
|
+
* extension surface (tui, palette, commands, keys, mode, input, agents),
|
|
76
|
+
* shared by a profile and the extensions it loads.
|
|
77
|
+
*/
|
|
78
|
+
globals: "axon" | "cognet" | "prompt" | "tui" | "none"
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Whether prepare() writes a type frame for this kind.
|
|
82
|
+
*
|
|
83
|
+
* Every kind has one today, because every kind has at least one ambient
|
|
84
|
+
* global to declare — even a prompt package, whose whole authoring
|
|
85
|
+
* surface is definePrompt().
|
|
86
|
+
*/
|
|
87
|
+
frame: boolean
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether prepare() installs dependencies before writing the frame.
|
|
91
|
+
*
|
|
92
|
+
* False for prompt packages: a prompt is text and declares nothing, so
|
|
93
|
+
* there is no node_modules to create. Its frame is self-contained
|
|
94
|
+
* precisely so that stays true — see prompt-dts.ts.
|
|
95
|
+
*
|
|
96
|
+
* Split from `frame` because the two stopped coinciding: a prompt needs
|
|
97
|
+
* declarations without an install, and folding both into one flag meant
|
|
98
|
+
* "no dependencies" silently bought "no types" as well.
|
|
99
|
+
*/
|
|
100
|
+
installs: boolean
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* WHICH framework packages this kind declares. Only meaningful when
|
|
104
|
+
* `installs` is true.
|
|
105
|
+
*
|
|
106
|
+
* "all" is the agent set — engines, the cognet host, the AIR grammar, h3.
|
|
107
|
+
* "types" is @arcforge/types alone, which is all a profile or an extension
|
|
108
|
+
* needs: they configure the terminal rather than run an agent, and their
|
|
109
|
+
* only requirement is that `tsconfig.base.json` and the Bun globals
|
|
110
|
+
* resolve. Declaring the full set for them is not just noise — under
|
|
111
|
+
* `file:` linking it changed how the tree hoisted and @types/bun stopped
|
|
112
|
+
* resolving, silently degrading every symbol in a user's plugin to any.
|
|
113
|
+
*/
|
|
114
|
+
framework: FrameworkSet
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* How publish() packages it. "source" ships the project's own files for
|
|
118
|
+
* the consumer to build; agent and module are pre-built images.
|
|
119
|
+
*/
|
|
120
|
+
bundle: "agent" | "module" | "source"
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether the registry accepts this kind.
|
|
124
|
+
*
|
|
125
|
+
* Backed by a Postgres enum (`registry_artifact_kind`), so this is not a
|
|
126
|
+
* preference — a kind the backend has never heard of is rejected at the
|
|
127
|
+
* API, and adding one is a migration. Every kind is publishable except a
|
|
128
|
+
* PROFILE, which never can be: it holds one person's credentials, history
|
|
129
|
+
* and agents.
|
|
130
|
+
*
|
|
131
|
+
* Stated here rather than as a union in publish.ts so the fact lives with
|
|
132
|
+
* every other per-kind fact, and so a kind that becomes publishable is one
|
|
133
|
+
* field plus a migration.
|
|
134
|
+
*/
|
|
135
|
+
publishable: boolean
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Extra tarball entries this kind contributes beyond the common set
|
|
139
|
+
* (config file, package.json, src/, plugins/, README.md), resolved against
|
|
140
|
+
* the project root at bundle time.
|
|
141
|
+
*
|
|
142
|
+
* Exists so the source bundler carries no per-kind branch: a prompt pack
|
|
143
|
+
* keeps its prompts at the TOP LEVEL — the folder IS the pack, and every
|
|
144
|
+
* .vue/.md in it is an invokable unit — which is a fact about prompts, so
|
|
145
|
+
* it is stated here with the rest of them rather than as an `if` inside
|
|
146
|
+
* the bundler.
|
|
147
|
+
*/
|
|
148
|
+
files?: (root: string) => Promise<string[]>
|
|
149
|
+
|
|
150
|
+
/** Visibility a freshly-scaffolded project publishes at. */
|
|
151
|
+
public: boolean
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Write the project's source files and return its root.
|
|
155
|
+
*
|
|
156
|
+
* Scaffolders write only what the USER owns. Generated frames belong to
|
|
157
|
+
* prepare() — which runs after install, the only point at which writing
|
|
158
|
+
* them can succeed.
|
|
159
|
+
*/
|
|
160
|
+
scaffold: (opts: ScaffoldOpts) => Promise<string>
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const KINDS: Record<Kind, KindSpec> = {
|
|
164
|
+
agent: {
|
|
165
|
+
config: "axon.config.ts",
|
|
166
|
+
include: [
|
|
167
|
+
"axon.config.ts",
|
|
168
|
+
"./**/*.d.ts",
|
|
169
|
+
"src/**/*.ts",
|
|
170
|
+
"src/**/*.vue",
|
|
171
|
+
"scripts/**/*.ts",
|
|
172
|
+
"server/**/*.ts",
|
|
173
|
+
"modules/**/*.ts",
|
|
174
|
+
"modules/**/*.vue",
|
|
175
|
+
],
|
|
176
|
+
globals: "axon",
|
|
177
|
+
frame: true,
|
|
178
|
+
framework: "all",
|
|
179
|
+
installs: true,
|
|
180
|
+
bundle: "agent",
|
|
181
|
+
publishable: true,
|
|
182
|
+
public: false,
|
|
183
|
+
scaffold: scaffoldAgent,
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
module: {
|
|
187
|
+
config: "module.config.ts",
|
|
188
|
+
include: [
|
|
189
|
+
"module.config.ts",
|
|
190
|
+
"./**/*.d.ts",
|
|
191
|
+
"src/**/*.ts",
|
|
192
|
+
"server/**/*.ts",
|
|
193
|
+
"src/prompts/**/*.vue",
|
|
194
|
+
"tests/**/*.ts",
|
|
195
|
+
],
|
|
196
|
+
globals: "axon",
|
|
197
|
+
frame: true,
|
|
198
|
+
framework: "all",
|
|
199
|
+
installs: true,
|
|
200
|
+
bundle: "module",
|
|
201
|
+
publishable: true,
|
|
202
|
+
public: true,
|
|
203
|
+
scaffold: scaffoldModule,
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
cognet: {
|
|
207
|
+
config: "cognet.config.ts",
|
|
208
|
+
// A cognet's whole directory is brain source, so the entry may sit at
|
|
209
|
+
// `src/main.ts` or `main.ts` and either is compiled (see
|
|
210
|
+
// resolveCognetMain). `*.ts` at the root covers cognet.config.ts and a
|
|
211
|
+
// flat entry alike; node_modules is excluded below rather than dodged
|
|
212
|
+
// by enumerating subdirectories.
|
|
213
|
+
include: [
|
|
214
|
+
"./**/*.d.ts",
|
|
215
|
+
"*.ts",
|
|
216
|
+
"src/**/*.ts",
|
|
217
|
+
"plugins/**/*.ts",
|
|
218
|
+
"tests/**/*.ts",
|
|
219
|
+
],
|
|
220
|
+
globals: "cognet",
|
|
221
|
+
frame: true,
|
|
222
|
+
framework: "all",
|
|
223
|
+
installs: true,
|
|
224
|
+
bundle: "source",
|
|
225
|
+
publishable: true,
|
|
226
|
+
public: true,
|
|
227
|
+
scaffold: scaffoldCognet,
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
bench: {
|
|
231
|
+
config: "bench.config.ts",
|
|
232
|
+
// fixtures/ is deliberately absent: it holds author-side inputs and
|
|
233
|
+
// whole agent projects, which carry their own tsconfig scope.
|
|
234
|
+
include: [
|
|
235
|
+
"bench.config.ts",
|
|
236
|
+
"./**/*.d.ts",
|
|
237
|
+
"tests/**/*.ts",
|
|
238
|
+
],
|
|
239
|
+
globals: "axon",
|
|
240
|
+
frame: true,
|
|
241
|
+
framework: "all",
|
|
242
|
+
installs: true,
|
|
243
|
+
bundle: "source",
|
|
244
|
+
publishable: true,
|
|
245
|
+
public: true,
|
|
246
|
+
scaffold: scaffoldBench,
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
prompt: {
|
|
250
|
+
config: "prompt.config.ts",
|
|
251
|
+
include: [
|
|
252
|
+
"prompt.config.ts",
|
|
253
|
+
"./**/*.d.ts",
|
|
254
|
+
],
|
|
255
|
+
globals: "prompt",
|
|
256
|
+
frame: true,
|
|
257
|
+
// A prompt declares no dependencies — see `installs`.
|
|
258
|
+
framework: "all",
|
|
259
|
+
installs: false,
|
|
260
|
+
bundle: "source",
|
|
261
|
+
publishable: true,
|
|
262
|
+
public: true,
|
|
263
|
+
scaffold: scaffoldPrompt,
|
|
264
|
+
// The pack's invokable units live at the top level, and components/
|
|
265
|
+
// travels with them (fragments they compose, never invokable alone).
|
|
266
|
+
async files(root) {
|
|
267
|
+
const top = (await fsx.list(root)).filter(
|
|
268
|
+
name => name.endsWith(".vue") || name.endsWith(".md"),
|
|
269
|
+
)
|
|
270
|
+
return fsx.exists(join(root, "components")) ? [...top, "components"] : top
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
extension: {
|
|
275
|
+
config: "extension.config.ts",
|
|
276
|
+
// `*.ts` at the root covers extension.config.ts, main.ts, and anything
|
|
277
|
+
// the author splits out and imports — the same globs a profile gets,
|
|
278
|
+
// because it is the same layout.
|
|
279
|
+
include: [
|
|
280
|
+
"./**/*.d.ts",
|
|
281
|
+
"*.ts",
|
|
282
|
+
"src/**/*.ts",
|
|
283
|
+
"plugins/**/*.ts",
|
|
284
|
+
],
|
|
285
|
+
globals: "tui",
|
|
286
|
+
frame: true,
|
|
287
|
+
// An extension declares @arcforge/types (for tsconfig.base.json and the
|
|
288
|
+
// Bun globals) and may declare anything else it needs — it is ordinary
|
|
289
|
+
// TypeScript running in the CLI's process, not a sandbox.
|
|
290
|
+
framework: "types",
|
|
291
|
+
installs: true,
|
|
292
|
+
// Source, not a built image: an extension is loaded by the TUI on the
|
|
293
|
+
// user's machine, which compiles it the same way it compiles a user's
|
|
294
|
+
// own main.ts. There is no separate artifact to produce.
|
|
295
|
+
bundle: "source",
|
|
296
|
+
publishable: true,
|
|
297
|
+
public: true,
|
|
298
|
+
scaffold: scaffoldExtension,
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The user's own Axon directory — ~/.axon/profiles/<email>/.
|
|
303
|
+
*
|
|
304
|
+
* A project kind like any other, and for the same payoff: it gets a type
|
|
305
|
+
* frame, a tsconfig, an install and a scaffolder without any of those
|
|
306
|
+
* growing a special case. What makes it unusual is only WHO runs it —
|
|
307
|
+
* every other kind is scaffolded by a person typing `axon init`, while a
|
|
308
|
+
* profile is prepared on boot for whoever logs in.
|
|
309
|
+
*
|
|
310
|
+
* Never published: it holds one person's credentials, history and agents.
|
|
311
|
+
* `bundle` is set to "source" because the field is not optional, and
|
|
312
|
+
* `public: false` states the intent; nothing calls publish() on a profile.
|
|
313
|
+
*/
|
|
314
|
+
profile: {
|
|
315
|
+
config: "profile.config.ts",
|
|
316
|
+
// `*.ts` at the root covers main.ts, profile.config.ts and any file the
|
|
317
|
+
// user splits out and imports (keybindings.ts, commands.ts). Root-level
|
|
318
|
+
// rather than enumerated so a file is typechecked whether or not
|
|
319
|
+
// anything imports it yet — an orphan with no checking is a worse
|
|
320
|
+
// first experience than one extra glob.
|
|
321
|
+
include: [
|
|
322
|
+
"./**/*.d.ts",
|
|
323
|
+
"*.ts",
|
|
324
|
+
"plugins/**/*.ts",
|
|
325
|
+
"extensions/**/*.ts",
|
|
326
|
+
],
|
|
327
|
+
globals: "tui",
|
|
328
|
+
frame: true,
|
|
329
|
+
framework: "types",
|
|
330
|
+
installs: true,
|
|
331
|
+
bundle: "source",
|
|
332
|
+
publishable: false,
|
|
333
|
+
public: false,
|
|
334
|
+
scaffold: scaffoldProfile,
|
|
335
|
+
},
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export const PROJECT_KINDS = Object.keys(KINDS) as Kind[]
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* "@me/thing" → "thing" — the directory takes only the unscoped segment while
|
|
342
|
+
* package.json keeps the full name. npm does the same: the folder is "thing",
|
|
343
|
+
* the package is "@me/thing". Every scaffolder needs this, so it lives once.
|
|
344
|
+
*/
|
|
345
|
+
export function bareName(name: string): string {
|
|
346
|
+
return name.split("/").at(-1) ?? name
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* What kind of project a directory holds, if any — decided by which config
|
|
351
|
+
* file is present.
|
|
352
|
+
*
|
|
353
|
+
* Lives with the table it reads: identifying a kind is the same question the
|
|
354
|
+
* table answers, and it used to sit on Project() where Projects() had to import
|
|
355
|
+
* it back from the thing it constructs.
|
|
356
|
+
*
|
|
357
|
+
* An agent's INLINE cognet is deliberately not a project. `<agent>/cognet/`
|
|
358
|
+
* holds a cognet.config.ts, so the table alone would call it one — and since
|
|
359
|
+
* `Projects.find()` walks UP from the cwd, running any command from inside
|
|
360
|
+
* that folder would open a standalone cognet with no package.json, no
|
|
361
|
+
* node_modules and nothing to publish. It is a part of the agent, the way
|
|
362
|
+
* `src/tools/` is; the agent above it is the project.
|
|
363
|
+
*/
|
|
364
|
+
export function detectKind(root: string): Kind | null {
|
|
365
|
+
const kind = PROJECT_KINDS.find(k => fsx.exists(join(root, KINDS[k].config))) ?? null
|
|
366
|
+
if (kind === "cognet" && isInlineCognet(root)) return null
|
|
367
|
+
return kind
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** Whether this cognet directory is an agent's inline brain rather than its own project. */
|
|
371
|
+
function isInlineCognet(root: string): boolean {
|
|
372
|
+
return basename(root) === INLINE_COGNET_DIR
|
|
373
|
+
&& fsx.exists(join(dirname(root), KINDS.agent.config))
|
|
374
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { join } from "node:path"
|
|
2
|
+
import { cp, readdir, readlink, rm } from "node:fs/promises"
|
|
3
|
+
import { isAbsolute } from "node:path"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Replace every absolute symlink under a tree with a real copy of its target.
|
|
7
|
+
*
|
|
8
|
+
* Relative links are left alone — they resolve within the tree and survive it
|
|
9
|
+
* moving. An absolute one points at wherever the install happened to run, so
|
|
10
|
+
* it dangles the moment that directory is deleted; resolving it here, while
|
|
11
|
+
* the target still exists, is what makes the tree self-contained.
|
|
12
|
+
*
|
|
13
|
+
* Does NOT descend through links: a symlinked package directory is another
|
|
14
|
+
* entry's content, so following it would revisit the same files repeatedly and,
|
|
15
|
+
* for a link out of the tree, walk off into the source install.
|
|
16
|
+
*/
|
|
17
|
+
export async function resolveAbsoluteLinks(dir: string): Promise<void> {
|
|
18
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => [])
|
|
19
|
+
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
const path = join(dir, entry.name)
|
|
22
|
+
|
|
23
|
+
if (entry.isSymbolicLink()) {
|
|
24
|
+
const to = await readlink(path).catch(() => null)
|
|
25
|
+
if (to === null || !isAbsolute(to)) continue
|
|
26
|
+
await rm(path, { force: true })
|
|
27
|
+
await cp(to, path, { recursive: true, dereference: true })
|
|
28
|
+
} else if (entry.isDirectory()) {
|
|
29
|
+
await resolveAbsoluteLinks(path)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises"
|
|
2
|
+
import { existsSync } from "node:fs"
|
|
3
|
+
import { join } from "node:path"
|
|
4
|
+
import { text } from "./text"
|
|
5
|
+
|
|
6
|
+
type BunfigOpts = {
|
|
7
|
+
root: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* bunfig.toml — the agent's scope → registry map.
|
|
12
|
+
*
|
|
13
|
+
* Bun resolves a package by looking up its SCOPE, so every namespace an agent
|
|
14
|
+
* installs from must appear here or Bun asks npmjs.com and 404s. `@axon` is
|
|
15
|
+
* scaffolded in, but modules are published under user and org namespaces too
|
|
16
|
+
* (`@cody/thing`), and those cannot be known ahead of time — so installing a
|
|
17
|
+
* scope for the first time registers it.
|
|
18
|
+
*
|
|
19
|
+
* Only scopes Axon actually serves are added. Anything else keeps resolving
|
|
20
|
+
* against public npm, which is what makes an agent able to depend on ordinary
|
|
21
|
+
* packages alongside Axon modules.
|
|
22
|
+
*/
|
|
23
|
+
export function Bunfig(opts: BunfigOpts) {
|
|
24
|
+
const path = join(opts.root, "bunfig.toml")
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Point `scope` at this registry, adding it or CORRECTING it.
|
|
28
|
+
*
|
|
29
|
+
* The correction is the part that matters. This used to return early the
|
|
30
|
+
* moment the scope existed, without ever checking the URL — so a project
|
|
31
|
+
* prepared against production kept fetching from production after
|
|
32
|
+
* switching to local staging, and vice versa. The two registries then
|
|
33
|
+
* mixed in the worst possible way: ranges resolved from one, tarballs
|
|
34
|
+
* fetched from the other, and a lockfile pinning URLs from whichever
|
|
35
|
+
* happened to be configured first.
|
|
36
|
+
*
|
|
37
|
+
* The URL is the whole content of the entry, so "already present" and
|
|
38
|
+
* "already correct" are different questions and only the second licenses
|
|
39
|
+
* doing nothing.
|
|
40
|
+
*/
|
|
41
|
+
async function ensure(scope: string, registryUrl: string): Promise<boolean> {
|
|
42
|
+
const source = existsSync(path) ? await readFile(path, "utf-8") : ""
|
|
43
|
+
if (urlOf(source, scope) === registryUrl) return false
|
|
44
|
+
|
|
45
|
+
// Drop any existing entry before writing, so a corrected scope
|
|
46
|
+
// replaces its old line rather than appearing twice — bun reads the
|
|
47
|
+
// first match, which would silently keep the stale registry.
|
|
48
|
+
await writeFile(path, withScope(withoutScope(source, scope), scope, registryUrl))
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
path,
|
|
54
|
+
|
|
55
|
+
/** Ensure `scope` maps to this registry, adding it if absent. Returns whether the file changed. */
|
|
56
|
+
ensure,
|
|
57
|
+
|
|
58
|
+
/** Ensure every scope in `names` (full package names) is mapped. */
|
|
59
|
+
async ensureAll(names: string[], registryUrl: string): Promise<boolean> {
|
|
60
|
+
let changed = false
|
|
61
|
+
const scopes = new Set(names.map(scopeOf).filter((scope): scope is string => scope !== null))
|
|
62
|
+
for (const scope of scopes) {
|
|
63
|
+
if (await ensure(scope, registryUrl)) changed = true
|
|
64
|
+
}
|
|
65
|
+
return changed
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
scopeOf,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Every scope this project maps, and the registry each points at.
|
|
72
|
+
*
|
|
73
|
+
* Read by `verify` to catch a bunfig left pointing at the registry a
|
|
74
|
+
* previous run used — the failure where ranges resolve against one
|
|
75
|
+
* registry and tarballs are fetched from another.
|
|
76
|
+
*/
|
|
77
|
+
async scopes(): Promise<Record<string, string>> {
|
|
78
|
+
if (!existsSync(path)) return {}
|
|
79
|
+
const source = await readFile(path, "utf-8")
|
|
80
|
+
const found: Record<string, string> = {}
|
|
81
|
+
const entry = /^\s*['"]?([A-Za-z0-9_-]+)['"]?\s*=\s*\{[^}]*url\s*=\s*["']([^"']+)["']/gm
|
|
82
|
+
for (const match of source.matchAll(entry)) found[match[1]!] = match[2]!
|
|
83
|
+
return found
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type BunfigT = ReturnType<typeof Bunfig>
|
|
89
|
+
|
|
90
|
+
/** "@axon/obsidian" → "axon". Unscoped names have no scope to map. */
|
|
91
|
+
export function scopeOf(packageName: string): string | null {
|
|
92
|
+
const match = /^@([^/]+)\//.exec(packageName)
|
|
93
|
+
return match ? match[1]! : null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function has(source: string, scope: string): boolean {
|
|
97
|
+
return new RegExp(`^\\s*['"]?${text.escape(scope)}['"]?\\s*=`, "m").test(source)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The registry URL currently mapped to `scope`, or null when unmapped.
|
|
102
|
+
*
|
|
103
|
+
* Reading the URL rather than merely detecting the scope is what lets `ensure`
|
|
104
|
+
* tell "already present" from "already correct" — the distinction a registry
|
|
105
|
+
* switch depends on.
|
|
106
|
+
*/
|
|
107
|
+
function urlOf(source: string, scope: string): string | null {
|
|
108
|
+
const match = new RegExp(
|
|
109
|
+
`^\\s*['"]?${text.escape(scope)}['"]?\\s*=\\s*\\{[^}]*url\\s*=\\s*["']([^"']+)["']`,
|
|
110
|
+
"m",
|
|
111
|
+
).exec(source)
|
|
112
|
+
return match?.[1] ?? null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Remove a scope's line entirely, so a rewrite cannot leave a duplicate behind. */
|
|
116
|
+
function withoutScope(source: string, scope: string): string {
|
|
117
|
+
return source
|
|
118
|
+
.split("\n")
|
|
119
|
+
.filter(line => !new RegExp(`^\\s*['"]?${text.escape(scope)}['"]?\\s*=`).test(line))
|
|
120
|
+
.join("\n")
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Insert the scope into `[install.scopes]`, creating that table if the file has
|
|
125
|
+
* none. The entry goes directly under the header so it cannot land inside a
|
|
126
|
+
* later table and silently change meaning.
|
|
127
|
+
*/
|
|
128
|
+
function withScope(source: string, scope: string, registryUrl: string): string {
|
|
129
|
+
const entry = `${scope} = { url = "${registryUrl}" }`
|
|
130
|
+
|
|
131
|
+
const header = /^\[install\.scopes\][ \t]*\r?\n/m.exec(source)
|
|
132
|
+
if (!header) {
|
|
133
|
+
const separator = source === "" || source.endsWith("\n") ? "" : "\n"
|
|
134
|
+
return `${source}${separator}[install.scopes]\n${entry}\n`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const at = header.index + header[0].length
|
|
138
|
+
return source.slice(0, at) + entry + "\n" + source.slice(at)
|
|
139
|
+
}
|