@kody-ade/kody-engine 0.4.368 → 0.4.370
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 +147 -5
- package/dist/implementations/types.ts +15 -0
- package/package.json +1 -1
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.
|
|
18
|
+
version: "0.4.370",
|
|
19
19
|
description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
|
|
20
20
|
license: "MIT",
|
|
21
21
|
type: "module",
|
|
@@ -1989,6 +1989,7 @@ function parseWorkflowStep(value) {
|
|
|
1989
1989
|
const target = stringField(raw.target);
|
|
1990
1990
|
const targetFact = stringField(raw.targetFact ?? raw.target_fact);
|
|
1991
1991
|
const cliArgs = raw.cliArgs;
|
|
1992
|
+
const report = parseReportPublication(raw.report);
|
|
1992
1993
|
return {
|
|
1993
1994
|
capability,
|
|
1994
1995
|
...action && isSafeSlug(action) ? { action } : {},
|
|
@@ -2001,7 +2002,35 @@ function parseWorkflowStep(value) {
|
|
|
2001
2002
|
...cliArgs && typeof cliArgs === "object" && !Array.isArray(cliArgs) ? { cliArgs } : {},
|
|
2002
2003
|
...isPlainObject(raw.runWhen) ? { runWhen: raw.runWhen } : {},
|
|
2003
2004
|
...stringList(raw.continueOn ?? raw.continue_on).length > 0 ? { continueOn: stringList(raw.continueOn ?? raw.continue_on) } : {},
|
|
2004
|
-
...raw.saveReport === true ? { saveReport: true } : {}
|
|
2005
|
+
...raw.saveReport === true ? { saveReport: true } : {},
|
|
2006
|
+
...report ? { report } : {}
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
function parseReportPublication(value) {
|
|
2010
|
+
if (!isPlainObject(value)) return void 0;
|
|
2011
|
+
const type = stringField(value.type);
|
|
2012
|
+
const owner = stringField(value.owner);
|
|
2013
|
+
if (!type || !/^[a-z0-9][a-z0-9_-]{0,79}$/.test(type) || !owner || !isSafeSlug(owner)) return void 0;
|
|
2014
|
+
const version = typeof value.version === "number" && Number.isInteger(value.version) && value.version > 0 ? value.version : void 0;
|
|
2015
|
+
const slug = stringField(value.slug);
|
|
2016
|
+
const slugFact = stringField(value.slugFact);
|
|
2017
|
+
const title = stringField(value.title);
|
|
2018
|
+
const titleFact = stringField(value.titleFact);
|
|
2019
|
+
const publishWhenFact = stringField(value.publishWhenFact);
|
|
2020
|
+
const reviewStatus = stringField(value.reviewStatus);
|
|
2021
|
+
const reviewArea = stringField(value.reviewArea);
|
|
2022
|
+
if (!slug && !slugFact) return void 0;
|
|
2023
|
+
return {
|
|
2024
|
+
type,
|
|
2025
|
+
...version ? { version } : {},
|
|
2026
|
+
owner,
|
|
2027
|
+
...slug ? { slug } : {},
|
|
2028
|
+
...slugFact ? { slugFact } : {},
|
|
2029
|
+
...title ? { title } : {},
|
|
2030
|
+
...titleFact ? { titleFact } : {},
|
|
2031
|
+
...publishWhenFact ? { publishWhenFact } : {},
|
|
2032
|
+
...reviewStatus ? { reviewStatus } : {},
|
|
2033
|
+
...reviewArea ? { reviewArea } : {}
|
|
2005
2034
|
};
|
|
2006
2035
|
}
|
|
2007
2036
|
function isPlainObject(value) {
|
|
@@ -14009,12 +14038,13 @@ var init_loadCapabilityState = __esm({
|
|
|
14009
14038
|
ctx.data.capabilityToolsList = declaredTools.map((name) => `- \`${name}\``).join("\n");
|
|
14010
14039
|
ctx.data.capabilityOperatorMention = mentions;
|
|
14011
14040
|
const mcpToolNames = declaredTools.map((name) => `mcp__kody-capability__${name}`);
|
|
14041
|
+
const submitStateTool = "mcp__kody-submit__submit_state";
|
|
14042
|
+
profile.claudeCode.enableSubmitTool = true;
|
|
14012
14043
|
if (mode === "append") {
|
|
14013
|
-
profile.claudeCode.tools = [.../* @__PURE__ */ new Set([...profile.claudeCode.tools ?? [], ...mcpToolNames])];
|
|
14044
|
+
profile.claudeCode.tools = [.../* @__PURE__ */ new Set([...profile.claudeCode.tools ?? [], ...mcpToolNames, submitStateTool])];
|
|
14014
14045
|
return;
|
|
14015
14046
|
}
|
|
14016
|
-
profile.claudeCode.tools = [...mcpToolNames,
|
|
14017
|
-
profile.claudeCode.enableSubmitTool = true;
|
|
14047
|
+
profile.claudeCode.tools = [...mcpToolNames, submitStateTool];
|
|
14018
14048
|
}
|
|
14019
14049
|
};
|
|
14020
14050
|
}
|
|
@@ -15873,6 +15903,106 @@ var init_parseJobStateFromAgentResult = __esm({
|
|
|
15873
15903
|
}
|
|
15874
15904
|
});
|
|
15875
15905
|
|
|
15906
|
+
// src/scripts/publishReport.ts
|
|
15907
|
+
function buildRuntimeReportMarkdown(input) {
|
|
15908
|
+
return [
|
|
15909
|
+
"---",
|
|
15910
|
+
`generatedAt: ${yamlString(input.generatedAt)}`,
|
|
15911
|
+
`reportType: ${input.reportType}`,
|
|
15912
|
+
`reportTypeVersion: ${input.reportTypeVersion}`,
|
|
15913
|
+
"producer:",
|
|
15914
|
+
` model: ${input.owner}`,
|
|
15915
|
+
` capability: ${input.capability}`,
|
|
15916
|
+
...input.reviewStatus ? [`reviewStatus: ${input.reviewStatus}`] : [],
|
|
15917
|
+
...input.reviewArea ? [`reviewArea: ${input.reviewArea}`] : [],
|
|
15918
|
+
"---",
|
|
15919
|
+
`# ${input.title}`,
|
|
15920
|
+
"",
|
|
15921
|
+
input.summary,
|
|
15922
|
+
"",
|
|
15923
|
+
"## Report data",
|
|
15924
|
+
"```json",
|
|
15925
|
+
JSON.stringify(input.data, null, 2),
|
|
15926
|
+
"```",
|
|
15927
|
+
""
|
|
15928
|
+
].join("\n");
|
|
15929
|
+
}
|
|
15930
|
+
function parsePublication(value) {
|
|
15931
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
15932
|
+
const raw = value;
|
|
15933
|
+
if (typeof raw.type !== "string" || !SAFE_SLUG.test(raw.type)) return null;
|
|
15934
|
+
if (typeof raw.owner !== "string" || !SAFE_SLUG.test(raw.owner)) return null;
|
|
15935
|
+
return raw;
|
|
15936
|
+
}
|
|
15937
|
+
function latestResult(raw, agentResult) {
|
|
15938
|
+
const results = [];
|
|
15939
|
+
if (Array.isArray(raw)) {
|
|
15940
|
+
for (const item of raw) {
|
|
15941
|
+
const parsed = parseCapabilityResult(item);
|
|
15942
|
+
if (parsed) results.push(parsed);
|
|
15943
|
+
}
|
|
15944
|
+
}
|
|
15945
|
+
if (agentResult?.finalText) results.push(...parseCapabilityResultsFromText(agentResult.finalText));
|
|
15946
|
+
return results.at(-1) ?? null;
|
|
15947
|
+
}
|
|
15948
|
+
function recordField6(value) {
|
|
15949
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
15950
|
+
}
|
|
15951
|
+
function resolveDotted(root, path51) {
|
|
15952
|
+
if (!path51) return void 0;
|
|
15953
|
+
return path51.split(".").reduce((value, key) => recordField6(value)?.[key], root);
|
|
15954
|
+
}
|
|
15955
|
+
function stringValue4(value) {
|
|
15956
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
15957
|
+
}
|
|
15958
|
+
function humanize(value) {
|
|
15959
|
+
return value.split(/[-_]+/).filter(Boolean).map((part) => part[0].toUpperCase() + part.slice(1)).join(" ");
|
|
15960
|
+
}
|
|
15961
|
+
function yamlString(value) {
|
|
15962
|
+
return JSON.stringify(value);
|
|
15963
|
+
}
|
|
15964
|
+
var SAFE_SLUG, publishReport;
|
|
15965
|
+
var init_publishReport = __esm({
|
|
15966
|
+
"src/scripts/publishReport.ts"() {
|
|
15967
|
+
"use strict";
|
|
15968
|
+
init_capabilityResult();
|
|
15969
|
+
init_stateRepo();
|
|
15970
|
+
SAFE_SLUG = /^[a-z0-9][a-z0-9_-]{0,79}$/;
|
|
15971
|
+
publishReport = async (ctx, _profile, agentResult) => {
|
|
15972
|
+
const publication = parsePublication(ctx.data.reportPublication);
|
|
15973
|
+
if (!publication) return;
|
|
15974
|
+
const result = latestResult(ctx.data.capabilityResults, agentResult);
|
|
15975
|
+
const stateData = recordField6(recordField6(ctx.data.nextJobState)?.data) ?? {};
|
|
15976
|
+
const data = { ...stateData, ...result?.facts ?? {} };
|
|
15977
|
+
if (publication.publishWhenFact && resolveDotted(data, publication.publishWhenFact) === void 0) return;
|
|
15978
|
+
const slug = publication.slug ?? stringValue4(resolveDotted(data, publication.slugFact));
|
|
15979
|
+
if (!slug || !SAFE_SLUG.test(slug)) return;
|
|
15980
|
+
const title = publication.title ?? stringValue4(resolveDotted(data, publication.titleFact)) ?? humanize(slug);
|
|
15981
|
+
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
15982
|
+
const markdown = buildRuntimeReportMarkdown({
|
|
15983
|
+
generatedAt,
|
|
15984
|
+
reportType: publication.type,
|
|
15985
|
+
reportTypeVersion: publication.version ?? 1,
|
|
15986
|
+
owner: publication.owner,
|
|
15987
|
+
capability: stringValue4(ctx.data.jobCapability) ?? stringValue4(ctx.data.capabilitySlug) ?? "unknown",
|
|
15988
|
+
title,
|
|
15989
|
+
summary: result?.summary ?? title,
|
|
15990
|
+
data,
|
|
15991
|
+
...publication.reviewStatus ? { reviewStatus: publication.reviewStatus } : {},
|
|
15992
|
+
...publication.reviewArea ? { reviewArea: publication.reviewArea } : {}
|
|
15993
|
+
});
|
|
15994
|
+
const runId = generatedAt.replace(/\.\d{3}Z$/, "Z").replace(/:/g, "-");
|
|
15995
|
+
writeStateText(
|
|
15996
|
+
ctx.config,
|
|
15997
|
+
ctx.cwd,
|
|
15998
|
+
`reports/${slug}/runs/${runId}.md`,
|
|
15999
|
+
markdown,
|
|
16000
|
+
`chore(reports): add ${slug} run`
|
|
16001
|
+
);
|
|
16002
|
+
};
|
|
16003
|
+
}
|
|
16004
|
+
});
|
|
16005
|
+
|
|
15876
16006
|
// src/scripts/parseReproOutput.ts
|
|
15877
16007
|
function extractTestPath(text) {
|
|
15878
16008
|
const m = text.match(/^[\s>*_#`~-]*TEST_PATH[\s>*_#`~-]*\s*:\s*(.+?)\s*$/im);
|
|
@@ -19292,6 +19422,7 @@ var init_scripts = __esm({
|
|
|
19292
19422
|
init_parseAgentResult();
|
|
19293
19423
|
init_parseIssueStateFromAgentResult();
|
|
19294
19424
|
init_parseJobStateFromAgentResult();
|
|
19425
|
+
init_publishReport();
|
|
19295
19426
|
init_parseReproOutput();
|
|
19296
19427
|
init_persistArtifacts();
|
|
19297
19428
|
init_persistFlowState();
|
|
@@ -19420,6 +19551,7 @@ var init_scripts = __esm({
|
|
|
19420
19551
|
advanceFlow,
|
|
19421
19552
|
persistFlowState,
|
|
19422
19553
|
applyCapabilityReports,
|
|
19554
|
+
publishReport,
|
|
19423
19555
|
recordClassification,
|
|
19424
19556
|
dispatchClassified,
|
|
19425
19557
|
notifyTerminal,
|
|
@@ -20552,6 +20684,7 @@ var init_executor = __esm({
|
|
|
20552
20684
|
"commitAndPush",
|
|
20553
20685
|
"ensurePr",
|
|
20554
20686
|
"applyCapabilityReports",
|
|
20687
|
+
"publishReport",
|
|
20555
20688
|
"openAgentFactoryStatePr"
|
|
20556
20689
|
]);
|
|
20557
20690
|
MAX_CHAIN_HOPS = 60;
|
|
@@ -20608,9 +20741,16 @@ function validateJob(input) {
|
|
|
20608
20741
|
flavor: j.flavor,
|
|
20609
20742
|
force: j.force === true,
|
|
20610
20743
|
saveReport: j.saveReport === true,
|
|
20744
|
+
report: parseReportPublication2(j.report),
|
|
20611
20745
|
resultTarget: parseCapabilityResultTarget(j.resultTarget)
|
|
20612
20746
|
};
|
|
20613
20747
|
}
|
|
20748
|
+
function parseReportPublication2(raw) {
|
|
20749
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
20750
|
+
const report = raw;
|
|
20751
|
+
if (typeof report.type !== "string" || typeof report.owner !== "string") return void 0;
|
|
20752
|
+
return raw;
|
|
20753
|
+
}
|
|
20614
20754
|
function parseCapabilityResultTarget(raw) {
|
|
20615
20755
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
20616
20756
|
const target = raw;
|
|
@@ -20686,6 +20826,7 @@ async function runCapabilityImplementationStep(valid, profileName, capabilityIde
|
|
|
20686
20826
|
preloadedData.selectedImplementation = profileName;
|
|
20687
20827
|
if (valid.schedule !== void 0 && valid.schedule.length > 0) preloadedData.jobSchedule = valid.schedule;
|
|
20688
20828
|
if (valid.saveReport === true) preloadedData.jobSaveReport = true;
|
|
20829
|
+
if (valid.report) preloadedData.reportPublication = valid.report;
|
|
20689
20830
|
if (valid.force === true) preloadedData.jobForce = true;
|
|
20690
20831
|
if (valid.evidence) preloadedData.capabilityEvidence = { evidence: valid.evidence };
|
|
20691
20832
|
if (valid.resultTarget) preloadedData.capabilityResultTarget = valid.resultTarget;
|
|
@@ -20841,6 +20982,7 @@ function workflowStepToJob(step, parent, chainData) {
|
|
|
20841
20982
|
flavor: parent.flavor,
|
|
20842
20983
|
force: parent.force,
|
|
20843
20984
|
saveReport: step.saveReport === true || parent.saveReport === true,
|
|
20985
|
+
...step.report ? { report: step.report } : {},
|
|
20844
20986
|
...parent.resultTarget ? { resultTarget: parent.resultTarget } : {}
|
|
20845
20987
|
};
|
|
20846
20988
|
}
|
|
@@ -500,6 +500,19 @@ export type AnyScript = PreflightScript | PostflightScript
|
|
|
500
500
|
|
|
501
501
|
export type JobFlavor = "instant" | "scheduled"
|
|
502
502
|
|
|
503
|
+
export interface ReportPublicationConfig {
|
|
504
|
+
type: string
|
|
505
|
+
version?: number
|
|
506
|
+
owner: string
|
|
507
|
+
slug?: string
|
|
508
|
+
slugFact?: string
|
|
509
|
+
title?: string
|
|
510
|
+
titleFact?: string
|
|
511
|
+
publishWhenFact?: string
|
|
512
|
+
reviewStatus?: string
|
|
513
|
+
reviewArea?: string
|
|
514
|
+
}
|
|
515
|
+
|
|
503
516
|
export interface Job {
|
|
504
517
|
/** Public action the user/operator invoked. Mirrors the capability action. */
|
|
505
518
|
action?: string
|
|
@@ -530,6 +543,8 @@ export interface Job {
|
|
|
530
543
|
force?: boolean
|
|
531
544
|
/** Ask the owning goal/loop to write a report run after its persisted decision. */
|
|
532
545
|
saveReport?: boolean
|
|
546
|
+
/** Workflow-owned request for the runtime to publish typed capability output. */
|
|
547
|
+
report?: ReportPublicationConfig
|
|
533
548
|
/** Internal parent context used by postflights to attach neutral capability output. */
|
|
534
549
|
resultTarget?: CapabilityResultTarget
|
|
535
550
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kody-ade/kody-engine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.370",
|
|
4
4
|
"description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|