@collective-intelligence/cli 0.2.16 → 0.2.18

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.
@@ -1,18 +1,17 @@
1
- import { NodePath } from "@effect/platform-node";
2
- import * as Data from "effect/Data";
3
1
  import * as Effect from "effect/Effect";
4
- import { flow } from "effect/Function";
5
2
  import * as Path from "effect/Path";
3
+ import * as Schema from "effect/Schema";
6
4
  import { fileURLToPath, pathToFileURL } from "node:url";
7
5
  import { createServer } from "vite";
6
+ import { ErrorKind } from "../errors/kind";
8
7
  import {
9
8
  workspaceSourceResolve,
10
9
  workspaceSourceSsrResolve
11
10
  } from "./workspace-source-condition";
12
11
 
13
- class PackageDeclarationError extends Data.TaggedError("PackageDeclarationError") {
12
+ class PackageDeclarationError extends Schema.TaggedError()("PackageDeclarationError", { kind: ErrorKind, message: Schema.String }) {
14
13
  }
15
- const path = Effect.runSync(Effect.provide(Path.Path, NodePath.layer)), isRecord = (value) => value !== null && typeof value === "object", isPackageDefinition = (value) => {
14
+ const isRecord = (value) => value !== null && typeof value === "object", isPackageDefinition = (value) => {
16
15
  if (!isRecord(value) || !isRecord(value.manifest))
17
16
  return !1;
18
17
  return value.manifest.apiVersion === "v4" && typeof value.manifest.fqn === "string" && Array.isArray(value.components) && (value.hostedContributions === void 0 || Array.isArray(value.hostedContributions)) && Array.isArray(value.schemaSidecars);
@@ -30,7 +29,7 @@ const path = Effect.runSync(Effect.provide(Path.Path, NodePath.layer)), isRecord
30
29
  if (entries.length !== fqns.length || !fqns.every((fqn) => Object.hasOwn(loaders, fqn)) || !entries.every(([, loader]) => isPackageLoader(loader)))
31
30
  throw TypeError(`Declaration packageLoaders must map exactly the declared packages (${fqns.join(", ")}) to lazy import functions`);
32
31
  return new Map(entries.flatMap(([fqn, loader]) => isPackageLoader(loader) ? [[fqn, loader]] : []));
33
- }, declarationSpecifier = (specifier) => {
32
+ }, declarationSpecifier = (path, specifier) => {
34
33
  if (specifier.startsWith("data:") || specifier.startsWith("file:") || specifier.startsWith("http:") || specifier.startsWith("https:") || !specifier.startsWith(".") && !specifier.startsWith("/"))
35
34
  return specifier;
36
35
  return pathToFileURL(path.resolve(process.cwd(), specifier)).href;
@@ -41,22 +40,29 @@ const path = Effect.runSync(Effect.provide(Path.Path, NodePath.layer)), isRecord
41
40
  const loaders = packageLoaderMap(loaded.packageLoaders, values);
42
41
  return values.map((definition) => normalizePackageDefinition(definition, loaders?.get(definition.manifest.fqn)));
43
42
  };
44
- export const loadPackageDeclarations = flow((specifier) => Effect.tryPromise(() => import(declarationSpecifier(specifier))).pipe(Effect.map((loaded) => isRecord(loaded) ? loaded : void 0), Effect.flatMap((loaded) => loaded === void 0 ? Effect.fail(new PackageDeclarationError({
45
- message: "Declaration module did not expose module exports"
46
- })) : Effect.succeed(normalizeModuleDeclarations(loaded)))), Effect.runPromise), loadFreshPackageDeclarations = flow((specifier) => {
47
- const resolved = declarationSpecifier(specifier);
43
+ export const loadPackageDeclarations = (specifier) => Effect.gen(function* loadPackageDeclarationsEffect() {
44
+ const path = yield* Path.Path, loaded = yield* Effect.tryPromise(() => import(declarationSpecifier(path, specifier)));
45
+ if (!isRecord(loaded))
46
+ return yield* new PackageDeclarationError({
47
+ kind: "terminal",
48
+ message: "Declaration module did not expose module exports"
49
+ });
50
+ return normalizeModuleDeclarations(loaded);
51
+ }), loadFreshPackageDeclarations = (specifier) => Effect.gen(function* loadFreshPackageDeclarationsEffect() {
52
+ const path = yield* Path.Path, resolved = declarationSpecifier(path, specifier);
48
53
  if (!resolved.startsWith("file:"))
49
- return Effect.promise(() => loadPackageDeclarations(resolved));
50
- const sourcePath = fileURLToPath(resolved), root = path.dirname(sourcePath);
51
- return Effect.acquireUseRelease(Effect.tryPromise(() => createServer({
54
+ return yield* loadPackageDeclarations(resolved);
55
+ const sourcePath = fileURLToPath(resolved);
56
+ return yield* Effect.acquireUseRelease(Effect.tryPromise(() => createServer({
52
57
  appType: "custom",
53
58
  configFile: !1,
54
59
  logLevel: "silent",
55
60
  resolve: workspaceSourceResolve(process.execArgv),
56
- root,
61
+ root: path.dirname(sourcePath),
57
62
  server: { middlewareMode: !0 },
58
63
  ssr: workspaceSourceSsrResolve(process.execArgv)
59
64
  })), (server) => Effect.tryPromise(() => server.ssrLoadModule(`/${encodeURIComponent(path.basename(sourcePath))}`)).pipe(Effect.flatMap((loaded) => isRecord(loaded) ? Effect.succeed(normalizeModuleDeclarations(loaded)) : Effect.fail(new PackageDeclarationError({
65
+ kind: "terminal",
60
66
  message: "Declaration module did not expose module exports"
61
67
  })))), (server) => Effect.promise(() => server.close()));
62
- }, Effect.runPromise);
68
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collective-intelligence/cli",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Distributable command-line tooling for Collective Intelligence Extension Packages.",
5
5
  "type": "module",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "ci": "./dist/cli.js"
11
11
  },
12
12
  "dependencies": {
13
- "@collective-intelligence/extensions-sdk-backend": "0.2.7",
13
+ "@collective-intelligence/extensions-sdk-backend": "0.2.8",
14
14
  "@module-federation/vite": "1.23.2",
15
15
  "@vitejs/plugin-react": "6.0.5",
16
16
  "acorn": "8.18.0",
@@ -32,17 +32,18 @@
32
32
  "type-check": "bun check"
33
33
  },
34
34
  "devDependencies": {
35
- "@collective-intelligence/extensions-sdk": "0.2.6",
36
- "@collective-intelligence/schema-codegen": "0.1.27",
35
+ "@collective-intelligence/extensions-sdk": "0.2.7",
36
+ "@collective-intelligence/schema-codegen": "0.1.28",
37
37
  "@effect/eslint-plugin": "latest",
38
- "@effect/platform-node": "4.1.0",
39
- "@effect/vitest": "4.1.0",
38
+ "@effect/platform-bun": "4.1.2",
39
+ "@effect/platform-node": "4.1.2",
40
+ "@effect/vitest": "4.1.2",
40
41
  "@jridgewell/trace-mapping": "0.3.31",
41
42
  "@oxlint/plugins": "1.90.0",
42
43
  "@types/bun": "1.4.2",
43
44
  "@types/react": "^19.2.14",
44
45
  "@typescript-eslint/utils": "8.22.0",
45
- "effect": "4.1.0",
46
+ "effect": "4.1.2",
46
47
  "eslint": "9.39.5",
47
48
  "eslint-plugin-react-you-might-not-need-an-effect": "1.0.2",
48
49
  "oxfmt": "0.66.0",
@@ -53,5 +54,5 @@
53
54
  "ultracite": "7.10.7",
54
55
  "vitest": "5.0.2"
55
56
  },
56
- "gitHead": "9def61f4fcbe540b36924ae462da89a97a43a4f8"
57
+ "gitHead": "b2a4e19aabe96ba0b9285a911f59d40d1d111a4d"
57
58
  }