-- deprecated --
Version 2 of this project is in active development here: Fabricus. It supports bidirectional sync and is implemented as an Anki plugin.
This contains code meant to be used with roam-backup and Anki. roam-backup
saves your Roam Research into Google Cloud Storage. Roam -> Anki Sync
reads from Google Cloud Storage and extracts any flashcards you defined into Anki.
- Any changes in Roam will be synced to Anki, preserving the card's existing review schedule.
- Lightning fast operation thanks to
ripgrep
. - Unit tests (hey that's a feature for small hacked together projects right?)
- A note will not sync if it changes in Roam Research in a way that requires the user to manually run tools->empty cards in Anki (e.g. removing a cloze field). Workaround is to do just that and run the tool again.
- See issues tab for more.
- You must install NodeJS, Git, Anki, ripgrep and the AnkiConnect Plugin.
- You must have have
roam-backup
saving to a Google Cloud Storage bucketGCS_BUCKET_NAME
. ripgrep
must be available on$PATH
(usually this isn't a problem).- Create a local
.env
file to define nodejs env variables. SeeUsage
section for what is expected there. - Create a new model in Anki called
ClozeUID
with 3 fields:{ Text: text, Extra: extra, UID: uid }
. Easiest way is to clone the existingCloze
model and add aUID
field. This field is used for idempotency. - AnkiConnect should be available on
http://127.0.0.1:8765
.
This program expects some Node environment variables to be present. To provide them, create a .env
file following the example below:
GCS_BUCKET_NAME="some-roam-backup"
GCS_SERVICEACCOUNT_KEYFILE="./key.json"
DEFAULT_DECK="Some Deckname"
ANKI_CONNECT_URL="http://127.0.0.1:8765"
GCS_SERVICEACCOUNT_KEYFILE
can be omitted if using application default credentials.
In Roam, a modified Anki cloze syntax is provided. Example:
- this is {c1:another} {c2:flashcard} {c3:haha}. #flashcard {uid:20200405151338}.
The necessary components are:
#flashcard
or[[flashcard]]
tag- cloze deletion(s) in the above format (note double colon).
- unique id in
{uid:something}
format, for idempotency. I usually use a timestamp generated via text expansion.
Everything must be on a single line.
npm start
will run a one-time sync from Roam to Anki. To make this run automatically, use your OS automation system of choice e.g. cron.
Once cards are synced, changes are pulled one way from roam to anki. The note fields will be overwritten in Anki if they have been changed there. Any tags on the note in Anki will be preserved.
An easy way to organize automatically synced cards is to filter by the ClozeUID
model and tag to your heart's content.
- If you have gCloud installed, you can run
gcloud auth application-default login
. - Otherwise, go to Google Cloud Console, download your service account keyfile and define add it to your
.env
file.