@usecontextlayer/cli 0.11.1 → 0.11.3

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/dist/cli.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { cp } from "node:fs/promises";
2
3
  import { EventEmitter, addAbortListener, on, once, setMaxListeners } from "node:events";
3
4
  import childProcess, { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
4
5
  import path from "node:path";
@@ -12348,9 +12349,12 @@ function superRefine(fn, params) {
12348
12349
  //#region env.ts
12349
12350
  const env = object({ CTX_PLATFORM_URL: url().default("http://localhost:3010") }).parse(process.env);
12350
12351
  //#endregion
12352
+ //#region package.json
12353
+ var version = "0.11.3";
12354
+ //#endregion
12351
12355
  //#region cli.ts
12352
- const program = new Command().name("ctx").description("ContextLayer CLI").version("0.11.1");
12353
- program.command("init <directory>").description("Create a Cloudflare React Router project, register an app, and set its immutable Git remote").action(async (directory) => {
12356
+ const program = new Command().name("ctx").description("ContextLayer CLI").version(version);
12357
+ program.command("init <directory>").description("Create a Cloudflare React Router project with local Composio tools, register an app, and set its immutable Git remote").action(async (directory) => {
12354
12358
  const result = await execa("pnpm", [
12355
12359
  "create",
12356
12360
  "cloudflare@latest",
@@ -12367,6 +12371,32 @@ program.command("init <directory>").description("Create a Cloudflare React Route
12367
12371
  });
12368
12372
  process.exitCode = result.exitCode;
12369
12373
  if (result.exitCode !== 0) return;
12374
+ await cp(new URL("./template/", import.meta.url), directory, { recursive: true });
12375
+ const configure = await execa("pnpm", [
12376
+ "config",
12377
+ "set",
12378
+ "--location=project",
12379
+ "--json",
12380
+ "minimumReleaseAgeExclude",
12381
+ "[\"@usecontextlayer/*\"]"
12382
+ ], {
12383
+ cwd: directory,
12384
+ reject: false,
12385
+ stdio: "inherit"
12386
+ });
12387
+ process.exitCode = configure.exitCode;
12388
+ if (configure.exitCode !== 0) return;
12389
+ const install = await execa("pnpm", [
12390
+ "add",
12391
+ `@usecontextlayer/tools@${version}`,
12392
+ "zod@^4.4.3"
12393
+ ], {
12394
+ cwd: directory,
12395
+ reject: false,
12396
+ stdio: "inherit"
12397
+ });
12398
+ process.exitCode = install.exitCode;
12399
+ if (install.exitCode !== 0) return;
12370
12400
  const response = await fetch(new URL("/api/apps", env.CTX_PLATFORM_URL), { method: "POST" });
12371
12401
  if (!response.ok) throw new Error(`App creation failed: HTTP ${response.status}`);
12372
12402
  const app = object({
@@ -0,0 +1,26 @@
1
+ import { cloudflare } from "@cloudflare/vite-plugin"
2
+ import { reactRouter } from "@react-router/dev/vite"
3
+ import tailwindcss from "@tailwindcss/vite"
4
+ import { defineConfig } from "vite"
5
+
6
+ export default defineConfig(({ command }) => ({
7
+ plugins: [
8
+ cloudflare({
9
+ auxiliaryWorkers: [
10
+ { configPath: "workers/local-tools/wrangler.jsonc", devOnly: true },
11
+ ],
12
+ config:
13
+ command === "serve"
14
+ ? {
15
+ services: [
16
+ { binding: "TOOLS", entrypoint: "Tools", service: "ctx-local-tools" },
17
+ ],
18
+ }
19
+ : {},
20
+ viteEnvironment: { name: "ssr" },
21
+ }),
22
+ tailwindcss(),
23
+ reactRouter(),
24
+ ],
25
+ resolve: { tsconfigPaths: true },
26
+ }))
@@ -0,0 +1,19 @@
1
+ import { type Tools, toolsContext } from "@usecontextlayer/tools"
2
+ import { createRequestHandler, RouterContextProvider } from "react-router"
3
+
4
+ const requestHandler = createRequestHandler(
5
+ () => import("virtual:react-router/server-build"),
6
+ import.meta.env.MODE,
7
+ )
8
+
9
+ export default {
10
+ async fetch(
11
+ request: Request,
12
+ env: Env & { TOOLS: Tools },
13
+ ctx: ExecutionContext<{ tools: Tools }>,
14
+ ) {
15
+ const context = new RouterContextProvider()
16
+ context.set(toolsContext, import.meta.env.DEV ? env.TOOLS : ctx.props.tools)
17
+ return requestHandler(request, context)
18
+ },
19
+ }
@@ -0,0 +1 @@
1
+ COMPOSIO_CONSUMER_KEY=
@@ -0,0 +1 @@
1
+ export { Tools } from "@usecontextlayer/tools/local"
@@ -0,0 +1,5 @@
1
+ {
2
+ "compatibility_date": "2026-09-26",
3
+ "main": "index.ts",
4
+ "name": "ctx-local-tools"
5
+ }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "name": "@usecontextlayer/cli",
20
20
  "type": "module",
21
- "version": "0.11.1",
21
+ "version": "0.11.3",
22
22
  "scripts": {
23
23
  "build": "tsdown",
24
24
  "dev:watch": "tsdown --watch",