Skip to content

Commit 4009673

Browse files
feat: initial commit — attune-help extracted from attune-ai monorepo
Extracted from Smart-AI-Memory/attune-ai/packages/attune-help/ to give this Python package its own dedicated repo, CI, and PyPI trusted-publishing path. Changes from the monorepo version: - Version bump 0.3.0 → 0.3.1 - Drop plugin/ subdirectory (Claude Code plugin wrapper now lives in Smart-AI-Memory/attune-docs) - Add .github/workflows/publish.yml for trusted-publishing to PyPI Fixes the attune-help MCP server runtime startup (plugin .mcp.json uses `uv run --from 'attune-help[plugin]'`) which was broken because the published PyPI version 0.3.0 didn't have the [plugin] extra registered. This repo ships 0.3.1 with the extra properly declared in pyproject.toml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 parents  commit 4009673

662 files changed

Lines changed: 44315 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Allow manual trigger
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
20+
with:
21+
python-version: '3.11'
22+
cache: 'pip'
23+
24+
- name: Install build dependencies
25+
run: pip install build
26+
27+
- name: Build package
28+
run: python -m build
29+
30+
- name: Upload artifacts
31+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
32+
with:
33+
name: dist
34+
path: dist/
35+
36+
publish:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 10
40+
environment: pypi
41+
permissions:
42+
id-token: write # Required for trusted publishing
43+
steps:
44+
- name: Download artifacts
45+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
46+
with:
47+
name: dist
48+
path: dist/
49+
50+
- name: Publish to PyPI
51+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
52+
# No token needed - uses OIDC trusted publishing

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
build/
8+
dist/
9+
*.egg-info/
10+
*.egg
11+
MANIFEST
12+
13+
# Unit test / coverage reports
14+
.pytest_cache/
15+
.coverage
16+
.coverage.*
17+
htmlcov/
18+
.tox/
19+
.nox/
20+
21+
# Virtual environments
22+
.venv/
23+
venv/
24+
env/
25+
ENV/
26+
27+
# IDE
28+
.vscode/
29+
.idea/
30+
*.swp
31+
*.swo
32+
33+
# OS
34+
.DS_Store
35+
Thumbs.db
36+
37+
# uv
38+
.uv/

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
Copyright 2026 Smart AI Memory
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
http://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.

README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# attune-help
2+
3+
Lightweight help runtime with progressive depth and
4+
audience adaptation. Read project help templates
5+
generated by [attune-ai](https://pypi.org/project/attune-ai/).
6+
7+
## Install
8+
9+
```bash
10+
pip install attune-help
11+
```
12+
13+
## Quick Start
14+
15+
```python
16+
from attune_help import HelpEngine
17+
18+
engine = HelpEngine(template_dir=".help/templates")
19+
20+
# Progressive depth: concept -> task -> reference
21+
print(engine.lookup("security-audit")) # concept
22+
print(engine.lookup("security-audit")) # task
23+
print(engine.lookup("security-audit")) # reference
24+
```
25+
26+
## How It Works
27+
28+
Each topic has three depth levels:
29+
30+
| Level | Type | What you get |
31+
|-------|------|-------------|
32+
| 0 | Concept | What is it? When to use it? |
33+
| 1 | Task | Step-by-step how-to |
34+
| 2 | Reference | Full detail, edge cases |
35+
36+
Repeated lookups on the same topic auto-advance.
37+
A new topic resets to concept.
38+
39+
## Renderers
40+
41+
```python
42+
# Plain text (default)
43+
engine = HelpEngine(renderer="plain")
44+
45+
# Rich terminal output (requires `pip install attune-help[rich]`)
46+
engine = HelpEngine(renderer="cli")
47+
48+
# Claude Code inline format
49+
engine = HelpEngine(renderer="claude_code")
50+
51+
# Auto-detect environment
52+
engine = HelpEngine(renderer="auto")
53+
```
54+
55+
## Template Directory
56+
57+
Templates are markdown files with YAML frontmatter:
58+
59+
```
60+
.help/templates/
61+
security/
62+
concept.md
63+
task.md
64+
reference.md
65+
api/
66+
concept.md
67+
task.md
68+
reference.md
69+
```
70+
71+
Generate templates with
72+
[attune-ai](https://pypi.org/project/attune-ai/):
73+
74+
```bash
75+
pip install attune-ai
76+
# Then in Claude Code:
77+
/coach init
78+
```
79+
80+
Or create them manually — any markdown file with
81+
`feature`, `depth`, and `source_hash` frontmatter
82+
fields works.
83+
84+
## Demo Templates
85+
86+
The package includes a demo feature showing the
87+
progressive depth format:
88+
89+
```python
90+
from attune_help import get_demo_path
91+
92+
# Copy to your project
93+
import shutil
94+
shutil.copytree(
95+
get_demo_path() / "security-audit",
96+
".help/templates/security-audit",
97+
)
98+
```
99+
100+
The `security-audit/` demo contains `concept.md`,
101+
`task.md`, and `reference.md` — the three depth
102+
levels that `/coach init` generates for each feature.
103+
104+
## API
105+
106+
### `HelpEngine`
107+
108+
```python
109+
HelpEngine(
110+
template_dir=None, # Override template path
111+
storage=None, # Session storage backend
112+
renderer="plain", # Output renderer
113+
user_id="default", # Session tracking ID
114+
)
115+
```
116+
117+
**Methods:**
118+
119+
- `lookup(topic)` — Progressive depth lookup
120+
- `get(template_id)` — Direct template access
121+
- `lookup_raw(topic)` — Returns `PopulatedTemplate`
122+
dataclass
123+
- `get_summary(skill)` — One-line skill summary
124+
- `precursor_warnings(file_path)` — File-aware
125+
warnings
126+
127+
### `SessionStorage` Protocol
128+
129+
Implement custom storage backends:
130+
131+
```python
132+
from attune_help import SessionStorage
133+
134+
class RedisStorage(SessionStorage):
135+
def load(self, user_id: str) -> dict: ...
136+
def save(self, user_id: str, state: dict) -> None: ...
137+
```
138+
139+
## License
140+
141+
Apache 2.0

pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[build-system]
2+
requires = ["setuptools>=68.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "attune-help"
7+
version = "0.3.1"
8+
description = "Lightweight help runtime with progressive depth and audience adaptation."
9+
readme = {file = "README.md", content-type = "text/markdown"}
10+
requires-python = ">=3.10"
11+
license = {file = "LICENSE"}
12+
authors = [
13+
{name = "Patrick Roebuck", email = "admin@smartaimemory.com"}
14+
]
15+
keywords = ["help", "documentation", "progressive-depth", "templates"]
16+
classifiers = [
17+
"Development Status :: 3 - Alpha",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: Apache Software License",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
"Topic :: Documentation",
26+
"Topic :: Software Development :: Libraries",
27+
]
28+
dependencies = [
29+
"python-frontmatter>=1.0.0",
30+
]
31+
32+
[project.optional-dependencies]
33+
rich = ["rich>=13.0.0"]
34+
plugin = ["mcp>=0.9.0"]
35+
36+
[project.scripts]
37+
attune-help-mcp = "attune_help.mcp.server:main"
38+
39+
[project.urls]
40+
Homepage = "https://github.com/Smart-AI-Memory/attune-ai"
41+
Repository = "https://github.com/Smart-AI-Memory/attune-ai"
42+
43+
[tool.setuptools.packages.find]
44+
where = ["src"]
45+
46+
[tool.setuptools.package-data]
47+
attune_help = ["templates/**/*.md", "templates/**/*.json", "demos/**/*.md"]

src/attune_help/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""attune-help: Lightweight help runtime with progressive depth.
2+
3+
Provides template loading, progressive depth escalation,
4+
audience adaptation, and feedback scoring — without the
5+
full attune-ai authoring toolkit.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
from attune_help.demos import get_demo_path
11+
from attune_help.engine import (
12+
AudienceProfile,
13+
HelpEngine,
14+
PopulatedTemplate,
15+
TemplateContext,
16+
)
17+
from attune_help.preamble import get_preamble # noqa: F401
18+
from attune_help.storage import LocalFileStorage, SessionStorage
19+
20+
__all__ = [
21+
"AudienceProfile",
22+
"HelpEngine",
23+
"LocalFileStorage",
24+
"PopulatedTemplate",
25+
"SessionStorage",
26+
"TemplateContext",
27+
"get_demo_path",
28+
"get_preamble",
29+
]
30+
31+
try:
32+
from importlib.metadata import version
33+
34+
__version__ = version("attune-help")
35+
except Exception: # noqa: BLE001
36+
__version__ = "dev"

src/attune_help/demos/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Demo templates showing the per-feature help format.
2+
3+
Contains a ``security-audit`` feature with concept, task,
4+
and reference templates. Copy the feature directory into
5+
your project's ``.help/templates/`` as a starting point.
6+
"""
7+
8+
from pathlib import Path
9+
10+
11+
def get_demo_path() -> Path:
12+
"""Return path to the bundled demo templates directory."""
13+
return Path(__file__).resolve().parent
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
feature: security-audit
3+
depth: concept
4+
generated_at: "2026-04-05T00:00:00+00:00"
5+
source_hash: demo
6+
status: demo
7+
---
8+
9+
# Security Audit
10+
11+
A security audit scans your codebase for vulnerabilities
12+
that are easy to introduce and hard to spot in code
13+
review. It catches the mistakes that slip through when
14+
you're focused on making things work — an `eval()` in a
15+
test fixture, a file path built from user input without
16+
validation, an API key that ended up in source control.
17+
18+
## What it finds
19+
20+
| Category | What to worry about |
21+
|----------|---------------------|
22+
| **Code injection** | `eval()`, `exec()`, and `compile()` on untrusted input |
23+
| **Path traversal** | File operations that don't validate the path first |
24+
| **Hardcoded secrets** | API keys, tokens, and passwords committed to source |
25+
| **SQL/command injection** | String concatenation in queries or shell commands |
26+
| **SSRF** | HTTP requests to URLs controlled by user input |
27+
| **Weak cryptography** | MD5/SHA1 for security purposes, hardcoded IVs |
28+
29+
## Why it matters
30+
31+
These vulnerabilities are common in everyday code —
32+
they're not exotic attacks. A path traversal bug is just
33+
a missing validation call. A hardcoded secret is a
34+
string that should have been an environment variable.
35+
Automated scanning catches these before they reach
36+
production.
37+
38+
## How deep it goes
39+
40+
| Depth | Time | What you get |
41+
|-------|------|-------------|
42+
| **Quick** | ~30s | Surface scan — eval/exec, obvious secrets |
43+
| **Standard** | ~2 min | Full pattern matching with severity ratings |
44+
| **Deep** | ~5 min | Multi-pass review with OWASP mapping and fix suggestions |

0 commit comments

Comments
 (0)