@akanjs/devkit 3.3.0-rc.69 → 3.3.0-rc.70
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.ko.md +2 -1
- package/README.md +2 -1
- package/akanApp/akanApp.host.ts +15 -2
- package/akanApp/akanApp.host.wiring.test.ts +111 -0
- package/akanApp/devHostPolicy.ts +5 -0
- package/akanApp/devMetadataRestart.ts +93 -0
- package/akanApp/devRecycler.test.ts +2 -0
- package/akanApp/devRecycler.ts +9 -0
- package/codeAgent/index.ts +1 -34
- package/codeAgent/skills/akan-page/SKILL.md +9 -4
- package/codeAgent/skills/akan-service/SKILL.md +11 -9
- package/csrE2e/ssrRegistry.e2e.test.ts +108 -22
- package/executors/executors.test.ts +15 -0
- package/executors/pkgExecutor.ts +2 -1
- package/frontendBuild/csrDevPatcher.test.ts +3 -4
- package/frontendBuild/csrDevPatcher.ts +4 -4
- package/frontendBuild/devChangePlanner.ts +0 -1
- package/frontendBuild/frontendBuild.test.ts +5 -3
- package/frontendBuild/ssrBaseArtifactBuilder.ts +12 -7
- package/frontendBuild/vendorNarrowing.test.ts +47 -3
- package/frontendBuild/vendorNarrowing.ts +10 -2
- package/incrementalBuilder/buildBatch.proc.ts +27 -1
- package/incrementalBuilder/buildBatchProtocol.ts +1 -0
- package/incrementalBuilder/builderWatch.ts +11 -1
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +80 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +11 -2
- package/incrementalBuilder/pendingMetadata.test.ts +27 -0
- package/incrementalBuilder/pendingMetadata.ts +19 -0
- package/integration/devStability.integration.test.ts +46 -21
- package/package.json +5 -10
- package/packageExports.test.ts +3 -2
- package/test/fakeTerminal.ts +45 -0
- package/tunnel/ssh2Module.ts +2 -6
- package/util/devInstallCommand.ts +7 -0
- package/workspace/slicePlanner.ts +1 -0
- package/codeAgent/agent/AkanCodeCompaction.ts +0 -49
- package/codeAgent/agent/AkanCodeServices.ts +0 -122
- package/codeAgent/agent/AkanContextFiles.ts +0 -94
- package/codeAgent/agent/CodeAgent.ts +0 -626
- package/codeAgent/agent/CodeAgentAllowed.ts +0 -35
- package/codeAgent/agent/CodeAgentAsks.ts +0 -66
- package/codeAgent/agent/CodeAgentCommandLine.ts +0 -372
- package/codeAgent/agent/CodeAgentEventMapper.ts +0 -225
- package/codeAgent/agent/CodeAgentGate.ts +0 -258
- package/codeAgent/agent/CodeAgentProxy.ts +0 -83
- package/codeAgent/agent/CodeAgentRpcHost.ts +0 -109
- package/codeAgent/agent/CodeAgentRpcListener.ts +0 -195
- package/codeAgent/agent/CodeAgentStreamPrinter.ts +0 -86
- package/codeAgent/agent/CodeAgentSuspended.ts +0 -85
- package/codeAgent/agent/CodeAgentUi.ts +0 -47
- package/codeAgent/agent/CodeMailbox.ts +0 -148
- package/codeAgent/agent/CodeSessionFork.ts +0 -56
- package/codeAgent/agent/CodeSessionIndex.ts +0 -78
- package/codeAgent/agent/SubagentPool.ts +0 -219
- package/codeAgent/agent/WorkspaceTrust.ts +0 -200
- package/codeAgent/agent/akanCodeCompaction.test.ts +0 -36
- package/codeAgent/agent/akanCodeModel.ts +0 -47
- package/codeAgent/agent/akanCodeServices.test.ts +0 -54
- package/codeAgent/agent/akanContextFiles.test.ts +0 -116
- package/codeAgent/agent/akanSystemPrompt.ts +0 -50
- package/codeAgent/agent/codeAgent.test.ts +0 -337
- package/codeAgent/agent/codeAgentCommandLine.test.ts +0 -212
- package/codeAgent/agent/codeAgentContract.test.ts +0 -755
- package/codeAgent/agent/codeAgentHosts.ts +0 -30
- package/codeAgent/agent/codeAgentProxy.test.ts +0 -126
- package/codeAgent/agent/codeAgentRpcListener.test.ts +0 -215
- package/codeAgent/agent/codeAgentSuspended.test.ts +0 -47
- package/codeAgent/agent/codeMailbox.test.ts +0 -76
- package/codeAgent/agent/codeSessionFork.test.ts +0 -58
- package/codeAgent/agent/codeSessionIndex.test.ts +0 -77
- package/codeAgent/agent/consoleToStderr.ts +0 -8
- package/codeAgent/agent/jsonLines.ts +0 -29
- package/codeAgent/agent/stringArg.ts +0 -5
- package/codeAgent/feedback/DevLogFeedback.ts +0 -82
- package/codeAgent/feedback/PreviewFeedback.ts +0 -46
- package/codeAgent/feedback/TurnFeedback.ts +0 -98
- package/codeAgent/feedback/VerifyFeedback.ts +0 -39
- package/codeAgent/tools/AkanCli.ts +0 -51
- package/codeAgent/tools/AkanCodePlugins.ts +0 -142
- package/codeAgent/tools/AkanEditScope.ts +0 -53
- package/codeAgent/tools/AkanEnvKeys.ts +0 -50
- package/codeAgent/tools/AkanToolPack.ts +0 -86
- package/codeAgent/tools/AkanVerifier.ts +0 -30
- package/codeAgent/tools/AskToolPack.ts +0 -99
- package/codeAgent/tools/DeepSeekWeb.ts +0 -127
- package/codeAgent/tools/MailToolPack.ts +0 -76
- package/codeAgent/tools/McpClient.ts +0 -209
- package/codeAgent/tools/McpOAuth.ts +0 -233
- package/codeAgent/tools/McpOAuthLoopback.ts +0 -64
- package/codeAgent/tools/McpServerConfig.ts +0 -131
- package/codeAgent/tools/McpSignIn.ts +0 -158
- package/codeAgent/tools/McpTokenStore.ts +0 -128
- package/codeAgent/tools/McpToolPack.ts +0 -206
- package/codeAgent/tools/SessionToolPack.ts +0 -91
- package/codeAgent/tools/WebToolPack.ts +0 -315
- package/codeAgent/tools/akanCodePlugins.test.ts +0 -954
- package/codeAgent/tools/askToolPack.test.ts +0 -116
- package/codeAgent/tools/deepSeekWeb.test.ts +0 -113
- package/codeAgent/tools/mcpOAuth.test.ts +0 -648
- package/codeAgent/tools/mcpServerConfig.test.ts +0 -341
- package/piDependencyPins.test.ts +0 -45
package/README.ko.md
CHANGED
|
@@ -54,7 +54,8 @@ resolve되지 않습니다.
|
|
|
54
54
|
- 가이드라인, 코드 생성, 그리고 `akan workflow`와 Akan MCP 서버 뒤의 계획 후 적용 워크플로.
|
|
55
55
|
- 공유 Biome 설정(`@akanjs/devkit/biome.base.json`)과 모든 워크스페이스가 확장하는 grit lint 규칙.
|
|
56
56
|
- Akan 네이티브 런타임 기반 앱 빌드(iOS, Android, macOS, Windows, Linux), 스토어 릴리스, 서명된 업데이트 릴리스.
|
|
57
|
-
-
|
|
57
|
+
- 함께 배포되는 akan 스킬과 `akan code`가 세션과 설정을 두는 폴더(`@akanjs/devkit/codeAgent`). 에이전트 자체는
|
|
58
|
+
`@akanjs/code`로 배포됩니다.
|
|
58
59
|
|
|
59
60
|
## 개발 서버 메모리
|
|
60
61
|
|
package/README.md
CHANGED
|
@@ -54,7 +54,8 @@ from outside the package.
|
|
|
54
54
|
- The shared Biome config (`@akanjs/devkit/biome.base.json`) and the grit lint rules every workspace extends.
|
|
55
55
|
- Native app builds on the Akan native runtime (iOS, Android, macOS, Windows, Linux), store releases, and signed
|
|
56
56
|
update releases.
|
|
57
|
-
- The
|
|
57
|
+
- The shipped akan skills and the folders `akan code` keeps its sessions and settings in (`@akanjs/devkit/codeAgent`);
|
|
58
|
+
the agent itself ships as `@akanjs/code`.
|
|
58
59
|
|
|
59
60
|
## Dev Server Sizing
|
|
60
61
|
|
package/akanApp/akanApp.host.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
UNAVAILABLE_REDIS_HOST,
|
|
24
24
|
} from "./devHostPolicy";
|
|
25
25
|
import { DevIdleSuspend } from "./devIdleSuspend";
|
|
26
|
+
import { DevMetadataRestart } from "./devMetadataRestart";
|
|
26
27
|
import { DevRecycler } from "./devRecycler";
|
|
27
28
|
import { DevStartTimeline } from "./devStartTimeline";
|
|
28
29
|
import { ProcessRss } from "./processRss";
|
|
@@ -47,6 +48,7 @@ export class AkanAppHost {
|
|
|
47
48
|
readonly #builder: DevBuilder;
|
|
48
49
|
readonly #idle: DevIdleSuspend;
|
|
49
50
|
readonly #recycler: DevRecycler;
|
|
51
|
+
readonly #metadata: DevMetadataRestart;
|
|
50
52
|
readonly #timeline: DevStartTimeline;
|
|
51
53
|
constructor(
|
|
52
54
|
private readonly app: App,
|
|
@@ -85,6 +87,7 @@ export class AkanAppHost {
|
|
|
85
87
|
toBuilder: (message) => this.#requests.send(message),
|
|
86
88
|
},
|
|
87
89
|
);
|
|
90
|
+
this.#metadata = new DevMetadataRestart({ logger, statuses, backend: this.#backend });
|
|
88
91
|
this.#gap = new BuilderGap({ graph, backend: this.#backend, logger });
|
|
89
92
|
this.#requests = new BuilderRequestRelay(
|
|
90
93
|
{ logger, env },
|
|
@@ -101,7 +104,7 @@ export class AkanAppHost {
|
|
|
101
104
|
{
|
|
102
105
|
builder: () => this.#builder.current,
|
|
103
106
|
away: () => this.#idle.away,
|
|
104
|
-
restartQueued: () => this.#recycler.pending || this.#backend.restartScheduled,
|
|
107
|
+
restartQueued: () => this.#recycler.pending || this.#metadata.pending || this.#backend.restartScheduled,
|
|
105
108
|
onRecycle: () => this.#gap.open("builder recycle"),
|
|
106
109
|
},
|
|
107
110
|
);
|
|
@@ -165,6 +168,7 @@ export class AkanAppHost {
|
|
|
165
168
|
builder: this.#builder,
|
|
166
169
|
gap: this.#gap,
|
|
167
170
|
rss: this.#rss,
|
|
171
|
+
metadata: this.#metadata,
|
|
168
172
|
});
|
|
169
173
|
}
|
|
170
174
|
#emitDevEvent(state: DevHostState, detail?: string) {
|
|
@@ -216,6 +220,7 @@ export class AkanAppHost {
|
|
|
216
220
|
//? Nothing reapplies once it stops: a pages ok received meanwhile would bring children back after it.
|
|
217
221
|
this.#stopping = true;
|
|
218
222
|
this.#recycler.drop();
|
|
223
|
+
this.#metadata.drop();
|
|
219
224
|
this.#idle.stop();
|
|
220
225
|
this.#backend.cancelTimers();
|
|
221
226
|
this.#builder.cancelRecovery();
|
|
@@ -260,6 +265,7 @@ export class AkanAppHost {
|
|
|
260
265
|
this.#builder.trackGeneration(message);
|
|
261
266
|
if (message.type === "build-status") {
|
|
262
267
|
this.#statuses.record(message.data);
|
|
268
|
+
this.#metadata.settle(message.data);
|
|
263
269
|
this.#backend.sendOrQueueStatus(message.data);
|
|
264
270
|
this.#backend.reviveAfterGreenBuild(message.data);
|
|
265
271
|
await this.#recycler.resumeFailed(message.data);
|
|
@@ -292,10 +298,17 @@ export class AkanAppHost {
|
|
|
292
298
|
this.#backend.send(answer);
|
|
293
299
|
return;
|
|
294
300
|
}
|
|
301
|
+
if (this.#metadata.holds(message)) return;
|
|
295
302
|
this.#backend.send(message);
|
|
296
303
|
}
|
|
297
304
|
get #restartPending(): boolean {
|
|
298
|
-
return
|
|
305
|
+
return (
|
|
306
|
+
this.#recycler.pending ||
|
|
307
|
+
this.#metadata.pending ||
|
|
308
|
+
this.#backend.restartPending ||
|
|
309
|
+
this.#builder.recovering ||
|
|
310
|
+
this.#rss.armed
|
|
311
|
+
);
|
|
299
312
|
}
|
|
300
313
|
/** Null when unreadable, meaning "no new information", never zero. */
|
|
301
314
|
static async readProcessRssBytes(pid: number): Promise<number | null> {
|
|
@@ -409,6 +409,117 @@ describe("AkanAppHost relays the builder to the backend", () => {
|
|
|
409
409
|
});
|
|
410
410
|
});
|
|
411
411
|
|
|
412
|
+
describe("AkanAppHost through a signal or dictionary save", () => {
|
|
413
|
+
isolateEnv({ AKAN_PUBLIC_REPO_NAME: "repo", AKAN_PUBLIC_SERVE_DOMAIN: "localhost", AKAN_PUBLIC_ENV: "local" });
|
|
414
|
+
|
|
415
|
+
const signalFile = "/app/lib/a/a.signal.ts";
|
|
416
|
+
const metadataSave = (generation: number) =>
|
|
417
|
+
({
|
|
418
|
+
type: "invalidate",
|
|
419
|
+
kinds: ["code"],
|
|
420
|
+
files: [signalFile],
|
|
421
|
+
generation,
|
|
422
|
+
devPlan: {
|
|
423
|
+
generation,
|
|
424
|
+
files: [signalFile],
|
|
425
|
+
generatedFiles: [],
|
|
426
|
+
roles: ["shared"],
|
|
427
|
+
actions: ["rebuild-client", "restart-backend"],
|
|
428
|
+
reasonByFile: { [signalFile]: ["runtime-metadata", "shared-path"] },
|
|
429
|
+
},
|
|
430
|
+
}) as unknown as BuilderMessage;
|
|
431
|
+
const registry = { type: "ssr-updated", data: { generation: 3, reload: true, epoch: 30 } } as BuilderMessage;
|
|
432
|
+
const css = (generation: number) =>
|
|
433
|
+
({ type: "css-updated", data: { generation, cssAssets: {} } }) as unknown as BuilderMessage;
|
|
434
|
+
const phaseStatus = (generation: number, phase: DevBuildStatus["phase"], ok: boolean) =>
|
|
435
|
+
({ type: "build-status", data: { ...status(generation, ok), phase } }) as BuilderMessage;
|
|
436
|
+
//? Css passes through the hold, and the host handles builder messages in order: once it lands, so did the ones before.
|
|
437
|
+
const handled = async (dev: DevHost, generation: number) => {
|
|
438
|
+
const marker = css(generation);
|
|
439
|
+
dev.builder().toHost(marker);
|
|
440
|
+
return await until(() => dev.backends[0].sent.includes(marker));
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
test("restarts the backend and not the builder once the save's pages build is green, and the running backend never takes that batch's updates", async () => {
|
|
444
|
+
const dev = await startedHost();
|
|
445
|
+
|
|
446
|
+
dev.builder().toHost(metadataSave(8));
|
|
447
|
+
dev.builder().toHost(registry);
|
|
448
|
+
dev.builder().toHost(pages(8));
|
|
449
|
+
expect(await handled(dev, 8)).toBe(true);
|
|
450
|
+
await Bun.sleep(300);
|
|
451
|
+
expect(dev.backends).toHaveLength(1);
|
|
452
|
+
expect(sentOf(dev.backends[0].sent, "invalidate")).toEqual([metadataSave(8)]);
|
|
453
|
+
expect(sentOf(dev.backends[0].sent, "ssr-updated")).toEqual([]);
|
|
454
|
+
expect(sentOf(dev.backends[0].sent, "pages-updated")).toEqual([]);
|
|
455
|
+
|
|
456
|
+
dev.builder().toHost({ type: "build-status", data: status(8, true) });
|
|
457
|
+
|
|
458
|
+
expect(await until(() => dev.backends.length === 2)).toBe(true);
|
|
459
|
+
readyBackend(dev);
|
|
460
|
+
expect(sentOf(dev.backend().sent, "pages-updated")).toEqual([pages(8)]);
|
|
461
|
+
expect(dev.builders).toHaveLength(1);
|
|
462
|
+
expect(dev.builder().stopped).toBe(0);
|
|
463
|
+
expect(dev.logged("recycling builder/backend")).toBe(false);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
test("a red pages build hands the held updates to the running backend before its status, and the next green one restarts it", async () => {
|
|
467
|
+
const dev = await startedHost();
|
|
468
|
+
dev.builder().toHost(metadataSave(8));
|
|
469
|
+
dev.builder().toHost(registry);
|
|
470
|
+
|
|
471
|
+
dev.builder().toHost({ type: "build-status", data: status(8, false) });
|
|
472
|
+
|
|
473
|
+
expect(await until(() => statusesOf(dev.backends[0].sent).some((sent) => sent.generation === 8))).toBe(true);
|
|
474
|
+
const sent = dev.backends[0].sent;
|
|
475
|
+
expect(sent.indexOf(registry)).toBeGreaterThan(-1);
|
|
476
|
+
expect(sent.indexOf(registry)).toBeLessThan(
|
|
477
|
+
sent.findIndex((message) => message.type === "build-status" && message.data.generation === 8),
|
|
478
|
+
);
|
|
479
|
+
expect(dev.backends).toHaveLength(1);
|
|
480
|
+
|
|
481
|
+
dev.builder().toHost(invalidate(9, ["rebuild-client"]));
|
|
482
|
+
dev.builder().toHost(pages(9));
|
|
483
|
+
dev.builder().toHost({ type: "build-status", data: status(9, true) });
|
|
484
|
+
|
|
485
|
+
expect(await until(() => dev.backends.length === 2)).toBe(true);
|
|
486
|
+
expect(sentOf(dev.backends[0].sent, "pages-updated")).toEqual([]);
|
|
487
|
+
expect(dev.builders).toHaveLength(1);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
test("a server save while the restart waits joins it instead of restarting the backend before the pages build", async () => {
|
|
491
|
+
const dev = await startedHost();
|
|
492
|
+
dev.builder().toHost(metadataSave(8));
|
|
493
|
+
dev.builder().toHost(invalidate(9, ["restart-backend"], ["/app/lib/a/a.service.ts"]));
|
|
494
|
+
expect(await handled(dev, 9)).toBe(true);
|
|
495
|
+
await Bun.sleep(300);
|
|
496
|
+
expect(dev.backends).toHaveLength(1);
|
|
497
|
+
|
|
498
|
+
dev.builder().toHost({ type: "build-status", data: status(9, true) });
|
|
499
|
+
|
|
500
|
+
expect(await until(() => dev.backends.length === 2)).toBe(true);
|
|
501
|
+
await Bun.sleep(300);
|
|
502
|
+
expect(dev.backends).toHaveLength(2);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test("a pages build older than the save, or green while a registry build since the save failed, keeps the backend", async () => {
|
|
506
|
+
const dev = await startedHost();
|
|
507
|
+
dev.builder().toHost(metadataSave(8));
|
|
508
|
+
dev.builder().toHost({ type: "build-status", data: status(7, true) });
|
|
509
|
+
dev.builder().toHost(phaseStatus(8, "ssr", false));
|
|
510
|
+
dev.builder().toHost({ type: "build-status", data: status(8, true) });
|
|
511
|
+
expect(await handled(dev, 8)).toBe(true);
|
|
512
|
+
await Bun.sleep(300);
|
|
513
|
+
expect(dev.backends).toHaveLength(1);
|
|
514
|
+
|
|
515
|
+
dev.builder().toHost(invalidate(9, ["rebuild-client"]));
|
|
516
|
+
dev.builder().toHost(phaseStatus(9, "ssr", true));
|
|
517
|
+
dev.builder().toHost({ type: "build-status", data: status(9, true) });
|
|
518
|
+
|
|
519
|
+
expect(await until(() => dev.backends.length === 2)).toBe(true);
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
412
523
|
describe("AkanAppHost through a builder's own restart", () => {
|
|
413
524
|
isolateEnv({ AKAN_PUBLIC_REPO_NAME: "repo", AKAN_PUBLIC_SERVE_DOMAIN: "localhost", AKAN_PUBLIC_ENV: "local" });
|
|
414
525
|
|
package/akanApp/devHostPolicy.ts
CHANGED
|
@@ -58,6 +58,11 @@ export const shouldRestartBackendByDevPlan = (
|
|
|
58
58
|
export const shouldRestartBuilderByDevPlan = (message: Extract<BuilderMessage, { type: "invalidate" }>): boolean =>
|
|
59
59
|
message.devPlan?.actions.includes("restart-builder") ?? false;
|
|
60
60
|
|
|
61
|
+
export const runtimeMetadataFilesOf = (plan: DevChangePlan | undefined): string[] =>
|
|
62
|
+
Object.entries(plan?.reasonByFile ?? {}).flatMap(([file, reasons]) =>
|
|
63
|
+
reasons.includes("runtime-metadata") ? [file] : [],
|
|
64
|
+
);
|
|
65
|
+
|
|
61
66
|
/** The gateway reports backend failures with `generation: -1`; the host assigns its own counter then. */
|
|
62
67
|
export const normalizeBackendReportedGeneration = (generation: number): number | undefined =>
|
|
63
68
|
generation >= 0 ? generation : undefined;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Logger } from "akanjs/common";
|
|
2
|
+
import type { BuilderMessage, DevBuildStatus } from "akanjs/server";
|
|
3
|
+
import type { DevBackend } from "./devBackend";
|
|
4
|
+
import type { DevBuildStatusBoard } from "./devBuildStatusBoard";
|
|
5
|
+
import { backendRestartReasonFromMessage, mergeInvalidateMessages, runtimeMetadataFilesOf } from "./devHostPolicy";
|
|
6
|
+
|
|
7
|
+
type InvalidateMessage = Extract<BuilderMessage, { type: "invalidate" }>;
|
|
8
|
+
type BatchUpdate = Extract<BuilderMessage, { type: "pages-updated" | "ssr-updated" | "csr-updated" }>;
|
|
9
|
+
|
|
10
|
+
//* A signal or dictionary save restarts the backend, never the builder, once a pages build at or past the save is green
|
|
11
|
+
//* and no registry build since the save failed: that pages build rebuilt the dictionary assets and rewrote the base
|
|
12
|
+
//* artifact a backend boots on, after its batch's registry builds reported. Until then the running backend keeps the
|
|
13
|
+
//* state from before the save, and each batch's updates wait here instead of reaching it.
|
|
14
|
+
export class DevMetadataRestart {
|
|
15
|
+
readonly #logger: Logger;
|
|
16
|
+
readonly #statuses: DevBuildStatusBoard;
|
|
17
|
+
readonly #backend: DevBackend;
|
|
18
|
+
#pending: { generation: number; message: InvalidateMessage } | null = null;
|
|
19
|
+
#held: BatchUpdate[] | null = null;
|
|
20
|
+
|
|
21
|
+
constructor({ logger, statuses, backend }: { logger: Logger; statuses: DevBuildStatusBoard; backend: DevBackend }) {
|
|
22
|
+
this.#logger = logger;
|
|
23
|
+
this.#statuses = statuses;
|
|
24
|
+
this.#backend = backend;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get pending(): boolean {
|
|
28
|
+
return !!this.#pending;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** True when the save's backend restart joins the pending one; the running backend still takes the invalidate. */
|
|
32
|
+
defers(message: InvalidateMessage): boolean {
|
|
33
|
+
const pending = this.#pending;
|
|
34
|
+
const metadata = runtimeMetadataFilesOf(message.devPlan);
|
|
35
|
+
if (!pending && metadata.length === 0) return false;
|
|
36
|
+
this.#held ??= [];
|
|
37
|
+
const merged = pending ? mergeInvalidateMessages(pending.message, message) : message;
|
|
38
|
+
if (metadata.length === 0 && pending) {
|
|
39
|
+
this.#pending = { generation: pending.generation, message: merged };
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const generation = Math.max(pending?.generation ?? -1, message.devPlan?.generation ?? message.generation ?? -1);
|
|
43
|
+
this.#pending = { generation, message: merged };
|
|
44
|
+
this.#logger.verbose(
|
|
45
|
+
`[dev-host] runtime metadata generation=${generation} files=${metadata.length}: the backend restarts once its pages build is green; the builder keeps running`,
|
|
46
|
+
);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Before the status reaches the backend: a red build hands it the updates it held first. */
|
|
51
|
+
settle(status: DevBuildStatus): void {
|
|
52
|
+
const pending = this.#pending;
|
|
53
|
+
if (!pending || status.phase !== "pages" || status.generation < pending.generation) return;
|
|
54
|
+
if (!status.ok || this.#registryFailedSince(pending.generation)) {
|
|
55
|
+
this.#release();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.#pending = null;
|
|
59
|
+
this.#held = null;
|
|
60
|
+
this.#logger.verbose(
|
|
61
|
+
`[dev-host] runtime metadata generation=${pending.generation} built at generation=${status.generation}; restarting the backend onto it`,
|
|
62
|
+
);
|
|
63
|
+
this.#backend.scheduleRestart(backendRestartReasonFromMessage(pending.message));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
holds(message: BuilderMessage): boolean {
|
|
67
|
+
if (!this.#held) return false;
|
|
68
|
+
if (message.type !== "pages-updated" && message.type !== "ssr-updated" && message.type !== "csr-updated")
|
|
69
|
+
return false;
|
|
70
|
+
this.#held.push(message);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A dev-host restart replaces the builder and backend itself, onto a boot build of its own. */
|
|
75
|
+
drop(): void {
|
|
76
|
+
this.#pending = null;
|
|
77
|
+
this.#held = null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//? The registry a failed build leaves is the one from before the save: a backend booted beside it would pair them.
|
|
81
|
+
#registryFailedSince(generation: number): boolean {
|
|
82
|
+
return (["csr", "ssr"] as const).some((phase) => {
|
|
83
|
+
const status = this.#statuses.phase(phase);
|
|
84
|
+
return status?.ok === false && status.generation >= generation;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#release(): void {
|
|
89
|
+
const held = this.#held ?? [];
|
|
90
|
+
this.#held = null;
|
|
91
|
+
for (const update of held) this.#backend.send(update);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -8,6 +8,7 @@ import type { BuilderRssRecycler } from "./builderRssRecycler";
|
|
|
8
8
|
import type { DevBackend } from "./devBackend";
|
|
9
9
|
import type { DevBuilder } from "./devBuilder";
|
|
10
10
|
import type { DevBuildStatusBoard } from "./devBuildStatusBoard";
|
|
11
|
+
import type { DevMetadataRestart } from "./devMetadataRestart";
|
|
11
12
|
import { DevRecycler } from "./devRecycler";
|
|
12
13
|
|
|
13
14
|
const logger = { verbose: () => undefined, warn: () => undefined, info: () => undefined } as unknown as Logger;
|
|
@@ -53,6 +54,7 @@ describe("DevRecycler", () => {
|
|
|
53
54
|
} as unknown as DevBuilder,
|
|
54
55
|
gap: {} as BuilderGap,
|
|
55
56
|
rss: { rearm: () => undefined } as unknown as BuilderRssRecycler,
|
|
57
|
+
metadata: { defers: () => false } as unknown as DevMetadataRestart,
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
await recycler.handleInvalidate(restartBuilder);
|
package/akanApp/devRecycler.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
shouldRestartBuilderByDevPlan,
|
|
18
18
|
shouldRestartDevHostByDevPlan,
|
|
19
19
|
} from "./devHostPolicy";
|
|
20
|
+
import type { DevMetadataRestart } from "./devMetadataRestart";
|
|
20
21
|
|
|
21
22
|
type InvalidateMessage = Extract<BuilderMessage, { type: "invalidate" }>;
|
|
22
23
|
|
|
@@ -31,6 +32,7 @@ export class DevRecycler {
|
|
|
31
32
|
readonly #builder: DevBuilder;
|
|
32
33
|
readonly #gap: BuilderGap;
|
|
33
34
|
readonly #rss: BuilderRssRecycler;
|
|
35
|
+
readonly #metadata: DevMetadataRestart;
|
|
34
36
|
#pending: {
|
|
35
37
|
message: InvalidateMessage;
|
|
36
38
|
refreshConfig: boolean;
|
|
@@ -53,6 +55,7 @@ export class DevRecycler {
|
|
|
53
55
|
builder: DevBuilder;
|
|
54
56
|
gap: BuilderGap;
|
|
55
57
|
rss: BuilderRssRecycler;
|
|
58
|
+
metadata: DevMetadataRestart;
|
|
56
59
|
},
|
|
57
60
|
) {
|
|
58
61
|
this.#app = app;
|
|
@@ -65,6 +68,7 @@ export class DevRecycler {
|
|
|
65
68
|
this.#builder = parts.builder;
|
|
66
69
|
this.#gap = parts.gap;
|
|
67
70
|
this.#rss = parts.rss;
|
|
71
|
+
this.#metadata = parts.metadata;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
get pending(): boolean {
|
|
@@ -94,6 +98,10 @@ export class DevRecycler {
|
|
|
94
98
|
await this.apply(merged, refreshConfig);
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
101
|
+
if (this.#metadata.defers(message)) {
|
|
102
|
+
this.#backend.send(message);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
97
105
|
if (await this.#shouldRestartBackend(message)) {
|
|
98
106
|
this.#backend.scheduleRestart(backendRestartReasonFromMessage(message));
|
|
99
107
|
return;
|
|
@@ -229,6 +237,7 @@ export class DevRecycler {
|
|
|
229
237
|
this.#builder.cancelRecovery();
|
|
230
238
|
this.#builder.resetRecovery();
|
|
231
239
|
this.#backend.dropPendingRestart();
|
|
240
|
+
this.#metadata.drop();
|
|
232
241
|
await this.#backend.restarting;
|
|
233
242
|
this.#statuses.reset();
|
|
234
243
|
this.#backend.dropQueuedStatuses();
|
package/codeAgent/index.ts
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
// agent/consoleToStderr is deliberately absent: it takes over globalThis.console, so an RPC entry imports it first.
|
|
3
|
-
|
|
4
|
-
export * from "../preview";
|
|
5
|
-
export * from "./agent/AkanCodeCompaction";
|
|
6
|
-
export * from "./agent/AkanCodeServices";
|
|
7
|
-
export * from "./agent/akanCodeModel";
|
|
1
|
+
export * from "./agent/AkanCodeEnv";
|
|
8
2
|
export * from "./agent/akanCodePaths";
|
|
9
|
-
export * from "./agent/akanSystemPrompt";
|
|
10
|
-
export * from "./agent/CodeAgent";
|
|
11
|
-
export * from "./agent/CodeAgentAsks";
|
|
12
|
-
export * from "./agent/CodeAgentEventMapper";
|
|
13
|
-
export * from "./agent/CodeAgentGate";
|
|
14
|
-
export * from "./agent/CodeAgentRpcHost";
|
|
15
|
-
export * from "./agent/CodeAgentStreamPrinter";
|
|
16
|
-
export * from "./agent/CodeAgentUi";
|
|
17
|
-
export * from "./agent/CodeMailbox";
|
|
18
|
-
export * from "./agent/CodeSessionFork";
|
|
19
|
-
export * from "./agent/CodeSessionIndex";
|
|
20
|
-
export * from "./agent/SubagentPool";
|
|
21
|
-
export * from "./feedback/DevLogFeedback";
|
|
22
|
-
export * from "./feedback/PreviewFeedback";
|
|
23
|
-
export * from "./feedback/TurnFeedback";
|
|
24
|
-
export * from "./feedback/VerifyFeedback";
|
|
25
|
-
export * from "./tools/AkanCli";
|
|
26
|
-
export * from "./tools/AkanCodePlugins";
|
|
27
|
-
export * from "./tools/AkanEditScope";
|
|
28
|
-
export * from "./tools/AkanEnvKeys";
|
|
29
|
-
export * from "./tools/AkanToolPack";
|
|
30
|
-
export * from "./tools/AkanVerifier";
|
|
31
|
-
export * from "./tools/MailToolPack";
|
|
32
|
-
export * from "./tools/McpClient";
|
|
33
|
-
export * from "./tools/McpToolPack";
|
|
34
|
-
export * from "./tools/SessionToolPack";
|
|
35
|
-
export * from "./tools/WebToolPack";
|
|
@@ -70,13 +70,18 @@ File names, stages, the `.render()` order and what a route file must never do ar
|
|
|
70
70
|
- `router.notFound()` from `.guard()`, `.head()` or `.render()` answers 404 with the nearest layout's `.notFound()`
|
|
71
71
|
above it (an unmatched URL: the deepest layout covering it), else the built-in 404.
|
|
72
72
|
- A layout's own 404 and error views: `.notFound(({ pathname }) => …)` and `.error(({ error }) => …)` on `layout()`
|
|
73
|
-
or `rootLayout()`.
|
|
74
|
-
|
|
73
|
+
or `rootLayout()`. What they return is drawn as that layout's own `.render()` children, inside its frame, so it
|
|
74
|
+
holds only the content (no second `<main>` or header). A `<title>` and `<meta>` at the top of it replace the
|
|
75
|
+
page's head: `.notFound(() => <><title>Not found</title>…</>)`, except below a `.loading()`, where the head is
|
|
76
|
+
already out.
|
|
75
77
|
- `<Link href="/books/OL45804W">`: write the path without the locale; Link adds it, or leaves it off for the default
|
|
76
78
|
locale under `i18n.localePrefix: "as-needed"`. It renders an `<a>` and takes its attributes; `activeClassName`
|
|
77
79
|
marks the current one from the press, before its page arrives; an `active` prop from a layout's render is late.
|
|
78
|
-
|
|
79
|
-
(`
|
|
80
|
+
`replace` and `scrollToTop={false}` change its push; it has no `shallow`, so a shallow one is an `onClick` that
|
|
81
|
+
calls `event.preventDefault()` and `router.push(href, { shallow: true })`.
|
|
82
|
+
- A page still loading, SSR or CSR: `pendingClassName` / `data-pending` on its `Link`, and `usePendingNavigation()`
|
|
83
|
+
(`akanjs/client`) for its `{ path, searchParams }`, `null` once it is drawn or shows its `.loading()`, and for a page
|
|
84
|
+
already held.
|
|
80
85
|
- From a handler: `router.push(href)` / `router.replace(href)`; in a server stage, `router.redirect(href)`.
|
|
81
86
|
- A page state a push opens in the query (a record in `?id=`): close it with `router.backOrReplace(href)`, never
|
|
82
87
|
`router.back()` or a `renderMode` branch. A CSR or native stack rewrites a push that keeps the pathname rather than
|
|
@@ -5,10 +5,9 @@ description: "Add a service module — behaviour not centred on one stored model
|
|
|
5
5
|
|
|
6
6
|
# Akan service modules
|
|
7
7
|
|
|
8
|
-
Behaviour
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
dictionary is a `serviceDictionary`.
|
|
8
|
+
Behaviour not centred on one stored model lives in a **service module**, `lib/_<service>/`, whose abstract is
|
|
9
|
+
`<service>.abstract.md` (no underscore). Its UI surface is limited to `<Service>.Util.tsx` and
|
|
10
|
+
`<Service>.Zone.tsx`, and its dictionary is a `serviceDictionary`.
|
|
12
11
|
|
|
13
12
|
## Rules
|
|
14
13
|
|
|
@@ -19,10 +18,9 @@ dictionary is a `serviceDictionary`.
|
|
|
19
18
|
`_preUpdate` / `_postCreate`, not inline. Fire-and-forget is explicitly `void`-ed.
|
|
20
19
|
- Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an
|
|
21
20
|
error.
|
|
22
|
-
- `serve(name, { serverMode: "batch" }, …)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`akan create-service` does.
|
|
21
|
+
- `serve(name, { serverMode: "batch" }, …)`, on the app's own `lib/_<app>/` for cron and queue work, mounts the
|
|
22
|
+
module, endpoints included, only in a `batch` or `all` process, never on a `federation` replica. A service a page
|
|
23
|
+
calls leaves it off, as `akan create-service` does.
|
|
26
24
|
|
|
27
25
|
## Reaching other things
|
|
28
26
|
|
|
@@ -66,7 +64,11 @@ interface ApiWork {
|
|
|
66
64
|
export class OpenlibraryService extends serve("openlibrary" as const, ({ plug }) => ({ bookApi: plug(BookApi) })) {
|
|
67
65
|
async getBook(id: string) {
|
|
68
66
|
const work = await this.bookApi.get<ApiWork>(`works/${id}.json`);
|
|
69
|
-
return work &&
|
|
67
|
+
return work && this.toBook(id, work);
|
|
68
|
+
}
|
|
69
|
+
// TypeScript `private`: lint refuses `#private` in a service.
|
|
70
|
+
private toBook(id: string, work: ApiWork) {
|
|
71
|
+
return { id, title: work.title };
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|