Compare commits
1 Commits
main
...
803404942b
| Author | SHA1 | Date | |
|---|---|---|---|
|
803404942b
|
4
.github/workflows/agent-markdown.yml
vendored
4
.github/workflows/agent-markdown.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Send task to coding agent
|
- name: Send task to coding agent
|
||||||
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
||||||
with:
|
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
|
api_token: ${{ secrets.AGENT_TOKEN }} # optional, required for authenticated API calls
|
||||||
route: agent-lake # default: agent-lake
|
route: agent-lake # default: agent-lake
|
||||||
debug: false
|
debug: false
|
||||||
13
.github/workflows/test.yml
vendored
13
.github/workflows/test.yml
vendored
@@ -13,13 +13,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- name: Test Local Action
|
||||||
|
id: test
|
||||||
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version: 20
|
debug: 'true'
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run unit tests
|
|
||||||
run: npm test
|
|
||||||
@@ -22,8 +22,9 @@ jobs:
|
|||||||
- name: Send task to coding agent
|
- name: Send task to coding agent
|
||||||
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
uses: https://git.yusufali.ca/actions/embed-markdown@main
|
||||||
with:
|
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
|
api_token: ${{ secrets.AGENT_TOKEN }} # optional, required for authenticated API calls
|
||||||
route: agent-lake # default: agent-lake
|
route: agent-lake # default: agent-lake
|
||||||
debug: false
|
debug: false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ description: 'Sends markdown files to the lake to embed into vector form'
|
|||||||
inputs:
|
inputs:
|
||||||
api_url:
|
api_url:
|
||||||
description: 'api url'
|
description: 'api url'
|
||||||
default: 'http://agent-api.k8s.private'
|
default: 'http://agents-api.servc-agents:3000'
|
||||||
required: false
|
required: false
|
||||||
api_token:
|
api_token:
|
||||||
description: 'API token for authentication'
|
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,
|
env = process.env,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const apiUrl =
|
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 apiToken = coreModule.getInput("api_token");
|
||||||
const route = coreModule.getInput("route") || "agent-lake";
|
const route = coreModule.getInput("route") || "agent-lake";
|
||||||
const method = coreModule.getInput("method") || "embeddings_insert";
|
const method = coreModule.getInput("method") || "embeddings_insert";
|
||||||
@@ -61,16 +61,6 @@ function sanitizeDocumentId(value) {
|
|||||||
return value.replace(/[^A-Za-z0-9.]/g, "");
|
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({
|
function buildRequestPayload({
|
||||||
route,
|
route,
|
||||||
method,
|
method,
|
||||||
@@ -92,7 +82,7 @@ function buildRequestPayload({
|
|||||||
segment_id: segmentId,
|
segment_id: segmentId,
|
||||||
document_id: sanitizeDocumentId([owner, repo, file].join(".")),
|
document_id: sanitizeDocumentId([owner, repo, file].join(".")),
|
||||||
embed_text: "",
|
embed_text: "",
|
||||||
store_text: buildStoreText({ owner, repo, file, content }),
|
store_text: content,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -175,7 +165,6 @@ async function main({
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
buildRequestPayload,
|
buildRequestPayload,
|
||||||
buildStoreText,
|
|
||||||
getConfig,
|
getConfig,
|
||||||
listMarkdownFiles,
|
listMarkdownFiles,
|
||||||
main,
|
main,
|
||||||
|
|||||||
@@ -1,33 +1,7 @@
|
|||||||
const test = require("node:test");
|
const test = require("node:test");
|
||||||
const assert = require("node:assert/strict");
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
const {
|
const { buildRequestPayload, main, sanitizeDocumentId } = require("./index");
|
||||||
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");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("sanitizeDocumentId removes special characters and preserves periods", () => {
|
test("sanitizeDocumentId removes special characters and preserves periods", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@@ -36,22 +10,7 @@ test("sanitizeDocumentId removes special characters and preserves periods", () =
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("buildStoreText prefixes repository metadata before the markdown content", () => {
|
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 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", () => {
|
|
||||||
const content = "# Title\n\n## First\nalpha\n\n## Second\nbeta\n";
|
const content = "# Title\n\n## First\nalpha\n\n## Second\nbeta\n";
|
||||||
const payload = buildRequestPayload({
|
const payload = buildRequestPayload({
|
||||||
route: "agent-lake",
|
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.embed_text, "");
|
||||||
assert.equal(
|
assert.equal(payload.inputs.inputs.store_text, content);
|
||||||
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(
|
assert.equal(
|
||||||
payload.inputs.inputs.document_id,
|
payload.inputs.inputs.document_id,
|
||||||
"acme.docsrepo.guidessetup.md",
|
"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.length, 1);
|
||||||
assert.equal(calls[0].url, "https://agents.example/api");
|
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.embed_text, "");
|
||||||
assert.equal(
|
assert.equal(calls[0].body.inputs.inputs.store_text, content);
|
||||||
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(
|
assert.equal(
|
||||||
calls[0].body.inputs.inputs.document_id,
|
calls[0].body.inputs.inputs.document_id,
|
||||||
"acme.docsrepo.README.md",
|
"acme.docsrepo.README.md",
|
||||||
|
|||||||
1
package-lock.json
generated
1
package-lock.json
generated
@@ -92,6 +92,7 @@
|
|||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
|
||||||
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
|
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@octokit/auth-token": "^4.0.0",
|
"@octokit/auth-token": "^4.0.0",
|
||||||
"@octokit/graphql": "^7.1.0",
|
"@octokit/graphql": "^7.1.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user