lc-review 0.0.10 → 0.0.11

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.
Files changed (2) hide show
  1. package/dist/index.mjs +52 -21
  2. package/package.json +3 -2
package/dist/index.mjs CHANGED
@@ -3,7 +3,8 @@ import { appendFile, readFile } from "node:fs/promises";
3
3
  import process from "node:process";
4
4
  import { z } from "zod";
5
5
  import { supermemo } from "supermemo";
6
- import { log } from "node:console";
6
+ import { parseArgs } from "node:util";
7
+ import { encode } from "@toon-format/toon";
7
8
 
8
9
  //#region src/core.ts
9
10
  const logRecordSchema = z.object({
@@ -100966,7 +100967,7 @@ const review = async (logFile, n, premium = false) => {
100966
100967
 
100967
100968
  //#endregion
100968
100969
  //#region package.json
100969
- var version = "0.0.10";
100970
+ var version = "0.0.11";
100970
100971
 
100971
100972
  //#endregion
100972
100973
  //#region src/index.ts
@@ -100974,7 +100975,12 @@ const INCLUDE_PREMIUM = false;
100974
100975
  const SOLUTIONS_FILE = "./solutions.log";
100975
100976
  await main();
100976
100977
  async function main() {
100977
- const args = process.argv.slice(2);
100978
+ const { values: globalValues, positionals: args } = parseArgs({
100979
+ args: process.argv.slice(2),
100980
+ options: { agent: { type: "boolean" } },
100981
+ allowPositionals: true,
100982
+ strict: false
100983
+ });
100978
100984
  const command = args.shift();
100979
100985
  switch (command) {
100980
100986
  case "help":
@@ -101018,13 +101024,14 @@ async function main() {
101018
101024
  case "debug:show-json-log": {
101019
101025
  const logFile = args.shift();
101020
101026
  if (!logFile) throw new Error("no log file provided");
101021
- await showJsonLog(logFile);
101027
+ await showJsonLog(logFile, globalValues.agent === true);
101022
101028
  break;
101023
101029
  }
101024
101030
  case "debug:show-problem-info": {
101025
- const problemNumber = args.shift();
101026
- if (!problemNumber) throw new Error("no problem number provided");
101027
- showProblemInfo(problemNumber);
101031
+ const problemNumbers = args.shift();
101032
+ if (!problemNumbers) throw new Error("no problem numbers provided");
101033
+ const isAgent = globalValues.agent === true;
101034
+ showProblemInfo(problemNumbers.split(","), isAgent);
101028
101035
  break;
101029
101036
  }
101030
101037
  default:
@@ -101062,26 +101069,50 @@ Debug commands:
101062
101069
 
101063
101070
  debug:show-json-log <log_file>
101064
101071
 
101065
- debug:show-problem-info <problem_number>
101072
+ debug:show-problem-info <problem_number>[,problem_number,...]
101066
101073
  `);
101067
101074
  }
101068
- async function showProblemInfo(problemNumber) {
101069
- const problem = ALL_PROBLEMS.find((p) => p.questionFrontendId === problemNumber);
101070
- if (!problem) {
101071
- console.log(`Problem ${problemNumber} not found.`);
101075
+ async function showProblemInfo(problemNumbers, isAgent) {
101076
+ const problems = [];
101077
+ for (const problemNumber of problemNumbers) {
101078
+ const problem = ALL_PROBLEMS.find((p) => p.questionFrontendId === problemNumber);
101079
+ if (problem) problems.push(problem);
101080
+ }
101081
+ if (!problems) {
101082
+ console.log(`No problems found for numbers: ${problemNumbers.join(", ")}`);
101083
+ return;
101084
+ }
101085
+ if (isAgent) {
101086
+ console.log(encode(problems.map((problem) => {
101087
+ return {
101088
+ id: problem.questionFrontendId,
101089
+ title: problem.title,
101090
+ difficulty: problem.difficulty,
101091
+ paidOnly: problem.paidOnly,
101092
+ acRate: problem.acRate,
101093
+ topics: problem.topicTags.map((tag) => tag.slug),
101094
+ url: `https://leetcode.com/problems/${problem.titleSlug}/`
101095
+ };
101096
+ })));
101072
101097
  return;
101073
101098
  }
101074
- log(`ID: ${problem.id}`);
101075
- log(`Title: ${problem.title}`);
101076
- log(`Difficulty: ${problem.difficulty}`);
101077
- log(`Paid only: ${problem.paidOnly}`);
101078
- log(`AC Rate: ${(problem.acRate * 100).toFixed(2)}%`);
101079
- if (problem.topicTags) log(`Topics: ${problem.topicTags.map((tag) => tag.name).join(", ")}`);
101080
- log(`URL: https://leetcode.com/problems/${problem.titleSlug}/`);
101081
- log(`AC rate: ${(problem.acRate * 100).toFixed(2)}%`);
101099
+ for (const problem of problems) {
101100
+ console.log(`ID: ${problem.questionFrontendId}`);
101101
+ console.log(`Title: ${problem.title}`);
101102
+ console.log(`Difficulty: ${problem.difficulty}`);
101103
+ console.log(`Paid only: ${problem.paidOnly}`);
101104
+ console.log(`AC Rate: ${(problem.acRate * 100).toFixed(2)}%`);
101105
+ if (problem.topicTags) console.log(`Topics: ${problem.topicTags.map((tag) => tag.name).join(", ")}`);
101106
+ console.log(`URL: https://leetcode.com/problems/${problem.titleSlug}/`);
101107
+ console.log("");
101108
+ }
101082
101109
  }
101083
- async function showJsonLog(logFile) {
101110
+ async function showJsonLog(logFile, isAgent) {
101084
101111
  const records = await readLogFromFile(logFile);
101112
+ if (isAgent) {
101113
+ console.log(encode(records));
101114
+ return;
101115
+ }
101085
101116
  console.log(JSON.stringify(records, null, 2));
101086
101117
  }
101087
101118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lc-review",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "LeetCode flashcards for spaced repetition learning",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "README.md"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsdown",
20
+ "build": "tsc --noEmit && tsdown",
21
21
  "fmt": "npx prettier --write .",
22
22
  "lc-review": "node ./dist/index.mjs",
23
23
  "test": "vitest run",
@@ -38,6 +38,7 @@
38
38
  "vitest": "4.0.16"
39
39
  },
40
40
  "dependencies": {
41
+ "@toon-format/toon": "2.1.0",
41
42
  "supermemo": "2.0.23",
42
43
  "zod": "4.2.1"
43
44
  },