@tanagram/cli 0.4.14 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -263,3 +263,5 @@ tanagram sync
263
263
  ---
264
264
 
265
265
  Built by [@fluttermatt](https://x.com/fluttermatt) and the [Tanagram](https://tanagram.ai/) team. Talk to us [on Twitter](https://x.com/tanagram_) or email: founders AT tanagram.ai
266
+
267
+ #
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tanagram
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,267 @@
1
+ # Tanagram CLI
2
+
3
+ A lightweight Go CLI that enforces policies from `AGENTS.md` files on your local git changes.
4
+
5
+ ## Quick Start
6
+
7
+ Run `tanagram` before committing to catch policy violations locally:
8
+
9
+ ```bash
10
+ $ tanagram
11
+
12
+ ✗ Found 1 policy violation(s):
13
+
14
+ webui/src/Button.tsx:42 - [No hardcoded colors] Don't use hard-coded color values; use theme colors instead
15
+ > background: "#FF5733"
16
+ ```
17
+
18
+ ## Installation
19
+
20
+ ### Quick Start (3 steps)
21
+
22
+ ```bash
23
+ # 1. Install globally via npm
24
+ npm install -g @tanagram/cli
25
+
26
+ # 2. Automatically add a Claude Code hook
27
+ tanagram config claude
28
+ # and/or if you use Cursor:
29
+ tanagram config cursor
30
+
31
+ # 3. Run tanagram (will prompt for API key on first run)
32
+ tanagram
33
+ ```
34
+
35
+ **Requirements:**
36
+ - Node.js >= 14.0.0
37
+ - **Anthropic API Key** (you'll be prompted to enter it on first run)
38
+
39
+ The CLI is written in Go but distributed via npm for easier installation and version management. During installation, npm automatically downloads the Go compiler and builds the binary for your platform (no manual setup needed!).
40
+
41
+ ### API Key Setup
42
+
43
+ Tanagram uses Claude AI (via Anthropic API) to extract policies from your instruction files. On first run, you'll be prompted to enter your API key, which will be saved to `~/.tanagram/config.json`.
44
+
45
+ **Get an API key:**
46
+ 1. Sign up at [https://console.anthropic.com](https://console.anthropic.com)
47
+ 2. Create an API key in the dashboard
48
+ 3. Run `tanagram` and enter your key when prompted
49
+
50
+ ## Usage
51
+
52
+ ```bash
53
+ # Check all changes (unstaged + staged) - automatically syncs if policies changed
54
+ tanagram
55
+ # or explicitly:
56
+ tanagram run
57
+
58
+ # Manually sync instruction files to cache
59
+ tanagram sync
60
+
61
+ # View all cached policies
62
+ tanagram list
63
+
64
+ # Show help
65
+ tanagram help
66
+ ```
67
+
68
+ **Smart Caching:** Policies are cached and automatically resynced when instruction files change (detected via MD5 hash).
69
+
70
+ ### Commands
71
+
72
+ - **`run`** (default) - Check git changes against policies with auto-sync
73
+ - **`sync`** - Manually sync all instruction files to cache
74
+ - **`list`** - View all cached policies (shows enforceable vs unenforceable)
75
+ - **`help`** - Show usage information
76
+
77
+ ### Claude Code Hook
78
+
79
+ Install the CLI as a Claude Code [hook](https://code.claude.com/docs/en/hooks) to have Claude automatically iterate on Tanagram's output.
80
+
81
+ **Easy setup (recommended):**
82
+ ```bash
83
+ tanagram config claude
84
+ ```
85
+
86
+ This automatically adds the hook to your `~/.claude/settings.json`. It's safe to run multiple times and will preserve any existing settings.
87
+
88
+ **Check hook status:**
89
+ ```bash
90
+ tanagram config list
91
+ ```
92
+
93
+ **Manual setup (alternative):**
94
+ If you prefer to manually edit your settings, add this to your `~/.claude/settings.json` (user settings) or `.claude/settings.json` (project settings):
95
+
96
+ ```json
97
+ {
98
+ "hooks": {
99
+ "SessionStart": [
100
+ {
101
+ "hooks": [
102
+ {
103
+ "command": "tanagram snapshot",
104
+ "type": "command"
105
+ }
106
+ ],
107
+ "matcher": "startup|clear"
108
+ }
109
+ ],
110
+ "Stop": [
111
+ {
112
+ "hooks": [
113
+ {
114
+ "command": "tanagram",
115
+ "type": "command"
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ ```
123
+
124
+ If you have existing hooks, you can merge this hook into your existing config.
125
+
126
+ ### Cursor Hook
127
+
128
+ Install the CLI as a Cursor Code [hook](https://cursor.com/docs/agent/hooks) to have Cursor automatically iterate on Tanagram's output.
129
+
130
+ **Easy setup (recommended):**
131
+ ```bash
132
+ tanagram config cursor
133
+ ```
134
+
135
+ This automatically adds the hook to your `~/.cursor/hooks.json`. It's safe to run multiple times and will preserve any existing settings.
136
+
137
+ **Check hook status:**
138
+ ```bash
139
+ tanagram config list
140
+ ```
141
+
142
+ **Manual setup (alternative):**
143
+ If you prefer to manually edit your settings, add this to your `~/.cursor/hooks.json` (user settings) or `.cursor/hooks.json` (project settings):
144
+
145
+ ```json
146
+ {
147
+ "hooks": {
148
+ "beforeSubmitPrompt": [
149
+ {
150
+ "command": "tanagram snapshot"
151
+ }
152
+ ],
153
+ "stop": [
154
+ {
155
+ "command": "tanagram"
156
+ }
157
+ ]
158
+ },
159
+ "version": 1
160
+ }
161
+ ```
162
+
163
+ If you have existing hooks, you can merge this hook into your existing config.
164
+
165
+
166
+ ## How It Works
167
+
168
+ 1. **Finds instruction files** - Searches for `AGENTS.md`, `POLICIES.md`, `CLAUDE.md`, `BUGBOT.md`, and `.cursor/rules/*.mdc` in your git repository
169
+ 2. **Checks cache** - Loads cached policies and MD5 hashes from `.tanagram/`
170
+ 3. **Auto-syncs** - Detects file changes via MD5 and automatically resyncs if needed
171
+ 4. **LLM extraction** - Uses Claude AI to extract ALL policies from instruction files
172
+ 5. **Gets git diff** - Analyzes all your changes (unstaged + staged)
173
+ 6. **LLM detection** - Checks violations using intelligent semantic analysis
174
+ 7. **Reports results** - Terminal output with detailed reasoning for each violation
175
+
176
+ ### Cache Location
177
+
178
+ Policies are cached in `.tanagram/cache.gob` at your git repository root. Add this to your `.gitignore`:
179
+
180
+ ```gitignore
181
+ .tanagram/
182
+ ```
183
+
184
+ ### What Can Be Enforced
185
+
186
+ **Everything!** Because the LLM reads and understands code like a human:
187
+
188
+ **Simple patterns:**
189
+ - "Don't use hard-coded colors" → Detects `#FF5733`, `rgb()`, etc.
190
+ - "Use ruff format, not black" → Detects `black` usage
191
+ - "Always use === instead of ==" → Detects `==` operators
192
+
193
+ **Complex guidelines:**
194
+ - "Break down code into modular functions" → Analyzes function length and complexity
195
+ - "Don't deeply layer code" → Detects excessive nesting
196
+ - "Ensure no code smells" → Identifies common anti-patterns
197
+ - "Use structured logging with request IDs" → Checks logging patterns
198
+ - "Prefer async/await for I/O" → Understands async patterns
199
+
200
+ **Language-specific idioms:**
201
+ - Knows Go uses PascalCase for exports (not Python's snake_case)
202
+ - Won't flag Go code for missing Python type hints
203
+ - Understands JavaScript !== Python !== Go
204
+
205
+ ### Exit Codes
206
+
207
+ - `0` - No violations found
208
+ - `2` - Violations found (triggers Claude Code automatic fix behavior)
209
+
210
+ ## Example
211
+
212
+ Create an `AGENTS.md` in your repo with policies:
213
+
214
+ ```markdown
215
+ # Development Policies
216
+
217
+ - Don't use hard-coded color values; use theme colors instead
218
+ - Use ruff format for Python formatting, not black
219
+ - Always use async/await for database operations
220
+ ```
221
+
222
+ Or use Cursor rules files in `.cursor/rules/`:
223
+
224
+ ```markdown
225
+ ---
226
+ description: TypeScript coding standards
227
+ globs: ["*.ts", "*.tsx"]
228
+ ---
229
+
230
+ # TypeScript Standards
231
+
232
+ - Use strict type checking
233
+ - Avoid using 'any' type
234
+ - Prefer interfaces over type aliases
235
+ ```
236
+
237
+ Then run `tanagram` to enforce them locally!
238
+
239
+ **Note:** For `.mdc` files, Tanagram extracts policies from the markdown content only (YAML frontmatter is used by Cursor and ignored during policy extraction).
240
+
241
+ ## Tanagram Web Integration
242
+
243
+ You can also use [Tanagram](https://tanagram.ai) to manage policies across your organization and enforce them on PRs.
244
+ If you have policies defined online, you can enforce them while you develop locally with the CLI as well.
245
+
246
+ ```bash
247
+ # Connect your account
248
+ tanagram login
249
+
250
+ # Download policies from your Tanagram account and cache them locally
251
+ tanagram sync
252
+ ```
253
+
254
+ For customers with an on-prem installation, set the `TANAGRAM_WEB_HOSTNAME` environment variable to the URL of your Tanagram instance — for example:
255
+
256
+ ```bash
257
+ export TANAGRAM_WEB_HOSTNAME=https://yourcompany.tanagram.ai
258
+
259
+ tanagram login
260
+ tanagram sync
261
+ ```
262
+
263
+ ---
264
+
265
+ Built by [@fluttermatt](https://x.com/fluttermatt) and the [Tanagram](https://tanagram.ai/) team. Talk to us [on Twitter](https://x.com/tanagram_) or email: founders AT tanagram.ai
266
+
267
+ #
Binary file
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tanagram
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,267 @@
1
+ # Tanagram CLI
2
+
3
+ A lightweight Go CLI that enforces policies from `AGENTS.md` files on your local git changes.
4
+
5
+ ## Quick Start
6
+
7
+ Run `tanagram` before committing to catch policy violations locally:
8
+
9
+ ```bash
10
+ $ tanagram
11
+
12
+ ✗ Found 1 policy violation(s):
13
+
14
+ webui/src/Button.tsx:42 - [No hardcoded colors] Don't use hard-coded color values; use theme colors instead
15
+ > background: "#FF5733"
16
+ ```
17
+
18
+ ## Installation
19
+
20
+ ### Quick Start (3 steps)
21
+
22
+ ```bash
23
+ # 1. Install globally via npm
24
+ npm install -g @tanagram/cli
25
+
26
+ # 2. Automatically add a Claude Code hook
27
+ tanagram config claude
28
+ # and/or if you use Cursor:
29
+ tanagram config cursor
30
+
31
+ # 3. Run tanagram (will prompt for API key on first run)
32
+ tanagram
33
+ ```
34
+
35
+ **Requirements:**
36
+ - Node.js >= 14.0.0
37
+ - **Anthropic API Key** (you'll be prompted to enter it on first run)
38
+
39
+ The CLI is written in Go but distributed via npm for easier installation and version management. During installation, npm automatically downloads the Go compiler and builds the binary for your platform (no manual setup needed!).
40
+
41
+ ### API Key Setup
42
+
43
+ Tanagram uses Claude AI (via Anthropic API) to extract policies from your instruction files. On first run, you'll be prompted to enter your API key, which will be saved to `~/.tanagram/config.json`.
44
+
45
+ **Get an API key:**
46
+ 1. Sign up at [https://console.anthropic.com](https://console.anthropic.com)
47
+ 2. Create an API key in the dashboard
48
+ 3. Run `tanagram` and enter your key when prompted
49
+
50
+ ## Usage
51
+
52
+ ```bash
53
+ # Check all changes (unstaged + staged) - automatically syncs if policies changed
54
+ tanagram
55
+ # or explicitly:
56
+ tanagram run
57
+
58
+ # Manually sync instruction files to cache
59
+ tanagram sync
60
+
61
+ # View all cached policies
62
+ tanagram list
63
+
64
+ # Show help
65
+ tanagram help
66
+ ```
67
+
68
+ **Smart Caching:** Policies are cached and automatically resynced when instruction files change (detected via MD5 hash).
69
+
70
+ ### Commands
71
+
72
+ - **`run`** (default) - Check git changes against policies with auto-sync
73
+ - **`sync`** - Manually sync all instruction files to cache
74
+ - **`list`** - View all cached policies (shows enforceable vs unenforceable)
75
+ - **`help`** - Show usage information
76
+
77
+ ### Claude Code Hook
78
+
79
+ Install the CLI as a Claude Code [hook](https://code.claude.com/docs/en/hooks) to have Claude automatically iterate on Tanagram's output.
80
+
81
+ **Easy setup (recommended):**
82
+ ```bash
83
+ tanagram config claude
84
+ ```
85
+
86
+ This automatically adds the hook to your `~/.claude/settings.json`. It's safe to run multiple times and will preserve any existing settings.
87
+
88
+ **Check hook status:**
89
+ ```bash
90
+ tanagram config list
91
+ ```
92
+
93
+ **Manual setup (alternative):**
94
+ If you prefer to manually edit your settings, add this to your `~/.claude/settings.json` (user settings) or `.claude/settings.json` (project settings):
95
+
96
+ ```json
97
+ {
98
+ "hooks": {
99
+ "SessionStart": [
100
+ {
101
+ "hooks": [
102
+ {
103
+ "command": "tanagram snapshot",
104
+ "type": "command"
105
+ }
106
+ ],
107
+ "matcher": "startup|clear"
108
+ }
109
+ ],
110
+ "Stop": [
111
+ {
112
+ "hooks": [
113
+ {
114
+ "command": "tanagram",
115
+ "type": "command"
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ ```
123
+
124
+ If you have existing hooks, you can merge this hook into your existing config.
125
+
126
+ ### Cursor Hook
127
+
128
+ Install the CLI as a Cursor Code [hook](https://cursor.com/docs/agent/hooks) to have Cursor automatically iterate on Tanagram's output.
129
+
130
+ **Easy setup (recommended):**
131
+ ```bash
132
+ tanagram config cursor
133
+ ```
134
+
135
+ This automatically adds the hook to your `~/.cursor/hooks.json`. It's safe to run multiple times and will preserve any existing settings.
136
+
137
+ **Check hook status:**
138
+ ```bash
139
+ tanagram config list
140
+ ```
141
+
142
+ **Manual setup (alternative):**
143
+ If you prefer to manually edit your settings, add this to your `~/.cursor/hooks.json` (user settings) or `.cursor/hooks.json` (project settings):
144
+
145
+ ```json
146
+ {
147
+ "hooks": {
148
+ "beforeSubmitPrompt": [
149
+ {
150
+ "command": "tanagram snapshot"
151
+ }
152
+ ],
153
+ "stop": [
154
+ {
155
+ "command": "tanagram"
156
+ }
157
+ ]
158
+ },
159
+ "version": 1
160
+ }
161
+ ```
162
+
163
+ If you have existing hooks, you can merge this hook into your existing config.
164
+
165
+
166
+ ## How It Works
167
+
168
+ 1. **Finds instruction files** - Searches for `AGENTS.md`, `POLICIES.md`, `CLAUDE.md`, `BUGBOT.md`, and `.cursor/rules/*.mdc` in your git repository
169
+ 2. **Checks cache** - Loads cached policies and MD5 hashes from `.tanagram/`
170
+ 3. **Auto-syncs** - Detects file changes via MD5 and automatically resyncs if needed
171
+ 4. **LLM extraction** - Uses Claude AI to extract ALL policies from instruction files
172
+ 5. **Gets git diff** - Analyzes all your changes (unstaged + staged)
173
+ 6. **LLM detection** - Checks violations using intelligent semantic analysis
174
+ 7. **Reports results** - Terminal output with detailed reasoning for each violation
175
+
176
+ ### Cache Location
177
+
178
+ Policies are cached in `.tanagram/cache.gob` at your git repository root. Add this to your `.gitignore`:
179
+
180
+ ```gitignore
181
+ .tanagram/
182
+ ```
183
+
184
+ ### What Can Be Enforced
185
+
186
+ **Everything!** Because the LLM reads and understands code like a human:
187
+
188
+ **Simple patterns:**
189
+ - "Don't use hard-coded colors" → Detects `#FF5733`, `rgb()`, etc.
190
+ - "Use ruff format, not black" → Detects `black` usage
191
+ - "Always use === instead of ==" → Detects `==` operators
192
+
193
+ **Complex guidelines:**
194
+ - "Break down code into modular functions" → Analyzes function length and complexity
195
+ - "Don't deeply layer code" → Detects excessive nesting
196
+ - "Ensure no code smells" → Identifies common anti-patterns
197
+ - "Use structured logging with request IDs" → Checks logging patterns
198
+ - "Prefer async/await for I/O" → Understands async patterns
199
+
200
+ **Language-specific idioms:**
201
+ - Knows Go uses PascalCase for exports (not Python's snake_case)
202
+ - Won't flag Go code for missing Python type hints
203
+ - Understands JavaScript !== Python !== Go
204
+
205
+ ### Exit Codes
206
+
207
+ - `0` - No violations found
208
+ - `2` - Violations found (triggers Claude Code automatic fix behavior)
209
+
210
+ ## Example
211
+
212
+ Create an `AGENTS.md` in your repo with policies:
213
+
214
+ ```markdown
215
+ # Development Policies
216
+
217
+ - Don't use hard-coded color values; use theme colors instead
218
+ - Use ruff format for Python formatting, not black
219
+ - Always use async/await for database operations
220
+ ```
221
+
222
+ Or use Cursor rules files in `.cursor/rules/`:
223
+
224
+ ```markdown
225
+ ---
226
+ description: TypeScript coding standards
227
+ globs: ["*.ts", "*.tsx"]
228
+ ---
229
+
230
+ # TypeScript Standards
231
+
232
+ - Use strict type checking
233
+ - Avoid using 'any' type
234
+ - Prefer interfaces over type aliases
235
+ ```
236
+
237
+ Then run `tanagram` to enforce them locally!
238
+
239
+ **Note:** For `.mdc` files, Tanagram extracts policies from the markdown content only (YAML frontmatter is used by Cursor and ignored during policy extraction).
240
+
241
+ ## Tanagram Web Integration
242
+
243
+ You can also use [Tanagram](https://tanagram.ai) to manage policies across your organization and enforce them on PRs.
244
+ If you have policies defined online, you can enforce them while you develop locally with the CLI as well.
245
+
246
+ ```bash
247
+ # Connect your account
248
+ tanagram login
249
+
250
+ # Download policies from your Tanagram account and cache them locally
251
+ tanagram sync
252
+ ```
253
+
254
+ For customers with an on-prem installation, set the `TANAGRAM_WEB_HOSTNAME` environment variable to the URL of your Tanagram instance — for example:
255
+
256
+ ```bash
257
+ export TANAGRAM_WEB_HOSTNAME=https://yourcompany.tanagram.ai
258
+
259
+ tanagram login
260
+ tanagram sync
261
+ ```
262
+
263
+ ---
264
+
265
+ Built by [@fluttermatt](https://x.com/fluttermatt) and the [Tanagram](https://tanagram.ai/) team. Talk to us [on Twitter](https://x.com/tanagram_) or email: founders AT tanagram.ai
266
+
267
+ #
Binary file
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tanagram
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.