@kody-ade/kody-engine-lite 0.1.96 → 0.1.98
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/cli.js +11 -14
- package/package.json +1 -1
- package/templates/kody.yml +46 -1
package/dist/bin/cli.js
CHANGED
|
@@ -444,8 +444,8 @@ function ensureFeatureBranch(issueNumber, title, cwd) {
|
|
|
444
444
|
logger.info(` Created new branch: ${branchName}`);
|
|
445
445
|
return branchName;
|
|
446
446
|
}
|
|
447
|
-
function syncWithDefault(cwd) {
|
|
448
|
-
const defaultBranch = getDefaultBranch(cwd);
|
|
447
|
+
function syncWithDefault(cwd, branch) {
|
|
448
|
+
const defaultBranch = branch ?? getDefaultBranch(cwd);
|
|
449
449
|
const current = getCurrentBranch(cwd);
|
|
450
450
|
if (current === defaultBranch) return;
|
|
451
451
|
try {
|
|
@@ -566,14 +566,6 @@ function getIssue(issueNumber) {
|
|
|
566
566
|
return null;
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
function closeIssue(issueNumber) {
|
|
570
|
-
try {
|
|
571
|
-
gh(["issue", "close", String(issueNumber)]);
|
|
572
|
-
logger.info(` Issue #${issueNumber} closed`);
|
|
573
|
-
} catch (err) {
|
|
574
|
-
logger.warn(` Failed to close issue #${issueNumber}: ${err}`);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
569
|
function getIssueLabels(issueNumber) {
|
|
578
570
|
try {
|
|
579
571
|
const output = gh(["issue", "view", String(issueNumber), "--json", "labels", "--jq", ".labels[].name"]);
|
|
@@ -2549,9 +2541,6 @@ PR #${existingPr.number}
|
|
|
2549
2541
|
postComment(ctx.input.issueNumber, `\u{1F389} PR created: ${pr.url}`);
|
|
2550
2542
|
} catch {
|
|
2551
2543
|
}
|
|
2552
|
-
if (ctx.input.issueNumber !== ctx.input.prNumber) {
|
|
2553
|
-
closeIssue(ctx.input.issueNumber);
|
|
2554
|
-
}
|
|
2555
2544
|
}
|
|
2556
2545
|
fs12.writeFileSync(shipPath, `# Ship
|
|
2557
2546
|
|
|
@@ -3184,7 +3173,7 @@ function ensureFeatureBranchIfNeeded(ctx) {
|
|
|
3184
3173
|
if (ctx.input.dryRun) return;
|
|
3185
3174
|
if (ctx.input.prNumber) {
|
|
3186
3175
|
try {
|
|
3187
|
-
syncWithDefault(ctx.projectDir);
|
|
3176
|
+
syncWithDefault(ctx.projectDir, ctx.input.prBaseBranch);
|
|
3188
3177
|
} catch (err) {
|
|
3189
3178
|
logger.warn(` Failed to sync with default branch: ${err}`);
|
|
3190
3179
|
}
|
|
@@ -4218,6 +4207,13 @@ ${input.feedback}`);
|
|
|
4218
4207
|
console.error(`Runner "${defaultRunnerName}" health check failed`);
|
|
4219
4208
|
process.exit(1);
|
|
4220
4209
|
}
|
|
4210
|
+
let prBaseBranch;
|
|
4211
|
+
if (input.prNumber) {
|
|
4212
|
+
const prDetails = getPRDetails(input.prNumber);
|
|
4213
|
+
if (prDetails) {
|
|
4214
|
+
prBaseBranch = prDetails.baseBranch;
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4221
4217
|
const ctx = {
|
|
4222
4218
|
taskId,
|
|
4223
4219
|
taskDir,
|
|
@@ -4229,6 +4225,7 @@ ${input.feedback}`);
|
|
|
4229
4225
|
dryRun: input.dryRun,
|
|
4230
4226
|
issueNumber: input.issueNumber,
|
|
4231
4227
|
prNumber: input.prNumber,
|
|
4228
|
+
prBaseBranch,
|
|
4232
4229
|
feedback: input.feedback,
|
|
4233
4230
|
local: input.local,
|
|
4234
4231
|
complexity: input.complexity
|
package/package.json
CHANGED
package/templates/kody.yml
CHANGED
|
@@ -25,6 +25,9 @@ on:
|
|
|
25
25
|
issue_comment:
|
|
26
26
|
types: [created]
|
|
27
27
|
|
|
28
|
+
pull_request:
|
|
29
|
+
types: [closed]
|
|
30
|
+
|
|
28
31
|
pull_request_review:
|
|
29
32
|
types: [submitted]
|
|
30
33
|
|
|
@@ -113,7 +116,10 @@ jobs:
|
|
|
113
116
|
esac
|
|
114
117
|
FROM_STAGE=$(echo "$KODY_ARGS" | grep -oP '(?<=--from )\S+' || echo "")
|
|
115
118
|
FEEDBACK=$(echo "$KODY_ARGS" | grep -oP '(?<=--feedback ")[^"]*' || echo "")
|
|
116
|
-
COMPLEXITY
|
|
119
|
+
COMPLEXITY=""
|
|
120
|
+
if echo "$KODY_ARGS" | grep -q -- '--complexity'; then
|
|
121
|
+
COMPLEXITY=$(echo "$KODY_ARGS" | tr ' ' '\n' | grep -A1 -- '--complexity' | tail -1)
|
|
122
|
+
fi
|
|
117
123
|
DRY_RUN="false"
|
|
118
124
|
if echo "$KODY_ARGS" | grep -q -- '--dry-run'; then
|
|
119
125
|
DRY_RUN="true"
|
|
@@ -330,6 +336,45 @@ jobs:
|
|
|
330
336
|
path: .kody/tasks/
|
|
331
337
|
retention-days: 3
|
|
332
338
|
|
|
339
|
+
# ─── Close Issue on PR Merge ────────────────────────────────────────────────
|
|
340
|
+
close-issue-on-merge:
|
|
341
|
+
if: >-
|
|
342
|
+
github.event_name == 'pull_request' &&
|
|
343
|
+
github.event.pull_request.merged == true
|
|
344
|
+
runs-on: ubuntu-latest
|
|
345
|
+
steps:
|
|
346
|
+
- name: Close linked issue
|
|
347
|
+
uses: actions/github-script@v7
|
|
348
|
+
with:
|
|
349
|
+
script: |
|
|
350
|
+
// Extract issue number from branch name (e.g. "42--feature-name")
|
|
351
|
+
const branch = context.payload.pull_request.head.ref;
|
|
352
|
+
const match = branch.match(/^(\d+)--/);
|
|
353
|
+
if (!match) return;
|
|
354
|
+
const issueNumber = parseInt(match[1], 10);
|
|
355
|
+
|
|
356
|
+
// Verify the issue exists and is open
|
|
357
|
+
try {
|
|
358
|
+
const { data: issue } = await github.rest.issues.get({
|
|
359
|
+
owner: context.repo.owner,
|
|
360
|
+
repo: context.repo.repo,
|
|
361
|
+
issue_number: issueNumber,
|
|
362
|
+
});
|
|
363
|
+
if (issue.state === 'closed') return;
|
|
364
|
+
if (issue.pull_request) return; // Skip if it's a PR, not an issue
|
|
365
|
+
|
|
366
|
+
await github.rest.issues.update({
|
|
367
|
+
owner: context.repo.owner,
|
|
368
|
+
repo: context.repo.repo,
|
|
369
|
+
issue_number: issueNumber,
|
|
370
|
+
state: 'closed',
|
|
371
|
+
state_reason: 'completed',
|
|
372
|
+
});
|
|
373
|
+
core.info(`Closed issue #${issueNumber} after PR #${context.payload.pull_request.number} was merged`);
|
|
374
|
+
} catch (e) {
|
|
375
|
+
core.warning(`Could not close issue #${issueNumber}: ${e.message}`);
|
|
376
|
+
}
|
|
377
|
+
|
|
333
378
|
# ─── Error Notifications ─────────────────────────────────────────────────────
|
|
334
379
|
notify-parse-error:
|
|
335
380
|
if: >-
|