Metadata-Version: 2.4
Name: kunyi
Version: 0.1.0
Summary: Generate Anki .apkg decks from JSON (MCQ) or TSV (basic) card data.
Project-URL: Homepage, https://github.com/LingT03/Kunyi
Project-URL: Bug Tracker, https://github.com/LingT03/Kunyi/issues
Project-URL: Changelog, https://github.com/LingT03/Kunyi/releases
License: PolyForm Noncommercial License 1.0.0
        
        https://polyformproject.org/licenses/noncommercial/1.0.0
        
        Required Notice: Copyright Ta'taang (Ling Thang) (https://github.com/LingT03)
        
        Acceptance
        
        In order to get any license under these terms, you must agree
        to them as both strict obligations and conditions to all
        your licenses.
        
        Copyright License
        
        The licensor grants you a copyright license for the
        software to do everything you might do with the software
        that would otherwise infringe the licensor's copyright
        in it for any permitted purpose. However, you may
        only distribute the software according to Distribution License
        and make changes or new works based on the software according
        to Changes and New Works License.
        
        Distribution License
        
        The licensor grants you an additional copyright license
        to distribute copies of the software. Your license
        to distribute covers distributing the software with
        changes and new works permitted by Changes and New Works License.
        
        Notices
        
        You must ensure that anyone who gets a copy of any part of
        the software from you also gets a copy of these terms or the
        URL for them above, as well as copies of any plain-text lines
        beginning with "Required Notice:" that the licensor provided
        with the software.
        
        Changes and New Works License
        
        The licensor grants you an additional copyright license to
        make changes and new works based on the software for any
        permitted purpose.
        
        Patent License
        
        The licensor grants you a patent license for the software that
        covers patent claims the licensor can license, or becomes able
        to license, that you would infringe by using the software.
        
        Noncommercial Purposes
        
        Any noncommercial purpose is a permitted purpose.
        
        Personal Uses
        
        Personal use for research, experiment, and testing for
        the benefit of public knowledge, personal study, private
        entertainment, hobby projects, amateur pursuits, or religious
        observance, without any anticipated commercial application,
        is use for a permitted purpose.
        
        Noncommercial Organizations
        
        Use by any charitable organization, educational institution,
        public research organization, public safety or health
        organization, environmental protection organization,
        or government institution is use for a permitted purpose
        regardless of the source of funding or obligations resulting
        from the funding.
        
        Fair Use
        
        You may have "fair use" rights for the software under the
        law. These terms do not limit them.
        
        No Other Rights
        
        These terms do not allow you to sublicense or transfer any of
        your licenses to anyone else, or prevent the licensor from
        granting licenses to anyone else. These terms do not imply
        any other licenses.
        
        Patent Defense
        
        If you make any written claim that the software infringes or
        contributes to infringement of any patent, your patent license
        for the software granted under these terms ends immediately. If
        your company makes such a claim, your patent license ends
        immediately for work on behalf of your company.
        
        Violations
        
        The first time you are notified in writing that you have
        violated any of these terms, or done anything with the software
        not covered by your licenses, your licenses can nonetheless
        continue if you come into full compliance with these terms,
        and take practical steps to correct past violations, within
        32 days of receiving notice. Otherwise, all your licenses
        end immediately.
        
        No Liability
        
        AS FAR AS THE LAW ALLOWS, THE SOFTWARE COMES AS IS, WITHOUT
        ANY WARRANTY OR CONDITION, AND THE LICENSOR WILL NOT BE LIABLE
        TO YOU FOR ANY DAMAGES ARISING OUT OF THESE TERMS OR THE USE
        OR NATURE OF THE SOFTWARE, UNDER ANY KIND OF LEGAL CLAIM.
        
        Definitions
        
        The "licensor" is the individual or entity offering these
        terms, and the "software" is the software the licensor makes
        available under these terms.
        
        "You" refers to the individual or entity agreeing to these
        terms.
        
        "Your company" is any legal entity, sole proprietorship,
        or other kind of organization that you work for, plus all
        organizations that have control over, are under the control of,
        or are under common control with that organization. "Control"
        means ownership of substantially all the assets of an entity,
        or the power to direct its management and policies by vote,
        contract, or otherwise. Control can be direct or indirect.
        
        "Your licenses" are all the licenses granted to you for the
        software under these terms.
        
        "Use" means anything you do with the software requiring one
        of your licenses.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: genanki>=0.13
Description-Content-Type: text/markdown

# kunyi

Generate Anki `.apkg` decks from JSON (MCQ) or TSV (basic) card data.

_Part of the [Seya](https://github.com/LingT03/Seya) study ecosystem._

---

## Installation

```bash
pip install kunyi
```

Or for local development:

```bash
git clone https://github.com/LingT03/Kunyi.git
cd Kunyi
pip install -e .
```

---

## CLI usage

```bash
# JSON — multiple-choice question cards
kunyi "Cloud Computing" cards.json

# TSV — basic front/back cards
kunyi "Calc 2 Formulas" formulas.tsv

# Explicit output path (recommended for subprocess callers)
kunyi "Cloud Computing" cards.json --output /path/to/deck.apkg

# Override format detection
kunyi "My Deck" cards.data --format tsv
```

On success the resolved `.apkg` path is printed to stdout (exit 0).  
On failure a human-readable message is printed to stderr (exit 1).

---

## Input formats

### JSON — MCQ cards

```json
{
  "cards": [
    {
      "question": "What does CPU stand for?",
      "choices": ["Central Processing Unit", "Core Power Unit", "Control Processing Unit"],
      "correct_answer": "Central Processing Unit",
      "explanation": "CPU stands for Central Processing Unit.",
      "tags": ["chapter-1"]
    }
  ]
}
```

`correct_answer` must be an element of `choices` — validated on parse.  
`tags` is optional.

### TSV — basic cards

Tab-delimited UTF-8. Optional header row (`front\tback`) is auto-detected and skipped.

```
front	back
What is spaced repetition?	A technique that spaces reviews over time.
What is active recall?	Actively retrieving information from memory.
```

---

## Library usage

```python
from pathlib import Path
from kunyi import AnkiCardDeck, MCQCard, BasicCard

deck = AnkiCardDeck(deck_name="My Deck")

deck.add_card(MCQCard(
    question="What does RAM stand for?",
    choices=["Random Access Memory", "Read Access Module"],
    correct_answer="Random Access Memory",
    explanation="RAM is the primary short-term memory of a computer.",
    tags=["hardware"],
))

deck.add_card(BasicCard(
    front="What is a CPU?",
    back="The central processing unit — the brain of a computer.",
))

deck.save_deck(Path("output/my_deck.apkg"))
```

---

## Running tests

```bash
pip install pytest
pytest tests/
```

---

## What is Anki?

[Anki](https://apps.ankiweb.net/) is a free flashcard program that uses spaced repetition and active recall to maximise long-term retention. `kunyi` generates `.apkg` files that can be imported directly into Anki.
