@kody-ade/kody-engine 0.4.330 → 0.4.331

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
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@kody-ade/kody-engine",
18
- version: "0.4.330",
18
+ version: "0.4.331",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -15340,7 +15340,14 @@ function parseAgentFactoryBundle(raw) {
15340
15340
  content: readJsonString(file.content, `files[${index}].content`)
15341
15341
  };
15342
15342
  });
15343
- return { title, summary, files };
15343
+ return {
15344
+ title,
15345
+ summary,
15346
+ files,
15347
+ model: value.model,
15348
+ models: value.models,
15349
+ modelCreatorContractsUsed: value.modelCreatorContractsUsed
15350
+ };
15344
15351
  }
15345
15352
  function buildAgentFactoryBranchName(issueNumber, title, now = Date.now()) {
15346
15353
  const slug2 = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48).replace(/-+$/g, "");
@@ -18231,6 +18238,255 @@ var init_syncFlow = __esm({
18231
18238
  }
18232
18239
  });
18233
18240
 
18241
+ // src/scripts/validateAgentFactoryBundle.ts
18242
+ function validateModelBundle(bundle, producer) {
18243
+ const failures = [];
18244
+ const expectedKind = CREATOR_KIND[producer];
18245
+ if (producer === FACTORY_PRODUCER) {
18246
+ const contracts = stringArray5(bundle.modelCreatorContractsUsed);
18247
+ for (const contract of CREATOR_CONTRACTS) {
18248
+ if (!contracts.includes(contract)) failures.push(`modelCreatorContractsUsed missing ${contract}`);
18249
+ }
18250
+ if (!Array.isArray(bundle.models) || bundle.models.length === 0) {
18251
+ failures.push("agent-factory bundle must include non-empty models array");
18252
+ return failures;
18253
+ }
18254
+ for (const [index, model] of bundle.models.entries()) {
18255
+ validateOneModel(model, bundle.files, `models[${index}]`, false, failures);
18256
+ }
18257
+ validateFactoryAssembly(bundle.models, failures);
18258
+ return failures;
18259
+ }
18260
+ validateOneModel(bundle.model, bundle.files, "model", true, failures, expectedKind, producer);
18261
+ return failures;
18262
+ }
18263
+ function validateOneModel(rawModel, files, label, strictSingleModel, failures, expectedKind, producer) {
18264
+ if (!rawModel || typeof rawModel !== "object" || Array.isArray(rawModel)) {
18265
+ failures.push(`${label} must be an object`);
18266
+ return;
18267
+ }
18268
+ const model = rawModel;
18269
+ const kind = stringField6(model.kind);
18270
+ if (!isModelKind(kind)) failures.push(`${label}.kind must be agent, capability, goal, agentLoop, or workflow`);
18271
+ if (expectedKind && kind !== expectedKind && producer)
18272
+ failures.push(`${producer} must output model.kind ${expectedKind}`);
18273
+ const slug2 = stringField6(model.slug);
18274
+ if (!isSlug2(slug2)) failures.push(`${label}.slug must be a lowercase slug`);
18275
+ if (isModelKind(kind)) {
18276
+ const docsUsed = stringArray5(model.docsUsed);
18277
+ for (const doc of REQUIRED_DOCS[kind]) {
18278
+ if (!docsUsed.includes(doc)) failures.push(`${label} docsUsed missing ${doc}`);
18279
+ }
18280
+ validateFilesForKind(kind, slug2, files, strictSingleModel, failures);
18281
+ validateModelShape(kind, model, failures);
18282
+ }
18283
+ }
18284
+ function validateFilesForKind(kind, slug2, files, strictSingleModel, failures) {
18285
+ const paths = files.map((file) => normalizeBundlePath(file.path));
18286
+ if (paths.some((filePath) => filePath === "executables" || filePath.startsWith("executables/"))) {
18287
+ failures.push("files must not use obsolete executables storage");
18288
+ }
18289
+ if (kind === "agent") {
18290
+ requirePath(paths, `agents/${slug2}.md`, "agent file", failures);
18291
+ if (strictSingleModel) rejectOtherRoots(paths, ["agents/"], "agent", failures);
18292
+ }
18293
+ if (kind === "capability") {
18294
+ requirePath(paths, `capabilities/${slug2}/profile.json`, "capability profile", failures);
18295
+ requirePath(paths, `capabilities/${slug2}/capability.md`, "capability body", failures);
18296
+ if (strictSingleModel) rejectOtherRoots(paths, [`capabilities/${slug2}/`], "capability", failures);
18297
+ const profile = parseJsonFile(files, `capabilities/${slug2}/profile.json`, failures);
18298
+ if (profile) {
18299
+ const profileName = stringField6(profile.name);
18300
+ if (profileName && profileName !== slug2) failures.push("capability profile name must match model.slug");
18301
+ if (profile.agent !== void 0)
18302
+ failures.push("capability profile must not set agent; agent wiring belongs outside capability creation");
18303
+ if (!["observe", "act", "verify"].includes(stringField6(profile.capabilityKind))) {
18304
+ failures.push("capability profile must declare capabilityKind observe, act, or verify");
18305
+ }
18306
+ }
18307
+ }
18308
+ if (kind === "goal") {
18309
+ requirePath(paths, `goals/templates/${slug2}/state.json`, "goal template state", failures);
18310
+ if (strictSingleModel) rejectOtherRoots(paths, [`goals/templates/${slug2}/`], "goal", failures);
18311
+ }
18312
+ if (kind === "agentLoop") {
18313
+ if (!paths.some((filePath) => filePath.endsWith("/state.json")))
18314
+ failures.push("agentLoop must produce a state.json file");
18315
+ if (strictSingleModel) rejectOtherRoots(paths, ["goals/templates/", "loops/"], "agentLoop", failures);
18316
+ }
18317
+ if (kind === "workflow") {
18318
+ requirePath(paths, `capabilities/${slug2}/profile.json`, "workflow capability profile", failures);
18319
+ const profile = parseJsonFile(files, `capabilities/${slug2}/profile.json`, failures);
18320
+ if (profile && (!profile.workflow || typeof profile.workflow !== "object")) {
18321
+ failures.push("workflow profile must include workflow object");
18322
+ }
18323
+ }
18324
+ }
18325
+ function validateFactoryAssembly(models, failures) {
18326
+ const available = /* @__PURE__ */ new Map();
18327
+ for (const model of models) {
18328
+ if (!model || typeof model !== "object" || Array.isArray(model)) continue;
18329
+ const input = model;
18330
+ const kind = stringField6(input.kind);
18331
+ const slug2 = stringField6(input.slug);
18332
+ if (isModelKind(kind) && isSlug2(slug2)) available.set(`${kind}:${slug2}`, kind);
18333
+ }
18334
+ for (const model of models) {
18335
+ if (!model || typeof model !== "object" || Array.isArray(model)) continue;
18336
+ const input = model;
18337
+ const kind = stringField6(input.kind);
18338
+ if (kind === "goal") {
18339
+ for (const capability of stringArray5(input.capabilities)) {
18340
+ if (!available.has(`capability:${capability}`)) {
18341
+ failures.push(`goal ${stringField6(input.slug)} references missing capability ${capability}`);
18342
+ }
18343
+ }
18344
+ }
18345
+ if (kind === "workflow") {
18346
+ for (const step of arrayObjects(input.steps)) {
18347
+ const capability = stringField6(step.capability);
18348
+ if (capability && !available.has(`capability:${capability}`)) {
18349
+ failures.push(`workflow ${stringField6(input.slug)} references missing capability ${capability}`);
18350
+ }
18351
+ }
18352
+ }
18353
+ if (kind === "agentLoop") {
18354
+ const wakeTarget = input.wakeTarget;
18355
+ if (wakeTarget && typeof wakeTarget === "object" && !Array.isArray(wakeTarget)) {
18356
+ const target = wakeTarget;
18357
+ const type = stringField6(target.type);
18358
+ const slug2 = stringField6(target.slug);
18359
+ const modelKind = type === "loop" ? "agentLoop" : type;
18360
+ if ((modelKind === "goal" || modelKind === "workflow" || modelKind === "capability") && !available.has(`${modelKind}:${slug2}`)) {
18361
+ failures.push(`agentLoop ${stringField6(input.slug)} references missing ${type} ${slug2}`);
18362
+ }
18363
+ }
18364
+ }
18365
+ }
18366
+ }
18367
+ function validateModelShape(kind, model, failures) {
18368
+ if (kind === "agent") {
18369
+ requireStringArrayIncludes(model.owns, "identity", "agent owns", failures);
18370
+ requireStringArrayIncludes(model.doesNotOwn, "tasks", "agent doesNotOwn", failures);
18371
+ }
18372
+ if (kind === "capability") {
18373
+ if (!["observe", "act", "verify"].includes(stringField6(model.capabilityKind))) {
18374
+ failures.push("capability model must declare capabilityKind observe, act, or verify");
18375
+ }
18376
+ if (!stringField6(model.ability)) failures.push("capability model must declare ability");
18377
+ for (const field of ["inputs", "outputs", "allowedActions", "forbiddenActions"]) {
18378
+ if (!Array.isArray(model[field])) failures.push(`capability model ${field} must be an array`);
18379
+ }
18380
+ requireStringArrayIncludes(model.doesNotOwn, "agent identity", "capability doesNotOwn", failures);
18381
+ requireStringArrayIncludes(model.doesNotOwn, "goal progress", "capability doesNotOwn", failures);
18382
+ }
18383
+ if (kind === "goal") {
18384
+ if (!stringField6(model.outcome)) failures.push("goal model must declare outcome");
18385
+ if (!Array.isArray(model.evidence) || model.evidence.length === 0)
18386
+ failures.push("goal model evidence must be non-empty");
18387
+ if (!Array.isArray(model.capabilities) || model.capabilities.length === 0) {
18388
+ failures.push("goal model capabilities must be non-empty");
18389
+ }
18390
+ }
18391
+ if (kind === "agentLoop") {
18392
+ if (!stringField6(model.cadence)) failures.push("agentLoop model must declare cadence");
18393
+ if (!model.wakeTarget || typeof model.wakeTarget !== "object" || Array.isArray(model.wakeTarget)) {
18394
+ failures.push("agentLoop model must declare wakeTarget object");
18395
+ }
18396
+ }
18397
+ if (kind === "workflow") {
18398
+ if (!Array.isArray(model.steps) || model.steps.length === 0) failures.push("workflow model steps must be non-empty");
18399
+ }
18400
+ }
18401
+ function parseJsonFile(files, wantedPath, failures) {
18402
+ const file = files.find((item) => normalizeBundlePath(item.path) === wantedPath);
18403
+ if (!file) return null;
18404
+ try {
18405
+ const parsed = JSON.parse(file.content);
18406
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
18407
+ failures.push(`${wantedPath} must contain a JSON object`);
18408
+ return null;
18409
+ }
18410
+ return parsed;
18411
+ } catch (err) {
18412
+ failures.push(`${wantedPath} must contain valid JSON: ${err instanceof Error ? err.message : String(err)}`);
18413
+ return null;
18414
+ }
18415
+ }
18416
+ function rejectOtherRoots(paths, allowedPrefixes, kind, failures) {
18417
+ for (const filePath of paths) {
18418
+ if (!allowedPrefixes.some((prefix) => filePath.startsWith(prefix))) {
18419
+ failures.push(`${kind} bundle contains out-of-bound file ${filePath}`);
18420
+ }
18421
+ }
18422
+ }
18423
+ function requirePath(paths, wantedPath, label, failures) {
18424
+ if (!paths.includes(wantedPath)) failures.push(`missing ${label}: ${wantedPath}`);
18425
+ }
18426
+ function normalizeBundlePath(filePath) {
18427
+ return filePath.replace(/^\.kody\/?/, "").replace(/^\/+/, "");
18428
+ }
18429
+ function stringField6(value) {
18430
+ return typeof value === "string" ? value.trim() : "";
18431
+ }
18432
+ function stringArray5(value) {
18433
+ if (!Array.isArray(value)) return [];
18434
+ return value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
18435
+ }
18436
+ function arrayObjects(value) {
18437
+ if (!Array.isArray(value)) return [];
18438
+ return value.filter(
18439
+ (item) => Boolean(item) && typeof item === "object" && !Array.isArray(item)
18440
+ );
18441
+ }
18442
+ function requireStringArrayIncludes(value, expected, label, failures) {
18443
+ if (!stringArray5(value).includes(expected)) failures.push(`${label} must include ${expected}`);
18444
+ }
18445
+ function isSlug2(value) {
18446
+ return /^[a-z][a-z0-9-]{0,63}$/.test(value);
18447
+ }
18448
+ function isModelKind(value) {
18449
+ return value === "agent" || value === "capability" || value === "goal" || value === "agentLoop" || value === "workflow";
18450
+ }
18451
+ var CREATOR_CONTRACTS, FACTORY_PRODUCER, REQUIRED_DOCS, CREATOR_KIND, validateAgentFactoryBundle;
18452
+ var init_validateAgentFactoryBundle = __esm({
18453
+ "src/scripts/validateAgentFactoryBundle.ts"() {
18454
+ "use strict";
18455
+ init_openAgentFactoryStatePr();
18456
+ CREATOR_CONTRACTS = [
18457
+ "agent-creator",
18458
+ "goal-creator",
18459
+ "loop-creator",
18460
+ "workflow-creator",
18461
+ "capability-creator"
18462
+ ];
18463
+ FACTORY_PRODUCER = "agent-factory";
18464
+ REQUIRED_DOCS = {
18465
+ agent: ["docs/agents.md"],
18466
+ capability: ["docs/capabilities.md", "docs/capability-kind-map.md", "docs/executables.md"],
18467
+ goal: ["docs/goals.md", "docs/jobs-model.md", "docs/capabilities.md"],
18468
+ agentLoop: ["docs/jobs-model.md", "docs/engine-company.md", "docs/ledgers.md"],
18469
+ workflow: ["docs/jobs-model.md", "docs/capabilities.md"]
18470
+ };
18471
+ CREATOR_KIND = {
18472
+ "agent-creator": "agent",
18473
+ "capability-creator": "capability",
18474
+ "goal-creator": "goal",
18475
+ "loop-creator": "agentLoop",
18476
+ "workflow-creator": "workflow"
18477
+ };
18478
+ validateAgentFactoryBundle = async (ctx, profile) => {
18479
+ if (ctx.data.agentDone !== true) return;
18480
+ const raw = String(ctx.data.prSummary ?? "");
18481
+ const bundle = parseAgentFactoryBundle(raw);
18482
+ const failures = validateModelBundle(bundle, profile.name);
18483
+ if (failures.length > 0) {
18484
+ throw new Error(`validateAgentFactoryBundle: ${failures.join("; ")}`);
18485
+ }
18486
+ };
18487
+ }
18488
+ });
18489
+
18234
18490
  // src/scripts/verify.ts
18235
18491
  var verify;
18236
18492
  var init_verify2 = __esm({
@@ -19004,6 +19260,7 @@ var init_scripts = __esm({
19004
19260
  init_stageMergeConflicts();
19005
19261
  init_startFlow();
19006
19262
  init_syncFlow();
19263
+ init_validateAgentFactoryBundle();
19007
19264
  init_verify2();
19008
19265
  init_verifyReproFails();
19009
19266
  init_verifyWithRetry();
@@ -19068,6 +19325,7 @@ var init_scripts = __esm({
19068
19325
  parseIssueStateFromAgentResult,
19069
19326
  parseJobStateFromAgentResult,
19070
19327
  parseReproOutput,
19328
+ validateAgentFactoryBundle,
19071
19329
  writeIssueStateComment,
19072
19330
  writeJobStateFile,
19073
19331
  appendCompanyActivity,
@@ -0,0 +1,13 @@
1
+ # Agent Creator
2
+
3
+ ## Purpose
4
+
5
+ Create one Kody Agent model from a focused request.
6
+
7
+ ## Contract
8
+
9
+ The input is a request for one agent identity. The creator must use `docs/agents.md`, return one review-ready agent file, and keep tasks, schedules, tools, outputs, workflows, goals, and loops out of the agent.
10
+
11
+ ## Boundary
12
+
13
+ This capability creates the who. It does not create what, when, or how.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "agent-creator",
3
+ "action": "agent-creator",
4
+ "implementation": "agent-creator",
5
+ "capabilityKind": "act",
6
+ "describe": "Create one Kody agent identity model from a focused request."
7
+ }
@@ -0,0 +1,13 @@
1
+ # Capability Creator
2
+
3
+ ## Purpose
4
+
5
+ Create one complete Kody Capability model from a focused ability contract.
6
+
7
+ ## Contract
8
+
9
+ The input is the ability to provide, its kind, interface, and constraints. The creator must use `docs/capabilities.md`, `docs/capability-kind-map.md`, and `docs/executables.md`; create one `observe`, `act`, or `verify` capability; and return review-ready files under `capabilities/<slug>/`.
10
+
11
+ ## Boundary
12
+
13
+ This capability creates the reusable how. It does not decide who runs it, which workflow calls it, which goal consumes it, or which loop wakes it.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "capability-creator",
3
+ "action": "capability-creator",
4
+ "implementation": "capability-creator",
5
+ "capabilityKind": "act",
6
+ "describe": "Create one complete single-responsibility Kody capability from an ability contract."
7
+ }
@@ -0,0 +1,13 @@
1
+ # Goal Creator
2
+
3
+ ## Purpose
4
+
5
+ Create one Kody Goal model from a focused outcome request.
6
+
7
+ ## Contract
8
+
9
+ The input is one desired durable outcome. The creator must use `docs/goals.md`, `docs/jobs-model.md`, and `docs/capabilities.md`; define evidence, allowed capabilities, route, facts, and blockers; and keep implementation and cadence details out of the goal.
10
+
11
+ ## Boundary
12
+
13
+ This capability creates the what. It does not create who, when, or implementation how.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "goal-creator",
3
+ "action": "goal-creator",
4
+ "implementation": "goal-creator",
5
+ "capabilityKind": "act",
6
+ "describe": "Create one Kody goal outcome model from a focused request."
7
+ }
@@ -0,0 +1,13 @@
1
+ # Loop Creator
2
+
3
+ ## Purpose
4
+
5
+ Create one Kody AgentLoop model from a focused wakeup request.
6
+
7
+ ## Contract
8
+
9
+ The input is one cadence and wakeup need. The creator must use `docs/jobs-model.md`, `docs/engine-company.md`, and `docs/ledgers.md`; define cadence, target, and operational ledger needs; and keep business completion out of the loop.
10
+
11
+ ## Boundary
12
+
13
+ This capability creates the when. It does not create who, what, or implementation how.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "loop-creator",
3
+ "action": "loop-creator",
4
+ "implementation": "loop-creator",
5
+ "capabilityKind": "act",
6
+ "describe": "Create one Kody agent loop wakeup model from a focused request."
7
+ }
@@ -0,0 +1,13 @@
1
+ # Workflow Creator
2
+
3
+ ## Purpose
4
+
5
+ Create one Kody Workflow model from a focused ordered-run request.
6
+
7
+ ## Contract
8
+
9
+ The input is one need for ordered capability steps in a single run. The creator must use `docs/jobs-model.md` and `docs/capabilities.md`; define step order and reasons; and keep long-term progress, cadence, completion, and implementation internals out of the workflow.
10
+
11
+ ## Boundary
12
+
13
+ This capability creates composed how for one run. It does not create who, durable what, or when.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "workflow-creator",
3
+ "action": "workflow-creator",
4
+ "implementation": "workflow-creator",
5
+ "capabilityKind": "act",
6
+ "describe": "Create one Kody workflow ordered-run model from a focused request."
7
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "agent-creator",
3
+ "action": "agent-creator",
4
+ "describe": "Create one Kody agent identity model from a focused request.",
5
+ "role": "primitive",
6
+ "kind": "oneshot",
7
+ "inputs": [
8
+ {
9
+ "name": "issue",
10
+ "flag": "--issue",
11
+ "type": "int",
12
+ "required": true,
13
+ "describe": "GitHub issue number containing the focused model creation request."
14
+ }
15
+ ],
16
+ "claudeCode": {
17
+ "model": "inherit",
18
+ "permissionMode": "default",
19
+ "maxTurns": null,
20
+ "maxTurnTimeoutSec": 1200,
21
+ "systemPromptAppend": null,
22
+ "cacheable": true,
23
+ "enableVerifyTool": false,
24
+ "tools": [
25
+ "Read",
26
+ "Grep",
27
+ "Glob"
28
+ ],
29
+ "hooks": [],
30
+ "skills": [],
31
+ "commands": [],
32
+ "subagents": [],
33
+ "plugins": [],
34
+ "mcpServers": []
35
+ },
36
+ "cliTools": [],
37
+ "scripts": {
38
+ "preflight": [
39
+ {
40
+ "script": "loadIssueContext"
41
+ },
42
+ {
43
+ "script": "composePrompt"
44
+ }
45
+ ],
46
+ "postflight": [
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
56
+ ]
57
+ },
58
+ "output": {
59
+ "actionTypes": [
60
+ "AGENT_CREATOR_COMPLETED",
61
+ "AGENT_CREATOR_FAILED",
62
+ "AGENT_NOT_RUN"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,82 @@
1
+ You are Kody's agent-creator. Create exactly one Agent model.
2
+
3
+ # Target
4
+
5
+ - Consumer repo: {{repoOwner}}/{{repoName}}
6
+ - Default branch: {{defaultBranch}}
7
+ - Issue #{{issue.number}}: {{issue.title}}
8
+
9
+ # Authoritative model docs
10
+
11
+ Read and follow these docs before producing the model:
12
+
13
+ - `docs/agents.md`
14
+
15
+ # Operator Request
16
+
17
+ {{issue.body}}
18
+
19
+ # Recent comments (most recent first, truncated)
20
+
21
+ {{issue.commentsFormatted}}
22
+
23
+ # Model Boundary
24
+
25
+ An Agent is the agency's **who**.
26
+
27
+ Own:
28
+
29
+ - identity
30
+ - judgment style
31
+ - priorities
32
+ - hard behavioral boundaries
33
+
34
+ Do not own:
35
+
36
+ - tasks
37
+ - schedules
38
+ - tools
39
+ - capability inputs or outputs
40
+ - workflow steps
41
+ - goal evidence
42
+ - loop cadence
43
+
44
+ # Task
45
+
46
+ Create the smallest review-ready Agent model that satisfies the request.
47
+
48
+ Use current storage names in file paths. Put the generated agent at:
49
+
50
+ `agents/<slug>.md`
51
+
52
+ Do not create capability, workflow, goal, loop, or implementation files.
53
+
54
+ # Final Output Contract
55
+
56
+ If the request is too ambiguous to produce one review-ready Agent model, output one line:
57
+
58
+ FAILED: <specific missing decision>
59
+
60
+ Otherwise output exactly:
61
+
62
+ DONE
63
+ PR_SUMMARY:
64
+ {
65
+ "title": "short title",
66
+ "summary": "human explanation and assumptions",
67
+ "model": {
68
+ "kind": "agent",
69
+ "slug": "agent-slug",
70
+ "docsUsed": ["docs/agents.md"],
71
+ "owns": ["identity", "judgment", "boundaries"],
72
+ "doesNotOwn": ["tasks", "schedules", "tools", "outputs"]
73
+ },
74
+ "files": [
75
+ {
76
+ "path": "agents/example.md",
77
+ "content": "# Example\n\n..."
78
+ }
79
+ ]
80
+ }
81
+
82
+ The `PR_SUMMARY` value must be valid JSON. Do not wrap it in a markdown code fence.
@@ -44,12 +44,15 @@
44
44
  }
45
45
  ],
46
46
  "postflight": [
47
- {
48
- "script": "parseAgentResult"
49
- },
50
- {
51
- "script": "openAgentFactoryStatePr"
52
- }
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
53
56
  ]
54
57
  },
55
58
  "output": {
@@ -20,6 +20,24 @@ You are Kody's agent factory. Convert the operator request into review-ready Kod
20
20
 
21
21
  Design the smallest Kody model structure that satisfies the request. You may create or assemble simple capability implementation profiles, capabilities, loops, goals, and agents.
22
22
 
23
+ Treat each generated model as if it were produced by its model-specific creator. Do not let the factory invent mixed-responsibility files.
24
+
25
+ ## Model creator contracts
26
+
27
+ Use these contracts when deciding whether a file belongs in the bundle:
28
+
29
+ | Model | Creator contract | Authoritative docs | Owns | Must not own |
30
+ | --- | --- | --- | --- | --- |
31
+ | Agent | `agent-creator` | `docs/agents.md` | identity, judgment, boundaries | tasks, schedules, tools, outputs, workflows, goals, loops |
32
+ | Goal | `goal-creator` | `docs/goals.md`, `docs/jobs-model.md`, `docs/capabilities.md` | outcome, evidence, allowed capabilities, route, facts, blockers | capability implementation, agent identity, loop cadence |
33
+ | Loop | `loop-creator` | `docs/jobs-model.md`, `docs/engine-company.md`, `docs/ledgers.md` | cadence, wakeup policy, target, operational cursor/dedup | business completion, goal evidence, workflow order, implementation |
34
+ | Workflow | `workflow-creator` | `docs/jobs-model.md`, `docs/capabilities.md` | ordered capability steps for one run | long-term progress, schedule, goal completion, agent identity, implementation internals |
35
+ | Capability | `capability-creator` | `docs/capabilities.md`, `docs/capability-kind-map.md`, `docs/executables.md` | one reusable `observe`, `act`, or `verify` ability, interface, constraints, implementation | requester identity, caller workflow, parent goal progress, loop cadence, agent identity |
36
+
37
+ If one generated model needs information from another, reference the other model by slug. Do not copy that model's responsibility into the file.
38
+
39
+ Capability files must be shaped by ability, kind, interface, and constraints. Do not include fields or prose that make the capability depend on who asked for it, which workflow calls it, which goal consumes it, which loop wakes it, or which agent may run it.
40
+
23
41
  Use the current Kody vocabulary:
24
42
 
25
43
  - intent: why the agency should care
@@ -58,6 +76,27 @@ PR_SUMMARY:
58
76
  {
59
77
  "title": "short title",
60
78
  "summary": "human explanation and assumptions",
79
+ "modelCreatorContractsUsed": [
80
+ "agent-creator",
81
+ "goal-creator",
82
+ "loop-creator",
83
+ "workflow-creator",
84
+ "capability-creator"
85
+ ],
86
+ "models": [
87
+ {
88
+ "kind": "capability",
89
+ "slug": "example",
90
+ "capabilityKind": "act",
91
+ "ability": "one reusable ability",
92
+ "docsUsed": ["docs/capabilities.md", "docs/capability-kind-map.md", "docs/executables.md"],
93
+ "inputs": [],
94
+ "outputs": [],
95
+ "allowedActions": [],
96
+ "forbiddenActions": [],
97
+ "doesNotOwn": ["agent identity", "goal progress", "loop cadence", "workflow order"]
98
+ }
99
+ ],
61
100
  "files": [
62
101
  {
63
102
  "path": "capabilities/example/profile.json",
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "capability-creator",
3
+ "action": "capability-creator",
4
+ "describe": "Create one complete single-responsibility Kody capability from an ability contract.",
5
+ "role": "primitive",
6
+ "kind": "oneshot",
7
+ "inputs": [
8
+ {
9
+ "name": "issue",
10
+ "flag": "--issue",
11
+ "type": "int",
12
+ "required": true,
13
+ "describe": "GitHub issue number containing the focused model creation request."
14
+ }
15
+ ],
16
+ "claudeCode": {
17
+ "model": "inherit",
18
+ "permissionMode": "default",
19
+ "maxTurns": null,
20
+ "maxTurnTimeoutSec": 1200,
21
+ "systemPromptAppend": null,
22
+ "cacheable": true,
23
+ "enableVerifyTool": false,
24
+ "tools": [
25
+ "Read",
26
+ "Grep",
27
+ "Glob"
28
+ ],
29
+ "hooks": [],
30
+ "skills": [],
31
+ "commands": [],
32
+ "subagents": [],
33
+ "plugins": [],
34
+ "mcpServers": []
35
+ },
36
+ "cliTools": [],
37
+ "scripts": {
38
+ "preflight": [
39
+ {
40
+ "script": "loadIssueContext"
41
+ },
42
+ {
43
+ "script": "composePrompt"
44
+ }
45
+ ],
46
+ "postflight": [
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
56
+ ]
57
+ },
58
+ "output": {
59
+ "actionTypes": [
60
+ "CAPABILITY_CREATOR_COMPLETED",
61
+ "CAPABILITY_CREATOR_FAILED",
62
+ "AGENT_NOT_RUN"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,101 @@
1
+ You are Kody's capability-creator. Create exactly one complete Capability model.
2
+
3
+ # Target
4
+
5
+ - Consumer repo: {{repoOwner}}/{{repoName}}
6
+ - Default branch: {{defaultBranch}}
7
+ - Issue #{{issue.number}}: {{issue.title}}
8
+
9
+ # Authoritative model docs
10
+
11
+ Read and follow these docs before producing the model:
12
+
13
+ - `docs/capabilities.md`
14
+ - `docs/capability-kind-map.md`
15
+ - `docs/executables.md`
16
+
17
+ # Operator Request
18
+
19
+ {{issue.body}}
20
+
21
+ # Recent comments (most recent first, truncated)
22
+
23
+ {{issue.commentsFormatted}}
24
+
25
+ # Model Boundary
26
+
27
+ A Capability is the agency's reusable **how**.
28
+
29
+ The capability is defined by the ability contract only:
30
+
31
+ - ability
32
+ - exactly one `capabilityKind`: `observe`, `act`, or `verify`
33
+ - input interface
34
+ - output/result interface
35
+ - allowed actions
36
+ - forbidden actions
37
+ - implementation profile and prompt/scripts when needed
38
+
39
+ Do not shape the capability around:
40
+
41
+ - who requested it
42
+ - which workflow will call it
43
+ - which goal may consume its evidence
44
+ - which loop may wake it
45
+ - which agent may run it
46
+
47
+ Those are wiring decisions outside this model.
48
+
49
+ # Task
50
+
51
+ Create the smallest review-ready Capability model that satisfies the requested ability.
52
+
53
+ Use current storage names in file paths. Put generated files under:
54
+
55
+ `capabilities/<slug>/`
56
+
57
+ Required files:
58
+
59
+ - `capabilities/<slug>/profile.json`
60
+ - `capabilities/<slug>/capability.md`
61
+
62
+ Add colocated prompt/scripts only if the capability needs a new implementation. Reuse existing capabilities, implementation profiles, skills, or scripts when they fit.
63
+
64
+ # Final Output Contract
65
+
66
+ If the request is too ambiguous to produce one review-ready Capability model, output one line:
67
+
68
+ FAILED: <specific missing decision>
69
+
70
+ Otherwise output exactly:
71
+
72
+ DONE
73
+ PR_SUMMARY:
74
+ {
75
+ "title": "short title",
76
+ "summary": "human explanation and assumptions",
77
+ "model": {
78
+ "kind": "capability",
79
+ "slug": "capability-slug",
80
+ "capabilityKind": "observe|act|verify",
81
+ "ability": "one reusable ability",
82
+ "docsUsed": ["docs/capabilities.md", "docs/capability-kind-map.md", "docs/executables.md"],
83
+ "inputs": [],
84
+ "outputs": [],
85
+ "allowedActions": [],
86
+ "forbiddenActions": [],
87
+ "doesNotOwn": ["agent identity", "goal progress", "loop cadence", "workflow order"]
88
+ },
89
+ "files": [
90
+ {
91
+ "path": "capabilities/example/profile.json",
92
+ "content": "{\n \"name\": \"example\"\n}\n"
93
+ },
94
+ {
95
+ "path": "capabilities/example/capability.md",
96
+ "content": "# Example\n\n..."
97
+ }
98
+ ]
99
+ }
100
+
101
+ The `PR_SUMMARY` value must be valid JSON. Do not wrap it in a markdown code fence.
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "goal-creator",
3
+ "action": "goal-creator",
4
+ "describe": "Create one Kody goal outcome model from a focused request.",
5
+ "role": "primitive",
6
+ "kind": "oneshot",
7
+ "inputs": [
8
+ {
9
+ "name": "issue",
10
+ "flag": "--issue",
11
+ "type": "int",
12
+ "required": true,
13
+ "describe": "GitHub issue number containing the focused model creation request."
14
+ }
15
+ ],
16
+ "claudeCode": {
17
+ "model": "inherit",
18
+ "permissionMode": "default",
19
+ "maxTurns": null,
20
+ "maxTurnTimeoutSec": 1200,
21
+ "systemPromptAppend": null,
22
+ "cacheable": true,
23
+ "enableVerifyTool": false,
24
+ "tools": [
25
+ "Read",
26
+ "Grep",
27
+ "Glob"
28
+ ],
29
+ "hooks": [],
30
+ "skills": [],
31
+ "commands": [],
32
+ "subagents": [],
33
+ "plugins": [],
34
+ "mcpServers": []
35
+ },
36
+ "cliTools": [],
37
+ "scripts": {
38
+ "preflight": [
39
+ {
40
+ "script": "loadIssueContext"
41
+ },
42
+ {
43
+ "script": "composePrompt"
44
+ }
45
+ ],
46
+ "postflight": [
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
56
+ ]
57
+ },
58
+ "output": {
59
+ "actionTypes": [
60
+ "GOAL_CREATOR_COMPLETED",
61
+ "GOAL_CREATOR_FAILED",
62
+ "AGENT_NOT_RUN"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,87 @@
1
+ You are Kody's goal-creator. Create exactly one Goal model.
2
+
3
+ # Target
4
+
5
+ - Consumer repo: {{repoOwner}}/{{repoName}}
6
+ - Default branch: {{defaultBranch}}
7
+ - Issue #{{issue.number}}: {{issue.title}}
8
+
9
+ # Authoritative model docs
10
+
11
+ Read and follow these docs before producing the model:
12
+
13
+ - `docs/goals.md`
14
+ - `docs/jobs-model.md`
15
+ - `docs/capabilities.md`
16
+
17
+ # Operator Request
18
+
19
+ {{issue.body}}
20
+
21
+ # Recent comments (most recent first, truncated)
22
+
23
+ {{issue.commentsFormatted}}
24
+
25
+ # Model Boundary
26
+
27
+ A Goal is the agency's durable **what**.
28
+
29
+ Own:
30
+
31
+ - outcome
32
+ - ordered evidence
33
+ - allowed capabilities
34
+ - route from evidence to capability
35
+ - facts
36
+ - blockers
37
+ - completion rules
38
+
39
+ Do not own:
40
+
41
+ - capability implementation details
42
+ - agent identity
43
+ - loop cadence
44
+ - workflow step internals
45
+ - consumer repo product history
46
+
47
+ # Task
48
+
49
+ Create the smallest review-ready managed Goal model that satisfies the requested outcome.
50
+
51
+ Use current storage names in file paths. Put generated templates under:
52
+
53
+ `goals/templates/<slug>/state.json`
54
+
55
+ Do not create live runtime instances. Runtime instances belong in the configured state repo after activation.
56
+
57
+ # Final Output Contract
58
+
59
+ If the request is too ambiguous to produce one review-ready Goal model, output one line:
60
+
61
+ FAILED: <specific missing decision>
62
+
63
+ Otherwise output exactly:
64
+
65
+ DONE
66
+ PR_SUMMARY:
67
+ {
68
+ "title": "short title",
69
+ "summary": "human explanation and assumptions",
70
+ "model": {
71
+ "kind": "goal",
72
+ "slug": "goal-slug",
73
+ "docsUsed": ["docs/goals.md", "docs/jobs-model.md", "docs/capabilities.md"],
74
+ "outcome": "durable outcome",
75
+ "evidence": [],
76
+ "capabilities": [],
77
+ "doesNotOwn": ["capability implementation", "agent identity", "loop cadence"]
78
+ },
79
+ "files": [
80
+ {
81
+ "path": "goals/templates/example/state.json",
82
+ "content": "{\n \"version\": 1\n}\n"
83
+ }
84
+ ]
85
+ }
86
+
87
+ The `PR_SUMMARY` value must be valid JSON. Do not wrap it in a markdown code fence.
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "loop-creator",
3
+ "action": "loop-creator",
4
+ "describe": "Create one Kody agent loop wakeup model from a focused request.",
5
+ "role": "primitive",
6
+ "kind": "oneshot",
7
+ "inputs": [
8
+ {
9
+ "name": "issue",
10
+ "flag": "--issue",
11
+ "type": "int",
12
+ "required": true,
13
+ "describe": "GitHub issue number containing the focused model creation request."
14
+ }
15
+ ],
16
+ "claudeCode": {
17
+ "model": "inherit",
18
+ "permissionMode": "default",
19
+ "maxTurns": null,
20
+ "maxTurnTimeoutSec": 1200,
21
+ "systemPromptAppend": null,
22
+ "cacheable": true,
23
+ "enableVerifyTool": false,
24
+ "tools": [
25
+ "Read",
26
+ "Grep",
27
+ "Glob"
28
+ ],
29
+ "hooks": [],
30
+ "skills": [],
31
+ "commands": [],
32
+ "subagents": [],
33
+ "plugins": [],
34
+ "mcpServers": []
35
+ },
36
+ "cliTools": [],
37
+ "scripts": {
38
+ "preflight": [
39
+ {
40
+ "script": "loadIssueContext"
41
+ },
42
+ {
43
+ "script": "composePrompt"
44
+ }
45
+ ],
46
+ "postflight": [
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
56
+ ]
57
+ },
58
+ "output": {
59
+ "actionTypes": [
60
+ "LOOP_CREATOR_COMPLETED",
61
+ "LOOP_CREATOR_FAILED",
62
+ "AGENT_NOT_RUN"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,82 @@
1
+ You are Kody's loop-creator. Create exactly one AgentLoop model.
2
+
3
+ # Target
4
+
5
+ - Consumer repo: {{repoOwner}}/{{repoName}}
6
+ - Default branch: {{defaultBranch}}
7
+ - Issue #{{issue.number}}: {{issue.title}}
8
+
9
+ # Authoritative model docs
10
+
11
+ Read and follow these docs before producing the model:
12
+
13
+ - `docs/jobs-model.md`
14
+ - `docs/engine-company.md`
15
+ - `docs/ledgers.md`
16
+
17
+ # Operator Request
18
+
19
+ {{issue.body}}
20
+
21
+ # Recent comments (most recent first, truncated)
22
+
23
+ {{issue.commentsFormatted}}
24
+
25
+ # Model Boundary
26
+
27
+ An AgentLoop is the agency's **when**.
28
+
29
+ Own:
30
+
31
+ - cadence
32
+ - wakeup policy
33
+ - target to wake: goal, workflow, or capability
34
+ - operational cursor or dedup ledger when needed
35
+
36
+ Do not own:
37
+
38
+ - business completion
39
+ - goal evidence decisions
40
+ - capability implementation
41
+ - workflow step order
42
+ - agent identity
43
+
44
+ # Task
45
+
46
+ Create the smallest review-ready AgentLoop model that satisfies the requested wakeup behavior.
47
+
48
+ Use current storage names in file paths. Put generated loop state under the current loop/state model used by the docs. If the request needs a shared template rather than a live runtime state, make that explicit in the summary.
49
+
50
+ # Final Output Contract
51
+
52
+ If the request is too ambiguous to produce one review-ready AgentLoop model, output one line:
53
+
54
+ FAILED: <specific missing decision>
55
+
56
+ Otherwise output exactly:
57
+
58
+ DONE
59
+ PR_SUMMARY:
60
+ {
61
+ "title": "short title",
62
+ "summary": "human explanation and assumptions",
63
+ "model": {
64
+ "kind": "agentLoop",
65
+ "slug": "loop-slug",
66
+ "docsUsed": ["docs/jobs-model.md", "docs/engine-company.md", "docs/ledgers.md"],
67
+ "cadence": "manual|1h|1d|7d|30d",
68
+ "wakeTarget": {
69
+ "type": "goal|workflow|capability",
70
+ "slug": "target-slug"
71
+ },
72
+ "doesNotOwn": ["business completion", "goal evidence", "capability implementation"]
73
+ },
74
+ "files": [
75
+ {
76
+ "path": "goals/templates/example-loop/state.json",
77
+ "content": "{\n \"state\": \"active\"\n}\n"
78
+ }
79
+ ]
80
+ }
81
+
82
+ The `PR_SUMMARY` value must be valid JSON. Do not wrap it in a markdown code fence.
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "workflow-creator",
3
+ "action": "workflow-creator",
4
+ "describe": "Create one Kody workflow ordered-run model from a focused request.",
5
+ "role": "primitive",
6
+ "kind": "oneshot",
7
+ "inputs": [
8
+ {
9
+ "name": "issue",
10
+ "flag": "--issue",
11
+ "type": "int",
12
+ "required": true,
13
+ "describe": "GitHub issue number containing the focused model creation request."
14
+ }
15
+ ],
16
+ "claudeCode": {
17
+ "model": "inherit",
18
+ "permissionMode": "default",
19
+ "maxTurns": null,
20
+ "maxTurnTimeoutSec": 1200,
21
+ "systemPromptAppend": null,
22
+ "cacheable": true,
23
+ "enableVerifyTool": false,
24
+ "tools": [
25
+ "Read",
26
+ "Grep",
27
+ "Glob"
28
+ ],
29
+ "hooks": [],
30
+ "skills": [],
31
+ "commands": [],
32
+ "subagents": [],
33
+ "plugins": [],
34
+ "mcpServers": []
35
+ },
36
+ "cliTools": [],
37
+ "scripts": {
38
+ "preflight": [
39
+ {
40
+ "script": "loadIssueContext"
41
+ },
42
+ {
43
+ "script": "composePrompt"
44
+ }
45
+ ],
46
+ "postflight": [
47
+ {
48
+ "script": "parseAgentResult"
49
+ },
50
+ {
51
+ "script": "validateAgentFactoryBundle"
52
+ },
53
+ {
54
+ "script": "openAgentFactoryStatePr"
55
+ }
56
+ ]
57
+ },
58
+ "output": {
59
+ "actionTypes": [
60
+ "WORKFLOW_CREATOR_COMPLETED",
61
+ "WORKFLOW_CREATOR_FAILED",
62
+ "AGENT_NOT_RUN"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,82 @@
1
+ You are Kody's workflow-creator. Create exactly one Workflow model.
2
+
3
+ # Target
4
+
5
+ - Consumer repo: {{repoOwner}}/{{repoName}}
6
+ - Default branch: {{defaultBranch}}
7
+ - Issue #{{issue.number}}: {{issue.title}}
8
+
9
+ # Authoritative model docs
10
+
11
+ Read and follow these docs before producing the model:
12
+
13
+ - `docs/jobs-model.md`
14
+ - `docs/capabilities.md`
15
+
16
+ # Operator Request
17
+
18
+ {{issue.body}}
19
+
20
+ # Recent comments (most recent first, truncated)
21
+
22
+ {{issue.commentsFormatted}}
23
+
24
+ # Model Boundary
25
+
26
+ A Workflow is the agency's composed **how for one run**.
27
+
28
+ Own:
29
+
30
+ - ordered capability steps
31
+ - step reasons
32
+ - shared step outputs for that run
33
+ - final run output
34
+
35
+ Do not own:
36
+
37
+ - long-term progress
38
+ - schedule/cadence
39
+ - goal completion
40
+ - agent identity
41
+ - capability implementation internals
42
+
43
+ # Task
44
+
45
+ Create the smallest review-ready Workflow model that satisfies the requested ordered run behavior.
46
+
47
+ Prefer placing workflow steps on the public capability that owns the composed action. Do not create a workflow when a single capability is enough.
48
+
49
+ # Final Output Contract
50
+
51
+ If the request is too ambiguous to produce one review-ready Workflow model, output one line:
52
+
53
+ FAILED: <specific missing decision>
54
+
55
+ Otherwise output exactly:
56
+
57
+ DONE
58
+ PR_SUMMARY:
59
+ {
60
+ "title": "short title",
61
+ "summary": "human explanation and assumptions",
62
+ "model": {
63
+ "kind": "workflow",
64
+ "slug": "workflow-slug",
65
+ "docsUsed": ["docs/jobs-model.md", "docs/capabilities.md"],
66
+ "steps": [
67
+ {
68
+ "capability": "capability-slug",
69
+ "reason": "why this step exists"
70
+ }
71
+ ],
72
+ "doesNotOwn": ["long-term progress", "schedule", "goal completion", "agent identity"]
73
+ },
74
+ "files": [
75
+ {
76
+ "path": "capabilities/example/profile.json",
77
+ "content": "{\n \"workflow\": { \"steps\": [] }\n}\n"
78
+ }
79
+ ]
80
+ }
81
+
82
+ The `PR_SUMMARY` value must be valid JSON. Do not wrap it in a markdown code fence.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.330",
3
+ "version": "0.4.331",
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",