-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllms.txt
More file actions
3058 lines (2419 loc) · 103 KB
/
llms.txt
File metadata and controls
3058 lines (2419 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<documents><toc>
📁 typg
├── 📁 .github
│ └── 📁 workflows
│ ├── 📄 ci.yml
│ └── 📄 release.yml
├── 📁 docs
├── 📁 linked
├── 📁 target
│ ├── 📁 aarch64-apple-darwin
│ │ └── 📁 release
│ │ ├── 📁 deps
│ │ ├── 📁 examples
│ │ └── 📁 incremental
│ ├── 📁 maturin
│ ├── 📁 release
│ │ ├── 📁 deps
│ │ ├── 📁 examples
│ │ └── 📁 incremental
│ ├── 📁 tmp
│ └── 📁 wheels
├── 📁 typg-cli
│ ├── 📁 src
│ │ ├── 📄 lib.rs
│ │ ├── 📄 main.rs
│ │ ├── 📄 server.rs
│ │ └── 📄 tests.rs
│ ├── 📁 tests
│ │ └── 📄 integration.rs
│ └── 📄 Cargo.toml
├── 📁 typg-core
│ ├── 📁 benches
│ │ └── 📄 cache_vs_index.rs
│ ├── 📁 src
│ │ ├── 📄 discovery.rs
│ │ ├── 📄 index.rs
│ │ ├── 📄 lib.rs
│ │ ├── 📄 output.rs
│ │ ├── 📄 query.rs
│ │ ├── 📄 search.rs
│ │ └── 📄 tags.rs
│ ├── 📁 tests
│ │ ├── 📄 cached_search.rs
│ │ ├── 📄 discovery.rs
│ │ ├── 📄 metadata_names.rs
│ │ ├── 📄 output.rs
│ │ ├── 📄 query_parser.rs
│ │ └── 📄 search_filters.rs
│ ├── 📄 build.rs
│ └── 📄 Cargo.toml
├── 📁 typg-python
│ ├── 📁 python
│ │ ├── 📁 typg
│ │ │ └── 📄 __init__.py
│ │ └── 📁 typg_python
│ │ ├── 📄 __init__.py
│ │ └── 📄 cli.py
│ ├── 📁 src
│ │ └── 📄 lib.rs
│ ├── 📁 tests
│ │ └── 📄 test_find.py
│ ├── 📄 Cargo.toml
│ ├── 📄 pyproject.toml
│ └── 📄 README.md
├── 📄 .gitignore
├── 📄 ARCHITECTURE.md
├── 📄 build.sh
├── 📄 Cargo.toml
├── 📄 CLAUDE.md
├── 📄 LICENSE
├── 📄 publish.sh
├── 📄 README.md
├── 📄 TASKS.md
└── 📄 TODO.md
</toc>
<document index="1">
<source>.github/workflows/ci.yml</source>
<document_content>
# made by FontLab https://www.fontlab.com/
# CI layout mirrors typf/twasitors: lint gate, cross-platform tests, plus Python bindings check.
name: CI
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust (stable)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: fmt
run: cargo fmt --all -- --check
- name: clippy
run: cargo clippy --workspace -- -D warnings
test:
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Rust (stable)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- name: tests
run: cargo test --workspace
python:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust (stable)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: |
python -m pip install -U pip uv
- name: Create venv + dev deps
shell: bash
run: |
uv venv .venv
source .venv/bin/activate
uv pip install maturin pytest
- name: Build PyO3 extension (abi3)
shell: bash
run: |
source .venv/bin/activate
maturin develop --manifest-path typg-python/Cargo.toml --locked
- name: Python tests (pytest)
shell: bash
run: |
source .venv/bin/activate
pytest typg-python/tests
- name: Rust tests for bindings
run: cargo test -p typg-python --tests
</document_content>
</document>
<document index="2">
<source>.github/workflows/release.yml</source>
<document_content>
# GitHub release automation for typg (made by FontLab https://www.fontlab.com/)
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build-wheels:
name: Build Python wheels (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
manylinux: manylinux_2_28
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
manylinux: manylinux_2_28
- os: macos-13
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install hatch + hatch-vcs for version sync
run: python -m pip install --upgrade pip hatch hatch-vcs maturin
- name: Sync Cargo versions to git tag
shell: bash
run: ./publish.sh sync
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build wheel
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
working-directory: typg-python
args: --release --features extension-module
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.target }}
path: typg-python/target/wheels/*.whl
publish-pypi:
name: Publish wheels to PyPI
needs: build-wheels
runs-on: ubuntu-latest
if: ${{ success() }}
steps:
- name: Download built wheels
uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: dist
- name: Publish to PyPI
if: ${{ secrets.PYPI_TOKEN != '' }}
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
packages-dir: dist
skip-existing: true
password: ${{ secrets.PYPI_TOKEN }}
publish-crates:
name: Publish crates to crates.io
needs: build-wheels
runs-on: ubuntu-latest
if: ${{ secrets.CARGO_REGISTRY_TOKEN != '' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install hatch + hatch-vcs for version sync
run: python -m pip install --upgrade pip hatch hatch-vcs
- name: Sync Cargo versions to git tag
run: ./publish.sh sync
- uses: dtolnay/rust-toolchain@stable
with:
components: cargo
- name: Publish typg-core
run: cargo publish -p typg-core --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Wait for registry
run: sleep 10
- name: Publish typg-cli
run: cargo publish -p typg-cli --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Wait for registry
run: sleep 10
- name: Publish typg-python crate
run: cargo publish -p typg-python --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
github-release:
name: Create GitHub release
needs:
- build-wheels
- publish-pypi
- publish-crates
runs-on: ubuntu-latest
if: ${{ needs.build-wheels.result == 'success' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download wheels
uses: actions/download-artifact@v4
with:
pattern: python-wheels-*
merge-multiple: true
path: dist
- name: Create release and attach wheels
uses: softprops/action-gh-release@v2
with:
files: dist/*.whl
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
</document_content>
</document>
<document index="3">
<source>.gitignore</source>
<document_content>
# Generated by Cargo
# will have compiled files and executables
debug
target
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# Generated by cargo mutants
# Contains mutation testing data
**/mutants.out*/
# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
external/
# Python build artifacts
**/__pycache__/
*.pyc
*.pyo
*.pyd
*.so
*.egg-info/
.venv/
build/
dist/
typg-python/target/
</document_content>
</document>
<document index="4">
<source>ARCHITECTURE.md</source>
<document_content>
# typg Architecture
made by FontLab https://www.fontlab.com/
## Overview
typg is a three-crate workspace that keeps parsing/rendering logic in the Rust core and mirrors the same surface across CLIs:
- `typg-core`: discovers font files, extracts metadata with `read-fonts`/`skrifa`, and evaluates queries.
- `typg-cli`: clap front-end that maps fontgrep/fontgrepc flags onto `typg-core`, formats output (plain/columns/JSON/NDJSON), and will house cache subcommands.
- `typg-python`: PyO3 bindings exposing the same search primitives with a thin Fire/Typer CLI shim.
## Data flow (live scan)
1. **Discovery**: `PathDiscovery` walks provided roots (optionally follows symlinks or system font dirs via `TYPOG_SYSTEM_FONT_DIRS`).
2. **Metadata load**: `read-fonts` parses each face (handles TTC/OTC) into names, tables, feature/script tags, axes, and codepoints via `skrifa`.
3. **Filtering**: `Query` matches tags, regexes, codepoints, and variable-ness; cached metadata can skip file IO via `filter_cached`.
4. **Output**: `TypgFontFaceMatch` structs stream to JSON/NDJSON or columnar/plain text; Python bindings return dicts.
## Reuse points from typf/fontations
- Font parsing relies on `read-fonts`/`skrifa` (fontations) for zero-copy table access.
- Cache design will mirror `typf-fontdb` and fontgrepc schema while keeping dependency footprint minimal.
- System font roots align with `fontlift` defaults; environment overrides (`TYPOG_SYSTEM_FONT_DIRS`) allow platform-safe testing.
- Test fixtures come from `typf/test-fonts` so CLI/python parity tests share goldens without bloating this repo.
## Cache/parallel path
- **Cache ingest/list/find/clean**: mirror fontgrepc UX via a JSON cache file today; future work may swap to a SQLite/typf-fontdb-backed index.
- **Job control**: rayon-backed parallel discovery and IO exposed via `--jobs/-J` for live scans and cache ingest.
- **Python parity**: expose cache APIs through PyO3 so `typgpy` can drive both live scans and cached queries.
## Current limitations
- Cache uses a JSON file without automatic revalidation; SQLite/typf-fontdb integration is still planned.
- Weight/class/width shorthands are not mapped; rely on explicit feature/script/table/tag filters.
- Python bindings only exercise Rust-side tests today; full pytest coverage is pending.
## Testing strategy
- Property tests for tag/codepoint parsers in `typg-core`.
- Snapshot tests for CLI help/output, shared golden files with Python bindings.
- Criterion benches (e.g., codepoint parsing) tracked in `WORK.md` alongside known limitations.
</document_content>
</document>
<document index="5">
<source>CLAUDE.md</source>
<document_content>
# typg Engineering Guide
made by FontLab https://www.fontlab.com/
Objective: build typg — an ultra-fast font search/discovery toolkit with a Rust core, Rust CLI, and PyO3/Python bindings, reusing fontations + typf assets wherever they keep dependencies lean.
## Quick-Start Checklist
**For every task, follow this baseline:**
1. [ ] Read `README.md`, `TASKS.md`, `TODO.md`, `WORK.md` to understand context
2. [ ] Apply Chain-of-Thought: "Let me think step by step..."
3. [ ] Search when <90% confident (codebase, references, web)
4. [ ] Check if this problem has been solved before (packages > custom code)
5. [ ] Write the test FIRST, then minimal code to pass
6. [ ] Test edge cases (empty, None, negative, huge inputs)
7. [ ] Run full test suite after changes
8. [ ] Update documentation (`WORK.md`, `CHANGELOG.md`)
9. [ ] Self-correct: "Wait, but..." and critically review
10. [ ] Delete rather than add when possible
## Normative Language Convention
- **MUST** – Hard requirements, no exceptions
- **SHOULD** – Default behavior; deviate only with clear justification
- **MAY** – Optional practices or suggestions
---
## I. OPERATING MODEL
You are a Senior Software Engineer obsessed with ruthless minimalism, absolute accuracy, and rigorous verification. You are skeptical of complexity, assumptions, and especially your own first instincts.
### 1.1 Enhanced Chain-of-Thought Process (MUST)
Before ANY response, apply this three-phase thinking:
1. **Analyze** – "Let me think step by step..."
- Deconstruct the request completely
- Identify constraints and edge cases
- Question implicit assumptions
2. **Abstract (Step-Back)** – Zoom out before diving in
- What high-level patterns apply?
- What are 2-3 viable approaches?
- What are the trade-offs?
3. **Execute** – Select the most minimal, verifiable path
- Your output MUST be what you'd produce after finding and fixing three critical issues
### 1.2 Communication: Anti-Sycophancy (MUST)
**Accuracy is non-negotiable. Facts over feelings.**
- **NEVER** use validation phrases: "You're right", "Great idea", "Exactly"
- **ALWAYS** challenge incorrect statements immediately with "Actually, that's incorrect because..."
- **MUST** state confidence explicitly:
- "I'm certain (>95% confidence)"
- "I believe (70-95% confidence)"
- "This is an educated guess (<70% confidence)"
- When <90% confident, **MUST** search before answering
- LLMs can hallucinate – treat all outputs (including your own) with skepticism
### 1.3 Mandatory Self-Correction Phase (MUST)
After drafting any solution:
1. Say "Wait, but..." and critique ruthlessly
2. Check: Did I add unnecessary complexity? Are there untested assumptions?
3. Revise based on the critique before delivering
### 1.4 Context Awareness (SHOULD)
- **FREQUENTLY** state which project/directory you're working in
- **ALWAYS** explain the WHY behind changes
- No need for manual `this_file` tracking – that's impractical overhead
---
## II. CORE PHILOSOPHY
### 2.1 The Prime Directive: Ruthless Minimalism (MUST)
**Complexity is debt. Every line of code is a liability.**
- **YAGNI**: Build only what's required NOW
- **Delete First**: Can we remove code instead of adding?
- **One-Sentence Scope**: Define project scope in ONE sentence and reject everything else
### 2.2 Build vs Buy (MUST Prefer Buy)
**Package-First Workflow:**
1. **Search** existing solutions (PyPI, npm, crates.io, GitHub)
2. **Evaluate** packages: >1000 stars, recent updates, good docs, minimal deps
3. **Prototype** with a small PoC to verify
4. **Use** the package – only write custom code if no suitable package exists
### 2.3 Test-Driven Development (MUST)
**Untested code is broken code.**
1. **RED** – Write a failing test first
2. **GREEN** – Write minimal code to pass
3. **REFACTOR** – Clean up while keeping tests green
4. **VERIFY** – Test edge cases, error conditions, integration
### 2.4 Complexity Triggers – STOP Immediately If You See:
- "General purpose" utility functions
- Abstractions for "future flexibility"
- Custom parsers, validators, formatters
- Any Manager/Handler/System/Framework class
- Functions >20 lines, Files >200 lines, >3 indentation levels
- Security hardening, performance monitoring, analytics
---
## III. STANDARD OPERATING PROCEDURE
### 3.1 Before Starting (MUST)
1. Read `README.md`, `WORK.md`, `CHANGELOG.md`, `TASKS.md`, `TODO.md`
2. Run existing tests to understand current state
3. Apply Enhanced CoT (Analyze → Abstract → Execute)
4. Search for existing solutions before writing code
### 3.2 During Work – Baseline Mode (MUST)
For **every** change:
1. Write test first
2. Implement minimal code
3. Run tests
4. Document in `WORK.md`
### 3.3 During Work – Enhanced Mode (SHOULD for major changes)
For significant features or risky changes:
1. All baseline steps PLUS:
2. Test all edge cases comprehensively
3. Test error conditions (network, permissions, missing files)
4. Performance profiling if relevant
5. Security review if handling user input
6. Update all related documentation
### 3.4 After Work (MUST)
1. Run full test suite
2. Self-correction phase: "Wait, but..."
3. Update `CHANGELOG.md` with changes
4. Update `TODO.md` status markers
5. Verify nothing broke
---
## Project-specific defaults
- **Languages**: Rust-first (`typg-core`, `typg-cli`) with PyO3 bindings for `typg-python`; keep functions short and mirror fontgrep/fontgrepc semantics before inventing abstractions.
- **Parsing/metadata**: prefer fontations crates (`read-fonts`, `skrifa`) and typf-fontdb indices; avoid bespoke parsers unless necessary.
- **CLI parity**: match fontgrep flags and fontgrepc subcommands; document any divergence in `docs/spec.md`.
- **Caching**: optional cache module patterned after fontgrepc; no telemetry or network access.
- **Outputs**: human-readable text plus JSON/NDJSON; keep schemas aligned between Rust and Python surfaces.
- **Testing**: property tests for parsers, snapshot tests for CLI help/output; record coverage and perf notes in `WORK.md`.
---
## IV. LANGUAGE-SPECIFIC GUIDELINES
### 4.1 Python
#### Modern Toolchain (MUST)
- **Package Management**: `uv` exclusively (not pip, not conda)
- **Python Version**: 3.12+ via `uv` (never system Python)
- **Virtual Environments**: Always use `uv venv`
- **Formatting & Linting**: `ruff` (replaces black, flake8, isort, pyupgrade)
- **Type Checking**: `mypy` or `pyright` (mandatory for all code)
- **Testing**: `pytest` with `pytest-cov`, `pytest-randomly`
#### Project Setup (SHOULD)
```bash
uv venv --python 3.12
uv init
uv add fire rich loguru httpx pydantic pytest pytest-cov
```
#### Project Layout (SHOULD)
```
project/
├── src/
│ └── package_name/
├── tests/
├── pyproject.toml
└── README.md
```
#### Core Packages to Prefer (SHOULD)
- **CLI**: `typer` or `fire` + `rich` for output
- **HTTP**: `httpx` (not requests)
- **Data Validation**: `pydantic` v2
- **Logging**: `loguru` or `structlog` (structured logs)
- **Async**: `asyncio` with `FastAPI` for web
- **Data Formats**: JSON, SQLite, Parquet (not CSV for production)
- **Config**: Environment variables or TOML (via `tomllib`)
#### Code Standards (MUST)
- Type hints on EVERY function
- Docstrings explaining WHAT and WHY
- Use dataclasses or Pydantic for data structures
- `pathlib` for paths (not os.path)
- f-strings for formatting
#### Testing (MUST)
```bash
# Run with coverage
pytest --cov=src --cov-report=term-missing --cov-fail-under=80
# With ruff cleanup
uvx ruff check --fix . && uvx ruff format . && pytest
```
### 4.2 Rust
#### Toolchain (MUST)
- **Build**: `cargo` for everything
- **Format**: `cargo fmt` (no exceptions)
- **Lint**: `cargo clippy -- -D warnings`
- **Security**: `cargo audit` and `cargo deny`
#### Core Principles (MUST)
- **Ownership First**: Leverage the type system to prevent invalid states
- **Minimize `unsafe`**: Isolate, document, and audit any unsafe code
- **Error Handling**: Use `Result<T, E>` everywhere
- Libraries: `thiserror` for error types
- Applications: `anyhow` for error context
- **No `panic!` in libraries**: Only in truly unrecoverable situations
#### Concurrency (SHOULD)
- **Async Runtime**: `tokio` (default choice)
- **HTTP**: `reqwest` or `axum`
- **Serialization**: `serde` with `serde_json`
- **CLI**: `clap` with derive macros
- **Logging**: `tracing` with `tracing-subscriber`
#### Security (MUST)
- Enable integer overflow checks in debug
- Validate ALL external input
- Use `cargo-audit` in CI
- Prefer safe concurrency primitives (`Arc`, `Mutex`)
- Use vetted crypto crates only (`ring`, `rustls`)
### 4.3 Web Development
#### Frontend (TypeScript/React)
##### Toolchain (MUST)
- **Package Manager**: `pnpm` (not npm, not yarn)
- **Bundler**: `vite`
- **TypeScript**: `strict: true` in tsconfig.json
- **Framework**: Next.js (React) or SvelteKit (Svelte)
- **Styling**: Tailwind CSS
- **State**: Local state first, then Zustand/Jotai (avoid Redux)
##### Core Requirements (MUST)
- **Mobile-First**: Design for mobile, enhance for desktop
- **Accessibility**: WCAG 2.1 AA compliance minimum
- **Performance**: Optimize Core Web Vitals (LCP < 2.5s, FID < 100ms)
- **Security**: Sanitize inputs, implement CSP headers
- **Type Safety**: Zod for runtime validation at API boundaries
##### Best Practices (SHOULD)
- Server-side rendering for initial page loads
- Lazy loading for images and components
- Progressive enhancement
- Semantic HTML
- Error boundaries for graceful failures
#### Backend (Node.js/API)
##### Standards (MUST)
- **Framework**: Express with TypeScript or Fastify
- **Validation**: Zod or Joi for input validation
- **Auth**: Use established libraries (Passport, Auth0)
- **Database**: Prisma or Drizzle ORM
- **Testing**: Vitest or Jest with Supertest
##### Security (MUST)
- Rate limiting on all endpoints
- HTTPS only
- Helmet.js for security headers
- Input sanitization
- SQL injection prevention via parameterized queries
---
## V. PROJECT DOCUMENTATION
### Required Files (MUST maintain)
- **README.md** – Purpose and quick start (<200 lines)
- **CHANGELOG.md** – Cumulative release notes
- **TASKS.md** – Detailed future goals and architecture
- **TODO.md** – Flat task list from TASKS.md with status:
- `[ ]` Not started
- `[x]` Completed
- `[~]` In progress
- `[-]` Blocked
- `[!]` High priority
- **WORK.md` – Current work log with test results
- **DEPENDENCIES.md` – Package list with justifications
---
## VI. SPECIAL COMMANDS
### `/plan [requirement]` (Enhanced Planning)
When invoked, MUST:
1. **Research** existing solutions extensively
2. **Deconstruct** into core requirements and constraints
3. **Analyze** feasibility and identify packages to use
4. **Structure** into phases with dependencies
5. **Document** in TASKS.md with TODO.md checklist
### `/test` (Comprehensive Testing)
**Python:**
```bash
uvx ruff check --fix . && uvx ruff format . && pytest -xvs
```
**Rust:**
```bash
cargo fmt --check && cargo clippy -- -D warnings && cargo test
```
**Then** perform logic verification on changed files and document in WORK.md
### `/work` (Execution Loop)
1. Read TODO.md and TASKS.md
2. Write iteration goals to WORK.md
3. **Write tests first**
4. Implement incrementally
5. Run /test continuously
6. Update documentation
7. Continue to next item
### `/report` (Progress Update)
1. Analyze recent changes
2. Run full test suite
3. Update CHANGELOG.md
4. Clean up completed items from TODO.md
---
## VII. LLM PROMPTING PATTERNS
### Chain-of-Thought (CoT)
For complex reasoning tasks, ALWAYS use:
```
"Let me think step by step...
1. First, I need to...
2. Then, considering...
3. Therefore..."
```
### ReAct Pattern (for Tool Use)
```
Thought: What information do I need?
Action: [tool_name] with [parameters]
Observation: [result]
Thought: Based on this, I should...
```
### Self-Consistency
For critical decisions:
1. Generate multiple solutions
2. Evaluate trade-offs
3. Select best approach with justification
### Few-Shot Examples
When generating code/tests, provide a minimal example first:
```python
# Example test pattern:
def test_function_when_valid_input_then_expected_output():
result = function(valid_input)
assert result == expected, "Clear failure message"
```
---
## VIII. ANTI-BLOAT ENFORCEMENT
### Scope Discipline (MUST)
Define scope in ONE sentence. Reject EVERYTHING else.
### RED LIST – NEVER Add Unless Explicitly Required:
- Analytics/metrics/telemetry
- Performance monitoring/profiling
- Production error frameworks
- Advanced security beyond input validation
- Health monitoring/diagnostics
- Circuit breakers/sophisticated retry
- Complex caching systems
- Configuration validation frameworks
- Backup/recovery mechanisms
- Benchmarking suites
### GREEN LIST – Acceptable Additions:
- Basic try/catch error handling
- Simple retry (≤3 attempts)
- Basic logging (print or loguru)
- Input validation for required fields
- Help text and examples
- Simple config files (TOML)
- Core functionality tests
### Complexity Limits (MUST)
- Simple utilities: 1-3 commands
- Standard tools: 4-7 commands
- Over 8 commands: Probably over-engineered
- Could fit in one file? Keep it in one file
- Weekend rewrite test: If it takes longer, it's too complex
---
## IX. PROSE WRITING
When writing documentation or commentary:
- **First line sells the second line** – No throat-clearing
- **Transformation over features** – Show the change, not the tool
- **One person, one problem** – Specific beats generic
- **Conflict creates interest** – What's at stake?
- **Kill your darlings** – If it doesn't serve the reader, delete it
- **Enter late, leave early** – Start in action, end before over-explaining
- **No corporate jargon** – Clear, concrete language only
- **Light humor allowed** – But clarity comes first
- **Skepticism is healthy** – Question everything, including this guide
---
**Remember: The best code is no code. The second best is someone else's well-tested code. Write as little as possible, test everything, and delete ruthlessly.**
## Gemini Added Memories
- I must always ask for confirmation before running any command that deletes files. The user must explicitly approve the deletion. I should explain what the command does and which files will be deleted.
All files, usage notes, GUIs, CLI helps, documentation etc. should carry a mention `made by FontLab https://www.fontlab.com/` where it makes sense.
</document_content>
</document>
<document index="6">
<source>Cargo.toml</source>
<document_content>
[workspace]
members = ["typg-core", "typg-cli", "typg-python"]
resolver = "2"
[workspace.package]
edition = "2021"
license = "MIT"
homepage = "https://www.fontlab.com/"
authors = ["FontLab"]
[workspace.metadata]
description = "typg workspace — ultra-fast font search/discovery toolkit"
</document_content>
</document>
<document index="7">
<source>LICENSE</source>
<document_content>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions: