Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Last active January 2, 2026 23:27
Show Gist options
  • Select an option

  • Save kuc-arc-f/9292111ab9f89fdf1b4ed2dc3f2730a0 to your computer and use it in GitHub Desktop.

Select an option

Save kuc-arc-f/9292111ab9f89fdf1b4ed2dc3f2730a0 to your computer and use it in GitHub Desktop.
Agent Skills JS , RAG Search , Qdrant database
{
"name": "scripts",
"version": "1.0.0",
"main": "sendtext.js",
"type": "module",
"scripts": {
"build": "npx tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/node": "^25.0.3",
"typescript": "^5.9.3"
},
"dependencies": {
}
}
//@ts-ignore
import { parseArgs } from 'node:util';
//@ts-ignore
import { spawn } from "child_process";
// コレクション名
const COLLECT_NAME = "document-2"
class RpcClient {
constructor(command) {
//@ts-ignore
this.proc = spawn(command);
//@ts-ignore
this.idCounter = 1;
//@ts-ignore
this.pending = new Map();
//@ts-ignore
this.proc.stdout.setEncoding("utf8");
//@ts-ignore
this.proc.stdout.on("data", (data) => this._handleData(data));
//@ts-ignore
this.proc.stderr.on("data", (err) => {
//console.error("Rust stderr:", err.toString())
});
//@ts-ignore
this.proc.on("exit", (code) => {
//console.log(`Rust server exited (${code})`)
});
}
_handleData(data) {
// 複数行対応
data.split("\n").forEach((line) => {
//console.log("line=", line)
if (!line.trim()) return;
try {
const msg = JSON.parse(line);
//@ts-ignore
if (msg.id && this.pending.has(msg.id)) {
//@ts-ignore
const { resolve } = this.pending.get(msg.id);
//@ts-ignore
this.pending.delete(msg.id);
//@ts-ignore
resolve(msg.result);
}
} catch (e) {
//console.error("JSON parse error:", e, line);
}
});
}
call(method, params = {}) {
//@ts-ignore
const id = this.idCounter++;
const payload = {
jsonrpc: "2.0",
id,
method,
params,
};
return new Promise((resolve, reject) => {
//@ts-ignore
this.pending.set(id, { resolve, reject });
//@ts-ignore
this.proc.stdin.write(JSON.stringify(payload) + "\n");
});
}
close() {
//@ts-ignore
this.proc.kill();
}
}
/**
*
* @param
*
* @return
*/
const main = async function(){
const options = {
// 受け取りたい引数の定義
message: {
type: 'string', // 文字列として受け取る
short: 'm', // -m でも受け取れる
},
};
//@ts-ignore
const { values } = parseArgs({ options });
// 実行結果の確認
const query = values.message
//console.log("query=", query)
//RpcClient
const client = new RpcClient("/work/rust/extra/qdrant_6/target/debug/rust_qdrant_6.exe");
const result1 = await client.call(
"tools/call",
{
name: "rag_search",
arguments:{
query: query,
}
},
);
client.close();
//console.log("resp=", result1);
//@ts-ignore
if(result1.content[0].text){
//@ts-ignore
//console.log("text:"+ result1.content[0].text);
console.log(result1.content[0].text);
}
}
main();
{
"chat.useAgentSkills": true
}
name description
searchrag-skill
検索クエリーを Scripts送信、Scripts searchrag から 対象RAG文章を受信し、概要文章を作成します。

SearchRag Skill

このスキルは、入力メッセージを送信し、値を返却します

Parameters

{ "type": "object", "properties": { "message": { "type": "string", "description": "送信メッセージ (例: 'hello')" }, }, "required": ["message"] }

Command

node scripts/dist/searchrag.js --message {{message}}

{
// Visit https://aka.ms/tsconfig to read more about this file
"compilerOptions": {
// File Layout
"rootDir": "./src",
"outDir": "./dist",
// Environment Settings
// See also https://aka.ms/tsconfig/module
"module": "nodenext",
"target": "esnext",
"moduleResolution": "NodeNext",
"types": [],
// For nodejs:
// "lib": ["esnext"],
// "types": ["node"],
// and npm install -D @types/node
// Other Outputs
"sourceMap": true,
"declaration": true,
"declarationMap": true,
// Stricter Typechecking Options
"noUncheckedIndexedAccess": true,
//"exactOptionalPropertyTypes": true,
// Style Options
// "noImplicitReturns": true,
// "noImplicitOverride": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
// "noFallthroughCasesInSwitch": true,
// "noPropertyAccessFromIndexSignature": true,
// Recommended Options
"strict": false,
"jsx": "react-jsx",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment