Skip to content

Commit 788ad27

Browse files
fix(ci): wasm nightly, python trusted publishing, better README
typescript-ci.yml: - dtolnay/rust-toolchain@nightly (wasm-pack needs --artifact-dir = nightly) - remove --out-dir flag (wasm-pack defaults to pkg/) - --scope promptexecution so package publishes as @promptexecution/tomllm - gate npm publish on v* tags python-ci.yml: - replace deprecated maturin upload with pypa/gh-action-pypi-publish - PyPI Trusted Publishing (OIDC, no token secret required) - gate PyPI publish on v* tags Cargo.toml: updated description + documentation URL pyproject.toml: added version, readme, keywords, classifiers, project URLs README.md: full rewrite — business description, no project-specific jargon, annotation prefix table, Rust/Python/TS usage examples, tail-map format docs src/lib.rs: updated crate-level doc comment to match Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent af180f8 commit 788ad27

6 files changed

Lines changed: 173 additions & 105 deletions

File tree

.github/workflows/python-ci.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ name: Python CI
33
on:
44
push:
55
branches: [main]
6+
tags: ["v*"]
67
pull_request:
78
branches: [main]
89

910
jobs:
1011
build:
12+
name: Build wheels (linux x86_64)
1113
runs-on: ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
15-
with:
16-
python-version: "3.11"
17-
- name: Build wheel
16+
- name: Build manylinux wheel
1817
uses: PyO3/maturin-action@v1
1918
with:
2019
command: build
@@ -27,18 +26,21 @@ jobs:
2726
path: dist/
2827

2928
publish-pypi:
29+
name: Publish to PyPI
3030
needs: build
31-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
31+
if: startsWith(github.ref, 'refs/tags/v')
3232
runs-on: ubuntu-latest
33+
permissions:
34+
id-token: write # required for PyPI Trusted Publishing (OIDC)
3335
steps:
3436
- uses: actions/download-artifact@v4
3537
with:
3638
name: wheels-linux
3739
path: dist/
38-
- name: Publish to PyPI
39-
uses: PyO3/maturin-action@v1
40+
- name: Publish
41+
# Trusted Publishing: no token needed once project is registered on PyPI
42+
# with this repo as a trusted publisher (https://pypi.org/manage/account/publishing/)
43+
# Fallback: set PYPI_API_TOKEN secret and use password auth below
44+
uses: pypa/gh-action-pypi-publish@release/v1
4045
with:
41-
command: upload
42-
args: --non-interactive --skip-existing dist/*
43-
env:
44-
MATURIN_PYPI_TOKEN: ${{ secrets.MATURIN_PYPI_TOKEN }}
46+
skip-existing: true

.github/workflows/typescript-ci.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: TypeScript / WASM CI
33
on:
44
push:
55
branches: [main]
6+
tags: ["v*"]
67
pull_request:
78
branches: [main]
89

@@ -11,38 +12,37 @@ jobs:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v4
14-
- uses: actions-rs/toolchain@v1
15+
# wasm-pack internally passes --artifact-dir to cargo, which requires nightly
16+
- uses: dtolnay/rust-toolchain@nightly
1517
with:
16-
toolchain: stable
17-
override: true
18-
target: wasm32-unknown-unknown
18+
targets: wasm32-unknown-unknown
1919
- name: Install wasm-pack
2020
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
21-
- name: Build WASM (bundler)
22-
run: wasm-pack build --target bundler --features wasm --out-dir pkg
23-
- name: Build WASM (nodejs)
24-
run: wasm-pack build --target nodejs --features wasm --out-dir pkg-nodejs
25-
- name: Upload WASM artifacts
21+
- name: Build WASM (bundler target)
22+
run: wasm-pack build --target bundler --features wasm --scope promptexecution
23+
- name: Upload WASM artifact
2624
uses: actions/upload-artifact@v4
2725
with:
2826
name: wasm-pkg
2927
path: pkg/
3028

3129
publish-npm:
30+
name: Publish to npm
3231
needs: wasm-build
33-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
32+
if: startsWith(github.ref, 'refs/tags/v')
3433
runs-on: ubuntu-latest
3534
steps:
36-
- uses: actions/checkout@v4
37-
- uses: actions/setup-node@v4
38-
with:
39-
node-version: "20"
40-
registry-url: "https://registry.npmjs.org"
4135
- uses: actions/download-artifact@v4
4236
with:
4337
name: wasm-pkg
4438
path: pkg/
45-
- name: Publish to npm
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: "20"
42+
registry-url: "https://registry.npmjs.org"
43+
- name: Publish
44+
# wasm-pack generates pkg/package.json with @promptexecution/tomllm name
4645
run: npm publish --access public
46+
working-directory: pkg/
4747
env:
4848
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
name = "tomllm"
33
version = "0.1.0"
44
edition = "2024"
5-
description = "TOML + LLM comment conventions: tribal knowledge in #comments, stripped for data pipelines"
5+
description = "Structured TOML annotations for AI-augmented applications — annotate config for LLMs, strip for pipelines"
66
license = "MIT"
77
repository = "https://github.com/PromptExecution/tomllm"
8-
keywords = ["toml", "llm", "agent", "config", "annotations"]
8+
documentation = "https://docs.rs/tomllm"
9+
keywords = ["toml", "llm", "ai", "config", "annotations"]
910
categories = ["parsing", "config", "text-processing"]
1011
readme = "README.md"
1112

README.md

Lines changed: 111 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,128 @@
11
# tomllm
22

3-
TOML + LLM comment conventions: tribal knowledge in `#comments`, stripped for data pipelines.
3+
**Structured TOML annotations for AI-augmented applications.**
44

5-
## Overview
5+
`tomllm` extends standard TOML with a lightweight comment convention that lets configuration files carry machine-readable documentation alongside their values. Annotation comments survive in source for human and LLM readers; a single call strips them for clean downstream serialization.
66

7-
`.tomllm` files are **valid TOML** with enriched `#` comment semantics:
7+
---
88

9-
- Comments associate with the next key-value pair or section header
10-
- Special prefixes encode tribal knowledge: `# 🤓`, `# @tribal:`, `# @example:`, `# @requires:`
11-
- Tail-map block (last ≤10 lines): fast executive agent scanning without full context load
12-
- Comments are FOR agents reading the **source file** as documentation — strip them for downstream pipelines
9+
## The problem
1310

14-
## Cognitive Tiers
11+
Configuration files written for LLM agents face a tension: agents need rich context (what does this key mean? what are valid values? what are the gotchas?) but downstream data pipelines need clean, minimal payloads. Embedding that context in comments today means either shipping noisy config to your pipeline or maintaining a separate documentation layer that drifts.
1512

16-
Each `.tomllm` file MAY declare its required cognitive tier in the tail-map:
13+
## What tomllm does
1714

18-
| Tier | Models | Tasks |
19-
|------|--------|-------|
20-
| `sm0l` | qwen2.5-3B, haiku | classify, route, grep, format |
21-
| `ch0nky` | qwen3-coder (local) | implement, refactor, debug |
22-
| `frontier` | claude-opus/sonnet | architecture, security, novel design |
15+
A `.tomllm` file is a **valid TOML file** — any TOML parser reads it normally. `tomllm` adds:
2316

24-
## Example
17+
**1. Annotation comments** — special prefixes associate structured metadata with the next key:
2518

2619
```toml
27-
# @tribal: always use uv pip, never pip install directly
2820
# @example: uv pip install requests
21+
# @requires: Python 3.9+, uv installed
22+
# @deprecated: use poetry instead
2923
package_manager = "uv"
3024

31-
# b00t:map v1
32-
# summary: Python toolchain config
33-
# tags: python, uv
34-
# tier: sm0l
35-
# complexity: 2
25+
# @example: DATABASE_URL=postgres://localhost/mydb
26+
database_url = "postgres://prod-host/mydb"
27+
```
28+
29+
**2. Stripping** — one call removes all annotation comments, yielding clean TOML or JSON for pipelines:
30+
31+
```rust
32+
let doc = TomllmDoc::parse(raw_config)?;
33+
let clean = doc.strip_for_pipeline(); // annotation-free JSON
3634
```
3735

36+
**3. Tail-map** — a structured metadata block at the end of any file enables fast scanning without full parsing:
37+
38+
```toml
39+
# tomllm:map v1
40+
# summary: Database connection config for production
41+
# tags: database, postgres, production
42+
# tier: ops
43+
# complexity: 3
44+
```
45+
46+
Agents can extract the tail-map in microseconds to route, prioritize, or skip files without deserializing their full contents.
47+
48+
---
49+
50+
## Annotation prefixes
51+
52+
| Prefix | Meaning |
53+
|--------|---------|
54+
| `# @example:` | Concrete usage example for this key |
55+
| `# @requires:` | Prerequisites or dependencies |
56+
| `# @deprecated:` | Deprecation notice with replacement |
57+
| `# @note:` | Non-obvious behavior or constraint |
58+
| `# @tribal:` | Institutional knowledge that isn't in the docs |
59+
60+
All annotation lines are stripped by `strip_for_pipeline()`. Plain comments (no prefix) are preserved.
61+
62+
---
63+
64+
## Install
65+
66+
```bash
67+
# Rust
68+
cargo add tomllm
69+
70+
# Python
71+
pip install tomllm
72+
73+
# npm / TypeScript
74+
npm install @promptexecution/tomllm
75+
```
76+
77+
---
78+
3879
## Usage
3980

4081
### Rust
4182

4283
```rust
43-
use tomllm::TomllmDoc;
84+
use tomllm::{TomllmDoc, MapBlock};
85+
86+
let input = r#"
87+
# @example: uv pip install requests
88+
package_manager = "uv"
89+
90+
# tomllm:map v1
91+
# summary: Python toolchain config
92+
# tags: python, packaging
93+
# complexity: 2
94+
"#;
4495

4596
let doc = TomllmDoc::parse(input)?;
46-
let clean_json = doc.strip_for_pipeline(); // stripped TOML as JSON
47-
let tier = doc.cognitive_tier(); // sm0l / ch0nky / frontier
48-
let map = doc.map_block; // Option<MapBlock>
97+
98+
// Strip annotations → clean JSON for pipelines
99+
let json = doc.strip_for_pipeline();
100+
101+
// Extract tail-map metadata
102+
if let Some(map) = &doc.map_block {
103+
println!("{} | tags: {:?}", map.summary, map.tags);
104+
}
105+
106+
// Pull all annotations out as structured data
107+
let annotations = doc.annotations();
49108
```
50109

51-
### Python (maturin)
110+
### Python
52111

53112
```python
54113
from tomllm import TomllmDoc, MapBlock
55114

56115
doc = TomllmDoc.parse(text)
57-
print(doc.cognitive_tier()) # "sm0l"
58-
print(doc.strip_for_pipeline()) # JSON string
59116

117+
# Clean TOML/JSON for downstream
118+
clean = doc.strip_for_pipeline()
119+
120+
# Tail-map metadata
60121
block = MapBlock.from_text(text)
61122
if block:
62-
print(block.summary, block.tier, block.tags)
123+
print(block.summary) # "Python toolchain config"
124+
print(block.tags) # ["python", "packaging"]
125+
print(block.complexity) # 2
63126
```
64127

65128
### TypeScript / WASM
@@ -68,41 +131,36 @@ if block:
68131
import init, { TomllmDoc } from '@promptexecution/tomllm';
69132

70133
await init();
134+
71135
const doc = TomllmDoc.parse(text);
136+
const clean = doc.strip_for_pipeline();
137+
const mapBlock = doc.map_block();
72138
```
73139

74-
## Install
75-
76-
```bash
77-
# Rust
78-
cargo add tomllm
79-
80-
# Python
81-
pip install tomllm
82-
83-
# npm
84-
npm install @promptexecution/tomllm
85-
```
140+
---
86141

87142
## Tail-map format
88143

144+
The tail-map is an optional block at the end of any `.tomllm` file (or any TOML file) that provides fast metadata extraction:
145+
89146
```toml
90-
# b00t:map v1
91-
# summary: one-line human+LLM description
147+
# tomllm:map v1
148+
# summary: one-line description for humans and agents
92149
# tags: comma, separated, keywords
93-
# tier: sm0l|ch0nky|frontier
94-
# cmds: b00t hive activate inference-qwen3, b00t hive status
150+
# tier: sm0l | standard | advanced
95151
# complexity: 1-10
96152
```
97153

154+
The `TomllmRegistry` can scan a directory of `.tomllm` files, extract only their tail-maps, and return a sorted/filtered index — useful for capability discovery, configuration routing, or context assembly.
155+
156+
---
157+
158+
## Motivation
159+
160+
This library was extracted from internal tooling at [PromptExecution](https://github.com/PromptExecution) where configuration files are read by both human engineers and LLM agents. The annotation convention emerged from a practical need: agents need context that pipelines don't, and maintaining two versions of every config file is unsustainable.
161+
162+
---
163+
98164
## License
99165

100166
MIT
101-
102-
<!-- b00t:map v1
103-
summary: tomllm — TOML + LLM comment conventions crate
104-
tags: toml, llm, agent, config, annotations, wasm, python
105-
tier: sm0l
106-
cmds: cargo test, maturin build --features python, wasm-pack build
107-
complexity: 3
108-
-->

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@ build-backend = "maturin"
44

55
[project]
66
name = "tomllm"
7+
version = "0.1.0"
78
requires-python = ">=3.9"
8-
description = "TOML + LLM comment conventions: tribal knowledge in #comments, stripped for data pipelines"
9+
description = "Structured TOML annotations for AI-augmented applications"
910
license = { text = "MIT" }
11+
readme = "README.md"
12+
keywords = ["toml", "llm", "ai", "config", "annotations", "agents"]
1013
classifiers = [
14+
"Development Status :: 3 - Alpha",
15+
"Intended Audience :: Developers",
16+
"License :: OSI Approved :: MIT License",
1117
"Programming Language :: Rust",
12-
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.9",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
1323
"Topic :: Software Development :: Libraries",
24+
"Topic :: Text Processing :: Markup",
1425
]
1526

27+
[project.urls]
28+
Repository = "https://github.com/PromptExecution/tomllm"
29+
Issues = "https://github.com/PromptExecution/tomllm/issues"
30+
1631
[tool.maturin]
1732
features = ["python"]
1833
module-name = "tomllm"

0 commit comments

Comments
 (0)