core

Kosha is a tool for building a context for code generation based on your repo and environment.

Utils

Utility functions for finding the repo root, copying the SKILL.md file, running async code from sync contexts, and getting installed package versions.


parse


def parse(
    code:NoneType=None, p:NoneType=None
):

Parse source, tag parents, return (tree, imp, top_fns, all_fns). Cached — called freely.


mv_skill_md


def mv_skill_md(
    dry_run:bool=True, dir:NoneType=None
)->None:

Copy bundled SKILL.md to .agents/skills/kosha/ at project root or specified dir.


repo_root


def repo_root(
    
)->Path:

Find the root of the current git repository, or None if not in a repo.


arun


def arun(
    coro
)->any:

Run an async coroutine from sync code, even if already inside an event loop

async def _add(a, b): return a + b
assert arun(_add(1, 2)) == 3
print('arun: sync context ok')
arun: sync context ok
async def _test_nested():
    result = arun(_add(10, 20))
    assert result == 30, f'got {result}'
arun(_test_nested())
print('arun: nested-loop context ok')
arun: nested-loop context ok
mv_skill_md()
Would copy /Users/71293/code/personal/orgs/kosha/nbs/SKILL.md to /Users/71293/code/personal/orgs/kosha/.agents/skills/kosha/SKILL.md
mv_skill_md(dir='.')
Would copy /Users/71293/code/personal/orgs/kosha/nbs/SKILL.md to .agents/skills/kosha/SKILL.md

pkg_trans_deps


def pkg_trans_deps(
    seeds:list, depth:int=2
)->L:

BFS over importlib.metadata requires: return seeds + all transitive deps up to depth levels (installed only, no optional extras).


env_pkg_versions


def env_pkg_versions(
    pyproject:bool=True, depth:int=1
)->dict:

Get a dict of installed package versions using importlib.metadata. passing depth traverse multiple layers of dependencies

installed_packages(pyproject=True)
['fastprogress', 'litesearch', 'pyan3', 'watchfiles']
pkg_trans_deps(['litesearch'], depth=1)
['notebook', 'fastlite', 'model2vec', 'pandas', 'litesearch', 'onnxruntime', 'pdf-oxide', 'codesigs', 'yake', 'usearch', 'chonkie', 'tokenizers', 'pillow']
# httpx depends on httpcore; depth=1 should include both httpx + httpcore
d1 = pkg_trans_deps(['httpx'], depth=1)
assert 'httpx' in d1, "seeds must be in result"
assert 'httpcore' in d1, f"depth=1 should include httpcore (direct dep of httpx): {d1}"
# depth=0 returns only seeds
assert list(pkg_trans_deps(['httpx'], depth=0)) == ['httpx'], "depth=0 should return only seeds"
# pyproject seeds → depth=2 expansion
pyp = installed_packages(pyproject=True)
if pyp:
    deep = pkg_trans_deps(list(pyp), depth=2)
    assert set(pyp).issubset(set(deep)), "seeds must be a subset of result"
    assert len(deep) >= len(pyp), "depth=2 should expand beyond pyproject direct deps"
    print(f"pkg_trans_deps ok: {len(pyp)} pyproject seeds → {len(deep)} packages at depth=2")
else:
    print("pkg_trans_deps ok (no pyproject deps to test)")
pkg_trans_deps ok: 4 pyproject seeds → 58 packages at depth=2
env_pkg_versions()
{'watchfiles': '1.1.1',
 'codesigs': '0.0.2',
 'fastcore': '1.12.40',
 'tokenizers': '0.22.2',
 'chonkie': '1.6.4',
 'pillow': '12.2.0',
 'anyio': '4.13.0',
 'notebook': '7.5.5',
 'fastlite': '0.2.4',
 'model2vec': '0.8.1',
 'pandas': '3.0.2',
 'litesearch': '0.0.23',
 'pyan3': '2.5.0',
 'onnxruntime': '1.24.4',
 'pdf_oxide': '0.3.37',
 'Jinja2': '3.1.6',
 'fastprogress': '1.1.5',
 'python-fasthtml': '0.13.3',
 'yake': '0.7.3',
 'usearch': '2.25.1'}

embedder

jina-embeddings-v2-base-code is a model designed for code understanding and generation tasks


static_embedder


def static_embedder(
    emb_model:str='minishlab/potion-retrieval-32M'
):

Call self as a function.


embedder


def embedder(
    emb_model:AttrDict={'model': 'mrsladoje/CodeRankEmbed-onnx-int8', 'onnx_path': 'onnx/model.onnx', 'prompt': {'query': 'Represent this query for searching relevant code: {text}', 'document': '{text}'}}
):

Call self as a function.

emb_doc(static_embedder)('def add(a, b): return a + b')
/Users/71293/code/personal/orgs/kosha/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
Fetching 10 files: 100%|██████████| 10/10 [00:00<00:00, 123725.78it/s]
array([[-7.19793513e-02,  1.24171309e-01, -4.61112633e-02,
         5.54490536e-02, -1.08527085e-02,  2.00515307e-04,
         3.17859463e-02,  8.73220898e-03,  2.46618260e-02,
         2.96881404e-02, -7.54409470e-03, -4.25347406e-03,
         4.59666625e-02, -9.10317712e-03,  1.02166471e-03,
         2.08956562e-02, -8.51069763e-03,  3.51498835e-02,
        -1.91850401e-02, -8.13944638e-02,  2.55163852e-02,
        -9.02607962e-02,  1.86812356e-02,  6.44628257e-02,
         1.27030155e-02,  1.53568434e-02, -9.89770330e-03,
         4.24869172e-02,  7.90027604e-02,  5.42380512e-02,
         1.72839724e-02,  2.81956401e-02,  1.62609909e-02,
         6.52461126e-02, -1.63905453e-02,  3.39555927e-02,
         6.15869686e-02, -1.10751984e-03, -7.54020782e-03,
        -4.95190620e-02,  4.08851206e-02, -1.06810421e-01,
        -2.51774229e-02, -3.83029208e-02,  2.09482927e-02,
         6.15174472e-02, -9.85541381e-03, -9.79128703e-02,
        -4.53243256e-02,  5.66159636e-02,  6.14626221e-02,
        -2.48122420e-02, -4.28730734e-02, -2.65088696e-02,
         7.74404928e-02,  6.14979677e-02, -1.35316830e-02,
        -5.52291982e-02,  4.10378985e-02,  1.08785175e-01,
         2.16541588e-02,  3.96157056e-02, -1.36188483e-02,
         1.92557219e-02,  6.58898130e-02, -1.34075448e-01,
         5.87901399e-02,  5.97105436e-02,  1.01340106e-02,
         2.07054224e-02,  2.57943459e-02,  5.60068078e-02,
        -3.03381961e-02,  4.57352549e-02, -4.56798039e-02,
         5.44504076e-02, -7.69701153e-02,  1.69832110e-02,
        -9.14259329e-02,  1.41202286e-01, -5.36907464e-03,
         5.43841394e-03,  3.49678919e-02,  6.52781799e-02,
         8.42770413e-02, -1.04425967e-01,  4.24356721e-02,
         1.07064862e-02,  2.48329584e-02,  3.55534703e-02,
        -1.23684093e-01, -2.28732936e-02, -5.79064433e-03,
         1.79605857e-02,  1.06230870e-01,  4.96392958e-02,
         3.74878012e-02,  6.35213824e-03,  1.13457710e-01,
        -2.44693439e-02,  1.28577305e-02, -7.63669088e-02,
         2.66179014e-02, -4.83139046e-03,  7.22420635e-03,
        -1.53204827e-02, -1.06342658e-01, -7.13057667e-02,
         8.56063440e-02, -5.22086769e-02,  4.52915505e-02,
        -1.24043435e-01,  7.48191401e-02,  1.39735118e-02,
        -7.76619986e-02,  5.14682904e-02, -2.20258199e-02,
        -4.91188988e-02,  7.35901818e-02, -5.05291782e-02,
         1.03492718e-02, -7.14892447e-02, -8.00476074e-02,
        -4.18624282e-02,  3.90714146e-02, -1.38218785e-02,
         2.68824957e-03,  2.67684311e-02, -6.72003180e-02,
        -3.21306288e-02, -3.66072878e-02, -4.60545048e-02,
         3.39410873e-03, -9.52908769e-03, -5.80850244e-02,
         6.62095100e-02,  6.29311278e-02, -2.71080155e-02,
        -1.39239682e-02,  2.74248924e-02,  9.99765471e-02,
         3.70159484e-02, -1.01971803e-02, -5.18977642e-03,
         3.54598090e-03, -2.57853419e-02,  8.22276995e-02,
        -1.86125748e-02,  6.10287476e-04, -4.69169244e-02,
         2.91096903e-02, -2.38232277e-02, -2.64808889e-02,
        -1.27907339e-02,  2.42996519e-03,  6.80453554e-02,
        -3.09638456e-02,  9.35487375e-02, -1.39230490e-02,
        -5.32236919e-02, -1.10671921e-02, -1.25991881e-01,
         2.06054226e-02, -1.54095208e-02,  1.58946775e-02,
        -1.09192468e-02,  2.42051817e-02,  5.78815155e-02,
         2.49833576e-02, -5.11512756e-02, -4.84475195e-02,
        -3.14998031e-02, -1.58940610e-02,  2.39253603e-02,
         2.85113091e-03,  2.24558245e-02, -2.48722844e-02,
        -1.23884581e-01, -3.04977689e-02, -6.26209453e-02,
        -1.04999512e-01,  2.21650545e-02, -4.37804088e-02,
         4.13765684e-02, -4.42921668e-02, -5.15574403e-03,
        -5.79100698e-02, -5.50524443e-02, -7.22430423e-02,
        -6.46154433e-02, -5.03867865e-02, -2.02935171e-05,
         1.82365701e-02, -5.23786545e-02, -9.42494813e-03,
         1.11821843e-02, -8.04556813e-03, -6.82367980e-02,
        -2.19582152e-02, -3.67489159e-02, -5.06924428e-02,
        -5.24882087e-03,  3.29912305e-02, -6.86286837e-02,
         3.37129682e-02,  2.33161040e-02, -8.72784406e-02,
         7.24888593e-02, -1.93430632e-02,  9.29706469e-02,
        -9.24474970e-02, -8.04823935e-02,  3.14762630e-02,
         6.92558512e-02,  9.14324895e-02, -3.95045616e-02,
         7.31697753e-02,  9.27315056e-02,  5.57277501e-02,
        -1.56699482e-03, -7.74639845e-03,  1.32614805e-04,
         2.09716074e-02,  9.36638117e-02, -6.14172146e-02,
         3.82114239e-02, -6.72924845e-03, -3.53876762e-02,
         4.51339688e-03,  2.56728940e-02, -6.47081947e-03,
        -4.34999801e-02,  1.44617644e-03, -2.00867001e-02,
         1.56391803e-02, -9.42892767e-03,  3.74484994e-02,
         1.75093953e-02,  4.43512201e-02,  3.84521075e-02,
        -1.18768878e-01, -6.48034289e-02,  7.80548155e-02,
         5.23247346e-02,  2.29864456e-02,  5.06184660e-02,
        -2.62260102e-02, -1.28894635e-02, -3.30473110e-02,
         2.26999857e-02, -8.07185248e-02,  6.81352541e-02,
        -9.71959978e-02, -5.18312752e-02, -3.16915214e-02,
         5.52780321e-03,  4.48350832e-02, -8.57735146e-03,
        -1.41979121e-02, -1.85021926e-02, -2.63848845e-02,
         1.79310422e-02,  3.67234759e-02, -4.64575626e-02,
        -4.10071062e-03,  2.75107194e-02, -2.46852562e-02,
        -7.52051920e-03, -3.87515090e-02,  1.16393659e-02,
         6.72818273e-02,  3.21855582e-02, -1.04809264e-02,
        -3.43379937e-02,  1.75824501e-02,  2.16513630e-02,
         1.25303585e-02, -2.74324734e-02,  1.94770452e-02,
         4.52367477e-02, -5.99312037e-02, -5.54498136e-02,
         4.83125113e-02,  8.62265285e-03,  1.23999314e-02,
        -3.91745158e-02,  7.87569024e-03,  8.98737758e-02,
         1.04716783e-02,  1.38472125e-03,  5.53051662e-03,
         6.31229728e-02,  1.28725357e-02, -1.66261159e-02,
         1.72695033e-02, -2.10563373e-02, -4.20381948e-02,
        -5.50256949e-03, -5.16938232e-03, -2.07393877e-02,
         6.01190999e-02,  3.13689075e-02, -6.94002882e-02,
         7.70751685e-02, -7.79627543e-03, -9.36089840e-04,
        -5.19082658e-02, -5.87413739e-03, -3.01886965e-02,
         1.38971433e-02,  5.82175702e-02, -4.50719446e-02,
        -3.63964848e-02, -6.95311502e-02, -8.51847231e-02,
        -5.11711948e-02, -4.36265133e-02,  9.87705588e-03,
         3.16545777e-02,  7.58996839e-03, -7.21724844e-03,
         1.41753582e-03,  1.78745314e-02, -2.19852235e-02,
         8.93497933e-03, -2.52738837e-02,  3.37409042e-02,
         5.77999279e-02, -5.87008446e-02,  3.15954201e-02,
         2.53855083e-02, -4.29958999e-02, -4.09234390e-02,
        -1.01431254e-02, -5.17037604e-03,  3.18553224e-02,
        -2.46300884e-02, -2.26516277e-02, -6.13546073e-02,
        -1.83887333e-02, -3.46145518e-02, -4.80685309e-02,
         4.20167968e-02, -2.91286316e-02, -4.95339260e-02,
         8.05401709e-03,  3.32846865e-03,  3.43616493e-02,
        -8.74033477e-03,  2.65119392e-02,  1.09138805e-02,
        -1.00516966e-02,  5.94579149e-03, -1.29905285e-03,
         2.35139616e-02,  2.21971106e-02,  5.16018132e-03,
         4.49814945e-02, -2.75235828e-02, -5.61447963e-02,
         3.38106453e-02,  2.34446488e-02,  5.94591871e-02,
        -3.45726614e-03,  2.38244720e-02,  3.09879370e-02,
        -6.55065998e-02, -6.70889206e-03,  5.71704060e-02,
         2.27135643e-02, -1.60611551e-02,  9.89084970e-03,
        -3.21147740e-02, -4.70394343e-02,  3.48185375e-02,
        -4.71187457e-02, -1.18496493e-02, -3.91344354e-02,
        -6.05052523e-02, -8.77273455e-03,  2.40187533e-02,
        -2.54306626e-02,  9.02194437e-03, -3.75776784e-04,
         6.06682617e-03,  1.05991652e-02, -1.97900012e-02,
        -5.99817447e-02, -1.89017132e-02,  1.94671862e-02,
         2.03341190e-02,  5.47164045e-02,  5.52613735e-02,
         1.93063077e-02, -4.38846312e-02,  4.48953547e-02,
        -4.76937518e-02, -5.22836670e-02,  7.96078984e-03,
        -2.95235272e-02,  1.30122202e-03, -3.18558328e-02,
        -7.88338482e-03,  2.51624119e-02,  4.81185094e-02,
        -9.35337599e-03, -4.61666211e-02, -1.61586627e-02,
        -3.63318622e-02,  3.77466120e-02,  2.62037031e-02,
         5.46525754e-02,  3.63820908e-03,  1.81446515e-03,
        -7.75614474e-03, -5.94017096e-04, -2.86508128e-02,
         5.23679610e-03,  1.48593625e-02, -1.33404825e-02,
        -2.65955143e-02, -2.74190456e-02,  5.55493608e-02,
         1.03155174e-03,  1.20861307e-02,  1.77602656e-02,
         1.08129613e-03,  4.24799398e-02,  2.37787943e-02,
         7.90456031e-03,  1.72500778e-02,  3.65378484e-02,
         3.92708741e-02, -4.29624841e-02,  2.46592541e-03,
        -1.95915326e-02,  4.95268442e-02,  7.03058857e-03,
        -1.10020889e-02, -6.13507852e-02, -4.19127643e-02,
        -1.97534561e-02,  5.88354701e-03,  3.46264690e-02,
         1.12070544e-02,  1.95327364e-02,  2.78279055e-02,
        -5.16369157e-02, -1.16125622e-03,  3.86484861e-02,
        -1.55769838e-02,  1.99638959e-02, -2.13579256e-02,
         3.54893468e-02, -2.30181813e-02,  1.23424027e-02,
        -2.94833444e-02, -6.01458177e-03, -8.34791735e-03,
        -1.65473595e-02,  3.65716629e-02,  1.00260298e-03,
         5.75290695e-02,  1.44622158e-02, -3.60233225e-02,
        -1.20674903e-02, -6.42415658e-02,  3.55051197e-02,
         7.07992539e-02,  9.00462177e-03, -6.31514122e-04,
        -7.05822110e-02,  6.80869892e-02,  3.32721248e-02,
        -5.82468770e-02,  3.36431675e-02, -1.41592138e-02,
        -1.62278339e-02,  4.83442238e-03, -1.57756098e-02,
         7.23227346e-03, -5.26669808e-02,  5.32574952e-02,
        -9.20321699e-03,  1.17382724e-02,  1.13060595e-02,
        -1.06308633e-03, -1.96917132e-02,  1.87559705e-02,
        -3.80138233e-02,  6.29443079e-02, -3.25064361e-02,
        -1.16687305e-02,  3.32028489e-03,  3.96761224e-02,
         1.00636743e-02,  1.56211983e-02, -2.52603125e-02,
         4.16543186e-02,  6.01122249e-03, -2.88661988e-03,
        -1.96584109e-02, -7.63682127e-02,  3.00656538e-02,
        -1.23971328e-02, -9.66596045e-03, -1.13185815e-04,
        -5.56876184e-04,  3.92999351e-02, -1.26103507e-04,
        -7.18869343e-02, -5.16503025e-03]], dtype=float32)
emb_doc(embedder)('def add(a, b): return a + b')
array([[ 1.1848e-02, -3.0869e-02,  2.4231e-02, -1.4404e-02, -8.3590e-04,
         4.9469e-02, -4.8828e-02, -2.7969e-02, -9.0027e-03, -2.9724e-02,
         4.6539e-02,  6.9458e-02, -1.0262e-02, -4.5319e-02,  1.8244e-03,
        -4.2694e-02,  3.5950e-02, -1.4320e-02, -5.1086e-02,  5.8098e-03,
         1.0651e-01, -4.6417e-02,  1.8097e-02, -4.7485e-02,  5.7495e-02,
        -3.5004e-02, -5.4047e-02,  1.2405e-02,  8.4152e-03,  3.8361e-02,
        -7.0129e-02,  6.0272e-02,  3.6346e-02,  2.6718e-02,  2.9480e-02,
         2.7222e-02,  3.1738e-02, -3.4058e-02, -5.7465e-02, -3.3966e-02,
        -2.2888e-02,  5.6030e-02,  3.2043e-02,  2.3209e-02,  4.4769e-02,
         6.5651e-03, -3.4142e-03,  1.6022e-02,  7.7515e-02, -2.0081e-02,
         3.2883e-03, -7.1045e-02, -7.4341e-02,  7.9575e-03,  2.4155e-02,
         1.9791e-02, -5.1880e-03, -2.0493e-02,  5.5237e-02, -2.2171e-02,
         7.5989e-02,  7.3181e-02,  4.8752e-03,  2.5543e-02,  8.8730e-03,
        -2.0798e-02,  9.5825e-03,  3.5309e-02,  1.0292e-02, -9.3765e-03,
         1.3924e-02, -5.5695e-02,  3.5767e-02, -1.5228e-02, -4.6234e-03,
         2.3346e-02, -9.1629e-03,  2.6489e-02,  9.2545e-03, -1.0910e-03,
         9.2163e-03, -5.5206e-02,  1.1029e-01, -5.1231e-03, -7.5134e-02,
         6.8848e-02, -4.6783e-02,  2.9037e-02, -1.0658e-02, -1.4297e-02,
        -2.2232e-02, -6.0364e-02, -2.3376e-02,  1.7487e-02, -1.1499e-01,
        -1.2428e-02,  4.2145e-02,  6.9809e-03,  1.1841e-02,  5.0323e-02,
         4.0512e-03,  2.7420e-02,  1.9028e-02,  4.5166e-03,  1.8845e-02,
        -3.7048e-02, -6.0196e-03, -1.5717e-02, -2.6581e-02, -2.7817e-02,
        -1.9669e-02,  2.8870e-02,  1.7105e-02, -4.1595e-02, -3.1616e-02,
         2.9617e-02, -5.8716e-02,  2.7969e-02,  2.9251e-02,  4.0283e-02,
        -3.5889e-02,  3.9917e-02, -5.0751e-02,  4.1504e-02, -3.9291e-03,
         4.4525e-02,  4.0894e-02, -1.7670e-02,  1.7563e-02, -1.6449e-02,
         2.0203e-02, -6.3904e-02,  7.6477e-02,  3.1433e-02,  1.0193e-02,
         8.7433e-03,  3.1769e-02,  3.2410e-02,  1.3588e-02,  7.5340e-03,
         7.1449e-03,  1.2276e-02, -1.0498e-02,  1.7639e-02, -6.3721e-02,
        -1.3985e-02,  7.0763e-03,  4.7226e-03, -2.4200e-02, -8.1329e-03,
         4.2480e-02,  4.2633e-02, -2.5196e-03,  6.4209e-02, -1.3374e-02,
        -2.5589e-02,  3.6011e-02,  1.5793e-02,  1.5244e-02, -3.8910e-02,
         8.1421e-02,  7.9193e-03, -6.5979e-02, -6.8550e-03, -1.8555e-02,
        -4.5959e-02,  1.6332e-04, -9.7809e-03, -2.9297e-03,  3.1342e-02,
         4.9500e-02, -5.3131e-02,  3.4515e-02,  3.2288e-02,  1.7681e-03,
        -2.3132e-02, -3.9673e-02,  1.4772e-03, -1.1215e-02, -4.7119e-02,
        -1.2939e-02, -7.3814e-03,  4.9927e-02, -1.1468e-04, -2.9297e-03,
        -4.8248e-02, -3.5645e-02, -8.3160e-03, -3.4943e-02,  3.1166e-03,
         5.9843e-04,  3.5217e-02,  1.0616e-04,  1.4458e-02, -4.1565e-02,
         5.7098e-02,  4.1618e-03,  6.2042e-02,  1.0826e-02,  6.6528e-02,
         3.9703e-02, -7.8064e-02,  1.6968e-02, -4.3274e-02, -1.9470e-02,
         3.2196e-02, -3.7727e-03, -1.3908e-02,  1.6663e-02, -9.3567e-02,
         3.2562e-02,  1.9196e-02, -2.5787e-02,  1.9638e-02,  7.2266e-02,
        -5.6610e-02, -2.2339e-02, -5.0018e-02, -4.0039e-02, -5.7190e-02,
         2.6627e-02,  6.9389e-03,  4.9194e-02, -5.2368e-02,  5.3894e-02,
         3.8433e-03, -3.6438e-02,  6.8848e-02, -4.4067e-02,  6.4941e-02,
        -2.6123e-02, -1.5121e-02,  6.2500e-02,  5.0171e-02,  4.7974e-02,
         1.4830e-04,  8.7814e-03,  4.0039e-02,  4.6051e-02, -2.9572e-02,
         3.6072e-02, -2.1301e-02, -5.3749e-03,  4.5441e-02, -1.7212e-02,
         1.7014e-02, -6.3354e-02, -3.5706e-02, -5.2567e-03,  3.0670e-03,
        -6.1279e-02, -2.9190e-02,  7.2510e-02, -2.5055e-02,  2.2217e-02,
         7.3204e-03, -6.4087e-02, -2.1194e-02, -5.9021e-02,  7.2289e-03,
         7.0496e-02,  4.8492e-02, -6.6872e-03,  3.0384e-03,  1.3954e-02,
         3.1250e-02, -1.3199e-02, -4.6143e-02,  5.1514e-02, -4.7180e-02,
        -6.9641e-02, -3.5828e-02, -1.0651e-02,  1.3535e-02, -1.9440e-02,
         2.6169e-02,  1.0077e-01, -9.6817e-03,  2.0844e-02,  2.4204e-03,
        -3.8666e-02,  3.6011e-02,  3.3112e-02,  6.7627e-02, -5.0232e-02,
         5.7953e-02,  7.9117e-03,  9.3002e-03,  1.3809e-02, -3.6621e-02,
         2.1942e-02, -1.1589e-02, -3.1342e-02,  8.3313e-03, -1.1681e-02,
         2.0233e-02,  1.2299e-02,  2.2936e-04, -1.1734e-02, -2.6703e-02,
        -5.8319e-02,  3.3844e-02, -1.2650e-02, -2.2934e-02, -2.4612e-02,
         4.4373e-02, -1.8682e-03, -1.0300e-02,  2.8046e-02,  7.3608e-02,
        -3.7201e-02,  1.3313e-02,  1.2054e-02, -1.5793e-02,  9.5415e-04,
         2.7847e-02, -1.8555e-02, -2.2936e-04,  5.7831e-02, -1.2268e-02,
        -2.4109e-02, -4.9957e-02,  1.3458e-02,  1.8494e-02, -2.7145e-02,
        -2.8366e-02, -2.3251e-03,  8.1787e-03,  6.2218e-03, -3.8788e-02,
        -4.8096e-02,  7.4577e-04, -2.0111e-02, -2.0432e-02, -2.0660e-02,
        -1.4168e-02,  3.8696e-02, -5.5817e-02, -2.3346e-02, -1.2970e-02,
         8.6609e-02,  5.4443e-02, -1.3947e-02,  3.2104e-02,  9.5291e-03,
         1.0277e-02,  5.7922e-02, -3.1982e-02, -2.8183e-02,  5.5054e-02,
        -3.6102e-02, -3.2440e-02,  1.6190e-02,  3.0182e-02, -2.4658e-02,
        -5.1788e-02,  5.5656e-03, -3.3691e-02,  6.3705e-03, -1.6266e-02,
        -3.1872e-03,  2.5620e-02, -1.4427e-02,  1.8082e-02,  8.6060e-03,
        -1.0815e-01,  1.8402e-02, -5.7526e-02,  2.9724e-02, -7.4341e-02,
         1.1154e-02,  3.2104e-02, -1.6907e-02,  2.2064e-02,  1.1719e-02,
        -2.2064e-02, -2.4185e-02,  3.6224e-02, -1.8539e-02, -2.2964e-02,
         2.1347e-02,  6.5430e-02,  3.0472e-02, -5.6839e-03, -5.5023e-02,
        -4.9133e-02, -3.1555e-02, -5.6610e-03,  4.2419e-02, -2.6184e-02,
        -1.3588e-02,  6.3934e-03,  2.8931e-02,  1.5350e-02, -4.1260e-02,
         1.9455e-02, -8.3771e-03, -1.6174e-02, -1.2505e-02, -1.4923e-02,
        -2.6337e-02, -4.1962e-02,  2.2614e-04,  1.4641e-02, -9.3231e-03,
        -4.9500e-02,  1.7029e-02, -4.8752e-03,  3.0869e-02, -5.8228e-02,
        -2.0233e-02,  2.2984e-03, -6.2675e-03, -5.8174e-03,  1.3664e-02,
         4.2511e-02,  5.1819e-02, -6.8321e-03,  2.6794e-02,  2.2491e-02,
        -2.3682e-02,  1.2863e-02,  1.7365e-02, -2.6283e-03,  6.3744e-03,
        -2.6077e-02, -3.8422e-02,  4.2816e-02,  2.1992e-03, -4.2999e-02,
         9.3002e-03,  4.1321e-02, -1.7120e-02,  1.7868e-02,  4.2297e-02,
         1.6708e-02, -2.2903e-02,  1.9592e-02,  8.5571e-02, -3.9307e-02,
         5.6610e-02, -1.3504e-02,  7.0374e-02, -1.1169e-02, -6.3629e-03,
         5.5511e-02,  1.2405e-02, -2.0351e-03, -1.6098e-02, -1.2894e-03,
         5.7030e-03,  4.8462e-02,  6.9824e-02,  9.3994e-03, -2.2644e-02,
         2.3880e-02,  3.3936e-02,  3.7903e-02, -4.7516e-02,  4.6814e-02,
        -3.3020e-02, -2.4155e-02,  5.8289e-02, -1.1177e-02,  1.5083e-02,
        -1.3977e-02,  6.9214e-02, -5.3345e-02, -1.0490e-02,  2.2526e-03,
        -1.7502e-02,  3.0792e-02,  3.5034e-02,  2.6321e-02,  1.1581e-02,
         7.3669e-02, -1.3565e-02,  8.0322e-02,  2.7771e-03,  5.9929e-03,
        -2.9572e-02,  3.1738e-02,  2.4658e-02,  9.8133e-04,  1.8784e-02,
        -2.4277e-02,  2.4918e-02,  5.0049e-02, -1.9928e-02, -1.2581e-02,
         4.1718e-02, -3.2562e-02,  4.0527e-02, -6.8512e-03, -5.1514e-02,
         1.7181e-02, -4.5929e-02,  2.5116e-02, -6.0181e-02,  2.1423e-02,
        -3.9673e-02, -3.8696e-02, -5.7129e-02, -2.3621e-02, -2.3758e-02,
         4.3427e-02, -3.9429e-02, -1.9485e-02,  1.0727e-02, -1.9363e-02,
        -4.0527e-02, -5.4901e-02, -1.7029e-02, -2.9221e-02,  1.1757e-02,
         5.2643e-02,  1.5198e-02, -4.7119e-02,  6.0921e-03,  3.5156e-02,
        -1.1314e-02,  2.4307e-02,  3.0762e-02,  2.9633e-02,  2.7939e-02,
        -2.5833e-02,  5.7281e-02, -3.1281e-03,  8.4305e-03, -2.0046e-03,
        -4.0405e-02,  8.2397e-02,  5.6335e-02,  5.9395e-03, -3.3226e-03,
        -2.2202e-03, -2.6276e-02,  1.4465e-02,  2.8992e-02, -5.1819e-02,
         3.3966e-02,  3.1525e-02, -3.1921e-02,  3.4332e-02,  6.1523e-02,
        -7.2693e-02, -3.8929e-03, -1.9302e-03,  1.0956e-02, -3.3813e-02,
        -1.4801e-02, -4.9622e-02,  1.7700e-02,  2.1347e-02, -2.8946e-02,
        -1.7960e-02, -3.0396e-02, -4.3945e-03,  4.1473e-02,  1.7151e-02,
        -8.0566e-03, -3.0060e-02, -4.0558e-02, -2.4780e-02, -1.1139e-01,
        -6.0730e-02, -2.9388e-02,  7.7393e-02, -5.5145e-02, -7.5760e-03,
         4.5509e-03, -5.7739e-02,  2.6382e-02,  6.9857e-04,  5.3131e-02,
        -2.1637e-02, -1.9104e-02, -3.1021e-02, -2.6993e-02, -2.9087e-03,
        -2.2297e-03, -4.3213e-02, -6.0791e-02,  1.5732e-02, -3.5461e-02,
        -5.4169e-02, -2.8793e-02, -1.0735e-04,  1.5656e-02, -2.8595e-02,
         5.5359e-02, -3.8544e-02,  1.4214e-02, -2.8351e-02, -5.2460e-02,
         1.6327e-02, -1.6613e-03,  1.6800e-02,  4.8706e-02,  4.4312e-02,
        -3.0960e-02,  8.1024e-03,  1.2405e-02,  3.6377e-02,  2.5314e-02,
        -1.8250e-02, -2.0538e-02, -2.0447e-02, -4.3365e-02, -3.2562e-02,
        -4.7363e-02, -3.5950e-02, -5.0598e-02,  5.0812e-02,  8.6899e-03,
         8.4381e-03,  2.7206e-02, -3.5461e-02,  9.5520e-03, -1.9485e-02,
        -7.1239e-04, -1.3557e-02, -3.7048e-02,  7.5607e-03,  3.3386e-02,
         3.6163e-02, -3.1567e-03,  3.7537e-02,  7.3051e-03, -4.4250e-03,
        -6.5536e-03, -1.9241e-02, -1.9241e-02, -4.7516e-02, -3.6499e-02,
         4.2953e-03,  7.6723e-04,  4.2236e-02, -2.1877e-03, -2.3376e-02,
        -1.0254e-02,  1.2001e-02,  2.4353e-02,  6.2317e-02,  2.3331e-02,
        -8.0811e-02, -2.3849e-02, -1.4786e-02, -3.3844e-02, -1.4610e-02,
        -9.1919e-02, -1.1627e-02,  5.6000e-02,  3.7567e-02,  3.1525e-02,
        -2.6688e-02,  1.6418e-02,  2.8458e-02, -7.0992e-03, -1.4557e-02,
        -7.9193e-03, -1.0719e-02, -2.4582e-02, -2.7359e-02, -1.3382e-02,
        -1.2314e-02, -4.6448e-02,  3.0090e-02, -3.1464e-02,  2.7557e-02,
         1.4374e-02,  8.4534e-03, -4.0985e-02, -1.3802e-02,  3.7354e-02,
         1.2230e-02,  1.8677e-02,  1.6937e-02,  8.1787e-03, -8.7952e-02,
         8.6975e-02, -4.3152e-02, -3.6285e-02,  1.3382e-02, -3.0777e-02,
         4.7302e-03,  3.2684e-02, -2.0294e-02, -4.9042e-02, -1.1169e-02,
         7.0618e-02,  4.4495e-02,  5.5267e-02, -1.7548e-02, -2.5253e-02,
         2.4002e-02, -3.6377e-02, -4.3411e-03, -1.2341e-03, -2.9907e-03,
         4.3716e-03, -4.1412e-02,  3.4851e-02, -4.0497e-02, -7.4158e-02,
         1.1093e-02,  7.8552e-02, -1.8448e-02, -5.4550e-04, -6.8298e-02,
         7.8506e-03, -1.5320e-02,  4.8187e-02,  5.2155e-02, -1.8463e-02,
        -2.5406e-02, -6.1760e-03,  2.6276e-02, -6.1378e-03, -4.2152e-03,
         1.6815e-02, -5.7800e-02, -2.3407e-02, -2.3697e-02, -8.0322e-02,
         4.7058e-02, -2.8625e-02,  4.2267e-03,  4.7722e-03, -4.8950e-02,
         3.3508e-02, -1.9592e-02,  3.7872e-02,  1.3170e-03, -3.4393e-02,
        -4.7913e-02, -9.9335e-03,  1.7426e-02, -7.7332e-02, -2.6733e-02,
        -5.5389e-02, -1.0735e-02, -1.7662e-03,  4.4708e-02,  2.9037e-02,
        -2.6611e-02, -3.1555e-02,  2.7435e-02, -1.9653e-02,  1.7365e-02,
         1.7166e-02, -2.8801e-03,  2.8976e-02,  3.9154e-02,  8.1787e-02,
         6.3049e-02, -1.2482e-02,  3.8300e-02, -2.7466e-02,  6.8176e-02,
        -1.8082e-02,  2.2202e-02,  4.3121e-02,  1.2802e-02,  4.9164e-02,
        -1.5795e-04,  2.6840e-02, -4.5135e-02]], dtype=float16)

Kosha

The main class for managing the code and environment databases, updating package metadata, embedding code snippets, and performing context-aware searches.


Kosha


def Kosha(
    dir:Path=None, install_skill:bool=False, xdg_dir:Path=None
):

Kosha allows you to build a context for code generation based on your repo and environment.


pkg_doc


def pkg_doc(
    pkg
)->dict:

Build pkg_store content dict: content=summary+readme, metadata=json.

pkg_doc('httpx')
{'content': 'The next generation HTTP client.\n<p align="center">\n  <a href="https://www.python-httpx.org/"><img width="350" height="208" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/butterfly.png" alt=\'HTTPX\'></a>\n</p>\n\n<p align="center"><strong>HTTPX</strong> <em>- A next-generation HTTP client for Python.</em></p>\n\n<p align="center">\n<a href="https://github.com/encode/httpx/actions">\n    <img src="https://github.com/encode/httpx/workflows/Test%20Suite/badge.svg" alt="Test Suite">\n</a>\n<a href="https://pypi.org/project/httpx/">\n    <img src="https://badge.fury.io/py/httpx.svg" alt="Package version">\n</a>\n</p>\n\nHTTPX is a fully featured HTTP client library for Python 3. It includes **an integrated command line client**, has support for both **HTTP/1.1 and HTTP/2**, and provides both **sync and async APIs**.\n\n---\n\nInstall HTTPX using pip:\n\n```shell\n$ pip install httpx\n```\n\nNow, let\'s get started:\n\n```pycon\n>>> import httpx\n>>> r = httpx.get(\'https://www.example.org/\')\n>>> r\n<Response [200 OK]>\n>>> r.status_code\n200\n>>> r.headers[\'content-type\']\n\'text/html; charset=UTF-8\'\n>>> r.text\n\'<!doctype html>\\n<html>\\n<head>\\n<title>Example Domain</title>...\'\n```\n\nOr, using the command-line client.\n\n```shell\n$ pip install \'httpx[cli]\'  # The command line client is an optional dependency.\n```\n\nWhich now allows us to use HTTPX directly from the command-line...\n\n<p align="center">\n  <img width="700" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/httpx-help.png" alt=\'httpx --help\'>\n</p>\n\nSending a request...\n\n<p align="center">\n  <img width="700" src="https://raw.githubusercontent.com/encode/httpx/master/docs/img/httpx-request.png" alt=\'httpx http://httpbin.org/json\'>\n</p>\n\n## Features\n\nHTTPX builds on the well-established usability of `requests`, and gives you:\n\n* A broadly [requests-compatible API](https://www.python-httpx.org/compatibility/).\n* An integrated command-line client.\n* HTTP/1.1 [and HTTP/2 support](https://www.python-httpx.org/http2/).\n* Standard synchronous interface,',
 'metadata': {'name': 'httpx',
  'version': '0.28.1',
  'keywords': '',
  'requires': 'httpcore brotli h2 certifi zstandard socksio idna pygments rich click brotlicffi anyio',
  'summary': 'The next generation HTTP client.'}}

has_init


def has_init(
    d:Path
)->bool:

True if dir is a Python package root: has init.py or a C-extension init.so.*


Kosha.pkgs_in_env


def pkgs_in_env(
    pyproject:bool=False
)->list:

Intersection of the packages table with packages installed in the environment.


Kosha.prune_old_pkgs


def prune_old_pkgs(
    
):

Keep only the latest version of each package in the database.


Kosha.prune_old_versions


def prune_old_versions(
    pkg:str
):

Keep only the latest version of a package in the database.


Kosha.update_repo


def update_repo(
    dir:Path=None, # directory to index; defaults to repo root
    embed:bool=True, # embed chunks after parsing
    files:L=None, # specific paths to (re)index; None = full sync
    exts:str='.py,.js,.ts,.jsx,.tsx,.java,.go,.cs,.ruby,.php,.swift,.kt,.kts,.rs,.scala,.lua',
    efn:function=embedder, # embedding function to use for code snippets
    verbose:bool=True, # verbose
    skip_file_re:str='^[.]|^(?:setup\\.py|conftest\\.py)$',
    skip_folder_re:str='^[.]|^(?:tests?|examples?|docs?|build|dist)$', func:type=Path, path:pathlib.Path | str='.',
    recursive:bool=True, symlinks:bool=True, file_glob:str=None, file_re:str=None, folder_re:str=None,
    skip_file_glob:str=None, ret_folders:bool=False, sort:bool=True, types:str | list=None
):

Index or update repo code chunks. Pass files= for incremental update (e.g. from watcher).


Kosha.update_pkgs


def update_pkgs(
    pkgs:str | list=None, embed:bool=True,
    exts:str='.py,.js,.ts,.jsx,.tsx,.java,.go,.cs,.ruby,.php,.swift,.kt,.kts,.rs,.scala,.lua', efn:function=embedder,
    verbose:bool=True, kwargs:VAR_KEYWORD
):

Call self as a function.


Kosha.process_repo


def process_repo(
    content:NoneType=None, reembed:bool=False, kwargs:VAR_KEYWORD
):

Embed all documents in the code store, or only those without embeddings if reembed=False.


Kosha.rm_pkg


def rm_pkg(
    pkg:str, ver:str=None
):

Remove a package and its code snippets from the database.


Kosha.update_pkg


def update_pkg(
    pkg:str, embed:bool=True,
    exts:str='.py,.js,.ts,.jsx,.tsx,.java,.go,.cs,.ruby,.php,.swift,.kt,.kts,.rs,.scala,.lua', efn:function=embedder,
    verbose:bool=True, imports:bool=False
):

Update package metadata in the packages table.


count_imp


def count_imp(
    files, own:str=''
)->Counter:

*External top-level imports from a source-string iterable. Reuses cached _parse.*


Kosha.process_env


def process_env(
    content:NoneType=None, reembed:bool=False, embed:bool=True, efn:function=embedder, sz:int=500
):

Embed all documents in the env store, or only those without embeddings if reembed=False.


process_content


def process_content(
    store, content:L, embed:bool=True, efn:function=embedder, sz:int=500
):

Embed chunks and upsert into store; no-op if content is empty.


embed_chunk


def embed_chunk(
    chunk:list, emb_fn:function=<lambda>, efn:function=embedder
):

Embed a list of code chunks using emb_f


Kosha.nuke


def nuke(
    
):

Reset the databases by dropping all tables.

import kosha.core as _kc, inspect
_f = Path(inspect.getfile(_kc))
_anchor = _f.parent
while has_init(_anchor): _anchor = _anchor.parent
_mod = '.'.join(_f.relative_to(_anchor).with_suffix('').parts)
assert _mod == 'kosha.core', f'expected kosha.core, got {_mod}'
print('mod_name anchor fix: ok —', _mod)
mod_name anchor fix: ok — kosha.core
dir2files(repo_root(), strict_skip_file_re, strict_skip_folder_re, exts=code_exts)
[Path('/Users/71293/code/personal/orgs/kosha/kosha/core.py'), Path('/Users/71293/code/personal/orgs/kosha/kosha/graph.py')]
k = Kosha(xdg_dir=Path('.'))
pkg='fastcore'
k._is_pkg_ingested(pkg)
[{'name': 'fastcore', 'version': '1.12.40'}]
k.env_st(limit=1)
[{'id': '01ab7b525aa85cfa5a582a93af902fec6579460e',
  'content': 'class _Getter:\n    "Abstract class with dynamic attributes providing access to DB objects"\n    def __init__(self, db): self.db = db\n    # NB: Define `__dir__` in subclass to get list of objects\n    def __repr__(self): return ", ".join(dir(self))\n    def __contains__(self, s): return (s if isinstance(s,str) else s.name) in dir(self)\n    def __iter__(self): return iter(self[dir(self)])\n    def __getitem__(self, idxs):\n        if isinstance(idxs,str): return self.db.table(idxs)\n        return [self.db.table(o) for o in idxs]\n    def __getattr__(self, k):\n        if k[0]==\'_\': raise AttributeError\n        return self.db[k]',
  'embedding': b'!\xacH\xa6\xf7){\x15W\xab\xe8\x8d\x84*\x93\xa8\xec\x1d\xf7\xab\xdf\x10\xa1\xa0\x16*\xb4*\x8b#.\xa4\xbd\x164\xa8\xb0$C,\x89-1\xac\x1a)\x98+\x8e\xa8\xef\xa8\\\x13L\'\xb4(T%\x00\xa6\xfc\xa2\x08*\xae\xab\xed\xa8\xaa(\xcf\x9fn\xa7\x15!\xa0+\xe3\xa4<\'\xb5\xa1F$P,P&^\xa2J)\xf8\xa3R \xb0\xa5\x9b\x9f*$\xe8\xa6\xfc\xa2.\xa7<\xa4\xba!\x89%9\xad\x03 !({$\xaa\x1aG*\x1d\x1d;&\xfd\x1dY\x15M\xa6\xa0(\xd5\xa2\xec&\x08!\xb2+\x8d)n [\xa4t)\xb9\x1e\xad\xa9<\x1b\xeb%\xbd\x90"\xa9\xe2$w\xa8\x8b\x9a\xd6%\x84\xab\x03\xa0?\xacQ\xa3\x8b\x18k\xaf-#0\xa4\xe1\xa3\xfa)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ae\xa6\xac\xa6\t)\xf5#\xf5!\x8c%a\x9c\xb9\xab\xd5\xa2\x03\x1bD,\xc5\xa0\x88\x17\xdb\x9d\xe0(\x84\x18\x90&\xee#\x9d+n\xa8|\x9f\x04\'\xbf&/\xa2\xf0!\x88\xa5\xf0(v\x10\xb8\x8d\x93\x9es\xa9w\xab;%\xdd\xacC&/\x18\xb4&x$\xc8\x1d\r\xa8\x1e)^+\x9b\x99\x96\xadf\x92[\xa9\x04\xa25\x9d\x8d%\xfe)\x0b%\xac).\xa1\x88\xaas$\xdb%,$^ \x0e"%\xa9\xf3\xa4\x9c\x9d\x99\xa4\xac)6(\x9b-\xe0\xa5z\xa3R\xa2\xd1\xaa\xf2(\x1f\x9a\xee\xa8~\x96',
  'metadata': '{"path": "/Users/71293/code/personal/orgs/karma/.venv/lib/python3.13/site-packages/fastlite/core.py", "uploaded_at": 1773452878.5692947, "name": "_Getter", "lang": ".py", "type": "ClassDef", "lineno": 26, "end_lineno": 38, "package": "fastlite", "version": "0.2.4", "mod_name": "fastlite.core._Getter"}',
  'uploaded_at': 1773452878.5692947,
  'package': 'fastlite'}]
k.pkgs(order_by='name')
[{'name': 'apsw',
  'version': '3.53.0.0',
  'summary': 'Another Python SQLite Wrapper',
  'uploaded_at': '2026-04-21 07:13:00'},
 {'name': 'apswutils',
  'version': '0.1.2',
  'summary': 'A fork of sqlite-minutils for apsw',
  'uploaded_at': '2026-04-21 07:11:48'},
 {'name': 'fastcore',
  'version': '1.12.40',
  'summary': 'Python supercharged for fastai development',
  'uploaded_at': '2026-04-22 04:11:11'},
 {'name': 'fastlite',
  'version': '0.2.4',
  'summary': 'A bit of extra usability for sqlite',
  'uploaded_at': '2026-04-21 07:10:31'},
 {'name': 'ghapi',
  'version': '1.0.13',
  'summary': 'A python client for the GitHub API',
  'uploaded_at': '2026-04-21 07:11:36'},
 {'name': 'httpx',
  'version': '0.28.1',
  'summary': 'The next generation HTTP client.',
  'uploaded_at': '2026-04-21 07:12:59'},
 {'name': 'litesearch',
  'version': '0.0.23',
  'summary': 'search through files with fts5, vectors and get reranked results. Fast',
  'uploaded_at': '2026-04-21 10:41:35'},
 {'name': 'python-fasthtml',
  'version': '0.13.3',
  'summary': 'The fastest way to create an HTML app',
  'uploaded_at': '2026-04-22 04:13:06'}]
k.update_pkg('jupyterlab')
updating pkg: jupyterlab ...
                                                                     
 updated pkg: jupyterlab with 22501 new/changed chunks, -22501 unchanged, -22501 removed
{'name': 'jupyterlab',
 'version': '4.5.6',
 'summary': 'JupyterLab computational environment',
 'uploaded_at': '2026-04-22 06:51:53'}
k.update_pkg('fastcore')
updating pkg: fastcore ...
package [{'name': 'fastcore', 'version': '1.12.40'}] already loaded.
k.update_repo(skip_file_glob='*.ipynb')
k.update_pkgs(['python-fasthtml','fastcore','litesearch','fastlite','apsw','ghapi','httpx'], embed=True)
loading pkgs {'fastlite', 'litesearch', 'httpx', 'python-fasthtml', 'apsw', 'fastcore', 'ghapi'} ......
Updating packages: 100%|██████████| 7/7 [00:00<00:00, 62.63pkg/s]
updating pkg: fastlite ...
package [{'name': 'fastlite', 'version': '0.2.4'}] already loaded.
updating pkg: litesearch ...
package [{'name': 'litesearch', 'version': '0.0.23'}] already loaded.
updating pkg: httpx ...
package [{'name': 'httpx', 'version': '0.28.1'}] already loaded.
updating pkg: python-fasthtml ...
package [{'name': 'python-fasthtml', 'version': '0.13.3'}] already loaded.
updating pkg: apsw ...
package [{'name': 'apsw', 'version': '3.53.0.0'}] already loaded.
updating pkg: fastcore ...
package [{'name': 'fastcore', 'version': '1.12.40'}] already loaded.
updating pkg: ghapi ...
package [{'name': 'ghapi', 'version': '1.0.13'}] already loaded.