@kody-ade/kody-engine 0.4.223 → 0.4.224

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.
@@ -0,0 +1,17 @@
1
+ # NPM Publish
2
+
3
+ ## Purpose
4
+
5
+ Publish current `package.json` version to npm from the repository CI sandbox.
6
+
7
+ ## Requirements
8
+
9
+ - Store npm automation token as `NPM_TOKEN` in `.kody/secrets.enc`.
10
+ - Kody must load that secret into the `NPM_TOKEN` environment variable before the executable runs.
11
+ - The executable must not read or decrypt `.kody/secrets.enc` directly.
12
+ - Run only after version in `package.json` is ready to publish.
13
+
14
+ ## Instructions
15
+
16
+ Use the `npm-publish` executable for the implementation details.
17
+ The duty owns the public action name and the reason this action exists; the executable owns the method.
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "npm-publish",
3
+ "action": "npm-publish",
4
+ "executable": "npm-publish",
5
+ "describe": "Publish the current package.json version to npm."
6
+ }
File without changes
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "npm-publish",
3
+ "role": "utility",
4
+ "phase": "shipped",
5
+ "describe": "Publish the current package.json version to npm using NPM_TOKEN. No agent.",
6
+ "inputs": [
7
+ {
8
+ "name": "dry-run",
9
+ "flag": "--dry-run",
10
+ "type": "bool",
11
+ "required": false,
12
+ "describe": "Print the publish plan without requiring NPM_TOKEN or publishing."
13
+ },
14
+ {
15
+ "name": "tag",
16
+ "flag": "--tag",
17
+ "type": "string",
18
+ "required": false,
19
+ "describe": "npm dist-tag to publish under. Defaults to latest."
20
+ },
21
+ {
22
+ "name": "access",
23
+ "flag": "--access",
24
+ "type": "enum",
25
+ "values": ["public", "restricted"],
26
+ "required": false,
27
+ "describe": "npm package access. Defaults to public."
28
+ },
29
+ {
30
+ "name": "issue",
31
+ "flag": "--issue",
32
+ "type": "int",
33
+ "required": false,
34
+ "describe": "Issue/PR number to post terminal notice on."
35
+ }
36
+ ],
37
+ "claudeCode": {
38
+ "model": "inherit",
39
+ "permissionMode": "acceptEdits",
40
+ "maxTurns": 0,
41
+ "maxThinkingTokens": null,
42
+ "systemPromptAppend": null,
43
+ "tools": [],
44
+ "hooks": [],
45
+ "skills": [],
46
+ "commands": [],
47
+ "subagents": [],
48
+ "plugins": [],
49
+ "mcpServers": []
50
+ },
51
+ "cliTools": [],
52
+ "inputArtifacts": [],
53
+ "outputArtifacts": [],
54
+ "scripts": {
55
+ "preflight": [
56
+ { "script": "setCommentTarget", "with": { "type": "issue" } },
57
+ { "script": "loadTaskState" },
58
+ { "shell": "publish.sh", "timeoutSec": 900 },
59
+ { "script": "skipAgent" }
60
+ ],
61
+ "postflight": [
62
+ { "script": "recordOutcome" },
63
+ { "script": "saveTaskState" },
64
+ { "script": "notifyTerminal", "with": { "label": "npm publish" } }
65
+ ]
66
+ },
67
+ "output": {
68
+ "actionTypes": [
69
+ "NPM_PUBLISH_COMPLETED",
70
+ "NPM_PUBLISH_FAILED"
71
+ ]
72
+ }
73
+ }
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # npm-publish: publish the current package.json version to npm.
4
+ #
5
+ # Secrets:
6
+ # - NPM_TOKEN must be present in the environment.
7
+ # Kody loads secrets before executables run; this script must not read or
8
+ # decrypt .kody/secrets.enc directly.
9
+ #
10
+ # Inputs:
11
+ # - KODY_ARG_DRY_RUN true|false
12
+ # - KODY_ARG_TAG npm dist-tag, default latest
13
+ # - KODY_ARG_ACCESS public|restricted, default public
14
+ #
15
+ # Stdout markers:
16
+ # - KODY_REASON=<text>
17
+ # - KODY_SKIP_AGENT=true
18
+
19
+ set -euo pipefail
20
+
21
+ dry_run="${KODY_ARG_DRY_RUN:-false}"
22
+ tag="${KODY_ARG_TAG:-latest}"
23
+ access="${KODY_ARG_ACCESS:-public}"
24
+ registry="${NPM_CONFIG_REGISTRY:-https://registry.npmjs.org/}"
25
+
26
+ fail() {
27
+ echo "KODY_REASON=$1"
28
+ echo "KODY_SKIP_AGENT=true"
29
+ exit "${2:-1}"
30
+ }
31
+
32
+ json_eval() {
33
+ node -e "$1"
34
+ }
35
+
36
+ [[ -f package.json ]] || fail "npm publish: package.json not found" 99
37
+
38
+ pkg_name="$(json_eval "const p=require('./package.json'); if(!p.name) process.exit(1); console.log(p.name)")" \
39
+ || fail "npm publish: package.json missing name" 99
40
+ pkg_version="$(json_eval "const p=require('./package.json'); if(!p.version) process.exit(1); console.log(p.version)")" \
41
+ || fail "npm publish: package.json missing version" 99
42
+
43
+ if [[ "$access" != "public" && "$access" != "restricted" ]]; then
44
+ fail "npm publish: --access must be public or restricted" 64
45
+ fi
46
+
47
+ echo "→ npm publish: ${pkg_name}@${pkg_version} tag=${tag} access=${access}"
48
+
49
+ if [[ "$dry_run" == "true" ]]; then
50
+ echo "KODY_REASON=dry-run — would publish ${pkg_name}@${pkg_version} to npm with tag ${tag}"
51
+ echo "KODY_SKIP_AGENT=true"
52
+ exit 0
53
+ fi
54
+
55
+ [[ -n "${NPM_TOKEN:-}" ]] || fail "npm publish: missing NPM_TOKEN secret" 64
56
+
57
+ tmp_npmrc="$(mktemp)"
58
+ auth_host="${registry#http://}"
59
+ auth_host="${auth_host#https://}"
60
+ auth_host="${auth_host%/}"
61
+ cleanup() {
62
+ rm -f "$tmp_npmrc"
63
+ }
64
+ trap cleanup EXIT
65
+
66
+ chmod 600 "$tmp_npmrc"
67
+ printf '%s\n' "registry=${registry}" >"$tmp_npmrc"
68
+ printf '%s\n' "//${auth_host}/:_authToken=${NPM_TOKEN}" >>"$tmp_npmrc"
69
+
70
+ export NODE_AUTH_TOKEN="$NPM_TOKEN"
71
+ export NPM_CONFIG_USERCONFIG="$tmp_npmrc"
72
+ export HUSKY=0
73
+ export SKIP_HOOKS=1
74
+ export CI="${CI:-1}"
75
+
76
+ if npm view "${pkg_name}@${pkg_version}" version --registry "$registry" >/dev/null 2>&1; then
77
+ echo "KODY_REASON=${pkg_name}@${pkg_version} is already published"
78
+ echo "KODY_SKIP_AGENT=true"
79
+ exit 0
80
+ fi
81
+
82
+ publish_args=(publish --access "$access" --tag "$tag" --registry "$registry")
83
+
84
+ if [[ -f pnpm-lock.yaml && -x "$(command -v pnpm)" ]]; then
85
+ echo " publish: pnpm ${publish_args[*]}"
86
+ pnpm "${publish_args[@]}"
87
+ else
88
+ echo " publish: npm ${publish_args[*]}"
89
+ npm "${publish_args[@]}"
90
+ fi
91
+
92
+ echo "KODY_REASON=published ${pkg_name}@${pkg_version} to npm with tag ${tag}"
93
+ echo "KODY_SKIP_AGENT=true"
File without changes
@@ -44,6 +44,7 @@ dry_run="${KODY_ARG_DRY_RUN:-false}"
44
44
  prefer="${KODY_ARG_PREFER:-}"
45
45
 
46
46
  default_branch="${KODY_CFG_GIT_DEFAULTBRANCH:-main}"
47
+ release_branch="${KODY_CFG_RELEASE_RELEASEBRANCH:-}"
47
48
  notify_cmd="${KODY_CFG_RELEASE_NOTIFYCOMMAND:-}"
48
49
  notify_timeout_s=$(( ${KODY_CFG_RELEASE_TIMEOUTMS:-600000} / 1000 ))
49
50
 
@@ -68,6 +69,97 @@ if [[ ! -f package.json ]]; then
68
69
  exit 1
69
70
  fi
70
71
 
72
+ read_pkg_version_from_ref() {
73
+ local ref="$1"
74
+ git show "${ref}:package.json" 2>/dev/null | node -e 'let s=""; process.stdin.on("data", c => s += c); process.stdin.on("end", () => { try { console.log(JSON.parse(s).version || "") } catch { process.exit(1) } })'
75
+ }
76
+
77
+ finish_release_with_deploy() {
78
+ local version="$1"
79
+ local tag="$2"
80
+ local release_url="${3:-}"
81
+
82
+ current_step="deploy"
83
+ set +e
84
+ deploy_pr_url=$(open_deploy_pr "$version" "$issue")
85
+ deploy_rc=$?
86
+ set -e
87
+ if [[ "$deploy_rc" -ne 0 ]]; then
88
+ echo "[release] deploy step failed (rc=${deploy_rc}) — published v${version} but ${default_branch}→${release_branch} promotion PR was not opened" >&2
89
+ echo "KODY_REASON=release v${version}: published, but ${default_branch}→${release_branch} deploy PR failed"
90
+ echo "RELEASE_TAG=${tag}"
91
+ [[ -n "$release_url" ]] && echo "RELEASE_URL=${release_url}"
92
+ echo "RELEASE_FAILED=true"
93
+ exit 1
94
+ fi
95
+ if [[ -z "$deploy_pr_url" ]]; then
96
+ echo " (deploy: no-op — single-branch repo)"
97
+ else
98
+ echo "✓ deploy: ${deploy_pr_url}"
99
+ fi
100
+
101
+ current_step="notify"
102
+ notify_status="skipped"
103
+ if [[ -n "$notify_cmd" ]]; then
104
+ cmd="${notify_cmd//\$VERSION/$version}"
105
+ cmd="${cmd//\$DEPLOY_PR_URL/${deploy_pr_url:-}}"
106
+ echo " notify: ${cmd}"
107
+ if timeout "$notify_timeout_s" bash -c "$cmd"; then
108
+ notify_status="ok"
109
+ else
110
+ notify_status="failed"
111
+ echo "[release] notifyCommand failed (non-fatal)" >&2
112
+ fi
113
+ fi
114
+
115
+ current_step="done"
116
+ [[ -n "$deploy_pr_url" ]] && echo "KODY_PR_URL=${deploy_pr_url}"
117
+ echo "RELEASE_TAG=${tag}"
118
+ [[ -n "$release_url" ]] && echo "RELEASE_URL=${release_url}"
119
+ [[ -n "$deploy_pr_url" ]] && echo "RELEASE_DEPLOY_PR=${deploy_pr_url}"
120
+ echo "KODY_REASON=release v${version} complete (notify=${notify_status})"
121
+ echo "RELEASE_COMPLETED=true"
122
+ echo "KODY_SKIP_AGENT=true"
123
+ }
124
+
125
+ resume_prepared_release_if_needed() {
126
+ [[ -n "$release_branch" && "$release_branch" != "$default_branch" ]] || return 1
127
+
128
+ current_step="resume-check"
129
+ git fetch origin "$default_branch" "$release_branch" --tags
130
+
131
+ local default_version release_version
132
+ default_version=$(read_pkg_version_from_ref "origin/${default_branch}" || echo "")
133
+ release_version=$(read_pkg_version_from_ref "origin/${release_branch}" || echo "")
134
+ [[ -n "$default_version" && -n "$release_version" ]] || return 1
135
+ [[ "$default_version" != "$release_version" ]] || return 1
136
+
137
+ local version="$default_version"
138
+ local tag="v${version}"
139
+ echo "→ release: resuming prepared ${tag}; ${default_branch} is not promoted to ${release_branch}"
140
+
141
+ current_step="publish"
142
+ git checkout "$default_branch"
143
+ git reset --hard "origin/$default_branch"
144
+
145
+ local publish_status release_url
146
+ publish_status=$(tag_and_publish "$version")
147
+ release_url=$(create_gh_release "$tag" || echo "")
148
+ echo "✓ publish: tag=${tag} status=${publish_status} release_url=${release_url:-<none>}"
149
+ if [[ "$publish_status" == "failed" ]]; then
150
+ echo "[release] publishCommand failed but tag + GH release exist" >&2
151
+ echo "KODY_REASON=tag + GH release created, but publishCommand failed"
152
+ echo "RELEASE_FAILED=true"
153
+ echo "KODY_SKIP_AGENT=true"
154
+ exit 1
155
+ fi
156
+
157
+ finish_release_with_deploy "$version" "$tag" "$release_url"
158
+ exit 0
159
+ }
160
+
161
+ resume_prepared_release_if_needed
162
+
71
163
  # ── 1. Prepare ────────────────────────────────────────────────────────────
72
164
  current_step="prepare"
73
165
  old_version=$(read_pkg_version)
@@ -134,50 +226,5 @@ if [[ "$publish_status" == "failed" ]]; then
134
226
  exit 1
135
227
  fi
136
228
 
137
- # ── 5. Deploy PR (default → release branch) ───────────────────────────────
138
- # Distinguish three outcomes: rc!=0 is a real failure (do NOT mask as no-op);
139
- # rc==0 + empty URL is a genuine single-branch no-op; rc==0 + URL is success.
140
- current_step="deploy"
141
- set +e
142
- deploy_pr_url=$(open_deploy_pr "$new_version" "$issue")
143
- deploy_rc=$?
144
- set -e
145
- release_branch="${KODY_CFG_RELEASE_RELEASEBRANCH:-}"
146
- if [[ "$deploy_rc" -ne 0 ]]; then
147
- echo "[release] deploy step failed (rc=${deploy_rc}) — published v${new_version} but the ${default_branch}→${release_branch} promotion PR was not opened" >&2
148
- echo "KODY_REASON=release v${new_version}: published, but the ${default_branch}→${release_branch} deploy PR failed"
149
- echo "RELEASE_TAG=${tag}"
150
- [[ -n "$release_url" ]] && echo "RELEASE_URL=${release_url}"
151
- echo "RELEASE_FAILED=true"
152
- exit 1
153
- fi
154
- if [[ -z "$deploy_pr_url" ]]; then
155
- echo " (deploy: no-op — single-branch repo)"
156
- else
157
- echo "✓ deploy: ${deploy_pr_url}"
158
- fi
159
-
160
- # ── 6. Notify ─────────────────────────────────────────────────────────────
161
- current_step="notify"
162
- notify_status="skipped"
163
- if [[ -n "$notify_cmd" ]]; then
164
- cmd="${notify_cmd//\$VERSION/$new_version}"
165
- cmd="${cmd//\$DEPLOY_PR_URL/${deploy_pr_url:-}}"
166
- echo " notify: ${cmd}"
167
- if timeout "$notify_timeout_s" bash -c "$cmd"; then
168
- notify_status="ok"
169
- else
170
- notify_status="failed"
171
- echo "[release] notifyCommand failed (non-fatal)" >&2
172
- fi
173
- fi
174
-
175
- # ── 7. Done ───────────────────────────────────────────────────────────────
176
- current_step="done"
177
- [[ -n "$deploy_pr_url" ]] && echo "KODY_PR_URL=${deploy_pr_url}"
178
- echo "RELEASE_TAG=${tag}"
179
- [[ -n "$release_url" ]] && echo "RELEASE_URL=${release_url}"
180
- [[ -n "$deploy_pr_url" ]] && echo "RELEASE_DEPLOY_PR=${deploy_pr_url}"
181
- echo "KODY_REASON=release v${new_version} complete (notify=${notify_status})"
182
- echo "RELEASE_COMPLETED=true"
183
- echo "KODY_SKIP_AGENT=true"
229
+ finish_release_with_deploy "$new_version" "$tag" "$release_url"
230
+ exit 0
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.4.223",
3
+ "version": "0.4.224",
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,6 +12,26 @@
12
12
  "templates",
13
13
  "kody.config.schema.json"
14
14
  ],
15
+ "scripts": {
16
+ "kody:run": "tsx bin/kody.ts",
17
+ "serve": "tsx bin/kody.ts serve",
18
+ "serve:vscode": "tsx bin/kody.ts serve vscode",
19
+ "serve:claude": "tsx bin/kody.ts serve claude",
20
+ "build": "tsup && node scripts/copy-assets.cjs",
21
+ "check:modularity": "tsx scripts/check-script-modularity.ts",
22
+ "pretest": "pnpm check:modularity",
23
+ "test": "vitest run tests/unit tests/int --coverage",
24
+ "posttest": "tsx scripts/check-coverage-floor.ts",
25
+ "test:smoke": "vitest run tests/smoke --no-coverage",
26
+ "test:e2e": "vitest run tests/e2e --no-coverage",
27
+ "test:all": "vitest run tests --no-coverage",
28
+ "typecheck": "tsc --noEmit",
29
+ "lint": "biome check",
30
+ "lint:fix": "biome check --write",
31
+ "format": "biome format --write",
32
+ "brain:publish": "docker buildx build --platform linux/amd64 -f runner/Dockerfile.brain -t ghcr.io/${KODY_BRAIN_GHCR_OWNER:-aharonyaircohen}/kody-brain:latest --push runner",
33
+ "prepublishOnly": "pnpm typecheck && vitest run tests/unit tests/int --no-coverage && pnpm build"
34
+ },
15
35
  "dependencies": {
16
36
  "@actions/cache": "^6.0.0",
17
37
  "@anthropic-ai/claude-agent-sdk": "0.2.119",
@@ -35,24 +55,5 @@
35
55
  "url": "git+https://github.com/aharonyaircohen/kody-engine.git"
36
56
  },
37
57
  "homepage": "https://github.com/aharonyaircohen/kody-engine",
38
- "bugs": "https://github.com/aharonyaircohen/kody-engine/issues",
39
- "scripts": {
40
- "kody:run": "tsx bin/kody.ts",
41
- "serve": "tsx bin/kody.ts serve",
42
- "serve:vscode": "tsx bin/kody.ts serve vscode",
43
- "serve:claude": "tsx bin/kody.ts serve claude",
44
- "build": "tsup && node scripts/copy-assets.cjs",
45
- "check:modularity": "tsx scripts/check-script-modularity.ts",
46
- "pretest": "pnpm check:modularity",
47
- "test": "vitest run tests/unit tests/int --coverage",
48
- "posttest": "tsx scripts/check-coverage-floor.ts",
49
- "test:smoke": "vitest run tests/smoke --no-coverage",
50
- "test:e2e": "vitest run tests/e2e --no-coverage",
51
- "test:all": "vitest run tests --no-coverage",
52
- "typecheck": "tsc --noEmit",
53
- "lint": "biome check",
54
- "lint:fix": "biome check --write",
55
- "format": "biome format --write",
56
- "brain:publish": "docker buildx build --platform linux/amd64 -f runner/Dockerfile.brain -t ghcr.io/${KODY_BRAIN_GHCR_OWNER:-aharonyaircohen}/kody-brain:latest --push runner"
57
- }
58
- }
58
+ "bugs": "https://github.com/aharonyaircohen/kody-engine/issues"
59
+ }