mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-02 21:33:52 +00:00
fix: inserting task plan into issue (#384)
* fix: inserting task plan into issue * cr
This commit is contained in:
parent
9d9b64fab7
commit
7cf1348947
1 changed files with 24 additions and 14 deletions
|
|
@ -15,6 +15,10 @@ export const TASK_CLOSE_TAG = "</open-swe-do-not-edit-task-plan>";
|
||||||
export const PROPOSED_PLAN_OPEN_TAG = "<open-swe-do-not-edit-proposed-plan>";
|
export const PROPOSED_PLAN_OPEN_TAG = "<open-swe-do-not-edit-proposed-plan>";
|
||||||
export const PROPOSED_PLAN_CLOSE_TAG = "</open-swe-do-not-edit-proposed-plan>";
|
export const PROPOSED_PLAN_CLOSE_TAG = "</open-swe-do-not-edit-proposed-plan>";
|
||||||
|
|
||||||
|
const DETAILS_OPEN_TAG = "<details>";
|
||||||
|
const DETAILS_CLOSE_TAG = "</details>";
|
||||||
|
const AGENT_CONTEXT_DETAILS_SUMMARY = "<summary>Agent Context</summary>";
|
||||||
|
|
||||||
function typeNarrowTaskPlan(taskPlan: unknown): taskPlan is TaskPlan {
|
function typeNarrowTaskPlan(taskPlan: unknown): taskPlan is TaskPlan {
|
||||||
return !!(
|
return !!(
|
||||||
typeof taskPlan === "object" &&
|
typeof taskPlan === "object" &&
|
||||||
|
|
@ -126,8 +130,6 @@ function insertPlanToIssueBody(
|
||||||
${planString}
|
${planString}
|
||||||
${closingPlanTag}`;
|
${closingPlanTag}`;
|
||||||
|
|
||||||
let newBody = "";
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!issueBody.includes(openingPlanTag) &&
|
!issueBody.includes(openingPlanTag) &&
|
||||||
!issueBody.includes(closingPlanTag)
|
!issueBody.includes(closingPlanTag)
|
||||||
|
|
@ -136,7 +138,7 @@ ${closingPlanTag}`;
|
||||||
!issueBody.includes(DETAILS_OPEN_TAG) &&
|
!issueBody.includes(DETAILS_OPEN_TAG) &&
|
||||||
!issueBody.includes(DETAILS_CLOSE_TAG)
|
!issueBody.includes(DETAILS_CLOSE_TAG)
|
||||||
) {
|
) {
|
||||||
newBody = `${issueBody}
|
return `${issueBody}
|
||||||
${DETAILS_OPEN_TAG}
|
${DETAILS_OPEN_TAG}
|
||||||
${AGENT_CONTEXT_DETAILS_SUMMARY}
|
${AGENT_CONTEXT_DETAILS_SUMMARY}
|
||||||
${wrappedPlan}
|
${wrappedPlan}
|
||||||
|
|
@ -144,22 +146,34 @@ ${DETAILS_CLOSE_TAG}`;
|
||||||
} else {
|
} else {
|
||||||
// No plan present yet, but details already exists.
|
// No plan present yet, but details already exists.
|
||||||
const contentBeforeDetailsTag = issueBody.split(DETAILS_OPEN_TAG)?.[0];
|
const contentBeforeDetailsTag = issueBody.split(DETAILS_OPEN_TAG)?.[0];
|
||||||
const contentAfterDetailsTag = issueBody.split(DETAILS_CLOSE_TAG)?.[0];
|
const contentAfterDetailsOpenTag =
|
||||||
|
issueBody.split(DETAILS_OPEN_TAG)?.[1] || "";
|
||||||
|
const contentAfterSummary = contentAfterDetailsOpenTag.includes(
|
||||||
|
AGENT_CONTEXT_DETAILS_SUMMARY,
|
||||||
|
)
|
||||||
|
? contentAfterDetailsOpenTag.split(AGENT_CONTEXT_DETAILS_SUMMARY)[1]
|
||||||
|
: contentAfterDetailsOpenTag;
|
||||||
|
const contentAfterDetailsCloseTag =
|
||||||
|
issueBody.split(DETAILS_CLOSE_TAG)?.[1] || "";
|
||||||
|
|
||||||
newBody = `${contentBeforeDetailsTag}
|
return `${contentBeforeDetailsTag}${DETAILS_OPEN_TAG}
|
||||||
${wrappedPlan}
|
${AGENT_CONTEXT_DETAILS_SUMMARY}
|
||||||
${contentAfterDetailsTag}`;
|
${wrappedPlan}${
|
||||||
|
contentAfterSummary.trim()
|
||||||
|
? `
|
||||||
|
${contentAfterSummary.trim()}`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
${DETAILS_CLOSE_TAG}${contentAfterDetailsCloseTag}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const contentBeforeOpenTag = issueBody.split(openingPlanTag)?.[0];
|
const contentBeforeOpenTag = issueBody.split(openingPlanTag)?.[0];
|
||||||
const contentAfterCloseTag = issueBody.split(closingPlanTag)?.[1];
|
const contentAfterCloseTag = issueBody.split(closingPlanTag)?.[1];
|
||||||
|
|
||||||
newBody = `${contentBeforeOpenTag}
|
return `${contentBeforeOpenTag}
|
||||||
${wrappedPlan}
|
${wrappedPlan}
|
||||||
${contentAfterCloseTag}`;
|
${contentAfterCloseTag}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBody;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addProposedPlanToIssue(
|
export async function addProposedPlanToIssue(
|
||||||
|
|
@ -197,10 +211,6 @@ export async function addProposedPlanToIssue(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const DETAILS_OPEN_TAG = "<details>";
|
|
||||||
const DETAILS_CLOSE_TAG = "</details>";
|
|
||||||
const AGENT_CONTEXT_DETAILS_SUMMARY = "<summary>Agent Context</summary>";
|
|
||||||
|
|
||||||
export async function addTaskPlanToIssue(
|
export async function addTaskPlanToIssue(
|
||||||
input: GetIssueTaskPlanInput,
|
input: GetIssueTaskPlanInput,
|
||||||
config: GraphConfig,
|
config: GraphConfig,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue