@kalphq/cli 0.0.0-dev-20260508015934 โ†’ 0.0.0-dev-20260508023853

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/index.js CHANGED
@@ -8,7 +8,7 @@ import pc from "picocolors";
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@kalphq/cli",
11
- version: "0.0.0-dev-20260508015934",
11
+ version: "0.0.0-dev-20260508023853",
12
12
  description: "Zero-config CLI for deploying Kalp agents",
13
13
  type: "module",
14
14
  license: "MIT",
@@ -85,7 +85,7 @@ var main = defineCommand({
85
85
  },
86
86
  subCommands: {
87
87
  create: () => import("./create-QTVTQ6QL.js").then((r) => r.default),
88
- push: () => import("./push-MBVDHUCT.js").then((r) => r.default),
88
+ push: () => import("./push-AR5R7BS6.js").then((r) => r.default),
89
89
  link: () => import("./link-WZQSR2TM.js").then((r) => r.default),
90
90
  secrets: () => import("./secrets-KFMVBKJQ.js").then((r) => r.default),
91
91
  login: () => import("./login-JYPWGL6P.js").then((r) => r.default),
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import { defineCommand, runMain } from \"citty\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport pkg from \"../package.json\";\n\nconst LOGO = \"๐Ÿฆ‹\";\n\nconst COMMANDS = [\n [\"create\", \"Add a new agent\"],\n [\"push\", \"Push agent to Kalp\"],\n [\"link\", \"Link project to Kalp cloud\"],\n [\"secrets\", \"Manage secrets\"],\n [\"login\", \"Authenticate with Kalp\"],\n [\"logout\", \"Sign out from Kalp\"],\n] as const;\n\nfunction printHelp(): void {\n p.log.info(`${pc.bold(\"Usage\")}: kalp <command> [options]`);\n console.log(\"\");\n p.log.info(pc.bold(\"Commands\"));\n\n for (const [name, desc] of COMMANDS) {\n console.log(` ${pc.cyan(name.padEnd(10))}${desc}`);\n }\n\n console.log(\"\");\n p.log.info(`Run ${pc.cyan(\"kalp <command> --help\")} for more info.`);\n}\n\nconst main = defineCommand({\n meta: {\n name: \"kalp\",\n version: pkg.version,\n description: \"๐Ÿฆ‹ Zero-config agent infrastructure\",\n },\n args: {\n help: {\n type: \"boolean\",\n alias: \"h\",\n description: \"Show help\",\n default: false,\n },\n },\n subCommands: {\n create: () => import(\"./commands/create\").then((r) => r.default),\n push: () => import(\"./commands/push\").then((r) => r.default),\n link: () => import(\"./commands/link\").then((r) => r.default),\n secrets: () => import(\"./commands/secrets\").then((r) => r.default),\n login: () => import(\"./commands/login\").then((r) => r.default),\n logout: () => import(\"./commands/logout\").then((r) => r.default),\n },\n run({ args }) {\n const firstArg = process.argv[2];\n\n if (args.help) {\n p.intro(`${LOGO} ${pc.bold(\"kalp\")}`);\n printHelp();\n p.outro(\"Happy coding ๐Ÿฆ‹\");\n return;\n }\n\n if (firstArg) {\n return;\n }\n\n p.intro(`${LOGO} ${pc.bold(\"kalp\")}`);\n printHelp();\n p.outro(\"Happy coding ๐Ÿฆ‹\");\n },\n});\n\nrunMain(main);\n","{\n \"name\": \"@kalphq/cli\",\n \"version\": \"0.0.0-dev-20260508015934\",\n \"description\": \"Zero-config CLI for deploying Kalp agents\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Kalp HQ\",\n \"bin\": {\n \"kalp\": \"./dist/index.js\"\n },\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm build\"\n },\n \"dependencies\": {\n \"@antfu/ni\": \"24.4.0\",\n \"@clack/prompts\": \"0.9.1\",\n \"@kalphq/compiler\": \"workspace:*\",\n \"@kalphq/project\": \"workspace:*\",\n \"@kalphq/sdk\": \"workspace:*\",\n \"citty\": \"0.1.6\",\n \"esbuild\": \"0.25.0\",\n \"json-stable-stringify\": \"1.3.0\",\n \"picocolors\": \"1.1.1\",\n \"zod\": \"3.25.76\"\n },\n \"devDependencies\": {\n \"@types/json-stable-stringify\": \"1.2.0\",\n \"@types/node\": \"^22.15.3\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.0.0\"\n }\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,eAAe;AACvC,YAAY,OAAO;AACnB,OAAO,QAAQ;;;ACFf;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,QAAU;AAAA,EACV,KAAO;AAAA,IACL,MAAQ;AAAA,EACV;AAAA,EACA,MAAQ;AAAA,EACR,OAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,gBAAkB;AAAA,EACpB;AAAA,EACA,cAAgB;AAAA,IACd,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,mBAAmB;AAAA,IACnB,eAAe;AAAA,IACf,OAAS;AAAA,IACT,SAAW;AAAA,IACX,yBAAyB;AAAA,IACzB,YAAc;AAAA,IACd,KAAO;AAAA,EACT;AAAA,EACA,iBAAmB;AAAA,IACjB,gCAAgC;AAAA,IAChC,eAAe;AAAA,IACf,MAAQ;AAAA,IACR,YAAc;AAAA,EAChB;AACF;;;ADpCA,IAAM,OAAO;AAEb,IAAM,WAAW;AAAA,EACf,CAAC,UAAU,iBAAiB;AAAA,EAC5B,CAAC,QAAQ,oBAAoB;AAAA,EAC7B,CAAC,QAAQ,4BAA4B;AAAA,EACrC,CAAC,WAAW,gBAAgB;AAAA,EAC5B,CAAC,SAAS,wBAAwB;AAAA,EAClC,CAAC,UAAU,oBAAoB;AACjC;AAEA,SAAS,YAAkB;AACzB,EAAE,MAAI,KAAK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ACpC,gBAAU;AACV,MAAE,QAAM,wBAAiB;AACzB;AAAA,IACF;AAEA,QAAI,UAAU;AACZ;AAAA,IACF;AAEA,IAAE,QAAM,GAAG,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,EAAE;AACpC,cAAU;AACV,IAAE,QAAM,wBAAiB;AAAA,EAC3B;AACF,CAAC;AAED,QAAQ,IAAI;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import { defineCommand, runMain } from \"citty\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport pkg from \"../package.json\";\n\nconst LOGO = \"๐Ÿฆ‹\";\n\nconst COMMANDS = [\n [\"create\", \"Add a new agent\"],\n [\"push\", \"Push agent to Kalp\"],\n [\"link\", \"Link project to Kalp cloud\"],\n [\"secrets\", \"Manage secrets\"],\n [\"login\", \"Authenticate with Kalp\"],\n [\"logout\", \"Sign out from Kalp\"],\n] as const;\n\nfunction printHelp(): void {\n p.log.info(`${pc.bold(\"Usage\")}: kalp <command> [options]`);\n console.log(\"\");\n p.log.info(pc.bold(\"Commands\"));\n\n for (const [name, desc] of COMMANDS) {\n console.log(` ${pc.cyan(name.padEnd(10))}${desc}`);\n }\n\n console.log(\"\");\n p.log.info(`Run ${pc.cyan(\"kalp <command> --help\")} for more info.`);\n}\n\nconst main = defineCommand({\n meta: {\n name: \"kalp\",\n version: pkg.version,\n description: \"๐Ÿฆ‹ Zero-config agent infrastructure\",\n },\n args: {\n help: {\n type: \"boolean\",\n alias: \"h\",\n description: \"Show help\",\n default: false,\n },\n },\n subCommands: {\n create: () => import(\"./commands/create\").then((r) => r.default),\n push: () => import(\"./commands/push\").then((r) => r.default),\n link: () => import(\"./commands/link\").then((r) => r.default),\n secrets: () => import(\"./commands/secrets\").then((r) => r.default),\n login: () => import(\"./commands/login\").then((r) => r.default),\n logout: () => import(\"./commands/logout\").then((r) => r.default),\n },\n run({ args }) {\n const firstArg = process.argv[2];\n\n if (args.help) {\n p.intro(`${LOGO} ${pc.bold(\"kalp\")}`);\n printHelp();\n p.outro(\"Happy coding ๐Ÿฆ‹\");\n return;\n }\n\n if (firstArg) {\n return;\n }\n\n p.intro(`${LOGO} ${pc.bold(\"kalp\")}`);\n printHelp();\n p.outro(\"Happy coding ๐Ÿฆ‹\");\n },\n});\n\nrunMain(main);\n","{\n \"name\": \"@kalphq/cli\",\n \"version\": \"0.0.0-dev-20260508023853\",\n \"description\": \"Zero-config CLI for deploying Kalp agents\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Kalp HQ\",\n \"bin\": {\n \"kalp\": \"./dist/index.js\"\n },\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm build\"\n },\n \"dependencies\": {\n \"@antfu/ni\": \"24.4.0\",\n \"@clack/prompts\": \"0.9.1\",\n \"@kalphq/compiler\": \"workspace:*\",\n \"@kalphq/project\": \"workspace:*\",\n \"@kalphq/sdk\": \"workspace:*\",\n \"citty\": \"0.1.6\",\n \"esbuild\": \"0.25.0\",\n \"json-stable-stringify\": \"1.3.0\",\n \"picocolors\": \"1.1.1\",\n \"zod\": \"3.25.76\"\n },\n \"devDependencies\": {\n \"@types/json-stable-stringify\": \"1.2.0\",\n \"@types/node\": \"^22.15.3\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.0.0\"\n }\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,eAAe;AACvC,YAAY,OAAO;AACnB,OAAO,QAAQ;;;ACFf;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,QAAU;AAAA,EACV,KAAO;AAAA,IACL,MAAQ;AAAA,EACV;AAAA,EACA,MAAQ;AAAA,EACR,OA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AAA,EACf;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,aAAa;AAAA,IACX,QAAQ,MAAM,OAAO,sBAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,IAC/D,MAAM,MAAM,OAAO,oBAAiB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,IAC3D,MAAM,MAAM,OAAO,oBAAiB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,IAC3D,SAAS,MAAM,OAAO,uBAAoB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,IACjE,OAAO,MAAM,OAAO,qBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,IAC7D,QAAQ,MAAM,OAAO,sBAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,EACjE;AAAA,EACA,IAAI,EAAE,KAAK,GAAG;AACZ,UAAM,WAAW,QAAQ,KAAK,CAAC;AAE/B,QAAI,KAAK,MAAM;AACb,MAAE,QAAM,GAAG,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,EAAE;AACpC,gBAAU;AACV,MAAE,QAAM,wBAAiB;AACzB;AAAA,IACF;AAEA,QAAI,UAAU;AACZ;AAAA,IACF;AAEA,IAAE,QAAM,GAAG,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,EAAE;AACpC,cAAU;AACV,IAAE,QAAM,wBAAiB;AAAA,EAC3B;AACF,CAAC;AAED,QAAQ,IAAI;","names":[]}
@@ -5,146 +5,51 @@ import {
5
5
 
6
6
  // src/commands/push.ts
7
7
  import { access as access2 } from "fs/promises";
8
- import { join as join3 } from "path";
8
+ import { join as join2 } from "path";
9
9
  import { defineCommand } from "citty";
10
10
  import * as p2 from "@clack/prompts";
11
11
  import pc from "picocolors";
12
12
 
13
13
  // src/utils/manifest/index.ts
14
- import { access, readFile as readFile2, readdir, rm as rm2, mkdtemp as mkdtemp2 } from "fs/promises";
15
- import { join as join2 } from "path";
14
+ import { access, readFile, rm, mkdtemp } from "fs/promises";
15
+ import { join } from "path";
16
16
  import { tmpdir } from "os";
17
17
  import { buildAgent } from "@kalphq/compiler";
18
18
 
19
- // src/utils/manifest/build.ts
20
- import { existsSync } from "fs";
21
- import { mkdtemp, readFile, rm } from "fs/promises";
22
- import { join, resolve } from "path";
23
- import { pathToFileURL } from "url";
24
- import { build } from "esbuild";
25
- async function getHash(payload) {
26
- const { createHash } = await import("crypto");
27
- return createHash("sha256").update(payload).digest("hex");
28
- }
29
- async function loadAgentModule(agentPath, cwd) {
30
- const tempDir = await mkdtemp(join(cwd, ".kalp-temp-"));
31
- const outFile = join(tempDir, "agent.manifest.mjs");
32
- await build({
33
- entryPoints: [agentPath],
34
- outfile: outFile,
35
- bundle: true,
36
- format: "esm",
37
- platform: "node",
38
- target: "node18",
39
- logLevel: "silent",
40
- packages: "external",
41
- plugins: [
42
- {
43
- name: "relative-js-to-ts",
44
- setup(buildCtx) {
45
- buildCtx.onResolve({ filter: /^\.\/.*\.js$/ }, (args) => {
46
- const resolved = resolve(args.resolveDir, args.path);
47
- if (existsSync(resolved)) {
48
- return { path: resolved };
49
- }
50
- const tsPath = resolved.replace(/\.js$/, ".ts");
51
- if (existsSync(tsPath)) {
52
- return { path: tsPath };
53
- }
54
- const tsxPath = resolved.replace(/\.js$/, ".tsx");
55
- if (existsSync(tsxPath)) {
56
- return { path: tsxPath };
57
- }
58
- return null;
59
- });
60
- }
61
- },
62
- {
63
- name: "tsconfig-paths",
64
- setup(buildCtx) {
65
- buildCtx.onResolve({ filter: /^@\// }, (args) => {
66
- const withoutPrefix = args.path.replace(/^@\//, "");
67
- const resolved = resolve(cwd, withoutPrefix);
68
- if (existsSync(resolved)) {
69
- return { path: resolved };
70
- }
71
- const tsPath = resolved + ".ts";
72
- if (existsSync(tsPath)) {
73
- return { path: tsPath };
74
- }
75
- const tsxPath = resolved + ".tsx";
76
- if (existsSync(tsxPath)) {
77
- return { path: tsxPath };
78
- }
79
- const indexTsPath = join(resolved, "index.ts");
80
- if (existsSync(indexTsPath)) {
81
- return { path: indexTsPath };
82
- }
83
- return null;
84
- });
85
- }
86
- }
87
- ]
88
- });
89
- const loaded = await import(`${pathToFileURL(outFile).href}?t=${Date.now()}`);
90
- const bundledCode = await readFile(outFile, "utf-8");
91
- const codeHash = await getHash(bundledCode);
92
- return {
93
- agent: loaded.default,
94
- tempDir,
95
- codeHash
96
- };
97
- }
98
- async function cleanupTempDir(tempDir) {
99
- await rm(tempDir, { recursive: true, force: true });
100
- }
101
-
102
19
  // src/utils/ir/hashIR.ts
103
20
  import { calculateAgentHash } from "@kalphq/compiler";
104
- function computePushHash(ir, handlers) {
21
+ function computePushHash(ir) {
22
+ const bundles = ir.bundles || {};
23
+ const handlers = Object.keys(bundles).reduce(
24
+ (acc, hash) => ({
25
+ ...acc,
26
+ [hash]: { hash }
27
+ }),
28
+ {}
29
+ );
105
30
  return calculateAgentHash(ir, handlers);
106
31
  }
107
32
 
108
33
  // src/utils/manifest/index.ts
109
34
  async function readAgentManifest(params) {
110
35
  const { cwd, agentName } = params;
111
- const agentPath = join2(cwd, "agents", agentName, "index.ts");
36
+ const agentPath = join(cwd, "agents", agentName, "index.ts");
112
37
  await access(agentPath);
113
- const tempOutDir = await mkdtemp2(join2(tmpdir(), "kalp-build-"));
38
+ const tempOutDir = await mkdtemp(join(tmpdir(), "kalp-build-"));
114
39
  try {
115
40
  await buildAgent(agentPath, tempOutDir, cwd);
116
- const irContent = await readFile2(join2(tempOutDir, "ir.json"), "utf-8");
41
+ const irContent = await readFile(join(tempOutDir, "ir.json"), "utf-8");
117
42
  const ir = JSON.parse(irContent);
118
- const handlersDir = join2(tempOutDir, "handlers");
119
- const handlerFiles = await readdir(handlersDir);
120
- const handlers = {};
121
- for (const file of handlerFiles) {
122
- if (!file.endsWith(".js")) continue;
123
- const code = await readFile2(join2(handlersDir, file), "utf-8");
124
- const parts = file.split(".");
125
- const hash = parts[1] || "no-hash";
126
- handlers[file] = {
127
- name: file,
128
- code,
129
- hash,
130
- size: Buffer.byteLength(code)
131
- };
132
- }
133
- const loaded = await loadAgentModule(agentPath, cwd);
134
- const codeHash = loaded.codeHash;
135
- await cleanupTempDir(loaded.tempDir);
136
43
  return {
137
44
  format: "kalp-agent-manifest",
138
- schemaVersion: 2,
139
- codeHash,
45
+ schemaVersion: 3,
140
46
  ir,
141
- handlers,
142
47
  metadata: {
143
48
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
144
49
  }
145
50
  };
146
51
  } finally {
147
- await rm2(tempOutDir, { recursive: true, force: true });
52
+ await rm(tempOutDir, { recursive: true, force: true });
148
53
  }
149
54
  }
150
55
 
@@ -250,7 +155,7 @@ var push_default = defineCommand({
250
155
  p2.log.error(`${pc.cyan("kalp.config.ts")} not found`);
251
156
  process.exit(1);
252
157
  }
253
- const agentPath = join3(cwd, "agents", agentName, "index.ts");
158
+ const agentPath = join2(cwd, "agents", agentName, "index.ts");
254
159
  try {
255
160
  await access2(agentPath);
256
161
  } catch {
@@ -260,10 +165,10 @@ var push_default = defineCommand({
260
165
  const s = p2.spinner();
261
166
  s.start(`Compiling ${pc.cyan(agentName)}`);
262
167
  const manifest = await readAgentManifest({ cwd, agentName });
263
- const hash = computePushHash(manifest.ir, manifest.handlers);
264
- s.stop(
265
- `Compiled ${pc.cyan(agentName)} \u2014 ${Object.keys(manifest.handlers).length} handlers`
266
- );
168
+ const bundles = manifest.ir.bundles || {};
169
+ const handlerCount = Object.keys(bundles).length;
170
+ const hash = computePushHash(manifest.ir);
171
+ s.stop(`Compiled ${pc.cyan(agentName)} \u2014 ${handlerCount} handlers`);
267
172
  s.start(`Checking for changes`);
268
173
  const statusResponse = await fetch(
269
174
  `http://localhost:3000/api/agents/${agentName}/status`
@@ -285,8 +190,7 @@ var push_default = defineCommand({
285
190
  body: JSON.stringify({
286
191
  agentName,
287
192
  ir: manifest.ir,
288
- hash,
289
- bundle: { handlers: manifest.handlers }
193
+ hash
290
194
  })
291
195
  });
292
196
  const body = await response.json().catch(() => null);
@@ -298,8 +202,17 @@ var push_default = defineCommand({
298
202
  printPushError(phase, errors, blockers);
299
203
  process.exit(1);
300
204
  }
205
+ const displayHandlers = Object.entries(bundles).reduce(
206
+ (acc, [hash2, bundle]) => ({
207
+ ...acc,
208
+ [hash2]: {
209
+ size: Buffer.byteLength(bundle.code)
210
+ }
211
+ }),
212
+ {}
213
+ );
301
214
  s.stop(pc.green("Pushed successfully"));
302
- printPushResult(agentName, hash, manifest.handlers);
215
+ printPushResult(agentName, hash, displayHandlers);
303
216
  const dashboardUrl = `http://localhost:3000/a/${agentName}`;
304
217
  p2.outro(`${LOGO} ${pc.green("Agent live at")} ${pc.cyan(dashboardUrl)}`);
305
218
  process.exit(0);
@@ -308,4 +221,4 @@ var push_default = defineCommand({
308
221
  export {
309
222
  push_default as default
310
223
  };
311
- //# sourceMappingURL=push-MBVDHUCT.js.map
224
+ //# sourceMappingURL=push-AR5R7BS6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/push.ts","../src/utils/manifest/index.ts","../src/utils/ir/hashIR.ts","../src/utils/issues.ts"],"sourcesContent":["import { access } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { ensureConfig } from \"@/utils/fs\";\nimport { readAgentManifest, computePushHash } from \"@/utils/manifest\";\nimport { renderLegacyError } from \"@/utils/issues\";\n\nconst LOGO = \"๐Ÿฆ‹\";\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n return `${(bytes / 1024).toFixed(1)} KB`;\n}\n\nfunction printPushResult(\n agentName: string,\n hash: string,\n handlers: Record<string, { size: number }>,\n) {\n const div = pc.dim(\"โ”€\".repeat(48));\n const handlerCount = Object.keys(handlers).length;\n const totalSize = Object.values(handlers).reduce((sum, h) => sum + h.size, 0);\n\n console.log(\"\\n\" + div);\n console.log(pc.green(\"โœ” Deployed\"));\n console.log(\"\");\n console.log(` ${pc.bold(agentName)} ${pc.dim(hash.slice(0, 7))}...`);\n console.log(\n ` ${pc.dim(String(handlerCount))} handlers ยท ${formatBytes(totalSize)}`,\n );\n console.log(div + \"\\n\");\n}\n\nfunction printPushError(\n phase: string,\n errors: string[],\n blockers?: string[],\n verbose?: boolean,\n) {\n const div = pc.dim(\"โ”€\".repeat(48));\n console.log(\"\\n\" + div);\n\n for (const e of errors) {\n console.log(renderLegacyError(e, verbose));\n console.log(\"\");\n }\n\n if (phase === \"analysis\" && blockers) {\n for (const b of blockers) {\n console.log(pc.red(`โœ˜ Blocker: ${b}`));\n }\n }\n\n if (!verbose) {\n console.log(pc.dim(`\\nRun with --verbose for more details.\\n`));\n }\n\n console.log(div + \"\\n\");\n}\n\nexport default defineCommand({\n meta: { name: \"push\", description: \"Push agent to Kalp cloud\" },\n args: {\n agent: {\n type: \"string\",\n alias: \"a\",\n description: \"Agent name to push\",\n required: false,\n },\n verbose: {\n type: \"boolean\",\n alias: \"v\",\n description: \"Show debug information\",\n default: false,\n },\n },\n async run({ args }) {\n const cwd = process.cwd();\n const agentName = args.agent;\n\n p.intro(`${LOGO} ${pc.bold(\"kalp push\")}`);\n\n if (!agentName) {\n p.log.error(`Missing required flag ${pc.cyan(\"-a <agent-name>\")}`);\n process.exit(1);\n }\n\n try {\n await ensureConfig(cwd);\n } catch {\n p.log.error(`${pc.cyan(\"kalp.config.ts\")} not found`);\n process.exit(1);\n }\n\n const agentPath = join(cwd, \"agents\", agentName, \"index.ts\");\n try {\n await access(agentPath);\n } catch {\n p.log.error(`Agent ${pc.cyan(agentName)} not found`);\n process.exit(1);\n }\n\n const s = p.spinner();\n s.start(`Compiling ${pc.cyan(agentName)}`);\n\n const manifest = await readAgentManifest({ cwd, agentName });\n\n const bundles = (manifest.ir.bundles || {}) as Record<\n string,\n { code: string }\n >;\n const handlerCount = Object.keys(bundles).length;\n\n const hash = computePushHash(manifest.ir);\n\n s.stop(`Compiled ${pc.cyan(agentName)} โ€” ${handlerCount} handlers`);\n\n s.start(`Checking for changes`);\n\n const statusResponse = await fetch(\n `http://localhost:3000/api/agents/${agentName}/status`,\n );\n\n const statusData = (await statusResponse.json().catch(() => null)) as {\n agentName: string;\n hash?: string;\n exists: boolean;\n } | null;\n\n if (statusData?.exists && statusData.hash === hash) {\n s.stop(pc.green(\"No changes detected\"));\n p.note(\n `Agent ${pc.cyan(agentName)} is already deployed with the same logic.`,\n \"Skipped\",\n );\n p.outro(`${LOGO} ${pc.green(\"No deployment needed\")}`);\n return;\n }\n\n s.start(`Pushing to cloud`);\n\n const response = await fetch(`http://localhost:3000/api/agents/push`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n agentName,\n ir: manifest.ir,\n hash,\n }),\n });\n\n const body = (await response.json().catch(() => null)) as Record<\n string,\n unknown\n > | null;\n\n if (!response.ok) {\n s.stop(pc.red(\"Push failed\"));\n const phase = (body?.phase as string) ?? \"unknown\";\n const errors = (body?.errors as string[]) ?? [`HTTP ${response.status}`];\n const blockers = body?.blockers as string[] | undefined;\n printPushError(phase, errors, blockers);\n process.exit(1);\n }\n\n const displayHandlers = Object.entries(bundles).reduce(\n (acc, [hash, bundle]) => ({\n ...acc,\n [hash]: {\n size: Buffer.byteLength(bundle.code),\n },\n }),\n {} as Record<string, { size: number }>,\n );\n\n s.stop(pc.green(\"Pushed successfully\"));\n printPushResult(agentName, hash, displayHandlers);\n\n const dashboardUrl = `http://localhost:3000/a/${agentName}`;\n p.outro(`${LOGO} ${pc.green(\"Agent live at\")} ${pc.cyan(dashboardUrl)}`);\n\n process.exit(0);\n },\n});\n","import { access, readFile, rm, mkdtemp } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\nimport { buildAgent } from \"@kalphq/compiler\";\n\nimport type { AgentManifestV3 } from \"@/utils/manifest/types\";\nexport type { AgentManifestV3 } from \"@/utils/manifest/types\";\nexport { computePushHash } from \"@/utils/ir/hashIR\";\n\n/**\n * Reads and compiles an agent into a pushable manifest.\n */\nexport async function readAgentManifest(params: {\n cwd: string;\n agentName: string;\n}): Promise<AgentManifestV3> {\n const { cwd, agentName } = params;\n const agentPath = join(cwd, \"agents\", agentName, \"index.ts\");\n await access(agentPath);\n\n // Use a temporary directory for the compiler output\n const tempOutDir = await mkdtemp(join(tmpdir(), \"kalp-build-\"));\n\n try {\n // Build the agent - compiler produces ir.bundles with all handler code\n await buildAgent(agentPath, tempOutDir, cwd);\n\n // Load the IR generated by the compiler (includes bundles with code)\n const irContent = await readFile(join(tempOutDir, \"ir.json\"), \"utf-8\");\n const ir = JSON.parse(irContent);\n\n return {\n format: \"kalp-agent-manifest\",\n schemaVersion: 3,\n ir,\n metadata: {\n generatedAt: new Date().toISOString(),\n },\n };\n } finally {\n // Cleanup temp build directory\n await rm(tempOutDir, { recursive: true, force: true });\n }\n}\n","import type { IRGraph } from \"@kalphq/sdk\";\nimport { calculateAgentHash } from \"@kalphq/compiler\";\n\nexport function getIRHash(ir: IRGraph): string {\n const { calculateIRHash } = require(\"@kalphq/compiler\");\n return calculateIRHash(ir);\n}\n\nexport function computePushHash(\n ir: IRGraph & { bundles?: Record<string, { code: string }> },\n): string {\n const bundles = ir.bundles || {};\n const handlers = Object.keys(bundles).reduce(\n (acc, hash) => ({\n ...acc,\n [hash]: { hash },\n }),\n {} as Record<string, { hash: string }>,\n );\n\n return calculateAgentHash(ir, handlers);\n}\n","import p from \"picocolors\";\n\n/**\n * Severity level for a validation issue.\n */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A structured validation issue found during agent analysis or compilation.\n */\nexport interface ValidationIssue {\n severity: Severity;\n message: string;\n context?: string;\n location?: string;\n fix?: string;\n debug?: string;\n}\n\ninterface RenderOptions {\n format?: \"pretty\" | \"json\" | \"minimal\";\n showDebug?: boolean;\n}\n\nconst severityIcons: Record<Severity, string> = {\n error: p.red(\"โœ˜\"),\n warning: p.yellow(\"โš \"),\n info: p.blue(\"โ„น\"),\n};\n\nconst severityLabels: Record<Severity, string> = {\n error: p.red(\"Error\"),\n warning: p.yellow(\"Warning\"),\n info: p.blue(\"Info\"),\n};\n\nfunction groupByContext(\n issues: ValidationIssue[],\n): Map<string, ValidationIssue[]> {\n const groups = new Map<string, ValidationIssue[]>();\n\n for (const issue of issues) {\n const context = issue.context ?? \"General\";\n const existing = groups.get(context) ?? [];\n existing.push(issue);\n groups.set(context, existing);\n }\n\n return groups;\n}\n\nfunction renderPrettyIssue(issue: ValidationIssue, showDebug: boolean): string {\n const lines: string[] = [];\n\n // Header with icon, severity label, and message\n lines.push(\n `${severityIcons[issue.severity]} ${severityLabels[issue.severity]}: ${p.bold(issue.message)}`,\n );\n\n // Context (location in code)\n if (issue.context) {\n lines.push(p.dim(` Found in: ${issue.context}`));\n }\n if (issue.location) {\n lines.push(p.dim(` Location: ${issue.location}`));\n }\n\n // Empty line before fix\n lines.push(\"\");\n\n // Fix section\n if (issue.fix) {\n lines.push(p.green(\" Fix:\"));\n const fixLines = issue.fix.split(\"\\n\");\n for (const fixLine of fixLines) {\n lines.push(` ${fixLine}`);\n }\n }\n\n // Debug info (optional)\n if (showDebug && issue.debug) {\n lines.push(\"\");\n lines.push(p.dim(` (debug: ${issue.debug})`));\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction renderGroupedIssues(\n issues: ValidationIssue[],\n showDebug: boolean,\n): string {\n const groups = groupByContext(issues);\n const output: string[] = [];\n\n for (const [context, contextIssues] of groups) {\n // Context header\n output.push(p.cyan(p.bold(`โ†’ ${context}`)));\n output.push(\"\");\n\n // Issues in this context\n for (const issue of contextIssues) {\n output.push(renderPrettyIssue(issue, showDebug));\n output.push(\"\"); // Empty line between issues\n }\n }\n\n return output.join(\"\\n\");\n}\n\nfunction renderMinimalIssue(issue: ValidationIssue): string {\n const icon =\n issue.severity === \"error\" ? \"โœ˜\" : issue.severity === \"warning\" ? \"โš \" : \"โ„น\";\n const context = issue.context ? ` [${issue.context}]` : \"\";\n return `${icon} ${issue.message}${context}`;\n}\n\nexport function renderIssues(\n issues: ValidationIssue[],\n options: RenderOptions = {},\n): string {\n const { format = \"pretty\", showDebug = false } = options;\n\n if (issues.length === 0) {\n return p.green(\"โœ“ No issues found\");\n }\n\n // Sort by severity: errors first, then warnings, then info\n const sorted = [...issues].sort((a, b) => {\n const severityOrder: Record<Severity, number> = {\n error: 0,\n warning: 1,\n info: 2,\n };\n return severityOrder[a.severity]! - severityOrder[b.severity]!;\n });\n\n switch (format) {\n case \"json\":\n return JSON.stringify(sorted, null, 2);\n\n case \"minimal\":\n return sorted.map(renderMinimalIssue).join(\"\\n\");\n\n case \"pretty\":\n default: {\n const output: string[] = [];\n\n // Summary header\n const errorCount = issues.filter((i) => i.severity === \"error\").length;\n const warningCount = issues.filter(\n (i) => i.severity === \"warning\",\n ).length;\n const infoCount = issues.filter((i) => i.severity === \"info\").length;\n\n if (errorCount > 0) {\n output.push(\n p.red(\n p.bold(`Found ${errorCount} error${errorCount > 1 ? \"s\" : \"\"}`),\n ),\n );\n }\n if (warningCount > 0) {\n output.push(\n p.yellow(`${warningCount} warning${warningCount > 1 ? \"s\" : \"\"}`),\n );\n }\n if (infoCount > 0) {\n output.push(p.blue(`${infoCount} info`));\n }\n output.push(\"\");\n\n // Grouped issues\n output.push(renderGroupedIssues(sorted, showDebug));\n\n return output.join(\"\\n\");\n }\n }\n}\n\n// Render legacy error strings in DX-first format\nexport function renderLegacyError(\n error: string,\n showDebug: boolean = true,\n): string {\n const lines: string[] = [];\n\n // Extract debug info if present\n const debugMatch = error.match(/\\(debug: (.+)\\)$/);\n const debug = debugMatch ? debugMatch[1] : undefined;\n const mainError = debugMatch\n ? error.replace(/\\(debug: .+\\)$/, \"\").trim()\n : error;\n\n lines.push(p.red(p.bold(`โœ˜ ${mainError.split(\"\\n\")[0]}`)));\n\n // Show fix if present in the error\n const fixMatch = mainError.match(/Fix:\\n((?:- .+\\n?)+)/);\n if (fixMatch) {\n lines.push(\"\");\n lines.push(p.green(\" Fix:\"));\n const fixLines = fixMatch[1]?.split(\"\\n\").filter(Boolean) ?? [];\n for (const line of fixLines) {\n lines.push(` ${line.replace(/^- /, \"\")}`);\n }\n }\n\n if (showDebug && debug) {\n lines.push(\"\");\n lines.push(p.dim(` (debug: ${debug})`));\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;AAAA,SAAS,UAAAA,eAAc;AACvB,SAAS,QAAAC,aAAY;AACrB,SAAS,qBAAqB;AAC9B,YAAYC,QAAO;AACnB,OAAO,QAAQ;;;ACJf,SAAS,QAAQ,UAAU,IAAI,eAAe;AAC9C,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,kBAAkB;;;ACF3B,SAAS,0BAA0B;AAO5B,SAAS,gBACd,IACQ;AACR,QAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,QAAM,WAAW,OAAO,KAAK,OAAO,EAAE;AAAA,IACpC,CAAC,KAAK,UAAU;AAAA,MACd,GAAG;AAAA,MACH,CAAC,IAAI,GAAG,EAAE,KAAK;AAAA,IACjB;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,mBAAmB,IAAI,QAAQ;AACxC;;;ADTA,eAAsB,kBAAkB,QAGX;AAC3B,QAAM,EAAE,KAAK,UAAU,IAAI;AAC3B,QAAM,YAAY,KAAK,KAAK,UAAU,WAAW,UAAU;AAC3D,QAAM,OAAO,SAAS;AAGtB,QAAM,aAAa,MAAM,QAAQ,KAAK,OAAO,GAAG,aAAa,CAAC;AAE9D,MAAI;AAEF,UAAM,WAAW,WAAW,YAAY,GAAG;AAG3C,UAAM,YAAY,MAAM,SAAS,KAAK,YAAY,SAAS,GAAG,OAAO;AACrE,UAAM,KAAK,KAAK,MAAM,SAAS;AAE/B,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,eAAe;AAAA,MAC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AC;AAAA,IACH;AAEA,MAAE,KAAK,GAAG,MAAM,qBAAqB,CAAC;AACtC,oBAAgB,WAAW,MAAM,eAAe;AAEhD,UAAM,eAAe,2BAA2B,SAAS;AACzD,IAAE,SAAM,GAAG,IAAI,IAAI,GAAG,MAAM,eAAe,CAAC,IAAI,GAAG,KAAK,YAAY,CAAC,EAAE;AAEvE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;","names":["access","join","p","join","access","hash"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalphq/cli",
3
- "version": "0.0.0-dev-20260508015934",
3
+ "version": "0.0.0-dev-20260508023853",
4
4
  "description": "Zero-config CLI for deploying Kalp agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "json-stable-stringify": "1.3.0",
24
24
  "picocolors": "1.1.1",
25
25
  "zod": "3.25.76",
26
- "@kalphq/sdk": "0.0.0-dev-20260508015934",
27
- "@kalphq/compiler": "0.0.0-dev-20260508015934",
28
- "@kalphq/project": "0.0.0-dev-20260508015934"
26
+ "@kalphq/compiler": "0.0.0-dev-20260508023853",
27
+ "@kalphq/project": "0.0.0-dev-20260508023853",
28
+ "@kalphq/sdk": "0.0.0-dev-20260508023853"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/json-stable-stringify": "1.2.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/push.ts","../src/utils/manifest/index.ts","../src/utils/manifest/build.ts","../src/utils/ir/hashIR.ts","../src/utils/issues.ts"],"sourcesContent":["import { access } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { ensureConfig } from \"@/utils/fs\";\nimport { readAgentManifest, computePushHash } from \"@/utils/manifest\";\nimport { renderLegacyError } from \"@/utils/issues\";\n\nconst LOGO = \"๐Ÿฆ‹\";\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n return `${(bytes / 1024).toFixed(1)} KB`;\n}\n\nfunction printPushResult(\n agentName: string,\n hash: string,\n handlers: Record<string, { size: number }>,\n) {\n const div = pc.dim(\"โ”€\".repeat(48));\n const handlerCount = Object.keys(handlers).length;\n const totalSize = Object.values(handlers).reduce((sum, h) => sum + h.size, 0);\n\n console.log(\"\\n\" + div);\n console.log(pc.green(\"โœ” Deployed\"));\n console.log(\"\");\n console.log(` ${pc.bold(agentName)} ${pc.dim(hash.slice(0, 7))}...`);\n console.log(\n ` ${pc.dim(String(handlerCount))} handlers ยท ${formatBytes(totalSize)}`,\n );\n console.log(div + \"\\n\");\n}\n\nfunction printPushError(\n phase: string,\n errors: string[],\n blockers?: string[],\n verbose?: boolean,\n) {\n const div = pc.dim(\"โ”€\".repeat(48));\n console.log(\"\\n\" + div);\n\n // Use DX-first rendering for all errors\n for (const e of errors) {\n console.log(renderLegacyError(e, verbose));\n console.log(\"\"); // Empty line between errors\n }\n\n if (phase === \"analysis\" && blockers) {\n for (const b of blockers) {\n console.log(pc.red(`โœ˜ Blocker: ${b}`));\n }\n }\n\n if (!verbose) {\n console.log(pc.dim(`\\nRun with --verbose for more details.\\n`));\n }\n\n console.log(div + \"\\n\");\n}\n\nexport default defineCommand({\n meta: { name: \"push\", description: \"Push agent to Kalp cloud\" },\n args: {\n agent: {\n type: \"string\",\n alias: \"a\",\n description: \"Agent name to push\",\n required: false,\n },\n verbose: {\n type: \"boolean\",\n alias: \"v\",\n description: \"Show debug information\",\n default: false,\n },\n },\n async run({ args }) {\n const cwd = process.cwd();\n const agentName = args.agent;\n\n p.intro(`${LOGO} ${pc.bold(\"kalp push\")}`);\n\n if (!agentName) {\n p.log.error(`Missing required flag ${pc.cyan(\"-a <agent-name>\")}`);\n process.exit(1);\n }\n\n try {\n await ensureConfig(cwd);\n } catch {\n p.log.error(`${pc.cyan(\"kalp.config.ts\")} not found`);\n process.exit(1);\n }\n\n const agentPath = join(cwd, \"agents\", agentName, \"index.ts\");\n try {\n await access(agentPath);\n } catch {\n p.log.error(`Agent ${pc.cyan(agentName)} not found`);\n process.exit(1);\n }\n\n const s = p.spinner();\n s.start(`Compiling ${pc.cyan(agentName)}`);\n\n const manifest = await readAgentManifest({ cwd, agentName });\n const hash = computePushHash(manifest.ir, manifest.handlers);\n\n s.stop(\n `Compiled ${pc.cyan(agentName)} โ€” ${Object.keys(manifest.handlers).length} handlers`,\n );\n\n // Pre-flight check: query Cloud for current agent status\n s.start(`Checking for changes`);\n const statusResponse = await fetch(\n `http://localhost:3000/api/agents/${agentName}/status`,\n );\n const statusData = (await statusResponse.json().catch(() => null)) as {\n agentName: string;\n hash?: string;\n exists: boolean;\n } | null;\n\n if (statusData?.exists && statusData.hash === hash) {\n s.stop(pc.green(\"No changes detected\"));\n p.note(\n `Agent ${pc.cyan(agentName)} is already deployed with the same logic.`,\n \"Skipped\",\n );\n p.outro(`${LOGO} ${pc.green(\"No deployment needed\")}`);\n return;\n }\n\n s.start(`Pushing to cloud`);\n\n const response = await fetch(`http://localhost:3000/api/agents/push`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n agentName,\n ir: manifest.ir,\n hash,\n bundle: { handlers: manifest.handlers },\n }),\n });\n\n const body = (await response.json().catch(() => null)) as Record<\n string,\n unknown\n > | null;\n\n if (!response.ok) {\n s.stop(pc.red(\"Push failed\"));\n const phase = (body?.phase as string) ?? \"unknown\";\n const errors = (body?.errors as string[]) ?? [`HTTP ${response.status}`];\n const blockers = body?.blockers as string[] | undefined;\n printPushError(phase, errors, blockers);\n process.exit(1);\n }\n\n s.stop(pc.green(\"Pushed successfully\"));\n printPushResult(agentName, hash, manifest.handlers);\n\n const dashboardUrl = `http://localhost:3000/a/${agentName}`;\n p.outro(`${LOGO} ${pc.green(\"Agent live at\")} ${pc.cyan(dashboardUrl)}`);\n\n process.exit(0);\n },\n});\n","// packages/cli/src/utils/manifest/index.ts\nimport { access, readFile, readdir, rm, mkdtemp } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\nimport { buildAgent } from \"@kalphq/compiler\";\nimport { loadAgentModule, cleanupTempDir } from \"@/utils/manifest/build\";\nimport type { AgentManifestV2 } from \"@/utils/manifest/types\";\n\nexport type {\n AgentManifestV2,\n LoadedAgentModule,\n} from \"@/utils/manifest/types\";\nexport type { HandlerMap, HandlerEntry } from \"@/utils/manifest/handlers\";\nexport { computePushHash } from \"@/utils/ir/hashIR\";\n\n/**\n * Reads and compiles an agent into a pushable manifest.\n */\nexport async function readAgentManifest(params: {\n cwd: string;\n agentName: string;\n}): Promise<AgentManifestV2> {\n const { cwd, agentName } = params;\n const agentPath = join(cwd, \"agents\", agentName, \"index.ts\");\n await access(agentPath);\n\n // Use a temporary directory for the compiler output\n const tempOutDir = await mkdtemp(join(tmpdir(), \"kalp-build-\"));\n\n try {\n // 1. Build the agent using the official compiler pipeline\n await buildAgent(agentPath, tempOutDir, cwd);\n\n // 2. Load the IR generated by the compiler\n const irContent = await readFile(join(tempOutDir, \"ir.json\"), \"utf-8\");\n const ir = JSON.parse(irContent);\n\n // 3. Collect bundled handlers\n const handlersDir = join(tempOutDir, \"handlers\");\n const handlerFiles = await readdir(handlersDir);\n const handlers: any = {};\n\n for (const file of handlerFiles) {\n if (!file.endsWith(\".js\")) continue;\n const code = await readFile(join(handlersDir, file), \"utf-8\");\n\n // Filename format: name.hash.js\n const parts = file.split(\".\");\n const hash = parts[1] || \"no-hash\";\n\n handlers[file] = {\n name: file,\n code,\n hash,\n size: Buffer.byteLength(code),\n };\n }\n\n // 4. Also load the module to get the codeHash (for legacy reasons)\n const loaded = await loadAgentModule(agentPath, cwd);\n const codeHash = loaded.codeHash;\n await cleanupTempDir(loaded.tempDir);\n\n return {\n format: \"kalp-agent-manifest\",\n schemaVersion: 2,\n codeHash,\n ir,\n handlers,\n metadata: {\n generatedAt: new Date().toISOString(),\n },\n };\n } finally {\n // Cleanup temp build directory\n await rm(tempOutDir, { recursive: true, force: true });\n }\n}\n","import { existsSync } from \"node:fs\";\nimport { mkdtemp, readFile, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { build } from \"esbuild\";\nimport type { LoadedAgentModule } from \"@/utils/manifest/types\";\n\nasync function getHash(payload: string): Promise<string> {\n const { createHash } = await import(\"node:crypto\");\n return createHash(\"sha256\").update(payload).digest(\"hex\");\n}\n\nexport async function loadAgentModule(\n agentPath: string,\n cwd: string,\n): Promise<LoadedAgentModule> {\n const tempDir = await mkdtemp(join(cwd, \".kalp-temp-\"));\n const outFile = join(tempDir, \"agent.manifest.mjs\");\n\n await build({\n entryPoints: [agentPath],\n outfile: outFile,\n bundle: true,\n format: \"esm\",\n platform: \"node\",\n target: \"node18\",\n logLevel: \"silent\",\n packages: \"external\",\n plugins: [\n {\n name: \"relative-js-to-ts\",\n setup(buildCtx) {\n buildCtx.onResolve({ filter: /^\\.\\/.*\\.js$/ }, (args) => {\n const resolved = resolve(args.resolveDir, args.path);\n if (existsSync(resolved)) {\n return { path: resolved };\n }\n\n const tsPath = resolved.replace(/\\.js$/, \".ts\");\n if (existsSync(tsPath)) {\n return { path: tsPath };\n }\n\n const tsxPath = resolved.replace(/\\.js$/, \".tsx\");\n if (existsSync(tsxPath)) {\n return { path: tsxPath };\n }\n\n return null;\n });\n },\n },\n {\n name: \"tsconfig-paths\",\n setup(buildCtx) {\n buildCtx.onResolve({ filter: /^@\\// }, (args) => {\n const withoutPrefix = args.path.replace(/^@\\//, \"\");\n const resolved = resolve(cwd, withoutPrefix);\n\n if (existsSync(resolved)) {\n return { path: resolved };\n }\n\n const tsPath = resolved + \".ts\";\n if (existsSync(tsPath)) {\n return { path: tsPath };\n }\n\n const tsxPath = resolved + \".tsx\";\n if (existsSync(tsxPath)) {\n return { path: tsxPath };\n }\n\n const indexTsPath = join(resolved, \"index.ts\");\n if (existsSync(indexTsPath)) {\n return { path: indexTsPath };\n }\n\n return null;\n });\n },\n },\n ],\n });\n\n const loaded = (await import(\n `${pathToFileURL(outFile).href}?t=${Date.now()}`\n )) as { default?: unknown };\n\n const bundledCode = await readFile(outFile, \"utf-8\");\n const codeHash = await getHash(bundledCode);\n\n return {\n agent: loaded.default,\n tempDir,\n codeHash,\n };\n}\n\nexport async function cleanupTempDir(tempDir: string): Promise<void> {\n await rm(tempDir, { recursive: true, force: true });\n}\n","import type { IRGraph } from \"@kalphq/sdk\";\nimport { calculateAgentHash } from \"@kalphq/compiler\";\nimport type { HandlerMap } from \"@/utils/manifest/handlers\";\n\nexport function getIRHash(ir: IRGraph): string {\n // Delegate to compiler's calculateIRHash for consistency\n const { calculateIRHash } = require(\"@kalphq/compiler\");\n return calculateIRHash(ir);\n}\n\nexport function computePushHash(ir: IRGraph, handlers: HandlerMap): string {\n // Use unified hash function from compiler for consistency with Cloud\n return calculateAgentHash(ir, handlers);\n}\n","import p from \"picocolors\";\n\n/**\n * Severity level for a validation issue.\n */\nexport type Severity = \"error\" | \"warning\" | \"info\";\n\n/**\n * A structured validation issue found during agent analysis or compilation.\n */\nexport interface ValidationIssue {\n severity: Severity;\n message: string;\n context?: string;\n location?: string;\n fix?: string;\n debug?: string;\n}\n\ninterface RenderOptions {\n format?: \"pretty\" | \"json\" | \"minimal\";\n showDebug?: boolean;\n}\n\nconst severityIcons: Record<Severity, string> = {\n error: p.red(\"โœ˜\"),\n warning: p.yellow(\"โš \"),\n info: p.blue(\"โ„น\"),\n};\n\nconst severityLabels: Record<Severity, string> = {\n error: p.red(\"Error\"),\n warning: p.yellow(\"Warning\"),\n info: p.blue(\"Info\"),\n};\n\nfunction groupByContext(\n issues: ValidationIssue[],\n): Map<string, ValidationIssue[]> {\n const groups = new Map<string, ValidationIssue[]>();\n\n for (const issue of issues) {\n const context = issue.context ?? \"General\";\n const existing = groups.get(context) ?? [];\n existing.push(issue);\n groups.set(context, existing);\n }\n\n return groups;\n}\n\nfunction renderPrettyIssue(issue: ValidationIssue, showDebug: boolean): string {\n const lines: string[] = [];\n\n // Header with icon, severity label, and message\n lines.push(\n `${severityIcons[issue.severity]} ${severityLabels[issue.severity]}: ${p.bold(issue.message)}`,\n );\n\n // Context (location in code)\n if (issue.context) {\n lines.push(p.dim(` Found in: ${issue.context}`));\n }\n if (issue.location) {\n lines.push(p.dim(` Location: ${issue.location}`));\n }\n\n // Empty line before fix\n lines.push(\"\");\n\n // Fix section\n if (issue.fix) {\n lines.push(p.green(\" Fix:\"));\n const fixLines = issue.fix.split(\"\\n\");\n for (const fixLine of fixLines) {\n lines.push(` ${fixLine}`);\n }\n }\n\n // Debug info (optional)\n if (showDebug && issue.debug) {\n lines.push(\"\");\n lines.push(p.dim(` (debug: ${issue.debug})`));\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction renderGroupedIssues(\n issues: ValidationIssue[],\n showDebug: boolean,\n): string {\n const groups = groupByContext(issues);\n const output: string[] = [];\n\n for (const [context, contextIssues] of groups) {\n // Context header\n output.push(p.cyan(p.bold(`โ†’ ${context}`)));\n output.push(\"\");\n\n // Issues in this context\n for (const issue of contextIssues) {\n output.push(renderPrettyIssue(issue, showDebug));\n output.push(\"\"); // Empty line between issues\n }\n }\n\n return output.join(\"\\n\");\n}\n\nfunction renderMinimalIssue(issue: ValidationIssue): string {\n const icon =\n issue.severity === \"error\" ? \"โœ˜\" : issue.severity === \"warning\" ? \"โš \" : \"โ„น\";\n const context = issue.context ? ` [${issue.context}]` : \"\";\n return `${icon} ${issue.message}${context}`;\n}\n\nexport function renderIssues(\n issues: ValidationIssue[],\n options: RenderOptions = {},\n): string {\n const { format = \"pretty\", showDebug = false } = options;\n\n if (issues.length === 0) {\n return p.green(\"โœ“ No issues found\");\n }\n\n // Sort by severity: errors first, then warnings, then info\n const sorted = [...issues].sort((a, b) => {\n const severityOrder: Record<Severity, number> = {\n error: 0,\n warning: 1,\n info: 2,\n };\n return severityOrder[a.severity]! - severityOrder[b.severity]!;\n });\n\n switch (format) {\n case \"json\":\n return JSON.stringify(sorted, null, 2);\n\n case \"minimal\":\n return sorted.map(renderMinimalIssue).join(\"\\n\");\n\n case \"pretty\":\n default: {\n const output: string[] = [];\n\n // Summary header\n const errorCount = issues.filter((i) => i.severity === \"error\").length;\n const warningCount = issues.filter(\n (i) => i.severity === \"warning\",\n ).length;\n const infoCount = issues.filter((i) => i.severity === \"info\").length;\n\n if (errorCount > 0) {\n output.push(\n p.red(\n p.bold(`Found ${errorCount} error${errorCount > 1 ? \"s\" : \"\"}`),\n ),\n );\n }\n if (warningCount > 0) {\n output.push(\n p.yellow(`${warningCount} warning${warningCount > 1 ? \"s\" : \"\"}`),\n );\n }\n if (infoCount > 0) {\n output.push(p.blue(`${infoCount} info`));\n }\n output.push(\"\");\n\n // Grouped issues\n output.push(renderGroupedIssues(sorted, showDebug));\n\n return output.join(\"\\n\");\n }\n }\n}\n\n// Render legacy error strings in DX-first format\nexport function renderLegacyError(\n error: string,\n showDebug: boolean = true,\n): string {\n const lines: string[] = [];\n\n // Extract debug info if present\n const debugMatch = error.match(/\\(debug: (.+)\\)$/);\n const debug = debugMatch ? debugMatch[1] : undefined;\n const mainError = debugMatch\n ? error.replace(/\\(debug: .+\\)$/, \"\").trim()\n : error;\n\n lines.push(p.red(p.bold(`โœ˜ ${mainError.split(\"\\n\")[0]}`)));\n\n // Show fix if present in the error\n const fixMatch = mainError.match(/Fix:\\n((?:- .+\\n?)+)/);\n if (fixMatch) {\n lines.push(\"\");\n lines.push(p.green(\" Fix:\"));\n const fixLines = fixMatch[1]?.split(\"\\n\").filter(Boolean) ?? [];\n for (const line of fixLines) {\n lines.push(` ${line.replace(/^- /, \"\")}`);\n }\n }\n\n if (showDebug && debug) {\n lines.push(\"\");\n lines.push(p.dim(` (debug: ${debug})`));\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;AAAA,SAAS,UAAAA,eAAc;AACvB,SAAS,QAAAC,aAAY;AACrB,SAAS,qBAAqB;AAC9B,YAAYC,QAAO;AAC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