krx-cli 1.7.0 → 1.7.2

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 CHANGED
@@ -7,7 +7,7 @@ install: npm install -g krx-cli
7
7
  binary: krx
8
8
  metadata:
9
9
  author: kyo504
10
- version: "1.7.0"
10
+ version: "1.7.2"
11
11
  invariants:
12
12
  - Always use YYYYMMDD format for --date (e.g., 20260310)
13
13
  - Data is T-1 (previous trading day), available from 2010 onwards
package/dist/cli.js CHANGED
@@ -48869,7 +48869,7 @@ function applyPipeline(data, options) {
48869
48869
  if (options.sort) {
48870
48870
  result = sortData(result, options.sort, options.direction ?? "desc");
48871
48871
  }
48872
- if (options.offset && options.offset > 0) {
48872
+ if (options.offset !== void 0 && options.offset > 0) {
48873
48873
  result = result.slice(options.offset);
48874
48874
  }
48875
48875
  if (options.limit && options.limit > 0) {
@@ -48889,7 +48889,8 @@ async function executeCommand(options) {
48889
48889
  process.exit(EXIT_CODES.AUTH_FAILURE);
48890
48890
  }
48891
48891
  const parentOpts = program3.opts();
48892
- const finalParams = parentOpts.code ? { ...params, isuCd: parentOpts.code } : params;
48892
+ const finalParams = params;
48893
+ const codeFilter = parentOpts.code;
48893
48894
  if (parentOpts.dryRun) {
48894
48895
  writeOutput(
48895
48896
  JSON.stringify(
@@ -48897,6 +48898,7 @@ async function executeCommand(options) {
48897
48898
  method: "POST",
48898
48899
  endpoint,
48899
48900
  params: finalParams,
48901
+ clientFilter: codeFilter ? { ISU_CD: codeFilter } : void 0,
48900
48902
  headers: { AUTH_KEY: "***" }
48901
48903
  },
48902
48904
  null,
@@ -48966,6 +48968,9 @@ async function executeCommand(options) {
48966
48968
  }
48967
48969
  data = result.data;
48968
48970
  }
48971
+ if (codeFilter) {
48972
+ data = data.filter((row) => row["ISU_CD"] === codeFilter);
48973
+ }
48969
48974
  if (data.length === 0) {
48970
48975
  writeError(noDataMessage ?? "No data");
48971
48976
  process.exit(EXIT_CODES.NO_DATA);
@@ -60527,7 +60532,7 @@ var EMPTY_COMPLETION_RESULT = {
60527
60532
  };
60528
60533
 
60529
60534
  // src/mcp/tools/result.ts
60530
- var MAX_RESULT_BYTES = 9e5;
60535
+ var MAX_RESULT_BYTES = 5e5;
60531
60536
  function successResult(data) {
60532
60537
  const text = JSON.stringify(data, null, 2);
60533
60538
  if (Buffer.byteLength(text, "utf-8") <= MAX_RESULT_BYTES) {
@@ -60538,7 +60543,7 @@ function successResult(data) {
60538
60543
  while (lo < hi) {
60539
60544
  const mid = Math.ceil((lo + hi) / 2);
60540
60545
  const candidate = JSON.stringify(data.slice(0, mid), null, 2);
60541
- if (Buffer.byteLength(candidate, "utf-8") <= MAX_RESULT_BYTES - 200) {
60546
+ if (Buffer.byteLength(candidate, "utf-8") <= MAX_RESULT_BYTES - 2e3) {
60542
60547
  lo = mid;
60543
60548
  } else {
60544
60549
  hi = mid - 1;
@@ -60582,7 +60587,8 @@ Notes:
60582
60587
  - Data is T-1 (previous trading day)
60583
60588
  - All response values are strings
60584
60589
  - Rate limit: 10,000 calls/day
60585
- - IMPORTANT: Full market listings can exceed the 1MB result limit. Use 'fields' to select only needed columns, or 'limit'+'offset' for pagination. If the response contains '_truncated', follow its instructions to retrieve remaining data.`;
60590
+ - IMPORTANT: When querying a specific stock, ALWAYS pass 'isuCd' to filter. Without it, all stocks in the market are returned.
60591
+ - Full market listings can exceed the result size limit. Use 'fields' to select only needed columns, or 'limit'+'offset' for pagination. If the response contains '_truncated', follow its instructions to retrieve remaining data.`;
60586
60592
  }
60587
60593
  function buildInputSchema(endpoints) {
60588
60594
  const shortNames = endpoints.map((e) => getEndpointShortName(e.path));
@@ -60661,21 +60667,19 @@ function createCategoryTool(categoryId) {
60661
60667
  err instanceof Error ? err.message : "Invalid date format"
60662
60668
  );
60663
60669
  }
60664
- const extraParams = {};
60665
- if (isuCd) {
60666
- extraParams["isuCd"] = isuCd;
60667
- }
60668
60670
  const rangeResult = await fetchDateRange({
60669
60671
  endpoint: endpoint.path,
60670
60672
  from: dateFrom,
60671
60673
  to: dateTo,
60672
- apiKey,
60673
- extraParams
60674
+ apiKey
60674
60675
  });
60675
60676
  if (!rangeResult.success) {
60676
60677
  return errorResult(rangeResult.error ?? "Date range fetch failed");
60677
60678
  }
60678
60679
  let data2 = rangeResult.data;
60680
+ if (isuCd) {
60681
+ data2 = data2.filter((row) => row["ISU_CD"] === isuCd);
60682
+ }
60679
60683
  const filterExpr = args.filter;
60680
60684
  const sortField2 = args.sort;
60681
60685
  const sortDirection2 = args.sort_direction ?? "desc";
@@ -60703,9 +60707,6 @@ function createCategoryTool(categoryId) {
60703
60707
  );
60704
60708
  }
60705
60709
  const params = { basDd: dateStr };
60706
- if (isuCd) {
60707
- params["isuCd"] = isuCd;
60708
- }
60709
60710
  const result = await krxFetch({
60710
60711
  endpoint: endpoint.path,
60711
60712
  params,
@@ -60720,6 +60721,9 @@ function createCategoryTool(categoryId) {
60720
60721
  const offsetN = args.offset;
60721
60722
  const limitN = args.limit;
60722
60723
  let data = result.data;
60724
+ if (isuCd) {
60725
+ data = data.filter((row) => row["ISU_CD"] === isuCd);
60726
+ }
60723
60727
  data = applyPipeline(data, {
60724
60728
  filter: filterExpr2,
60725
60729
  sort: sortField,