@akanjs/cli 3.1.1-rc.1 → 3.1.1-rc.10
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/.build-stamp +1 -1
- package/{CodeAgent-4pnxwptq.js → CodeAgent-8d5qs787.js} +2 -2
- package/{CodeTui-hhndze8h.js → CodeTui-z5vkm9ea.js} +1 -1
- package/TunnelShare-qkm8zp03.js +14 -0
- package/{agent.command-p02330r6.js → agent.command-ydftceda.js} +5 -5
- package/akanCode.js +2 -2
- package/{application.command-1117fgq9.js → application.command-wthg8nn9.js} +11 -11
- package/{applicationBuildRunner-9cnnsdm5.js → applicationBuildRunner-t2r84sz6.js} +72 -26
- package/buildBatch.proc.js +5 -5
- package/{cloud.command-ttb2s2x6.js → cloud.command-sz11hpre.js} +22 -17
- package/cloud.script-nqevg5qw.js +24 -0
- package/{code.command-16pm1p2v.js → code.command-9h3yrzhe.js} +6 -6
- package/{context.command-6ys86sqf.js → context.command-15j9b7c0.js} +16 -16
- package/context.runner-8gg030b0.js +25 -0
- package/{guideline.command-3zay3d8g.js → guideline.command-snh85ctf.js} +2 -2
- package/guidelines/agentRule/agentRule.instruction.md +21 -4
- package/guidelines/conventions/conventions.instruction.md +10 -7
- package/guidelines/pageRule/pageRule.instruction.md +8 -0
- package/guidelines/queryRule/queryRule.instruction.md +13 -1
- package/guidelines/runtimeRule/runtimeRule.instruction.md +12 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +2 -1
- package/incrementalBuilder.proc.js +3 -3
- package/{index-jgs8z8xb.js → index-0fz95kxe.js} +1 -1
- package/{index-2ar6tffh.js → index-2azahjaw.js} +67 -19
- package/{index-vcpbrrf2.js → index-2mwc0g0d.js} +1 -1
- package/{index-qkcwsg6r.js → index-2xcc2ax5.js} +2 -2
- package/{index-sww1x1mv.js → index-301pdbzz.js} +56 -9
- package/{index-z6v7k9sb.js → index-31es1yev.js} +24 -2
- package/{index-p4dnj2wc.js → index-3wypz6xj.js} +59 -8
- package/{index-e9e9cebg.js → index-40brg4px.js} +3 -3
- package/{index-tk3jg2bm.js → index-42j4a8zq.js} +2 -2
- package/{index-1mfyyxh5.js → index-4vgbysa0.js} +3 -3
- package/{index-9hbhm6cs.js → index-55j120r8.js} +1 -1
- package/{index-7f0edwsj.js → index-6txx6a9p.js} +45 -4
- package/{index-zn6bn1s2.js → index-74tjjsnc.js} +4 -4
- package/{index-g2s33373.js → index-905qdgqp.js} +1 -1
- package/{index-1cq1hq12.js → index-9th4gszy.js} +17 -15
- package/{index-bb4hj03s.js → index-a58emady.js} +10 -10
- package/{index-4w3skd33.js → index-a5dhqkdr.js} +3 -3
- package/{index-sh9mmp5v.js → index-b70zct19.js} +7 -7
- package/{index-z9xepn8t.js → index-bt438yxm.js} +556 -142
- package/{index-ngpn9hzy.js → index-espk51ah.js} +2 -2
- package/{index-b5vptvnt.js → index-hmt54t45.js} +4 -4
- package/{index-qfzfaq96.js → index-j9vyj3dj.js} +3 -3
- package/{index-ekpp5tax.js → index-js6geqjn.js} +4 -97
- package/{index-fmder14z.js → index-pcwzkdqb.js} +1 -1
- package/{index-jaa81e9r.js → index-qfp55x1y.js} +4 -4
- package/{index-sng3vt0p.js → index-skk9zc1x.js} +2 -2
- package/{index-rr7jk14m.js → index-wcej7g4z.js} +13 -10
- package/{index-q8age5az.js → index-xb8809yb.js} +2 -2
- package/{index-ynqxpwx6.js → index-xjf5j657.js} +1 -1
- package/index.js +22 -22
- package/{library.command-a8n9h8j4.js → library.command-gycrwhf1.js} +3 -3
- package/{localRegistry.command-c2mxqf4h.js → localRegistry.command-jtd8gaes.js} +12 -12
- package/{module.command-b6f1p1xa.js → module.command-v6hgs1bc.js} +5 -5
- package/{package.command-tc27ftmy.js → package.command-shzpcfph.js} +3 -3
- package/package.json +2 -2
- package/{page.command-m5wyqfkd.js → page.command-ptxn5kqk.js} +3 -3
- package/{pipeline.command-4qxyafpz.js → pipeline.command-zz31pgax.js} +2 -2
- package/{primitive.command-9yaatk0d.js → primitive.command-a1vse91z.js} +6 -6
- package/{projectTypecheck-87k6z6ab.js → projectTypecheck-2ztky9cf.js} +1 -1
- package/{quality.command-fxn07zwp.js → quality.command-ah8qcakd.js} +2 -2
- package/{repair.command-evg9g911.js → repair.command-cvazbz99.js} +5 -5
- package/{scalar.command-xsejjeq1.js → scalar.command-0acvyp26.js} +4 -4
- package/{subspace.command-4mjjxgmf.js → subspace.command-822qx2bx.js} +8 -8
- package/templates/app/tsconfig.json.template +2 -7
- package/templates/env/_env.server.type.ts +10 -5
- package/templates/facetIndex/index.ts +2 -2
- package/templates/workspaceRoot/bunfig.toml.template +0 -4
- package/{tunnel.command-7f41pm7y.js → tunnel.command-ycmja19q.js} +7 -7
- package/{workflow.command-qpyq0ya5.js → workflow.command-abb1d5xy.js} +10 -10
- package/{workspace.command-qvwdqmnd.js → workspace.command-qm7cw29v.js} +33 -32
- package/TunnelShare-8qtffcex.js +0 -14
- package/cloud.script-fqp3zh02.js +0 -24
- package/context.runner-3jrypwe3.js +0 -25
|
@@ -31,7 +31,10 @@ pages declaring one name never clash, and a registry kept outside the surface re
|
|
|
31
31
|
**refuses every call until the app names a guard of its own** — the same answer `None` gives, with no boot
|
|
32
32
|
warning. A product with accounts names it in its `option.ts`, `option.setAgentAccess(SignedIn)`, taking the same
|
|
33
33
|
guard classes every endpoint takes (an array is ANDed, `null` clears what a library set); without one the chat
|
|
34
|
-
cannot spend the LLM key.
|
|
34
|
+
cannot spend the LLM key. **The guard decides who, not what** — the browser writes the instructions, tools and
|
|
35
|
+
transcript — so `option.setAgentRequestPolicy((request, { account, ip }) => request)` sees each turn after the
|
|
36
|
+
guard, before the quota and the model (tool names as the page published them), and returns what is sent, or
|
|
37
|
+
throws an `Err` (`agent.error.requestRefused`) to refuse it.
|
|
35
38
|
`persist` keeps the transcript across reloads (sessionStorage; `{ storage: "local" }` to outlive the tab),
|
|
36
39
|
default off, and `shortcut={false}` gives the browser back the Cmd/Ctrl+L the launcher otherwise captures.
|
|
37
40
|
**`persist` also takes a `SessionHistory` of the app's own** — `{ load, save, clear }` — which is how a
|
|
@@ -104,7 +107,10 @@ pages declaring one name never clash, and a registry kept outside the surface re
|
|
|
104
107
|
parts, so that is what it answers with no `host` set. A `host` the app named is a gateway the class knows
|
|
105
108
|
nothing about, and it stays text-only until `option.setLlm({ accepts })` says otherwise — handing bytes to a
|
|
106
109
|
model that cannot decode them kills the whole turn on a 400, where text-only degrades them to a note the model
|
|
107
|
-
can repeat back.
|
|
110
|
+
can repeat back. A `host` naming OpenAI's own endpoint is the default host by hostname, not a gateway, and an
|
|
111
|
+
app's own chat-completions adaptor claims through `OpenaiLlm.acceptsOf(llmOption)` instead of copying the rule —
|
|
112
|
+
a copy that read "any host is a gateway" kept a vision model text-only for an app that spelled out
|
|
113
|
+
`https://api.openai.com/v1`.
|
|
108
114
|
- **A refusal is `agent.error.llmRequestFailed`, and it names the host** — unless the prompt did not fit. The
|
|
109
115
|
provider's own sentence rides in `reason` and the hostname in `provider`. `LlmOverflow.refusal(host, status,
|
|
110
116
|
reason)` builds it, and reads the one refusal a chat can undo — a prompt past the window, recognized from each
|
|
@@ -627,7 +633,7 @@ pages declaring one name never clash, and a registry kept outside the surface re
|
|
|
627
633
|
|
|
628
634
|
## Built-In Tools
|
|
629
635
|
- The framework publishes six built-ins on every store surface: `navigate` (internal paths only, the same router
|
|
630
|
-
`Link` rides), `goBack` (this session's history — global, because history is not a control a page owns and a page
|
|
636
|
+
`Link` rides, so the app's navigation guards are asked and a refusal is reported as a kept page), `goBack` (this session's history — global, because history is not a control a page owns and a page
|
|
631
637
|
that draws no back link is not one you may not leave — a screen that must not be left withholds them with `builtins`,
|
|
632
638
|
not with prose), `readScreen` (the rendered DOM as compact text — headings, links, control values, and `(disabled)`
|
|
633
639
|
on a control or button that has it; the chat's own UI is skipped via `data-agent-ui`, and a password value is never
|
|
@@ -648,7 +654,18 @@ pages declaring one name never clash, and a registry kept outside the surface re
|
|
|
648
654
|
page the user left. The reading built-ins (`readScreen`, `readState`, `highlight`, `viewImage`) declare it,
|
|
649
655
|
because a wait costs 120ms of quiet at the very least and they change nothing a resource holds.
|
|
650
656
|
New tools and state from a fresh route are still only listed from the next turn: the catalogue is snapshotted
|
|
651
|
-
when the turn starts.
|
|
657
|
+
when the turn starts. **So a navigation ends the model's turn, and a name nobody listed is answered with the names
|
|
658
|
+
that exist.** A call is looked up when it runs, so one batched behind `navigate` already reaches the new screen —
|
|
659
|
+
but the model wrote it against the old catalogue, and a screen-scoped name it never saw is one it composed
|
|
660
|
+
(`addBacklogTicketInProject` for `addBacklogTicket`), and refused with a bare `Unknown tool` it composes the next.
|
|
661
|
+
`AgentService.preamble` therefore says that a navigation ends the turn and that names are never guessed, and the
|
|
662
|
+
session answers an unknown name with the tools listed now — saying, when the catalogue moved since the turn's
|
|
663
|
+
list was written, that the call was written against the screen it left and the new one's tools arrive with their
|
|
664
|
+
arguments next turn. `navigate`'s own answer says the same, reports the path the page actually landed on when a
|
|
665
|
+
redirect or the not-found page moved it elsewhere, and a path with no route is refused with the internal links on
|
|
666
|
+
screen (`ScreenTarget.linkedRoutes`) rather than an invitation to compose another. Layout-level tools — a channel
|
|
667
|
+
post, a new wiki page — stay listed across routes, which is why the cross-screen requests that use only them never
|
|
668
|
+
hit this.
|
|
652
669
|
- **A tool that waits for its own work costs no model turns; one that returns early costs one round trip per
|
|
653
670
|
look.** The session awaits `run`, so a `.exec` that awaits the store action finishing the job simply makes the
|
|
654
671
|
turn take that long — and the change report that follows carries whatever landed, so the model needs no second
|
|
@@ -253,7 +253,8 @@ Declared in `akan.config.ts`, narrowed — never widened — by an env at boot;
|
|
|
253
253
|
`ca-certificates` and `tzdata`.
|
|
254
254
|
- **Native apps are the `native` section** (iOS, Android, desktop). A desktop app's carried server listens on a
|
|
255
255
|
loopback port any local program can call — guard it as a network server — and ships `private/` and its env
|
|
256
|
-
readable on the user's computer; read runtime files from `AKAN_APP_DIR
|
|
256
|
+
readable on the user's computer; read runtime files from `AKAN_APP_DIR`, and keep a secret the user gives it with
|
|
257
|
+
`NativeSecret` (the OS credential store), never in a file.
|
|
257
258
|
- **`database: { modes: [...] }`** (`single`, `multiple`, `cluster`), chosen by `AKAN_DATABASE_MODE`; an app running
|
|
258
259
|
in two modes avoids `q.raw`.
|
|
259
260
|
|
|
@@ -334,8 +335,9 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
|
|
|
334
335
|
`remove<Model>(id)`, and `pickAndWrite` writes through the save hooks (`queryRule`).
|
|
335
336
|
- **`<model>.service.ts`** — a few lines: load → chain → `return await ….save()` (keep the `return await`). Side
|
|
336
337
|
effects go in `override async _preUpdate` / `_postCreate`; fire-and-forget is `void`-ed. Load every referenced
|
|
337
|
-
document, then save, then notify
|
|
338
|
-
|
|
338
|
+
document, then save, then notify; writes that must land together go in `this.transaction(async () => …)` and
|
|
339
|
+
their notification in `this.afterCommit(…)` (`queryRule`). Return `null` / `false` for not allowed or not found;
|
|
340
|
+
the signal decides whether that is an error.
|
|
339
341
|
- **`<model>.signal.ts`** — `XInternal` → `XSlice` → `XEndpoint`, all three even when empty; `exec` is a one-liner
|
|
340
342
|
calling the service.
|
|
341
343
|
- **`<model>.store.ts`** — custom actions only for a toast, an optimistic update, or a multi-field write:
|
|
@@ -395,9 +397,9 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
|
|
|
395
397
|
wrong JSON type, a value outside its enum or a missing required field answers 400 with `data.name` naming the
|
|
396
398
|
path (`data.items.2.price`); a defaulted field may be left out, an undeclared key is dropped, and a stored model's
|
|
397
399
|
input keeps an absent field absent.
|
|
398
|
-
- **Reserved names**: generated CRUD (`create<Model>`, `update<Model>`, `remove<Model>`, …) exists for every model
|
|
399
|
-
|
|
400
|
-
|
|
400
|
+
- **Reserved names**: generated CRUD (`create<Model>`, `update<Model>`, `remove<Model>`, …) exists for every model
|
|
401
|
+
whose slice mounts the verb. `fetch.*` is one namespace across modules and a pubsub or message is routed by its bare
|
|
402
|
+
name, so the server refuses to boot on two claims of one name (`[DI:fetch]`, `[DI:socket]`), naming both.
|
|
401
403
|
- **Queries (`queryRule`)**: the root slice takes `queryKey` + `args`, never a raw query. A slice `exec` returns a
|
|
402
404
|
`query<Filter>(…)` descriptor (never a `list<Filter>` array) and is paged through `initX(…, { sort, page, limit })`.
|
|
403
405
|
A projection is bare on the facade (`pickById(id, { secret: true })`), under `select` on a filter accessor — the
|
|
@@ -415,7 +417,8 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
|
|
|
415
417
|
screen with `page().prompt(name, description)`, and publish one component a host draws with
|
|
416
418
|
`page().app(name, description, load)` — a read-only tool whose `load` may only query.
|
|
417
419
|
- **In-page agent (`agentRule`)**: mount `<Agent.Chat />` once in a layout; it never executes tools and refuses
|
|
418
|
-
every call until `option.setAgentAccess(<guard>)
|
|
420
|
+
every call until `option.setAgentAccess(<guard>)`, which decides who — what a turn may ask is
|
|
421
|
+
`option.setAgentRequestPolicy`; the LLM is `option.setLlm({ apiKey, model, host })`, never env.
|
|
419
422
|
The surface is what components declare — `st.tool(…).exec(fn)` beside its control, `st.use` / `st.sel` /
|
|
420
423
|
`st.ref` keys — never a store class. `st.use.x({ agent: false })` hides a key; its model's `hidden` / `secret` /
|
|
421
424
|
`visual` fields are stripped at read. A tool value is capped at 20,000 characters. Route guidance is
|
|
@@ -78,6 +78,14 @@ body shape — this is the full contract behind them. Before changing route beha
|
|
|
78
78
|
- **A route guard is not authorization for data.** It keeps a person off a screen and redirects early; every query
|
|
79
79
|
the screen makes is still judged by that endpoint's own `guards`. Write both: the signal guard is the gate, the
|
|
80
80
|
route guard is the courtesy that answers before the screen draws.
|
|
81
|
+
- **Keeping a person on a page is `router.addNavigationGuard(guard)`, not `.guard()`.** `guard({ kind, from, to })`
|
|
82
|
+
is asked before every in-app move — `push`, `replace`, `back`, a `Link`, the browser's back and forward (`pop`), a
|
|
83
|
+
native back or swipe, the agent's `navigate` and `goBack` — with routes free of locale and basePath and `to: null`
|
|
84
|
+
for a `back`. `false`, a throw or a rejection keeps the page, `router.navigation()` rejects with
|
|
85
|
+
`NavigationRefused`, and a refused browser back is undone before the page redraws. Guards answer one at a time; a
|
|
86
|
+
move started while one decides is refused. Register it from an effect and return the remover
|
|
87
|
+
(`useEffect(() => router.addNavigationGuard(…), [isDirty])`). Redirects, `notFound()`, `setLang` and moves off the
|
|
88
|
+
origin are not asked; a closing tab is `beforeunload`'s.
|
|
81
89
|
|
|
82
90
|
## MCP Apps — `.app()`
|
|
83
91
|
|
|
@@ -72,6 +72,9 @@ this is the full contract behind them.
|
|
|
72
72
|
"there is at most one of these", not for claiming the next item off a queue. Pass a query that matches one row.
|
|
73
73
|
The query is a compare-and-set in every mode: of two concurrent `updateOne({ id, balance: { $gte: n } }, …)` that
|
|
74
74
|
both read the row as matching, only one applies, so `modifiedCount` is the verdict.
|
|
75
|
+
- **`{ touch: false }` leaves `updatedAt` as stored** on a query-level write: in the options of `updateOne` /
|
|
76
|
+
`updateMany` / `updateById`, or `.set(update, { touch: false })` on a filter chain. Bookkeeping that is no edit — a
|
|
77
|
+
lease heartbeat, a mirrored snapshot — otherwise moves the row in every `updatedAt` period and sort.
|
|
75
78
|
- **A filter may not be keyed after its own model.** Filter methods are assigned after CRUD, so a filter `chat` on
|
|
76
79
|
model `chat` would silently swap the single-document `removeChat`/`updateChat` for a hookless query-level one. It
|
|
77
80
|
throws at boot instead (`assertFilterFitsCrud`).
|
|
@@ -112,9 +115,18 @@ this is the full contract behind them.
|
|
|
112
115
|
document path**: they fire no hooks, so a model whose removal cascades or carries a `_postRemove` still goes
|
|
113
116
|
through `remove<Model>(id)`.
|
|
114
117
|
- The write-through pair is `pickAndWrite(id, data)` / `pickOneAndWrite(query, data)` — pick the document, write
|
|
115
|
-
into it and save it, so the save hooks do run; reach for those when the write has to be seen by them.
|
|
118
|
+
into it and save it, so the save hooks do run; reach for those when the write has to be seen by them. A third
|
|
119
|
+
argument `{ touch: false }`, like `doc.save({ touch: false })`, keeps `updatedAt` while the hooks and live sync
|
|
120
|
+
still run — a nudge that re-sends a row its rooms must re-read, with no edit to stamp.
|
|
116
121
|
- `upsertById(data, { preserveTimestamps })` writes a record whole under its own id, new or in place, with no
|
|
117
122
|
hook: the write a sync or a backfill repeats safely, keeping the record's `createdAt`/`updatedAt` when asked.
|
|
123
|
+
- **Writes that must land together go in `this.transaction(async () => …)`**, which every service has: it commits
|
|
124
|
+
when the body resolves, returns its value, and rolls back when it throws, rethrowing that error unchanged. A
|
|
125
|
+
server has one database, so it covers every model, hooks and query-level writes included; a nested call joins the
|
|
126
|
+
outer one, with no savepoint. Cache, `memory` and outside calls are not in it — hand them to
|
|
127
|
+
`this.afterCommit(fn)`, run once the commit lands, never after a rollback, at once outside one; one that throws is
|
|
128
|
+
logged, never thrown, and the rest still run. On SQLite it holds the only write turn: keep it short.
|
|
129
|
+
`@Transaction()` is deprecated.
|
|
118
130
|
|
|
119
131
|
## Text Search In A Filter — `q.search()`
|
|
120
132
|
|
|
@@ -239,6 +239,10 @@ const config: AppConfig = { docker: "FROM oven/bun:1.4.4-slim\n…" }; // verbat
|
|
|
239
239
|
`RUN if [ "$TARGETARCH" = "<arch>" ]` guard, so a multi-arch build runs it on one leg only. `preRuns` land
|
|
240
240
|
before `bun install --production` (where a native dependency's build tools have to be), `postRuns` after it
|
|
241
241
|
and before the app files are copied.
|
|
242
|
+
- **The image installs the versions the workspace locked.** `akan build` writes a `bun.lock` beside the image's
|
|
243
|
+
`package.json`, cut down from the workspace's to what the server needs, and the image installs it
|
|
244
|
+
`--frozen-lockfile`. A workspace without a root `bun.lock` gets a warning and an unlocked install; a Dockerfile
|
|
245
|
+
written whole copies `bun.lock` itself.
|
|
242
246
|
- **A lib declares the steps its own runtime needs**, and every app that mounts it inherits them:
|
|
243
247
|
`libs/<lib>/akan.config.ts` takes `docker: { preRuns, postRuns }` and nothing else — the base image and the
|
|
244
248
|
command belong to the app. Lib steps are emitted before the app's own, and an identical step declared twice
|
|
@@ -513,6 +517,14 @@ The carried server asks the shell that showed the dialog over its IPC channel, s
|
|
|
513
517
|
and nothing else, and no page ever holds a path. Behind a dev build `akan start` checks the grant's signature
|
|
514
518
|
against a key in `~/.akan/native` instead, in `operationMode` local only; every other server refuses a grant.
|
|
515
519
|
|
|
520
|
+
**A secret the user gives the server is kept by the OS, never in a file.** `NativeSecret.set(key, value)`,
|
|
521
|
+
`get(key)` (null when none is kept) and `remove(key)` from `akanjs/server` reach the OS credential store through the
|
|
522
|
+
shell that carries the server — the macOS Keychain, the Windows Credential Manager, the Secret Service on Linux — in a
|
|
523
|
+
store of the server's own, apart from the page's `secretStorage`, so no page script reads it. Anywhere but a carried
|
|
524
|
+
server `NativeSecret.available` is false and every call rejects: keep secrets in the env there. On macOS without a
|
|
525
|
+
Team ID signature, any program of the same user can read the store's key through `security`, as with
|
|
526
|
+
`secretStorage`.
|
|
527
|
+
|
|
516
528
|
**Devices belong to the shell, not the server.** Displays and their changes (`screen`), windows placed on them
|
|
517
529
|
(`window`), the system volume and mute (`volume`), global shortcuts (`global-shortcut`), keep-awake (`keep-awake`)
|
|
518
530
|
and launch at login (`autostart`) are native runtime plugins, each added to `native.plugins`. Every builtin plugin's
|
|
@@ -250,7 +250,8 @@ query-level writes are in `queryRule`; these are the shapes that build green and
|
|
|
250
250
|
a `list<Filter>(...)` / `listBy...(...)` array. Returning an array type-checks but fails at runtime with
|
|
251
251
|
`Unknown document field path: 0`. (See Recipe 3.)
|
|
252
252
|
- **Custom endpoint names must not collide with generated CRUD.** `create/update/remove/view/edit/merge<Model>`
|
|
253
|
-
already exist. A collision
|
|
253
|
+
already exist wherever the slice mounts the verb. A collision builds green and the server refuses to boot
|
|
254
|
+
(`[DI:fetch]`) — pick a distinct verb.
|
|
254
255
|
- **Numbers are `Int` or `Float`, never `Number`.** `field(Number)` / `.body("x", Number)` fail to typecheck.
|
|
255
256
|
- **Array fields use `field([T])`** — `tags: field([String])`, `images: field([File])`.
|
|
256
257
|
- **Reading a secret field needs an explicit select, and the two call sites spell it differently.**
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
CodegenLock,
|
|
9
9
|
WorkspaceExecutor,
|
|
10
10
|
AppExecutor
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-wcej7g4z.js";
|
|
12
12
|
import"./index-52w0fvh8.js";
|
|
13
13
|
import {
|
|
14
14
|
GraphClientEntryDiscovery,
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
DevChangePlanner,
|
|
20
20
|
DevGeneratedIndexSync,
|
|
21
21
|
SsrDevBundler
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-espk51ah.js";
|
|
23
23
|
import {
|
|
24
24
|
ServerGraphFile
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-0fz95kxe.js";
|
|
26
26
|
import {
|
|
27
27
|
prepareDevWatchBatch
|
|
28
28
|
} from "./index-a5vmm6x4.js";
|
|
@@ -6,19 +6,19 @@ import {
|
|
|
6
6
|
resolveMobileTargets
|
|
7
7
|
} from "./index-m9jj544v.js";
|
|
8
8
|
import {
|
|
9
|
-
NativePublicEnv,
|
|
10
9
|
UpdatePackFolder,
|
|
10
|
+
NativePublicEnv,
|
|
11
11
|
NativeApp
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-bt438yxm.js";
|
|
13
13
|
import {
|
|
14
14
|
ExitCodeError
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-3wypz6xj.js";
|
|
16
16
|
import {
|
|
17
17
|
ConfigLock
|
|
18
18
|
} from "./index-bqbf654f.js";
|
|
19
19
|
|
|
20
20
|
// pkgs/@akanjs/devkit/cloud/cloudApi.ts
|
|
21
|
-
import { isRecord as isRecord2 } from "akanjs/common";
|
|
21
|
+
import { isRecord as isRecord2, Logger } from "akanjs/common";
|
|
22
22
|
|
|
23
23
|
// pkgs/@akanjs/devkit/cloud/cloudHttpError.ts
|
|
24
24
|
import { isRecord } from "akanjs/common";
|
|
@@ -46,9 +46,17 @@ class CloudHttpError extends Error {
|
|
|
46
46
|
return error instanceof CloudHttpError ? error.status : null;
|
|
47
47
|
}
|
|
48
48
|
get error() {
|
|
49
|
+
const error = this.#payload?.error;
|
|
50
|
+
return typeof error === "string" ? error : null;
|
|
51
|
+
}
|
|
52
|
+
get data() {
|
|
53
|
+
const data = this.#payload?.data;
|
|
54
|
+
return isRecord(data) ? data : null;
|
|
55
|
+
}
|
|
56
|
+
get #payload() {
|
|
49
57
|
try {
|
|
50
58
|
const parsed = JSON.parse(this.body);
|
|
51
|
-
return isRecord(parsed)
|
|
59
|
+
return isRecord(parsed) ? parsed : null;
|
|
52
60
|
} catch {
|
|
53
61
|
return null;
|
|
54
62
|
}
|
|
@@ -274,8 +282,11 @@ class CloudApi {
|
|
|
274
282
|
return new Error("The server did not accept your sign-in: run `akan login`, then try again.", { cause: error });
|
|
275
283
|
if (error.status === 403)
|
|
276
284
|
return new Error(`The project refused: ${who}.`, { cause: error });
|
|
277
|
-
if (error.status === 400)
|
|
278
|
-
|
|
285
|
+
if (error.status === 400) {
|
|
286
|
+
const { data } = error;
|
|
287
|
+
const why = `${error.error ? `: ${error.error}` : ""}${data ? ` ${Logger.inlineData(data)}` : ""}`;
|
|
288
|
+
return new Error(`The project refused the request${why}.`, { cause: error });
|
|
289
|
+
}
|
|
279
290
|
const { errKey } = error;
|
|
280
291
|
if (error.status === 503 && unavailable && errKey && errKey !== "base.error.serverUnavailable")
|
|
281
292
|
return new Error(`${unavailable}: ${errKey}.`, { cause: error });
|
|
@@ -378,12 +389,13 @@ class CloudApi {
|
|
|
378
389
|
}
|
|
379
390
|
// pkgs/@akanjs/devkit/cloud/cloudUpdates.ts
|
|
380
391
|
import path2 from "path";
|
|
381
|
-
import { Logger as
|
|
392
|
+
import { Logger as Logger3 } from "akanjs/common";
|
|
382
393
|
|
|
383
394
|
// pkgs/@akanjs/devkit/cloud/updatePackUpload.ts
|
|
384
|
-
import { Logger, sleep } from "akanjs/common";
|
|
395
|
+
import { Logger as Logger2, sleep } from "akanjs/common";
|
|
385
396
|
class UpdatePackUpload {
|
|
386
397
|
static maxBytes = 200 * 1024 * 1024;
|
|
398
|
+
static maxAppBytes = 1024 * 1024 * 1024;
|
|
387
399
|
static #transientPut = new Set([0, 408, 429, 500, 502, 503, 504]);
|
|
388
400
|
static #putFloorBytesPerSecond = 64 * 1024;
|
|
389
401
|
static #maxPutRetryAfterMs = 60000;
|
|
@@ -415,7 +427,10 @@ class UpdatePackUpload {
|
|
|
415
427
|
}
|
|
416
428
|
async stage(archive, fields) {
|
|
417
429
|
const file = Bun.file(archive);
|
|
418
|
-
if (
|
|
430
|
+
if (fields.kind === "app") {
|
|
431
|
+
if (file.size < 1 || file.size > UpdatePackUpload.maxAppBytes)
|
|
432
|
+
throw new Error(`The release archive is ${file.size} bytes; a project takes 1 byte to 1 GiB.`);
|
|
433
|
+
} else if (file.size < 1 || file.size > UpdatePackUpload.maxBytes)
|
|
419
434
|
throw new Error(`The pack archive is ${file.size} bytes; a project takes 1 byte to 200 MiB.`);
|
|
420
435
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
421
436
|
for await (const chunk of file.stream())
|
|
@@ -477,7 +492,7 @@ class UpdatePackUpload {
|
|
|
477
492
|
const waitMs = Math.max(this.#commitRetryMs, error instanceof CloudHttpError && error.retryAfterMs || 0);
|
|
478
493
|
if (now + waitMs > deadline)
|
|
479
494
|
throw error;
|
|
480
|
-
|
|
495
|
+
Logger2.rawLog(`The project is still taking the pack; asking again in ${Math.round(waitMs / 1000)}s.`);
|
|
481
496
|
await sleep(waitMs);
|
|
482
497
|
}
|
|
483
498
|
}
|
|
@@ -536,7 +551,7 @@ class CloudUpdates {
|
|
|
536
551
|
const target = channel ?? pack.channel;
|
|
537
552
|
return await UpdatePackFolder.withArchive(pack, async (archive) => {
|
|
538
553
|
const release = await new UpdatePackUpload(this.cloudApi, this.devProjectId).send(archive, { appName: pack.app, target: pack.target, platform: pack.platform, channel: target, notes }).catch((error) => {
|
|
539
|
-
throw
|
|
554
|
+
throw CloudUpdates.#refusal(error, "a pack is uploaded by a project member signed in with `akan login`");
|
|
540
555
|
});
|
|
541
556
|
const label = `${pack.app} ${pack.target} ${pack.platform} on channel ${target}: release ${release.id}`;
|
|
542
557
|
if (release.status === "rejected")
|
|
@@ -544,12 +559,45 @@ class CloudUpdates {
|
|
|
544
559
|
${(release.problems ?? []).map((problem) => ` - ${problem}`).join(`
|
|
545
560
|
`)}`, 2);
|
|
546
561
|
if (release.status === "published")
|
|
547
|
-
|
|
562
|
+
Logger3.rawLog(`Published ${label} (${pack.files} files, native API ${pack.nativeApi}).`);
|
|
548
563
|
else
|
|
549
|
-
|
|
564
|
+
Logger3.rawLog(`Staged ${label} (${pack.files} files, native API ${pack.nativeApi}). Publish it from the project's release screen.`);
|
|
550
565
|
return release;
|
|
551
566
|
});
|
|
552
567
|
}
|
|
568
|
+
async pushRelease(release, {
|
|
569
|
+
appName,
|
|
570
|
+
target,
|
|
571
|
+
notes,
|
|
572
|
+
signer,
|
|
573
|
+
url
|
|
574
|
+
}) {
|
|
575
|
+
const { platform, arch, channel } = release;
|
|
576
|
+
return await release.withArchive(release.record(signer), async (archive) => {
|
|
577
|
+
const record = await new UpdatePackUpload(this.cloudApi, this.devProjectId).send(archive, { appName, target, platform, kind: "app", arch, channel, notes }).catch((error) => {
|
|
578
|
+
throw CloudUpdates.#refusal(error, "a release is uploaded by a project member signed in with `akan login`");
|
|
579
|
+
});
|
|
580
|
+
const label = `${appName} ${target} ${platform}-${arch} on channel ${channel}: release ${record.id}`;
|
|
581
|
+
const problems = (record.problems ?? []).map((problem) => ` - ${problem}`).join(`
|
|
582
|
+
`);
|
|
583
|
+
if (record.status === "rejected")
|
|
584
|
+
throw new ExitCodeError(`The project rejected ${label}:
|
|
585
|
+
${problems}`, 2);
|
|
586
|
+
const manifestUrl = typeof record.manifestUrl === "string" ? record.manifestUrl : `${url}/${platform}-${arch}/${channel}/app.json`;
|
|
587
|
+
const files = 1 + release.manifestFiles.length + release.payloads.length;
|
|
588
|
+
const what = `${label} (${release.manifest.bundle}, ${files} files)`;
|
|
589
|
+
Logger3.rawLog(record.status === "published" ? `Published ${what}. Installed apps read ${manifestUrl}.` : `Staged ${what}. Publish it from the project's release screen; installed apps read ${manifestUrl}.`);
|
|
590
|
+
if (problems)
|
|
591
|
+
Logger3.rawLog(`The project noted:
|
|
592
|
+
${problems}`);
|
|
593
|
+
return record;
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
static #refusal(error, who) {
|
|
597
|
+
const refusal = CloudApi.refusal(error, who);
|
|
598
|
+
const verdict = error instanceof CloudHttpError && error.status === 400 && !!error.errKey?.startsWith("release.error.");
|
|
599
|
+
return verdict && refusal instanceof Error ? new ExitCodeError(refusal.message, 2) : refusal;
|
|
600
|
+
}
|
|
553
601
|
async registerBinary(app, pack, { distribution, env }) {
|
|
554
602
|
const { cloudApi, devProjectId } = this;
|
|
555
603
|
const bundlePath = await CloudUpdates.storeBundlePath(app, pack.target, pack.platform);
|
|
@@ -585,13 +633,13 @@ ${(release.problems ?? []).map((problem) => ` - ${problem}`).join(`
|
|
|
585
633
|
}))).catch((error) => {
|
|
586
634
|
throw CloudApi.refusal(error, "a binary is registered by a project member signed in with `akan login`");
|
|
587
635
|
});
|
|
588
|
-
|
|
636
|
+
Logger3.rawLog(`Registered ${pack.app} ${pack.target} ${pack.platform} (${distribution}): binary ${binary.id}, native API ${pack.nativeApi}.`);
|
|
589
637
|
return binary;
|
|
590
638
|
});
|
|
591
639
|
}
|
|
592
640
|
}
|
|
593
641
|
// pkgs/@akanjs/devkit/cloud/pipelineSecrets.ts
|
|
594
|
-
import { capitalize, Logger as
|
|
642
|
+
import { capitalize, Logger as Logger4, PipelineNames } from "akanjs/common";
|
|
595
643
|
class PipelineSecrets {
|
|
596
644
|
cloudApi;
|
|
597
645
|
devProjectId;
|
|
@@ -628,7 +676,7 @@ class PipelineSecrets {
|
|
|
628
676
|
unavailable: PipelineSecrets.#secretsUnavailable
|
|
629
677
|
});
|
|
630
678
|
});
|
|
631
|
-
|
|
679
|
+
Logger4.rawLog(`Saved ${saved.name} for ${saved.scope === "*" ? "every branch" : `branch ${saved.scope}`}. Builds that start from now on use it.`);
|
|
632
680
|
}
|
|
633
681
|
async list(branch) {
|
|
634
682
|
PipelineSecrets.assertBranch(branch);
|
|
@@ -638,7 +686,7 @@ class PipelineSecrets {
|
|
|
638
686
|
});
|
|
639
687
|
});
|
|
640
688
|
const secrets = listed.filter((secret) => !branch || secret.scope === "*" || secret.scope === branch);
|
|
641
|
-
|
|
689
|
+
Logger4.rawLog(PipelineSecrets.format(secrets));
|
|
642
690
|
}
|
|
643
691
|
async remove({ name, branch }) {
|
|
644
692
|
PipelineSecrets.assertName(name);
|
|
@@ -648,7 +696,7 @@ class PipelineSecrets {
|
|
|
648
696
|
unavailable: PipelineSecrets.#secretsUnavailable
|
|
649
697
|
});
|
|
650
698
|
});
|
|
651
|
-
|
|
699
|
+
Logger4.rawLog(removed ? `Removed ${name} for ${branch ? `branch ${branch}` : "every branch"}.` : `No ${name} for ${branch ? `branch ${branch}` : "every branch"} to remove.`);
|
|
652
700
|
}
|
|
653
701
|
static format(secrets) {
|
|
654
702
|
if (!secrets.length)
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-3wypz6xj.js";
|
|
6
6
|
import {
|
|
7
7
|
LibSource,
|
|
8
8
|
formatLibStatuses,
|
|
9
9
|
CommandExecutionError,
|
|
10
10
|
LibExecutor
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-wcej7g4z.js";
|
|
12
12
|
|
|
13
13
|
// pkgs/@akanjs/cli/library/library.script.ts
|
|
14
14
|
import { Logger } from "akanjs/common";
|
|
@@ -4,26 +4,27 @@ import {
|
|
|
4
4
|
CloudApi,
|
|
5
5
|
CloudUpdates,
|
|
6
6
|
PipelineSecrets
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-2azahjaw.js";
|
|
8
8
|
import {
|
|
9
9
|
PkgExecutor
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-wcej7g4z.js";
|
|
11
11
|
import {
|
|
12
|
+
UpdatePackFolder,
|
|
12
13
|
NativePublicEnv,
|
|
13
|
-
|
|
14
|
-
} from "./index-
|
|
14
|
+
NativeApp
|
|
15
|
+
} from "./index-bt438yxm.js";
|
|
15
16
|
import {
|
|
16
17
|
script
|
|
17
|
-
} from "./index-
|
|
18
|
+
} from "./index-3wypz6xj.js";
|
|
18
19
|
import {
|
|
19
20
|
ApplicationScript
|
|
20
|
-
} from "./index-
|
|
21
|
+
} from "./index-9th4gszy.js";
|
|
21
22
|
import {
|
|
22
23
|
PackageScript
|
|
23
|
-
} from "./index-
|
|
24
|
+
} from "./index-42j4a8zq.js";
|
|
24
25
|
import {
|
|
25
26
|
CloudRunner
|
|
26
|
-
} from "./index-
|
|
27
|
+
} from "./index-6txx6a9p.js";
|
|
27
28
|
|
|
28
29
|
// pkgs/@akanjs/cli/cloud/cloud.script.ts
|
|
29
30
|
import { Logger } from "akanjs/common";
|
|
@@ -93,6 +94,7 @@ class CloudScript2 extends script("cloud", [CloudRunner, ApplicationScript, Pack
|
|
|
93
94
|
}
|
|
94
95
|
async pushUpdate(workspace, app, {
|
|
95
96
|
platform,
|
|
97
|
+
arch = null,
|
|
96
98
|
target,
|
|
97
99
|
env,
|
|
98
100
|
channel,
|
|
@@ -104,6 +106,22 @@ class CloudScript2 extends script("cloud", [CloudRunner, ApplicationScript, Pack
|
|
|
104
106
|
pack: packDir,
|
|
105
107
|
publicEnv
|
|
106
108
|
}) {
|
|
109
|
+
if (platform && platform !== "ios" && platform !== "android") {
|
|
110
|
+
if (packDir || publicEnv)
|
|
111
|
+
throw new Error("--pack and --public-env take a phone's web bundle; a desktop release goes up as `akan publish-update` wrote it.");
|
|
112
|
+
return await this.#pushRelease(workspace, app, platform, {
|
|
113
|
+
arch,
|
|
114
|
+
target,
|
|
115
|
+
env: env ?? "main",
|
|
116
|
+
channel,
|
|
117
|
+
notes,
|
|
118
|
+
subspace,
|
|
119
|
+
given,
|
|
120
|
+
allowLocalRelease
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (arch)
|
|
124
|
+
throw new Error("--arch picks a desktop release's CPU; a phone's update is its web bundle.");
|
|
107
125
|
if (packDir && publicEnv)
|
|
108
126
|
throw new Error("--public-env picks what a pack is built with, and --pack uploads one already built: give one.");
|
|
109
127
|
const devProjectId = await this.cloudRunner.projectOf(workspace, subspace, app.name);
|
|
@@ -116,6 +134,35 @@ class CloudScript2 extends script("cloud", [CloudRunner, ApplicationScript, Pack
|
|
|
116
134
|
notes
|
|
117
135
|
});
|
|
118
136
|
}
|
|
137
|
+
async#pushRelease(workspace, app, platform, {
|
|
138
|
+
arch,
|
|
139
|
+
target,
|
|
140
|
+
env,
|
|
141
|
+
channel,
|
|
142
|
+
notes,
|
|
143
|
+
subspace,
|
|
144
|
+
given,
|
|
145
|
+
allowLocalRelease
|
|
146
|
+
}) {
|
|
147
|
+
const hostArch = process.arch === "arm64" || process.arch === "x64" ? process.arch : null;
|
|
148
|
+
const cpu = arch ?? hostArch;
|
|
149
|
+
if (!cpu)
|
|
150
|
+
throw new Error(`This computer's CPU is ${process.arch}: name the release's with --arch arm64 or x64.`);
|
|
151
|
+
if (env === "local" && !allowLocalRelease)
|
|
152
|
+
throw new Error("A release with --env local is blocked. Pass --allow-local-release only for explicit local release testing.");
|
|
153
|
+
const devProjectId = await this.cloudRunner.projectOf(workspace, subspace, app.name);
|
|
154
|
+
const read = await this.cloudRunner.readRelease(app, {
|
|
155
|
+
platform: platform === "desktop" ? NativeApp.desktopPlatform() : platform,
|
|
156
|
+
arch: cpu,
|
|
157
|
+
target,
|
|
158
|
+
env,
|
|
159
|
+
channel
|
|
160
|
+
});
|
|
161
|
+
return await this.cloudRunner.pushRelease(await this.#cloudApi(workspace, given), devProjectId, app, {
|
|
162
|
+
...read,
|
|
163
|
+
notes
|
|
164
|
+
});
|
|
165
|
+
}
|
|
119
166
|
async#packToPush(app, {
|
|
120
167
|
platform,
|
|
121
168
|
target,
|
|
@@ -128,7 +175,7 @@ class CloudScript2 extends script("cloud", [CloudRunner, ApplicationScript, Pack
|
|
|
128
175
|
if (packDir)
|
|
129
176
|
return await this.cloudRunner.readPack(app, packDir, { platform, target, env, allowLocalRelease });
|
|
130
177
|
if (!platform)
|
|
131
|
-
throw new Error("push-update needs --platform ios or android to pack, or --pack <dir> to upload what `akan pack-update` wrote.");
|
|
178
|
+
throw new Error("push-update needs --platform ios or android to pack, or --pack <dir> to upload what `akan pack-update` wrote, or --platform desktop for the release `akan publish-update` wrote.");
|
|
132
179
|
return await this.applicationScript.packUpdate(app, platform, {
|
|
133
180
|
target: target ?? undefined,
|
|
134
181
|
env: env ?? "main",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isScannedRootEntry,
|
|
11
11
|
AppExecutor,
|
|
12
12
|
LibExecutor
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-wcej7g4z.js";
|
|
14
14
|
import {
|
|
15
15
|
FileSys2
|
|
16
16
|
} from "./index-52w0fvh8.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
workflowPathsForPlan,
|
|
24
24
|
workflowRunArtifactPath,
|
|
25
25
|
workflowSyncDir
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-xjf5j657.js";
|
|
27
27
|
|
|
28
28
|
// pkgs/@akanjs/devkit/akanContext.ts
|
|
29
29
|
import { readdir } from "fs/promises";
|
|
@@ -372,6 +372,25 @@ class AkanContextAnalyzer {
|
|
|
372
372
|
hint
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
+
static async#configLeftovers(workspace, sysPaths) {
|
|
376
|
+
const leftovers = [];
|
|
377
|
+
for (const sysPath of sysPaths) {
|
|
378
|
+
const tsconfigPath = `${sysPath}/tsconfig.json`;
|
|
379
|
+
const tsconfig = await safeReadText(path.join(workspace.workspaceRoot, tsconfigPath));
|
|
380
|
+
if (tsconfig && (/"name"\s*:\s*"next"/.test(tsconfig) || tsconfig.includes(".next/types")))
|
|
381
|
+
leftovers.push({
|
|
382
|
+
path: tsconfigPath,
|
|
383
|
+
message: `${tsconfigPath} still names the Next.js TS plugin or .next/types, which Akan never uses \u2014 delete the "next" plugin entry and the ".next/types/**/*.ts" include.`
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
const bunfig = await safeReadText(path.join(workspace.workspaceRoot, "bunfig.toml"));
|
|
387
|
+
if (bunfig?.includes("bun-plugin-tailwind"))
|
|
388
|
+
leftovers.push({
|
|
389
|
+
path: "bunfig.toml",
|
|
390
|
+
message: "bunfig.toml still loads bun-plugin-tailwind, which is not installed and which Akan never uses (it compiles Tailwind itself) \u2014 delete the [serve.static] section, which Akan never reads."
|
|
391
|
+
});
|
|
392
|
+
return leftovers;
|
|
393
|
+
}
|
|
375
394
|
static async doctor(workspace, {
|
|
376
395
|
strict = false,
|
|
377
396
|
runIdOrPlan = null,
|
|
@@ -415,6 +434,9 @@ class AkanContextAnalyzer {
|
|
|
415
434
|
const agentDrift = await AkanContextAnalyzer.#agentGuideDrift(workspace);
|
|
416
435
|
if (agentDrift)
|
|
417
436
|
report({ severity: "warning", code: agentDrift.code, path: "AGENTS.md", message: agentDrift.message }, repairAction("generated", "akan agent install agents-md", agentDrift.hint, true));
|
|
437
|
+
const sysPaths = [...context.apps, ...context.libs].map((sys) => sys.path);
|
|
438
|
+
for (const leftover of await AkanContextAnalyzer.#configLeftovers(workspace, sysPaths))
|
|
439
|
+
diagnostics.push({ severity: "warning", code: "config-leftover", ...leftover });
|
|
418
440
|
for (const sys of [...context.apps, ...context.libs]) {
|
|
419
441
|
for (const module of sys.modules) {
|
|
420
442
|
const moduleShapeCommand = `akan repair module-shape --app ${sys.name} --module ${module.name}`;
|