fix: first needs to be issue body #4

Merged
drgroot merged 1 commits from f into main 2026-01-10 05:32:11 +00:00
3 changed files with 72 additions and 8 deletions
Showing only changes of commit 2b4d3f23e5 - Show all commits

View File

@@ -4,8 +4,8 @@ Sends issue comment text to an embeddings API so issue discussions can be stored
## How it works ## How it works
- Reads issue comments via the GitHub API. - Reads issue body and comments via the GitHub API.
- Builds a request payload using the first comment for `embed_text` and the latest comment for `store_text`. - Builds a request payload using the issue body for `embed_text` and the latest comment for `store_text`.
- POSTs the payload to the configured API URL with optional token auth. - POSTs the payload to the configured API URL with optional token auth.
## Inputs ## Inputs

38
dist/index.js vendored
View File

@@ -32900,6 +32900,35 @@ async function issueComments() {
} }
} }
async function issueBody() {
if (!repoFullName || !issueNumber) return null;
const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}`;
const headers = { Accept: "application/vnd.github+json" };
if (githubToken) {
headers.Authorization = `Bearer ${githubToken}`;
}
try {
const response = await fetch(url, { headers });
if (!response.ok) {
core.warning(
`Failed to fetch issue body (${response.status}): ${response.statusText}`,
);
return null;
}
const issue = await response.json();
if (!issue?.body) return null;
return String(issue.body);
} catch (error) {
core.warning(`Error fetching issue body: ${error}`);
return null;
}
}
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
}; };
@@ -32920,7 +32949,7 @@ async function run() {
); );
} }
const comments = await issueComments(); const [body, comments] = await Promise.all([issueBody(), issueComments()]);
if (!comments || comments.length < 1) { if (!comments || comments.length < 1) {
if (!debug) { if (!debug) {
core.setFailed("Unable to determine the task to send to the agent"); core.setFailed("Unable to determine the task to send to the agent");
@@ -32931,6 +32960,9 @@ async function run() {
task = "[debug] empty task"; task = "[debug] empty task";
} }
const embedText = body ? body.trim() : String(comments[0]).trim();
const storeText = String(comments[comments.length - 1]).trim();
const requestPayload = { const requestPayload = {
type: "input", type: "input",
route, route,
@@ -32942,8 +32974,8 @@ async function run() {
inputs: { inputs: {
segment_id, segment_id,
document_id, document_id,
embed_text: String(comments[0]).trim(), embed_text: embedText,
store_text: String(comments[comments.length - 1]).trim(), store_text: storeText,
}, },
}, },
}; };

View File

@@ -68,6 +68,35 @@ async function issueComments() {
} }
} }
async function issueBody() {
if (!repoFullName || !issueNumber) return null;
const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}`;
const headers = { Accept: "application/vnd.github+json" };
if (githubToken) {
headers.Authorization = `Bearer ${githubToken}`;
}
try {
const response = await fetch(url, { headers });
if (!response.ok) {
core.warning(
`Failed to fetch issue body (${response.status}): ${response.statusText}`,
);
return null;
}
const issue = await response.json();
if (!issue?.body) return null;
return String(issue.body);
} catch (error) {
core.warning(`Error fetching issue body: ${error}`);
return null;
}
}
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
}; };
@@ -88,7 +117,7 @@ async function run() {
); );
} }
const comments = await issueComments(); const [body, comments] = await Promise.all([issueBody(), issueComments()]);
if (!comments || comments.length < 1) { if (!comments || comments.length < 1) {
if (!debug) { if (!debug) {
core.setFailed("Unable to determine the task to send to the agent"); core.setFailed("Unable to determine the task to send to the agent");
@@ -99,6 +128,9 @@ async function run() {
task = "[debug] empty task"; task = "[debug] empty task";
} }
const embedText = body ? body.trim() : String(comments[0]).trim();
const storeText = String(comments[comments.length - 1]).trim();
const requestPayload = { const requestPayload = {
type: "input", type: "input",
route, route,
@@ -110,8 +142,8 @@ async function run() {
inputs: { inputs: {
segment_id, segment_id,
document_id, document_id,
embed_text: String(comments[0]).trim(), embed_text: embedText,
store_text: String(comments[comments.length - 1]).trim(), store_text: storeText,
}, },
}, },
}; };