fix: first needs to be issue body
All checks were successful
Dependabot Auto-Merge / dependabot (pull_request) Has been skipped
Dependabot Auto-Merge / devopsbot (pull_request) Has been skipped
Dependabot Auto-Merge / rennovatebot (pull_request) Has been skipped
COMMIT LINT / commitlint (pull_request) Successful in 1m40s
Unit Tests / unittest (pull_request) Successful in 48s
All checks were successful
Dependabot Auto-Merge / dependabot (pull_request) Has been skipped
Dependabot Auto-Merge / devopsbot (pull_request) Has been skipped
Dependabot Auto-Merge / rennovatebot (pull_request) Has been skipped
COMMIT LINT / commitlint (pull_request) Successful in 1m40s
Unit Tests / unittest (pull_request) Successful in 48s
This commit is contained in:
@@ -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
38
dist/index.js
vendored
@@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
38
index.js
38
index.js
@@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user