@kody-ade/kody-engine 0.1.7 → 0.2.0

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -61
  3. package/dist/bin/kody2.js +2512 -0
  4. package/dist/executables/build/profile.json +83 -0
  5. package/dist/executables/build/prompts/fix-ci.md +42 -0
  6. package/dist/executables/build/prompts/fix.md +40 -0
  7. package/dist/executables/build/prompts/resolve.md +34 -0
  8. package/dist/executables/build/prompts/run.md +31 -0
  9. package/dist/executables/types.ts +154 -0
  10. package/kody.config.schema.json +406 -0
  11. package/package.json +23 -28
  12. package/templates/kody2.yml +57 -0
  13. package/dist/bin/cli.mjs +0 -10781
  14. package/dist/bin/cli.mjs.map +0 -1
  15. package/opencode/agents/admin-expert.md +0 -73
  16. package/opencode/agents/advisor.md +0 -128
  17. package/opencode/agents/architect.md +0 -193
  18. package/opencode/agents/autofix.md +0 -103
  19. package/opencode/agents/build-delegation-test.md +0 -93
  20. package/opencode/agents/build-delegation.md +0 -98
  21. package/opencode/agents/build-manager.md +0 -212
  22. package/opencode/agents/build.md +0 -266
  23. package/opencode/agents/clarify.md +0 -84
  24. package/opencode/agents/code-reviewer.md +0 -42
  25. package/opencode/agents/commit.md +0 -27
  26. package/opencode/agents/docs.md +0 -123
  27. package/opencode/agents/domain/admin-expert.md +0 -43
  28. package/opencode/agents/domain/llm-expert.md +0 -55
  29. package/opencode/agents/domain/payload-expert.md +0 -67
  30. package/opencode/agents/domain/security-auditor.md +0 -62
  31. package/opencode/agents/domain/ui-expert.md +0 -43
  32. package/opencode/agents/domain/web-expert.md +0 -45
  33. package/opencode/agents/e2e-test-writer.md +0 -156
  34. package/opencode/agents/fix.md +0 -158
  35. package/opencode/agents/gap.md +0 -206
  36. package/opencode/agents/kody-expert.md +0 -173
  37. package/opencode/agents/llm-expert.md +0 -90
  38. package/opencode/agents/neuron.md +0 -12
  39. package/opencode/agents/payload-expert.md +0 -32
  40. package/opencode/agents/plan-gap.md +0 -132
  41. package/opencode/agents/pr.md +0 -25
  42. package/opencode/agents/review.md +0 -163
  43. package/opencode/agents/security-auditor.md +0 -33
  44. package/opencode/agents/taskify.md +0 -344
  45. package/opencode/agents/test-writer.md +0 -261
  46. package/opencode/agents/test.md +0 -142
  47. package/opencode/agents/verify.md +0 -30
  48. package/opencode/agents/web-expert.md +0 -63
  49. package/opencode/docs/BROWSER_AUTOMATION.md +0 -64
  50. package/opencode/docs/PIPELINE.md +0 -210
  51. package/opencode/opencode.json +0 -98
  52. package/templates/kody.yml +0 -312
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "build",
3
+ "describe": "Implement a GitHub issue or apply PR feedback end-to-end.",
4
+
5
+ "inputs": [
6
+ {
7
+ "name": "mode",
8
+ "flag": "--mode",
9
+ "type": "enum",
10
+ "values": ["run", "fix", "fix-ci", "resolve"],
11
+ "required": true,
12
+ "describe": "Which Build mode to run."
13
+ },
14
+ {
15
+ "name": "issue",
16
+ "flag": "--issue",
17
+ "type": "int",
18
+ "requiredWhen": { "mode": "run" },
19
+ "describe": "GitHub issue number to implement."
20
+ },
21
+ {
22
+ "name": "pr",
23
+ "flag": "--pr",
24
+ "type": "int",
25
+ "requiredWhen": { "mode": ["fix", "fix-ci", "resolve"] },
26
+ "describe": "GitHub PR number to operate on."
27
+ },
28
+ {
29
+ "name": "feedback",
30
+ "flag": "--feedback",
31
+ "type": "string",
32
+ "required": false,
33
+ "describe": "Inline override for fix mode. If absent, the executor reads the latest PR review comment."
34
+ },
35
+ {
36
+ "name": "runId",
37
+ "flag": "--run-id",
38
+ "type": "string",
39
+ "required": false,
40
+ "describe": "Specific failed workflow run ID for fix-ci. Defaults to latest failed run on the PR branch."
41
+ }
42
+ ],
43
+
44
+ "claudeCode": {
45
+ "model": "inherit",
46
+ "permissionMode": "acceptEdits",
47
+ "maxTurns": null,
48
+ "systemPromptAppend": null,
49
+ "tools": ["Read", "Write", "Edit", "Bash", "Grep", "Glob"],
50
+ "hooks": {
51
+ "PreToolUse": [],
52
+ "PostToolUse": [],
53
+ "Stop": []
54
+ },
55
+ "skills": [],
56
+ "commands": [],
57
+ "subagents": [],
58
+ "plugins": [],
59
+ "mcpServers": []
60
+ },
61
+
62
+ "cliTools": [],
63
+
64
+ "scripts": {
65
+ "preflight": [
66
+ { "script": "runFlow", "runWhen": { "args.mode": "run" } },
67
+ { "script": "fixFlow", "runWhen": { "args.mode": "fix" } },
68
+ { "script": "fixCiFlow", "runWhen": { "args.mode": "fix-ci" } },
69
+ { "script": "resolveFlow", "runWhen": { "args.mode": "resolve" } },
70
+ { "script": "loadConventions" },
71
+ { "script": "loadCoverageRules" },
72
+ { "script": "composePrompt" }
73
+ ],
74
+ "postflight": [
75
+ { "script": "parseAgentResult" },
76
+ { "script": "verify" },
77
+ { "script": "checkCoverageWithRetry" },
78
+ { "script": "commitAndPush" },
79
+ { "script": "ensurePr" },
80
+ { "script": "postIssueComment" }
81
+ ]
82
+ }
83
+ }
@@ -0,0 +1,42 @@
1
+ You are Kody, an autonomous engineer. A CI workflow on PR #{{pr.number}} (`{{branch}}`) is failing. Read the failed-step log below and fix the root cause. The wrapper handles git/gh — you do not.
2
+
3
+ # Repo
4
+ - {{repoOwner}}/{{repoName}}, default branch: {{defaultBranch}}
5
+
6
+ # PR #{{pr.number}}: {{pr.title}}
7
+
8
+ # Failing workflow
9
+ - Workflow: {{failedWorkflowName}}
10
+ - Run URL: {{failedRunUrl}}
11
+
12
+ # Failed-step log (truncated, most recent ~30KB)
13
+
14
+ ```
15
+ {{failedLogTail}}
16
+ ```
17
+
18
+ {{conventionsBlock}}{{toolsUsage}}# Current PR diff (truncated)
19
+
20
+ ```diff
21
+ {{prDiff}}
22
+ ```
23
+
24
+ # Required steps
25
+ 1. Read the log carefully. Identify the actual failure — compile error, failing test, lint rule, missing dep, etc.
26
+ 2. Make the minimum edits to fix the root cause. Do NOT disable tests or rules just to make CI pass.
27
+ 3. Re-run the relevant quality command locally with Bash and confirm exit 0.
28
+ 4. Final message format (or `FAILED: <reason>` on failure):
29
+
30
+ ```
31
+ DONE
32
+ COMMIT_MSG: fix(ci): <short root-cause description>
33
+ PR_SUMMARY:
34
+ <2-4 bullets: what was failing, what you changed, why it fixes it>
35
+ ```
36
+
37
+ # Rules
38
+ - Do NOT run git/gh. Wrapper handles it.
39
+ - Do NOT disable/skip tests or lint rules just to pass CI.
40
+ - If the failure is environmental (missing secret, broken runner) and not code, emit `FAILED: <explanation>`.
41
+ - Stay on `{{branch}}`.
42
+ {{systemPromptAppend}}
@@ -0,0 +1,40 @@
1
+ You are Kody, an autonomous engineer. Apply the feedback below to the existing PR branch `{{branch}}` (already checked out). The wrapper handles git/gh — you do not.
2
+
3
+ # Repo
4
+ - {{repoOwner}}/{{repoName}}, default branch: {{defaultBranch}}
5
+
6
+ # PR #{{pr.number}}: {{pr.title}}
7
+ {{pr.body}}
8
+
9
+ # Feedback to address (AUTHORITATIVE — supersedes the original issue spec)
10
+
11
+ {{feedback}}
12
+
13
+ {{conventionsBlock}}{{coverageBlock}}{{toolsUsage}}# Existing PR diff (current state, truncated)
14
+
15
+ ```diff
16
+ {{prDiff}}
17
+ ```
18
+
19
+ # Required steps
20
+ 1. Read the feedback carefully. It takes precedence over the original issue spec. If feedback says "remove X", remove X even if the issue asked for it.
21
+ 2. Research ONLY what's needed to address the feedback. Make the minimum edits required.
22
+ 3. Run each quality command with Bash. Fix the root cause of any failure you introduced by this round of edits.
23
+ 4. Final message format (or a single `FAILED: <reason>` line on failure):
24
+
25
+ ```
26
+ DONE
27
+ COMMIT_MSG: <conventional-commit message for this round of fixes>
28
+ PR_SUMMARY:
29
+ <2-4 bullets describing what changed in THIS fix round — not the whole PR>
30
+ ```
31
+
32
+ # Rules
33
+ - **Treat the feedback as a concrete change request, not a code review to argue with.** If feedback says "add an X branch", you must add an X branch — not document that the existing Y branch already covers the case. "Already handles it in a different way" is NOT an acceptable reason to skip an edit.
34
+ - **Your DONE is only valid if your edits produce a diff that materially implements the requested change.** A diff that only adds tests asserting the *current* behavior, or only tweaks comments/docs, does NOT count as addressing a change request. If the feedback asks for a new code path, the diff MUST contain that new code path.
35
+ - **"Already satisfied" is only allowed when the code already does exactly what the feedback asks for, verifiable by reading the implementation.** If in doubt, make the edit.
36
+ - Do NOT run git/gh commands. The wrapper handles it.
37
+ - Stay on `{{branch}}`.
38
+ - Do not modify files under `.kody/`, `.kody-engine/`, `.kody2/`, `node_modules/`, `dist/`, `build/`, `.env`, `*.log`.
39
+ - If the feedback is ambiguous or conflicts with the issue, err toward what the feedback says.
40
+ {{systemPromptAppend}}
@@ -0,0 +1,34 @@
1
+ You are Kody, an autonomous engineer. A `git merge origin/{{baseBranch}}` into PR #{{pr.number}} (`{{branch}}`) produced conflicts. Resolve them. The wrapper handles git/gh — you do not.
2
+
3
+ # Repo
4
+ - {{repoOwner}}/{{repoName}}
5
+
6
+ # PR #{{pr.number}}: {{pr.title}}
7
+
8
+ # Conflicted files
9
+
10
+ {{conflictedFiles}}
11
+
12
+ {{conventionsBlock}}{{toolsUsage}}# Working-tree conflict markers (truncated)
13
+
14
+ {{conflictMarkersPreview}}
15
+
16
+ # Required steps
17
+ 1. For each conflicted file: read it, understand both sides of the `<<<<<<<` / `=======` / `>>>>>>>` markers, and produce the correct merged content. Remove all conflict markers.
18
+ 2. Preserve the PR's intent (the HEAD side) unless `origin/{{baseBranch}}` made a change that should be preserved (e.g. security fix, renamed API). Use judgement.
19
+ 3. After resolving, run the quality commands with Bash and fix any issues YOUR resolution introduced.
20
+ 4. Final message format (or `FAILED: <reason>` on failure):
21
+
22
+ ```
23
+ DONE
24
+ COMMIT_MSG: fix: resolve merge conflicts with {{baseBranch}}
25
+ PR_SUMMARY:
26
+ <2-4 bullets: which files had conflicts, how you resolved each, any judgement calls>
27
+ ```
28
+
29
+ # Rules
30
+ - Do NOT run git/gh. Wrapper handles the merge commit.
31
+ - Do NOT delete files to "resolve" conflicts. Merge the content.
32
+ - Do NOT leave any `<<<<<<<`, `=======`, or `>>>>>>>` markers in files.
33
+ - Stay on `{{branch}}`.
34
+ {{systemPromptAppend}}
@@ -0,0 +1,31 @@
1
+ You are Kody, an autonomous engineer. Take a GitHub issue from spec to a tested set of edits in ONE session. The wrapper handles git/gh — you do not.
2
+
3
+ # Repo
4
+ - {{repoOwner}}/{{repoName}}, default branch: {{defaultBranch}}
5
+ - current branch (already checked out): {{branch}}
6
+
7
+ {{conventionsBlock}}{{coverageBlock}}{{toolsUsage}}# Issue #{{issue.number}}: {{issue.title}}
8
+ {{issue.body}}
9
+
10
+ # Required steps (all in this one session — no handoff)
11
+ 1. **Research** — read the issue carefully. Use Grep/Glob/Read to investigate the codebase: locate relevant files, understand existing patterns, check related tests, identify constraints. Do not edit anything yet.
12
+ 2. **Plan** — before any Edit/Write, output a short plan (5–10 lines): what files you'll change, the approach, what could go wrong. No fluff.
13
+ 3. **Build** — Edit/Write to implement the change. Stay within the plan; if you discover the plan was wrong, briefly say so and adjust.
14
+ 4. **Verify** — run each quality command with Bash. On failure, fix the root cause and re-run. When reporting that a command passed, you MUST have just run it and seen exit code 0 in this session — do not paraphrase prior output.
15
+ 5. Your FINAL message must use this exact format (or a single `FAILED: <reason>` line on failure):
16
+
17
+ ```
18
+ DONE
19
+ COMMIT_MSG: <conventional-commit message, e.g. "feat: add X" or "fix: handle Y">
20
+ PR_SUMMARY:
21
+ <2-6 short bullet points naming the files/functions/endpoints you added or modified. No marketing fluff. No restating the issue.>
22
+ ```
23
+
24
+ # Rules
25
+ - Do NOT run **any** `git` or `gh` commands. The wrapper handles all git/gh operations. If a quality gate fails, that's the failure — do not investigate it via git.
26
+ - Stay on the current branch (`{{branch}}`). It is already checked out for you.
27
+ - Do NOT modify files under: `.kody/`, `.kody-engine/`, `.kody-lean/`, `.kody2/`, `node_modules/`, `dist/`, `build/`, `.env`, or any `*.log`.
28
+ - Do NOT post issue comments — the wrapper handles that.
29
+ - Pre-existing quality-gate failures: assume they are NOT your responsibility unless your edits touched related code.
30
+ - Keep the plan and reasoning concise. Long monologues waste turns.
31
+ {{systemPromptAppend}}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Types shared by the generic executor and executables.
3
+ *
4
+ * The executor reads a Profile, validates the user's CLI args against
5
+ * Profile.inputs, then runs the declared preflight scripts → agent →
6
+ * postflight scripts. The executor knows nothing about any specific role
7
+ * (build, review, plan, etc.) — it only executes what the profile declares.
8
+ */
9
+
10
+ import type { Kody2Config } from "../config.js"
11
+ import type { AgentResult } from "../agent.js"
12
+
13
+ // ────────────────────────────────────────────────────────────────────────────
14
+ // Profile shape (mirrors the JSON on disk).
15
+ // ────────────────────────────────────────────────────────────────────────────
16
+
17
+ export interface Profile {
18
+ name: string
19
+ describe: string
20
+ inputs: InputSpec[]
21
+ claudeCode: ClaudeCodeSpec
22
+ cliTools: CliToolSpec[]
23
+ scripts: {
24
+ preflight: ScriptEntry[]
25
+ postflight: ScriptEntry[]
26
+ }
27
+ outputContract?: OutputContract
28
+ /** Absolute directory the profile was loaded from. Used to resolve prompt.md. */
29
+ dir: string
30
+ }
31
+
32
+ export interface InputSpec {
33
+ name: string
34
+ flag: string
35
+ type: "int" | "string" | "bool" | "enum"
36
+ /** Allowed values for `type: "enum"`. */
37
+ values?: string[]
38
+ required?: boolean
39
+ /**
40
+ * Only required when another input matches one of these values.
41
+ * e.g. `{ mode: "run" }` or `{ mode: ["fix", "fix-ci", "resolve"] }`.
42
+ */
43
+ requiredWhen?: Record<string, string | string[]>
44
+ describe: string
45
+ }
46
+
47
+ export interface ClaudeCodeSpec {
48
+ /** "inherit" → use Kody2Config.agent.model. Or a concrete "provider/model". */
49
+ model: string
50
+ permissionMode: "default" | "acceptEdits" | "plan" | "bypassPermissions"
51
+ /** null = unbounded. */
52
+ maxTurns: number | null
53
+ /** Text appended on top of Claude Code's baseline system prompt. */
54
+ systemPromptAppend: string | null
55
+ /** SDK built-in tools this executable is allowed to use (capability pack). */
56
+ tools: string[]
57
+ /** Claude Code hooks. `matcher` is a tool-name glob; `command` is a shell invocation. */
58
+ hooks: {
59
+ PreToolUse: HookEntry[]
60
+ PostToolUse: HookEntry[]
61
+ Stop: HookEntry[]
62
+ }
63
+ skills: string[]
64
+ commands: string[]
65
+ subagents: string[]
66
+ plugins: string[]
67
+ mcpServers: McpServerSpec[]
68
+ }
69
+
70
+ export interface HookEntry {
71
+ matcher: string
72
+ command: string
73
+ }
74
+
75
+ export interface McpServerSpec {
76
+ name: string
77
+ command: string
78
+ args?: string[]
79
+ env?: Record<string, string>
80
+ }
81
+
82
+ export interface CliToolSpec {
83
+ name: string
84
+ install: {
85
+ required: boolean
86
+ checkCommand: string
87
+ installCommand?: string
88
+ }
89
+ verify: string
90
+ usage: string
91
+ allowedUses: string[]
92
+ }
93
+
94
+ export interface ScriptEntry {
95
+ script: string
96
+ /**
97
+ * Optional conditional. Keys are dotted paths into the context (e.g.
98
+ * "args.mode"). Values are a single primitive or an array of primitives.
99
+ * The script runs only when every key matches. Missing `runWhen` = always.
100
+ */
101
+ runWhen?: Record<string, string | number | boolean | Array<string | number | boolean>>
102
+ }
103
+
104
+ export interface OutputContract {
105
+ finalMessage?: {
106
+ onSuccess?: string[]
107
+ onFailure?: string[]
108
+ }
109
+ }
110
+
111
+ // ────────────────────────────────────────────────────────────────────────────
112
+ // Run-time context passed to every script.
113
+ // ────────────────────────────────────────────────────────────────────────────
114
+
115
+ export interface Context {
116
+ /** Validated CLI args, keyed by input `name`. */
117
+ args: Record<string, unknown>
118
+ /** Project root. */
119
+ cwd: string
120
+ /** Loaded kody.config.json. */
121
+ config: Kody2Config
122
+ /** Stream-output verbosity. */
123
+ verbose?: boolean
124
+ quiet?: boolean
125
+ /** Opaque bag scripts populate during preflight (issue, pr, diff, logs, …). */
126
+ data: Record<string, unknown>
127
+ /** Final output the executor returns. */
128
+ output: {
129
+ exitCode: number
130
+ prUrl?: string
131
+ reason?: string
132
+ }
133
+ /**
134
+ * If a preflight script sets this to true, the executor skips the agent
135
+ * invocation and proceeds straight to postflight. Used by e.g. the
136
+ * clean-merge resolve path.
137
+ */
138
+ skipAgent?: boolean
139
+ }
140
+
141
+ // ────────────────────────────────────────────────────────────────────────────
142
+ // Script signatures. Two phases, two contracts.
143
+ // ────────────────────────────────────────────────────────────────────────────
144
+
145
+ export type PreflightScript = (ctx: Context, profile: Profile) => Promise<void>
146
+
147
+ export type PostflightScript = (
148
+ ctx: Context,
149
+ profile: Profile,
150
+ agentResult: AgentResult | null,
151
+ ) => Promise<void>
152
+
153
+ /** A registered script may be either phase; registry looks it up by name. */
154
+ export type AnyScript = PreflightScript | PostflightScript