@kody-ade/kody-engine 0.2.9 → 0.2.11
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/kody2.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.2.
|
|
6
|
+
version: "0.2.11",
|
|
7
7
|
description: "kody2 \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
|
|
8
8
|
license: "MIT",
|
|
9
9
|
type: "module",
|
|
@@ -1963,6 +1963,27 @@ var loadCoverageRules = async (ctx) => {
|
|
|
1963
1963
|
ctx.data.coverageRules = ctx.config.testRequirements ?? [];
|
|
1964
1964
|
};
|
|
1965
1965
|
|
|
1966
|
+
// src/scripts/loadIssueContext.ts
|
|
1967
|
+
var DEFAULT_COMMENT_LIMIT = 12;
|
|
1968
|
+
var DEFAULT_COMMENT_MAX_BYTES = 4e3;
|
|
1969
|
+
var loadIssueContext = async (ctx) => {
|
|
1970
|
+
const issueNumber = ctx.args.issue;
|
|
1971
|
+
if (typeof issueNumber !== "number" || issueNumber <= 0) {
|
|
1972
|
+
throw new Error("loadIssueContext: ctx.args.issue (positive integer) is required");
|
|
1973
|
+
}
|
|
1974
|
+
const issue = getIssue(issueNumber, ctx.cwd);
|
|
1975
|
+
const cfgCtx = ctx.config.issueContext ?? {};
|
|
1976
|
+
const limit = cfgCtx.commentLimit ?? DEFAULT_COMMENT_LIMIT;
|
|
1977
|
+
const maxBytes = cfgCtx.commentMaxBytes ?? DEFAULT_COMMENT_MAX_BYTES;
|
|
1978
|
+
const sorted = [...issue.comments].sort((a, b) => a.createdAt < b.createdAt ? 1 : -1);
|
|
1979
|
+
const kept = sorted.slice(0, limit);
|
|
1980
|
+
const commentsFormatted = kept.length === 0 ? "(no comments yet)" : kept.map((c) => `- **${c.author}** (${c.createdAt}):
|
|
1981
|
+
${truncate2(c.body, maxBytes).replace(/\n/g, "\n ")}`).join("\n\n");
|
|
1982
|
+
ctx.data.issue = { ...issue, commentsFormatted };
|
|
1983
|
+
ctx.data.commentTargetType = "issue";
|
|
1984
|
+
ctx.data.commentTargetNumber = issueNumber;
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1966
1987
|
// src/state.ts
|
|
1967
1988
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
1968
1989
|
var STATE_BEGIN = "<!-- kody2:state:v1:begin -->";
|
|
@@ -2966,6 +2987,7 @@ var preflightScripts = {
|
|
|
2966
2987
|
releaseFlow,
|
|
2967
2988
|
watchStalePrsFlow,
|
|
2968
2989
|
loadTaskState,
|
|
2990
|
+
loadIssueContext,
|
|
2969
2991
|
loadConventions,
|
|
2970
2992
|
loadCoverageRules,
|
|
2971
2993
|
composePrompt
|
|
@@ -37,13 +37,12 @@
|
|
|
37
37
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"preflight": [
|
|
40
|
-
{ "script": "
|
|
40
|
+
{ "script": "loadIssueContext" },
|
|
41
41
|
{ "script": "loadTaskState" },
|
|
42
42
|
{ "script": "composePrompt" }
|
|
43
43
|
],
|
|
44
44
|
"postflight": [
|
|
45
45
|
{ "script": "parseAgentResult" },
|
|
46
|
-
{ "script": "postIssueComment" },
|
|
47
46
|
{ "script": "writeRunSummary" },
|
|
48
47
|
{ "script": "saveTaskState" }
|
|
49
48
|
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
You are the **kody2 orchestrator** for issue #{{issue.number}} on {{repoOwner}}/{{repoName}}.
|
|
2
|
+
|
|
3
|
+
Your job: drive a 2-step flow **plan → build** by posting `@kody2 <subcommand>` comments on the issue and watching the state-comment for completion signals. You do NOT edit files. You do NOT run git. You use `gh` (via Bash) only to post comments and read the state-comment.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Issue #{{issue.number}}: {{issue.title}}
|
|
8
|
+
|
|
9
|
+
{{issue.body}}
|
|
10
|
+
|
|
11
|
+
# Required flow (plan-then-build)
|
|
12
|
+
|
|
13
|
+
1. **Kick off plan.** Post an issue comment with EXACTLY this body:
|
|
14
|
+
```
|
|
15
|
+
@kody2 plan
|
|
16
|
+
```
|
|
17
|
+
Use: `gh issue comment {{issue.number}} --body "@kody2 plan"` (in the cwd).
|
|
18
|
+
2. **Wait for plan to complete.** Poll the issue's state-comment every ~30s. The state-comment is the one whose body starts with `<!-- kody2:state:v1:begin -->`. Fetch it with:
|
|
19
|
+
```
|
|
20
|
+
gh api repos/{{repoOwner}}/{{repoName}}/issues/{{issue.number}}/comments --paginate --jq '.[] | select(.body | contains("kody2:state:v1:begin")) | .body'
|
|
21
|
+
```
|
|
22
|
+
Parse the JSON block inside the sentinels. Look for `core.lastOutcome.type == "PLAN_COMPLETED"`.
|
|
23
|
+
If `core.lastOutcome.type == "PLAN_FAILED"` OR if 10 minutes pass without completion → abort with:
|
|
24
|
+
```
|
|
25
|
+
FAILED: plan did not complete (<reason from state or "timeout">)
|
|
26
|
+
```
|
|
27
|
+
3. **Kick off build.** Post:
|
|
28
|
+
```
|
|
29
|
+
@kody2 build
|
|
30
|
+
```
|
|
31
|
+
Same `gh issue comment` command.
|
|
32
|
+
4. **Wait for build to complete.** Same poll technique. Look for `core.lastOutcome.type == "RUN_COMPLETED"` (build's success marker) or `RUN_FAILED`. If `RUN_FAILED` or 30 minutes pass → abort with `FAILED: build did not complete (...)`.
|
|
33
|
+
5. **Emit final summary.**
|
|
34
|
+
|
|
35
|
+
# Required final output
|
|
36
|
+
|
|
37
|
+
On success:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
DONE
|
|
41
|
+
COMMIT_MSG: chore(orchestrator): plan-then-build for #{{issue.number}}
|
|
42
|
+
PR_SUMMARY:
|
|
43
|
+
- Posted `@kody2 plan` and observed PLAN_COMPLETED.
|
|
44
|
+
- Posted `@kody2 build` and observed RUN_COMPLETED.
|
|
45
|
+
- Final PR: <prUrl from state>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
On failure, a single line: `FAILED: <concrete reason>`.
|
|
49
|
+
|
|
50
|
+
# Rules
|
|
51
|
+
|
|
52
|
+
- NEVER edit files. Read-only flow.
|
|
53
|
+
- NEVER run git. Only `gh` via Bash for comment posting and state polling.
|
|
54
|
+
- Between polls, sleep ~30 seconds. Do NOT poll faster than once every 30 seconds.
|
|
55
|
+
- Hard cap: 40 turns total across the whole flow. If you're approaching the cap, fail early with `FAILED: turn budget exhausted`.
|
|
56
|
+
- If you post an `@kody2` comment and the state-comment does NOT update within the poll window, the child executable likely didn't run — check the GitHub Actions runs tab URL via `gh run list --limit 5 --json conclusion,status,url` to diagnose, then fail with a concrete reason.
|
|
@@ -30,14 +30,13 @@
|
|
|
30
30
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"preflight": [
|
|
33
|
-
{ "script": "
|
|
33
|
+
{ "script": "loadIssueContext" },
|
|
34
34
|
{ "script": "loadTaskState" },
|
|
35
35
|
{ "script": "loadConventions" },
|
|
36
36
|
{ "script": "composePrompt" }
|
|
37
37
|
],
|
|
38
38
|
"postflight": [
|
|
39
39
|
{ "script": "parseAgentResult" },
|
|
40
|
-
{ "script": "postIssueComment" },
|
|
41
40
|
{ "script": "writeRunSummary" },
|
|
42
41
|
{ "script": "saveTaskState" }
|
|
43
42
|
]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
You are a senior engineer producing an **implementation plan** for the GitHub issue below. You will NOT write code. You will NOT run git or gh commands. You will NOT modify files. Your only outputs are:
|
|
2
|
+
|
|
3
|
+
1. Use Read / Grep / Glob / Bash (read-only) to study the codebase as much as needed.
|
|
4
|
+
2. Emit a final message with the plan wrapped in the required markers (see "Required output").
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Repo
|
|
9
|
+
- {{repoOwner}}/{{repoName}}, default branch: {{defaultBranch}}
|
|
10
|
+
|
|
11
|
+
# Issue #{{issue.number}}: {{issue.title}}
|
|
12
|
+
|
|
13
|
+
{{issue.body}}
|
|
14
|
+
|
|
15
|
+
Recent comments (most recent first, truncated):
|
|
16
|
+
{{issue.commentsFormatted}}
|
|
17
|
+
|
|
18
|
+
{{conventionsBlock}}
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Required output
|
|
23
|
+
|
|
24
|
+
Your FINAL message must be exactly this shape (no extra text before or after):
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
DONE
|
|
28
|
+
COMMIT_MSG: plan: <very short title>
|
|
29
|
+
PR_SUMMARY:
|
|
30
|
+
<A concrete implementation plan in markdown. Include:
|
|
31
|
+
- Files to change (with paths), and the change in each.
|
|
32
|
+
- New files to create, with their purpose and rough shape.
|
|
33
|
+
- Any ambiguities that need the human to resolve first.
|
|
34
|
+
- Verification checklist (typecheck / tests / lint expectations).
|
|
35
|
+
Keep to ~60 lines or less. No filler. No marketing language.>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Rules
|
|
39
|
+
- Read-only. Do NOT modify any file.
|
|
40
|
+
- Do NOT run git or gh commands.
|
|
41
|
+
- No speculative scope — plan only what the issue asks for.
|
|
42
|
+
- If the issue is ambiguous and you cannot make progress without input, output `FAILED: <what's unclear>` instead of a plan.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kody-ade/kody-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "kody2 — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|