krx-cli 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +1 -1
- package/dist/cli.js +37 -11
- package/dist/cli.js.map +3 -3
- package/dist/mcp.js +25 -10
- package/dist/mcp.js.map +3 -3
- package/package.json +1 -1
package/SKILL.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -48878,6 +48878,17 @@ function applyPipeline(data, options) {
|
|
|
48878
48878
|
return result;
|
|
48879
48879
|
}
|
|
48880
48880
|
|
|
48881
|
+
// src/utils/isin.ts
|
|
48882
|
+
var KRX_ISIN_RE = /^KR\d{10}$/;
|
|
48883
|
+
function matchesIsuCode(isuCd, srtCd, query) {
|
|
48884
|
+
if (isuCd === query || srtCd === query) return true;
|
|
48885
|
+
if (KRX_ISIN_RE.test(query)) {
|
|
48886
|
+
const short = query.slice(3, 9);
|
|
48887
|
+
return isuCd === short || srtCd === short;
|
|
48888
|
+
}
|
|
48889
|
+
return false;
|
|
48890
|
+
}
|
|
48891
|
+
|
|
48881
48892
|
// src/cli/command-helper.ts
|
|
48882
48893
|
async function executeCommand(options) {
|
|
48883
48894
|
const { endpoint, params, program: program3, noDataMessage } = options;
|
|
@@ -48889,7 +48900,8 @@ async function executeCommand(options) {
|
|
|
48889
48900
|
process.exit(EXIT_CODES.AUTH_FAILURE);
|
|
48890
48901
|
}
|
|
48891
48902
|
const parentOpts = program3.opts();
|
|
48892
|
-
const finalParams =
|
|
48903
|
+
const finalParams = params;
|
|
48904
|
+
const codeFilter = parentOpts.code;
|
|
48893
48905
|
if (parentOpts.dryRun) {
|
|
48894
48906
|
writeOutput(
|
|
48895
48907
|
JSON.stringify(
|
|
@@ -48897,6 +48909,7 @@ async function executeCommand(options) {
|
|
|
48897
48909
|
method: "POST",
|
|
48898
48910
|
endpoint,
|
|
48899
48911
|
params: finalParams,
|
|
48912
|
+
clientFilter: codeFilter ? { ISU_CD: codeFilter } : void 0,
|
|
48900
48913
|
headers: { AUTH_KEY: "***" }
|
|
48901
48914
|
},
|
|
48902
48915
|
null,
|
|
@@ -48966,6 +48979,15 @@ async function executeCommand(options) {
|
|
|
48966
48979
|
}
|
|
48967
48980
|
data = result.data;
|
|
48968
48981
|
}
|
|
48982
|
+
if (codeFilter) {
|
|
48983
|
+
data = data.filter(
|
|
48984
|
+
(row) => matchesIsuCode(
|
|
48985
|
+
String(row["ISU_CD"] ?? ""),
|
|
48986
|
+
String(row["ISU_SRT_CD"] ?? ""),
|
|
48987
|
+
codeFilter
|
|
48988
|
+
)
|
|
48989
|
+
);
|
|
48990
|
+
}
|
|
48969
48991
|
if (data.length === 0) {
|
|
48970
48992
|
writeError(noDataMessage ?? "No data");
|
|
48971
48993
|
process.exit(EXIT_CODES.NO_DATA);
|
|
@@ -60598,7 +60620,9 @@ function buildInputSchema(endpoints) {
|
|
|
60598
60620
|
date_to: external_exports.string().optional().describe(
|
|
60599
60621
|
"End date for range query (YYYYMMDD). Use with date_from for multi-day data."
|
|
60600
60622
|
),
|
|
60601
|
-
isuCd: external_exports.string().optional().describe(
|
|
60623
|
+
isuCd: external_exports.string().optional().describe(
|
|
60624
|
+
"Stock/item code to filter. Accepts both ISIN (e.g., KR7005930003) and short code (e.g., 005930)."
|
|
60625
|
+
),
|
|
60602
60626
|
sort: external_exports.string().optional().describe("Sort results by this field name"),
|
|
60603
60627
|
sort_direction: external_exports.enum(["asc", "desc"]).optional().describe("Sort direction (default: desc)"),
|
|
60604
60628
|
offset: external_exports.number().optional().describe("Skip first N results (use with limit for pagination)"),
|
|
@@ -60662,21 +60686,21 @@ function createCategoryTool(categoryId) {
|
|
|
60662
60686
|
err instanceof Error ? err.message : "Invalid date format"
|
|
60663
60687
|
);
|
|
60664
60688
|
}
|
|
60665
|
-
const extraParams = {};
|
|
60666
|
-
if (isuCd) {
|
|
60667
|
-
extraParams["isuCd"] = isuCd;
|
|
60668
|
-
}
|
|
60669
60689
|
const rangeResult = await fetchDateRange({
|
|
60670
60690
|
endpoint: endpoint.path,
|
|
60671
60691
|
from: dateFrom,
|
|
60672
60692
|
to: dateTo,
|
|
60673
|
-
apiKey
|
|
60674
|
-
extraParams
|
|
60693
|
+
apiKey
|
|
60675
60694
|
});
|
|
60676
60695
|
if (!rangeResult.success) {
|
|
60677
60696
|
return errorResult(rangeResult.error ?? "Date range fetch failed");
|
|
60678
60697
|
}
|
|
60679
60698
|
let data2 = rangeResult.data;
|
|
60699
|
+
if (isuCd) {
|
|
60700
|
+
data2 = data2.filter(
|
|
60701
|
+
(row) => matchesIsuCode(row["ISU_CD"] ?? "", row["ISU_SRT_CD"] ?? "", isuCd)
|
|
60702
|
+
);
|
|
60703
|
+
}
|
|
60680
60704
|
const filterExpr = args.filter;
|
|
60681
60705
|
const sortField2 = args.sort;
|
|
60682
60706
|
const sortDirection2 = args.sort_direction ?? "desc";
|
|
@@ -60704,9 +60728,6 @@ function createCategoryTool(categoryId) {
|
|
|
60704
60728
|
);
|
|
60705
60729
|
}
|
|
60706
60730
|
const params = { basDd: dateStr };
|
|
60707
|
-
if (isuCd) {
|
|
60708
|
-
params["isuCd"] = isuCd;
|
|
60709
|
-
}
|
|
60710
60731
|
const result = await krxFetch({
|
|
60711
60732
|
endpoint: endpoint.path,
|
|
60712
60733
|
params,
|
|
@@ -60721,6 +60742,11 @@ function createCategoryTool(categoryId) {
|
|
|
60721
60742
|
const offsetN = args.offset;
|
|
60722
60743
|
const limitN = args.limit;
|
|
60723
60744
|
let data = result.data;
|
|
60745
|
+
if (isuCd) {
|
|
60746
|
+
data = data.filter(
|
|
60747
|
+
(row) => matchesIsuCode(row["ISU_CD"] ?? "", row["ISU_SRT_CD"] ?? "", isuCd)
|
|
60748
|
+
);
|
|
60749
|
+
}
|
|
60724
60750
|
data = applyPipeline(data, {
|
|
60725
60751
|
filter: filterExpr2,
|
|
60726
60752
|
sort: sortField,
|