@kody-ade/kody-engine 0.3.61 → 0.3.63

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/bin/kody.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@kody-ade/kody-engine",
6
- version: "0.3.61",
6
+ version: "0.3.63",
7
7
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
8
8
  license: "MIT",
9
9
  type: "module",
@@ -586,14 +586,16 @@ async function runChatTurn(opts) {
586
586
  await emit(opts.sink, "chat.error", opts.sessionId, "error", { error });
587
587
  return { exitCode: 64, error };
588
588
  }
589
- const prompt = buildPrompt(turns, opts.systemPrompt ?? CHAT_SYSTEM_PROMPT);
589
+ const systemPrompt = opts.systemPrompt ?? CHAT_SYSTEM_PROMPT;
590
+ const prompt = buildPrompt(turns);
590
591
  const invoke = opts.invokeAgent ?? ((p) => runAgent({
591
592
  prompt: p,
592
593
  model: opts.model,
593
594
  cwd: opts.cwd,
594
595
  litellmUrl: opts.litellmUrl,
595
596
  verbose: opts.verbose,
596
- quiet: opts.quiet
597
+ quiet: opts.quiet,
598
+ systemPromptAppend: systemPrompt
597
599
  }));
598
600
  let result;
599
601
  try {
@@ -624,12 +626,9 @@ async function runChatTurn(opts) {
624
626
  await emit(opts.sink, "chat.done", opts.sessionId, "done", { sessionId: opts.sessionId });
625
627
  return { exitCode: 0, reply };
626
628
  }
627
- function buildPrompt(turns, systemPrompt) {
628
- const header = `System: ${systemPrompt}`;
629
+ function buildPrompt(turns) {
629
630
  const body = turns.map((t) => `${t.role === "user" ? "User" : "Assistant"}: ${t.content}`).join("\n\n");
630
- return `${header}
631
-
632
- ${body}
631
+ return `${body}
633
632
 
634
633
  Assistant:`;
635
634
  }
@@ -5888,6 +5887,62 @@ function tryPostPr3(prNumber, body, cwd) {
5888
5887
  }
5889
5888
  }
5890
5889
 
5890
+ // src/deployments.ts
5891
+ function findPreviewDeploymentUrl(prNumber, cwd) {
5892
+ const sha = getPrHeadSha(prNumber, cwd);
5893
+ if (!sha) return null;
5894
+ const raw = safeGh2(
5895
+ ["api", `repos/{owner}/{repo}/deployments?sha=${sha}&environment=Preview&per_page=10`],
5896
+ cwd
5897
+ );
5898
+ if (!raw) return null;
5899
+ let deployments;
5900
+ try {
5901
+ deployments = JSON.parse(raw);
5902
+ } catch {
5903
+ return null;
5904
+ }
5905
+ if (!Array.isArray(deployments) || deployments.length === 0) return null;
5906
+ for (const d of deployments) {
5907
+ const url = latestSuccessUrl(d.id, cwd);
5908
+ if (url) return url;
5909
+ }
5910
+ return null;
5911
+ }
5912
+ function getPrHeadSha(prNumber, cwd) {
5913
+ const out = safeGh2(["api", `repos/{owner}/{repo}/pulls/${prNumber}`, "--jq", ".head.sha"], cwd);
5914
+ if (!out) return null;
5915
+ const trimmed = out.trim();
5916
+ return trimmed.length > 0 ? trimmed : null;
5917
+ }
5918
+ function latestSuccessUrl(deploymentId, cwd) {
5919
+ const raw = safeGh2(
5920
+ ["api", `repos/{owner}/{repo}/deployments/${deploymentId}/statuses?per_page=10`],
5921
+ cwd
5922
+ );
5923
+ if (!raw) return null;
5924
+ let statuses;
5925
+ try {
5926
+ statuses = JSON.parse(raw);
5927
+ } catch {
5928
+ return null;
5929
+ }
5930
+ if (!Array.isArray(statuses)) return null;
5931
+ for (const s of statuses) {
5932
+ if (s.state === "success" && typeof s.environment_url === "string" && s.environment_url.length > 0) {
5933
+ return s.environment_url;
5934
+ }
5935
+ }
5936
+ return null;
5937
+ }
5938
+ function safeGh2(args, cwd) {
5939
+ try {
5940
+ return gh2(args, { cwd });
5941
+ } catch {
5942
+ return null;
5943
+ }
5944
+ }
5945
+
5891
5946
  // src/scripts/resolvePreviewUrl.ts
5892
5947
  var DEFAULT_PREVIEW_URL = "http://localhost:3000";
5893
5948
  var resolvePreviewUrl = async (ctx) => {
@@ -5903,6 +5958,15 @@ var resolvePreviewUrl = async (ctx) => {
5903
5958
  ctx.data.previewUrlSource = "env";
5904
5959
  return;
5905
5960
  }
5961
+ const prNumber = typeof ctx.args.pr === "number" ? ctx.args.pr : null;
5962
+ if (prNumber !== null) {
5963
+ const fromDeployment = findPreviewDeploymentUrl(prNumber, ctx.cwd);
5964
+ if (fromDeployment) {
5965
+ ctx.data.previewUrl = fromDeployment;
5966
+ ctx.data.previewUrlSource = "deployment";
5967
+ return;
5968
+ }
5969
+ }
5906
5970
  ctx.data.previewUrl = DEFAULT_PREVIEW_URL;
5907
5971
  ctx.data.previewUrlSource = "default";
5908
5972
  };
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.3.61",
3
+ "version": "0.3.63",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,18 +12,6 @@
12
12
  "templates",
13
13
  "kody.config.schema.json"
14
14
  ],
15
- "scripts": {
16
- "kody": "tsx bin/kody.ts",
17
- "build": "tsup && node scripts/copy-assets.cjs",
18
- "test": "vitest run tests/unit tests/int --no-coverage",
19
- "test:e2e": "vitest run tests/e2e --no-coverage",
20
- "test:all": "vitest run tests --no-coverage",
21
- "typecheck": "tsc --noEmit",
22
- "lint": "biome check",
23
- "lint:fix": "biome check --write",
24
- "format": "biome format --write",
25
- "prepublishOnly": "pnpm build"
26
- },
27
15
  "dependencies": {
28
16
  "@actions/cache": "^6.0.0",
29
17
  "@anthropic-ai/claude-agent-sdk": "0.2.119"
@@ -44,5 +32,16 @@
44
32
  "url": "git+https://github.com/aharonyaircohen/kody-engine.git"
45
33
  },
46
34
  "homepage": "https://github.com/aharonyaircohen/kody-engine",
47
- "bugs": "https://github.com/aharonyaircohen/kody-engine/issues"
48
- }
35
+ "bugs": "https://github.com/aharonyaircohen/kody-engine/issues",
36
+ "scripts": {
37
+ "kody": "tsx bin/kody.ts",
38
+ "build": "tsup && node scripts/copy-assets.cjs",
39
+ "test": "vitest run tests/unit tests/int --no-coverage",
40
+ "test:e2e": "vitest run tests/e2e --no-coverage",
41
+ "test:all": "vitest run tests --no-coverage",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "biome check",
44
+ "lint:fix": "biome check --write",
45
+ "format": "biome format --write"
46
+ }
47
+ }