everything-dev 1.8.13 → 1.9.0

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.
Files changed (56) hide show
  1. package/dist/api-contract.cjs +53 -15
  2. package/dist/api-contract.cjs.map +1 -1
  3. package/dist/api-contract.mjs +53 -15
  4. package/dist/api-contract.mjs.map +1 -1
  5. package/dist/cli/init.cjs +7 -7
  6. package/dist/cli/init.cjs.map +1 -1
  7. package/dist/cli/init.d.cts.map +1 -1
  8. package/dist/cli/init.d.mts.map +1 -1
  9. package/dist/cli/init.mjs +7 -7
  10. package/dist/cli/init.mjs.map +1 -1
  11. package/dist/cli.cjs +27 -0
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.mjs +27 -0
  14. package/dist/cli.mjs.map +1 -1
  15. package/dist/contract.cjs +20 -1
  16. package/dist/contract.cjs.map +1 -1
  17. package/dist/contract.d.cts +46 -1
  18. package/dist/contract.d.cts.map +1 -1
  19. package/dist/contract.d.mts +46 -1
  20. package/dist/contract.d.mts.map +1 -1
  21. package/dist/contract.meta.cjs +9 -0
  22. package/dist/contract.meta.cjs.map +1 -1
  23. package/dist/contract.meta.d.cts +13 -0
  24. package/dist/contract.meta.d.mts +13 -0
  25. package/dist/contract.meta.mjs +9 -0
  26. package/dist/contract.meta.mjs.map +1 -1
  27. package/dist/contract.mjs +19 -2
  28. package/dist/contract.mjs.map +1 -1
  29. package/dist/index.cjs +2 -0
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/orchestrator.cjs +0 -1
  34. package/dist/orchestrator.cjs.map +1 -1
  35. package/dist/orchestrator.d.cts.map +1 -1
  36. package/dist/orchestrator.d.mts.map +1 -1
  37. package/dist/orchestrator.mjs +0 -1
  38. package/dist/orchestrator.mjs.map +1 -1
  39. package/dist/plugin.cjs +80 -2
  40. package/dist/plugin.cjs.map +1 -1
  41. package/dist/plugin.d.cts +21 -0
  42. package/dist/plugin.d.cts.map +1 -1
  43. package/dist/plugin.d.mts +21 -0
  44. package/dist/plugin.d.mts.map +1 -1
  45. package/dist/plugin.mjs +80 -2
  46. package/dist/plugin.mjs.map +1 -1
  47. package/package.json +1 -1
  48. package/skills/dev-workflow/SKILL.md +3 -3
  49. package/src/api-contract.ts +95 -22
  50. package/src/cli/init.ts +8 -11
  51. package/src/cli.ts +32 -0
  52. package/src/contract.meta.ts +9 -0
  53. package/src/contract.ts +21 -0
  54. package/src/orchestrator.ts +2 -21
  55. package/src/plugin.ts +116 -2
  56. package/src/scripts/sync-api-contract.ts +0 -24
package/src/cli.ts CHANGED
@@ -310,6 +310,38 @@ async function main() {
310
310
  return;
311
311
  }
312
312
 
313
+ if (descriptor.key === "typesGen") {
314
+ console.log();
315
+ if (result.status === "error") {
316
+ console.error(`[CLI] ${result.error || "Unknown error"}`);
317
+ process.exit(1);
318
+ }
319
+ console.log(colors.green(`${icons.ok} Types generated`));
320
+ if (result.source) {
321
+ console.log(
322
+ ` ${colors.dim("Mode:")} ${result.source === "remote" ? colors.cyan("remote") : colors.dim("local")}`,
323
+ );
324
+ }
325
+ if (result.generated.length > 0) {
326
+ console.log(` ${colors.dim("Generated:")}`);
327
+ for (const f of result.generated) console.log(` ${colors.dim(f)}`);
328
+ }
329
+ if (result.fetched.length > 0) {
330
+ console.log(` ${colors.dim("Fetched from remote:")}`);
331
+ for (const url of result.fetched) console.log(` ${colors.dim(url)}`);
332
+ }
333
+ if (result.skipped.length > 0) {
334
+ console.log(` ${colors.dim("Skipped (local):")}`);
335
+ for (const s of result.skipped) console.log(` ${colors.dim(s)}`);
336
+ }
337
+ if (result.failed.length > 0) {
338
+ console.log(` ${colors.yellow("Failed:")}`);
339
+ for (const f of result.failed) console.log(` ${colors.error(f)}`);
340
+ }
341
+ console.log();
342
+ return;
343
+ }
344
+
313
345
  if (result?.status === "error") {
314
346
  console.error(`[CLI] ${result.error || "Unknown error"}`);
315
347
  process.exit(1);
@@ -121,6 +121,15 @@ export const cliCommandMeta = {
121
121
  noSync: { description: "Only upgrade packages, skip template sync" },
122
122
  },
123
123
  },
124
+ typesGen: {
125
+ commandPath: ["types", "gen"],
126
+ summary: "Generate type definitions from configured API and plugin contracts",
127
+ interactive: false,
128
+ fields: {
129
+ env: { description: "Environment: development (default) or production" },
130
+ dryRun: { description: "Preview what would be fetched without writing files" },
131
+ },
132
+ },
124
133
  status: {
125
134
  commandPath: ["status"],
126
135
  summary: "Show project health, versions, and update availability",
package/src/contract.ts CHANGED
@@ -221,6 +221,21 @@ export const StatusResultSchema = z.object({
221
221
  error: z.string().optional(),
222
222
  });
223
223
 
224
+ export const TypesGenOptionsSchema = z.object({
225
+ env: z.enum(["development", "production"]).optional(),
226
+ dryRun: z.boolean().default(false),
227
+ });
228
+
229
+ export const TypesGenResultSchema = z.object({
230
+ status: z.enum(["success", "error"]),
231
+ generated: z.array(z.string()),
232
+ fetched: z.array(z.string()),
233
+ skipped: z.array(z.string()),
234
+ failed: z.array(z.string()),
235
+ source: z.enum(["local", "remote"]).optional(),
236
+ error: z.string().optional(),
237
+ });
238
+
224
239
  export const bosContract = oc.router({
225
240
  dev: oc.route({ method: "POST", path: "/dev" }).input(DevOptionsSchema).output(DevResultSchema),
226
241
  start: oc
@@ -266,6 +281,10 @@ export const bosContract = oc.router({
266
281
  .input(UpgradeOptionsSchema)
267
282
  .output(UpgradeResultSchema),
268
283
  status: oc.route({ method: "GET", path: "/status" }).output(StatusResultSchema),
284
+ typesGen: oc
285
+ .route({ method: "POST", path: "/types/gen" })
286
+ .input(TypesGenOptionsSchema)
287
+ .output(TypesGenResultSchema),
269
288
  });
270
289
 
271
290
  export type DevOptions = z.infer<typeof DevOptionsSchema>;
@@ -289,3 +308,5 @@ export type SyncResult = z.infer<typeof SyncResultSchema>;
289
308
  export type UpgradeOptions = z.infer<typeof UpgradeOptionsSchema>;
290
309
  export type UpgradeResult = z.infer<typeof UpgradeResultSchema>;
291
310
  export type StatusResult = z.infer<typeof StatusResultSchema>;
311
+ export type TypesGenOptions = z.infer<typeof TypesGenOptionsSchema>;
312
+ export type TypesGenResult = z.infer<typeof TypesGenResultSchema>;
@@ -1,4 +1,3 @@
1
- import { createConnection } from "node:net";
2
1
  import { Command } from "@effect/platform";
3
2
  import type { ExitCode } from "@effect/platform/CommandExecutor";
4
3
  import { Deferred, Effect, Option, Ref, Stream } from "effect";
@@ -63,26 +62,8 @@ const probeHttpOk = (url: string, timeoutMs = 400) =>
63
62
  clearTimeout(timer);
64
63
  }
65
64
  },
66
- catch: () => false,
67
- });
68
-
69
- const probeTcpOpen = (port: number, timeoutMs = 250) =>
70
- Effect.async<boolean>((resume) => {
71
- const socket = createConnection({ host: "127.0.0.1", port });
72
- const timer = setTimeout(() => {
73
- socket.destroy();
74
- resume(Effect.succeed(false));
75
- }, timeoutMs);
76
- socket.once("connect", () => {
77
- clearTimeout(timer);
78
- socket.destroy();
79
- resume(Effect.succeed(true));
80
- });
81
- socket.once("error", () => {
82
- clearTimeout(timer);
83
- resume(Effect.succeed(false));
84
- });
85
- });
65
+ catch: () => false,
66
+ });
86
67
 
87
68
  const detectStatus = (
88
69
  line: string,
package/src/plugin.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  type PublishOptions,
41
41
  type StartOptions,
42
42
  type SyncOptions,
43
+ type TypesGenOptions,
43
44
  type UpgradeOptions,
44
45
  } from "./contract";
45
46
  import { devApp, startApp } from "./dev-session";
@@ -256,8 +257,11 @@ function listPluginAttachments(config: BosConfig | null) {
256
257
  .sort((a, b) => a.key.localeCompare(b.key));
257
258
  }
258
259
 
259
- async function refreshApiContractBridge(configDir: string): Promise<void> {
260
- const refreshed = await loadConfig({ cwd: configDir, env: "development" });
260
+ async function refreshApiContractBridge(
261
+ configDir: string,
262
+ env: "development" | "production" = "development",
263
+ ): Promise<void> {
264
+ const refreshed = await loadConfig({ cwd: configDir, env });
261
265
  if (!refreshed) return;
262
266
 
263
267
  await syncApiContractBridge({
@@ -1467,6 +1471,116 @@ export default createPlugin({
1467
1471
  }
1468
1472
  }),
1469
1473
 
1474
+ typesGen: builder.typesGen.handler(async ({ input }: { input: TypesGenOptions }) => {
1475
+ try {
1476
+ const configPath = findConfigPath();
1477
+ if (!configPath) {
1478
+ return {
1479
+ status: "error" as const,
1480
+ generated: [],
1481
+ fetched: [],
1482
+ skipped: [],
1483
+ failed: [],
1484
+ error: "No bos.config.json found in current directory",
1485
+ };
1486
+ }
1487
+
1488
+ const projectDir = resolve(dirname(configPath));
1489
+ const env =
1490
+ input.env ?? (process.env.NODE_ENV === "production" ? "production" : "development");
1491
+
1492
+ const refreshed = await loadConfig({ cwd: projectDir, env });
1493
+ if (!refreshed) {
1494
+ return {
1495
+ status: "error" as const,
1496
+ generated: [],
1497
+ fetched: [],
1498
+ skipped: [],
1499
+ failed: [],
1500
+ error: "Failed to load bos.config.json",
1501
+ };
1502
+ }
1503
+
1504
+ if (input.dryRun) {
1505
+ const pluginEntries = Object.entries(refreshed.runtime.plugins ?? {});
1506
+ const fetched: string[] = [];
1507
+ const skipped: string[] = [];
1508
+
1509
+ if (refreshed.runtime.api.source !== "local") {
1510
+ fetched.push(refreshed.runtime.api.url);
1511
+ } else {
1512
+ skipped.push("api (local)");
1513
+ }
1514
+
1515
+ if (refreshed.runtime.auth) {
1516
+ if (refreshed.runtime.auth.source !== "local") {
1517
+ fetched.push(refreshed.runtime.auth.url);
1518
+ } else {
1519
+ skipped.push("auth (local)");
1520
+ }
1521
+ }
1522
+
1523
+ for (const [key, plugin] of pluginEntries) {
1524
+ if (plugin.url && plugin.source !== "local") {
1525
+ fetched.push(plugin.url);
1526
+ } else if (plugin.localPath) {
1527
+ skipped.push(`${key} (local)`);
1528
+ }
1529
+ }
1530
+
1531
+ return {
1532
+ status: "success" as const,
1533
+ generated: [
1534
+ "ui/src/api-contract.gen.ts",
1535
+ "ui/src/auth-types.gen.ts",
1536
+ "api/src/plugins-client.gen.ts",
1537
+ "api/src/auth-client.gen.ts",
1538
+ ],
1539
+ fetched,
1540
+ skipped,
1541
+ failed: [],
1542
+ source: refreshed.runtime.api.source,
1543
+ };
1544
+ }
1545
+
1546
+ const result = await syncApiContractBridge({
1547
+ configDir: projectDir,
1548
+ runtimeConfig: refreshed.runtime,
1549
+ apiBaseUrl: refreshed.runtime.api.url,
1550
+ });
1551
+
1552
+ const generated = [
1553
+ "ui/src/api-contract.gen.ts",
1554
+ "api/src/plugins-client.gen.ts",
1555
+ "api/src/auth-client.gen.ts",
1556
+ ];
1557
+ if (
1558
+ refreshed.runtime.auth &&
1559
+ (refreshed.runtime.auth.source !== "local" || refreshed.runtime.auth.localPath)
1560
+ ) {
1561
+ generated.push("ui/src/auth-types.gen.ts");
1562
+ }
1563
+
1564
+ return {
1565
+ status: "success" as const,
1566
+ generated,
1567
+ fetched: result.source === "remote" ? [refreshed.runtime.api.url] : [],
1568
+ skipped: result.source === "local" ? ["api (local)"] : [],
1569
+ failed: [],
1570
+ source: result.source,
1571
+ };
1572
+ } catch (error) {
1573
+ return {
1574
+ status: "error" as const,
1575
+ generated: [],
1576
+ fetched: [],
1577
+ skipped: [],
1578
+ failed: [],
1579
+ error: error instanceof Error ? error.message : "Unknown error",
1580
+ };
1581
+ }
1582
+ }),
1583
+
1470
1584
  status: builder.status.handler(async () => {
1471
1585
  try {
1472
1586
  const configPath = findConfigPath();
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { dirname } from "node:path";
4
- import { syncApiContractBridge } from "../api-contract";
5
- import { loadConfig } from "../config";
6
-
7
- async function main() {
8
- const result = await loadConfig({ cwd: process.cwd(), env: "development" });
9
- if (!result) {
10
- throw new Error("No bos.config.json found");
11
- }
12
-
13
- const configDir = dirname(result.source.path);
14
- await syncApiContractBridge({
15
- configDir,
16
- runtimeConfig: result.runtime,
17
- apiBaseUrl: result.runtime.api.url,
18
- });
19
- }
20
-
21
- main().catch((error) => {
22
- console.error("[sync-api-contract]", error instanceof Error ? error.message : String(error));
23
- process.exit(1);
24
- });