Compare commits
1 Commits
main
...
803404942b
| Author | SHA1 | Date | |
|---|---|---|---|
|
803404942b
|
2
.github/workflows/agent-markdown.yml
vendored
2
.github/workflows/agent-markdown.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: Send task to coding agent
|
||||
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
||||
with:
|
||||
api_url: ${{ secrets.AGENT_API_URL }} # default: http://agent-api.k8s.private
|
||||
api_url: ${{ secrets.AGENT_API_URL }} # default: https://api.servc.io
|
||||
api_token: ${{ secrets.AGENT_TOKEN }} # optional, required for authenticated API calls
|
||||
route: agent-lake # default: agent-lake
|
||||
debug: false
|
||||
13
.github/workflows/test.yml
vendored
13
.github/workflows/test.yml
vendored
@@ -13,13 +13,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
- name: Test Local Action
|
||||
id: test
|
||||
uses: ./
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm test
|
||||
debug: 'true'
|
||||
@@ -22,8 +22,9 @@ jobs:
|
||||
- name: Send task to coding agent
|
||||
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
||||
with:
|
||||
api_url: ${{ secrets.AGENT_API_URL }} # default: http://agent-api.k8s.private
|
||||
api_url: ${{ secrets.AGENT_API_URL }} # default: https://api.servc.io
|
||||
api_token: ${{ secrets.AGENT_TOKEN }} # optional, required for authenticated API calls
|
||||
route: agent-lake # default: agent-lake
|
||||
debug: false
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ description: 'Sends markdown files to the lake to embed into vector form'
|
||||
inputs:
|
||||
api_url:
|
||||
description: 'api url'
|
||||
default: 'http://agent-api.k8s.private'
|
||||
default: 'http://agents-api.servc-agents:3000'
|
||||
required: false
|
||||
api_token:
|
||||
description: 'API token for authentication'
|
||||
|
||||
1005
dist/index.js
vendored
1005
dist/index.js
vendored
File diff suppressed because one or more lines are too long
15
index.js
15
index.js
@@ -18,7 +18,7 @@ function getConfig({
|
||||
env = process.env,
|
||||
} = {}) {
|
||||
const apiUrl =
|
||||
coreModule.getInput("api_url") || "http://agent-api.k8s.private";
|
||||
coreModule.getInput("api_url") || "http://agents-api.servc-agents:3000";
|
||||
const apiToken = coreModule.getInput("api_token");
|
||||
const route = coreModule.getInput("route") || "agent-lake";
|
||||
const method = coreModule.getInput("method") || "embeddings_insert";
|
||||
@@ -61,16 +61,6 @@ function sanitizeDocumentId(value) {
|
||||
return value.replace(/[^A-Za-z0-9.]/g, "");
|
||||
}
|
||||
|
||||
function buildStoreText({ owner, repo, file, content }) {
|
||||
return [
|
||||
`repo_name: ${repo}`,
|
||||
`repo_owner: ${owner}`,
|
||||
`path: ${file}`,
|
||||
"",
|
||||
content,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function buildRequestPayload({
|
||||
route,
|
||||
method,
|
||||
@@ -92,7 +82,7 @@ function buildRequestPayload({
|
||||
segment_id: segmentId,
|
||||
document_id: sanitizeDocumentId([owner, repo, file].join(".")),
|
||||
embed_text: "",
|
||||
store_text: buildStoreText({ owner, repo, file, content }),
|
||||
store_text: content,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -175,7 +165,6 @@ async function main({
|
||||
|
||||
module.exports = {
|
||||
buildRequestPayload,
|
||||
buildStoreText,
|
||||
getConfig,
|
||||
listMarkdownFiles,
|
||||
main,
|
||||
|
||||
@@ -1,33 +1,7 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {
|
||||
buildRequestPayload,
|
||||
buildStoreText,
|
||||
getConfig,
|
||||
main,
|
||||
sanitizeDocumentId,
|
||||
} = require("./index");
|
||||
|
||||
test("getConfig defaults to the ingress API URL", () => {
|
||||
const config = getConfig({
|
||||
coreModule: {
|
||||
getInput() {
|
||||
return "";
|
||||
},
|
||||
},
|
||||
githubModule: {
|
||||
context: {
|
||||
serverUrl: "https://github.example",
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
});
|
||||
|
||||
assert.equal(config.apiUrl, "http://agent-api.k8s.private");
|
||||
assert.equal(config.route, "agent-lake");
|
||||
assert.equal(config.method, "embeddings_insert");
|
||||
});
|
||||
const { buildRequestPayload, main, sanitizeDocumentId } = require("./index");
|
||||
|
||||
test("sanitizeDocumentId removes special characters and preserves periods", () => {
|
||||
assert.equal(
|
||||
@@ -36,22 +10,7 @@ test("sanitizeDocumentId removes special characters and preserves periods", () =
|
||||
);
|
||||
});
|
||||
|
||||
test("buildStoreText prefixes repository metadata before the markdown content", () => {
|
||||
const content = "# Title\n\n## First\nalpha\n\n## Second\nbeta\n";
|
||||
const storeText = buildStoreText({
|
||||
owner: "acme",
|
||||
repo: "docs-repo",
|
||||
file: "guides/setup.md",
|
||||
content,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
storeText,
|
||||
"repo_name: docs-repo\nrepo_owner: acme\npath: guides/setup.md\n\n# Title\n\n## First\nalpha\n\n## Second\nbeta\n",
|
||||
);
|
||||
});
|
||||
|
||||
test("buildRequestPayload sends metadata-prefixed store_text and an empty embed_text", () => {
|
||||
test("buildRequestPayload sends the full document in store_text and an empty embed_text", () => {
|
||||
const content = "# Title\n\n## First\nalpha\n\n## Second\nbeta\n";
|
||||
const payload = buildRequestPayload({
|
||||
route: "agent-lake",
|
||||
@@ -64,10 +23,7 @@ test("buildRequestPayload sends metadata-prefixed store_text and an empty embed_
|
||||
});
|
||||
|
||||
assert.equal(payload.inputs.inputs.embed_text, "");
|
||||
assert.equal(
|
||||
payload.inputs.inputs.store_text,
|
||||
"repo_name: docs-repo\nrepo_owner: acme\npath: guides/setup.md\n\n# Title\n\n## First\nalpha\n\n## Second\nbeta\n",
|
||||
);
|
||||
assert.equal(payload.inputs.inputs.store_text, content);
|
||||
assert.equal(
|
||||
payload.inputs.inputs.document_id,
|
||||
"acme.docsrepo.guidessetup.md",
|
||||
@@ -136,10 +92,7 @@ test("main sends one request per file even when the document contains multiple s
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0].url, "https://agents.example/api");
|
||||
assert.equal(calls[0].body.inputs.inputs.embed_text, "");
|
||||
assert.equal(
|
||||
calls[0].body.inputs.inputs.store_text,
|
||||
"repo_name: docs-repo\nrepo_owner: acme\npath: README.md\n\n# Title\n\n## First\nalpha\n\n## Second\nbeta\n",
|
||||
);
|
||||
assert.equal(calls[0].body.inputs.inputs.store_text, content);
|
||||
assert.equal(
|
||||
calls[0].body.inputs.inputs.document_id,
|
||||
"acme.docsrepo.README.md",
|
||||
|
||||
1
package-lock.json
generated
1
package-lock.json
generated
@@ -92,6 +92,7 @@
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
|
||||
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^4.0.0",
|
||||
"@octokit/graphql": "^7.1.0",
|
||||
|
||||
Reference in New Issue
Block a user