Skip to main content

Lightweight help runtime with progressive depth and audience adaptation.

Project description

attune-help

Lightweight help runtime with progressive depth and audience adaptation. Read project help templates generated by attune-ai.

Install

pip install attune-help

Quick Start

from attune_help import HelpEngine

engine = HelpEngine(template_dir=".help/templates")

# Progressive depth: concept -> task -> reference
print(engine.lookup("security-audit"))   # concept
print(engine.lookup("security-audit"))   # task
print(engine.lookup("security-audit"))   # reference

How It Works

Each topic has three depth levels:

Level Type What you get
0 Concept What is it? When to use it?
1 Task Step-by-step how-to
2 Reference Full detail, edge cases

Repeated lookups on the same topic auto-advance. A new topic resets to concept.

Renderers

# Plain text (default)
engine = HelpEngine(renderer="plain")

# Rich terminal output (requires `pip install attune-help[rich]`)
engine = HelpEngine(renderer="cli")

# Claude Code inline format
engine = HelpEngine(renderer="claude_code")

# Structured JSON (for apps, web, tests)
engine = HelpEngine(renderer="json")

# Auto-detect environment (CLAUDE_CODE → claude_code,
# interactive TTY + rich → cli, otherwise → plain)
engine = HelpEngine(renderer="auto")

# Switch renderer at runtime
engine.set_renderer("cli")

Passing an unknown renderer name raises ValueError.

Template Directory

Templates are markdown files with YAML frontmatter:

.help/templates/
  security/
    concept.md
    task.md
    reference.md
  api/
    concept.md
    task.md
    reference.md

Generate templates with attune-ai:

pip install attune-ai
# Then in Claude Code:
/coach init

Or create them manually — any markdown file with feature, depth, and source_hash frontmatter fields works.

Demo Templates

The package includes a demo feature showing the progressive depth format:

from attune_help import get_demo_path

# Copy to your project
import shutil
shutil.copytree(
    get_demo_path() / "security-audit",
    ".help/templates/security-audit",
)

The security-audit/ demo contains concept.md, task.md, and reference.md — the three depth levels that /coach init generates for each feature.

Discovery

engine.list_topics()                  # all slugs
engine.list_topics(type="concepts")   # filter by type
engine.search("security")             # [(slug, score), ...]
engine.suggest("secrity-audit")       # ranked slugs

Miss handling:

# Returns None by default
engine.lookup("typoed-slug")

# Returns "No help for 'typoed-slug'. Did you mean: ..."
engine.lookup("typoed-slug", suggest_on_miss=True)

Progressive Depth Controls

engine.lookup("security-audit")    # concept
engine.lookup("security-audit")    # task
engine.lookup("security-audit")    # reference (depth 2)

engine.simpler("security-audit")   # step back to task
engine.simpler("security-audit")   # step back to concept

engine.reset("security-audit")     # clear one topic
engine.reset()                     # clear all topics

Topics are tracked independently — interleaving lookup("a") / lookup("b") / lookup("a") does not reset a's depth. An LRU cap of 32 topics keeps session state bounded.

API

HelpEngine

HelpEngine(
    template_dir=None,    # Override template path
    storage=None,         # Session storage backend
    renderer="plain",     # Output renderer
    user_id="default",    # Session tracking ID
)

Methods:

  • lookup(topic, *, suggest_on_miss=False) — Progressive depth lookup with optional "did you mean" on miss
  • simpler(topic) — Step back one depth level
  • reset(topic=None) — Clear depth history for one topic or all
  • list_topics(type=None, limit=None) — Enumerate slugs
  • search(query, limit=10) — Fuzzy-search slugs
  • suggest(topic, limit=5) — Ranked slug suggestions
  • get(template_id) — Direct template access
  • lookup_raw(topic) — Returns PopulatedTemplate dataclass
  • get_summary(skill) — One-line skill summary (falls back to bundled when an override lacks it)
  • precursor_warnings(file_path) — File-aware warnings (supports Python, JS/TS, Rust, Go, Ruby, Java, …)
  • set_renderer(name) — Change renderer at runtime

SessionStorage Protocol

Implement custom storage backends:

from attune_help import SessionStorage

class RedisStorage(SessionStorage):
    def load(self, user_id: str) -> dict: ...
    def save(self, user_id: str, state: dict) -> None: ...

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

attune_help-0.4.0.tar.gz (402.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

attune_help-0.4.0-py3-none-any.whl (692.5 kB view details)

Uploaded Python 3

File details

Details for the file attune_help-0.4.0.tar.gz.

File metadata

  • Download URL: attune_help-0.4.0.tar.gz
  • Upload date:
  • Size: 402.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for attune_help-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f7c422e54047b5b7d1d89c9c927ff3cafef858bc32e79b98f7df4420145d90e7
MD5 a018c1a2095c7a2ae686c454fa606547
BLAKE2b-256 db7d0cf2f141b642835630554df3e24c03b9446091a5297854a510ffec6303fe

See more details on using hashes here.

File details

Details for the file attune_help-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: attune_help-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 692.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for attune_help-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a91835d8a9a5332ee03fa4cbf0fb461ae3a57b76458c5151f2385cebccf0f9d
MD5 44b75dda90d3652d559982922784f16d
BLAKE2b-256 6f23e2355bca36063199672f36a4586a8fd79ce4d87fa9cd21e39cef8e0e21e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page