anrs 0.1.0__tar.gz

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.
Files changed (75) hide show
  1. anrs-0.1.0/ANRS_README.md +157 -0
  2. anrs-0.1.0/MANIFEST.in +1 -0
  3. anrs-0.1.0/PKG-INFO +194 -0
  4. anrs-0.1.0/README.md +58 -0
  5. anrs-0.1.0/pyproject.toml +70 -0
  6. anrs-0.1.0/setup.cfg +4 -0
  7. anrs-0.1.0/setup.py +4 -0
  8. anrs-0.1.0/src/anrs/__init__.py +3 -0
  9. anrs-0.1.0/src/anrs/adapter.py +147 -0
  10. anrs-0.1.0/src/anrs/backup.py +374 -0
  11. anrs-0.1.0/src/anrs/completion.py +203 -0
  12. anrs-0.1.0/src/anrs/constants.py +81 -0
  13. anrs-0.1.0/src/anrs/data/adapters/README.md +107 -0
  14. anrs-0.1.0/src/anrs/data/adapters/claude-code/CLAUDE.md +33 -0
  15. anrs-0.1.0/src/anrs/data/adapters/claude-code/README.md +140 -0
  16. anrs-0.1.0/src/anrs/data/adapters/claude-code/modes/CLAUDE-build.md +71 -0
  17. anrs-0.1.0/src/anrs/data/adapters/claude-code/modes/CLAUDE-plan.md +89 -0
  18. anrs-0.1.0/src/anrs/data/adapters/claude-code/modes/CLAUDE-review.md +97 -0
  19. anrs-0.1.0/src/anrs/data/adapters/codex/AGENTS.md +33 -0
  20. anrs-0.1.0/src/anrs/data/adapters/codex/README.md +140 -0
  21. anrs-0.1.0/src/anrs/data/adapters/codex/modes/AGENTS-build.md +71 -0
  22. anrs-0.1.0/src/anrs/data/adapters/codex/modes/AGENTS-plan.md +89 -0
  23. anrs-0.1.0/src/anrs/data/adapters/codex/modes/AGENTS-review.md +97 -0
  24. anrs-0.1.0/src/anrs/data/adapters/cursor/README.md +124 -0
  25. anrs-0.1.0/src/anrs/data/adapters/cursor/modes/cursorrules-build +87 -0
  26. anrs-0.1.0/src/anrs/data/adapters/cursor/modes/cursorrules-plan +113 -0
  27. anrs-0.1.0/src/anrs/data/adapters/cursor/modes/cursorrules-review +120 -0
  28. anrs-0.1.0/src/anrs/data/adapters/opencode/README.md +86 -0
  29. anrs-0.1.0/src/anrs/data/adapters/opencode/agents/anrs-build.md +88 -0
  30. anrs-0.1.0/src/anrs/data/adapters/opencode/agents/anrs-plan.md +80 -0
  31. anrs-0.1.0/src/anrs/data/adapters/opencode/agents/anrs-review.md +73 -0
  32. anrs-0.1.0/src/anrs/data/adapters/opencode/opencode.json +43 -0
  33. anrs-0.1.0/src/anrs/data/templates/README.md +40 -0
  34. anrs-0.1.0/src/anrs/data/templates/files/ENTRY.md +35 -0
  35. anrs-0.1.0/src/anrs/data/templates/files/config.json +20 -0
  36. anrs-0.1.0/src/anrs/data/templates/files/failure-cases/README.md +34 -0
  37. anrs-0.1.0/src/anrs/data/templates/files/harness/config.template.json +22 -0
  38. anrs-0.1.0/src/anrs/data/templates/files/plans/active.README.md +21 -0
  39. anrs-0.1.0/src/anrs/data/templates/files/plans/backlog.README.md +17 -0
  40. anrs-0.1.0/src/anrs/data/templates/files/plans/task-template.md +31 -0
  41. anrs-0.1.0/src/anrs/data/templates/files/scratchpad.md +15 -0
  42. anrs-0.1.0/src/anrs/data/templates/files/skills/index.template.json +5 -0
  43. anrs-0.1.0/src/anrs/data/templates/files/state.template.json +14 -0
  44. anrs-0.1.0/src/anrs/data/templates/manifests/full.json +28 -0
  45. anrs-0.1.0/src/anrs/data/templates/manifests/minimal.json +24 -0
  46. anrs-0.1.0/src/anrs/data/templates/manifests/standard.json +30 -0
  47. anrs-0.1.0/src/anrs/doctor_cmd.py +453 -0
  48. anrs-0.1.0/src/anrs/harness/evaluators/l1_static_checks.py +240 -0
  49. anrs-0.1.0/src/anrs/harness/evaluators/l2_dynamic_tests.py +268 -0
  50. anrs-0.1.0/src/anrs/harness/evaluators/l3_stability.py +189 -0
  51. anrs-0.1.0/src/anrs/harness/evaluators/security_scan.py +287 -0
  52. anrs-0.1.0/src/anrs/harness/quality_gate.py +321 -0
  53. anrs-0.1.0/src/anrs/harness_cmd.py +120 -0
  54. anrs-0.1.0/src/anrs/init_cmd.py +505 -0
  55. anrs-0.1.0/src/anrs/main.py +38 -0
  56. anrs-0.1.0/src/anrs/state.py +203 -0
  57. anrs-0.1.0/src/anrs/status.py +94 -0
  58. anrs-0.1.0/src/anrs/upgrade.py +219 -0
  59. anrs-0.1.0/src/anrs.egg-info/PKG-INFO +194 -0
  60. anrs-0.1.0/src/anrs.egg-info/SOURCES.txt +73 -0
  61. anrs-0.1.0/src/anrs.egg-info/dependency_links.txt +1 -0
  62. anrs-0.1.0/src/anrs.egg-info/entry_points.txt +2 -0
  63. anrs-0.1.0/src/anrs.egg-info/requires.txt +22 -0
  64. anrs-0.1.0/src/anrs.egg-info/top_level.txt +1 -0
  65. anrs-0.1.0/tests/test_adapter.py +219 -0
  66. anrs-0.1.0/tests/test_backup.py +538 -0
  67. anrs-0.1.0/tests/test_constants.py +85 -0
  68. anrs-0.1.0/tests/test_doctor.py +213 -0
  69. anrs-0.1.0/tests/test_harness.py +252 -0
  70. anrs-0.1.0/tests/test_init.py +595 -0
  71. anrs-0.1.0/tests/test_integration.py +336 -0
  72. anrs-0.1.0/tests/test_main.py +58 -0
  73. anrs-0.1.0/tests/test_state.py +177 -0
  74. anrs-0.1.0/tests/test_status.py +188 -0
  75. anrs-0.1.0/tests/test_upgrade.py +320 -0
@@ -0,0 +1,157 @@
1
+ # ANRS: AI-Native Repo Spec
2
+
3
+ > A practical specification for structuring AI-friendly code repositories.
4
+
5
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
+ [![Version](https://img.shields.io/badge/version-0.1-blue.svg)]()
7
+ [![Standard](https://img.shields.io/badge/AI%20Native-Repo%20Spec-green.svg)]()
8
+
9
+ [English](README.md) | [中文](README.zh.md)
10
+
11
+ ---
12
+
13
+ ## What is ANRS?
14
+
15
+ ANRS (AI-Native Repo Spec) is a vendor-neutral specification that defines how to structure a repository so that AI agents can work within it safely and effectively.
16
+
17
+ When AI agents operate in traditional codebases, they often lose track of their current task, hallucinate commands, or modify unrelated files. ANRS solves this by providing a standard set of boundaries and context:
18
+
19
+ - **Explicit State (`state.json`)** — Replaces fragile chat history. The AI always reads this file first to know "what task I am doing" and "what step I am on."
20
+ - **Defined Skills (`skills/`)** — Replaces open-ended guessing. The AI is restricted to documented checklists, preventing undefined behaviors.
21
+ - **Mandatory Harness (`.anrs/harness/`)** — Replaces blind commits. AI-generated code must pass checks and tests before task completion.
22
+
23
+ > **Note**: ANRS is a **specification**, not a runtime tool. It's a standardized folder structure (`.anrs/`) plus execution protocols that any AI tool can follow.
24
+
25
+ ---
26
+
27
+ ## Design Principles
28
+
29
+ - **Deterministic Execution** — AI follows a fixed loop: Read → Plan → Execute → Verify.
30
+ - **Atomic Changes** — Code and state update together. Always rollback-safe.
31
+ - **Vendor Neutral** — Works with Cursor, Claude, Codex, and others.
32
+ - **Layered Verification** — Security → Lint → Test → Risk. Gate before commit.
33
+ - **Learn from Failures** — Failed attempts are archived for future reference.
34
+
35
+ ---
36
+
37
+ ## Architecture Overview
38
+
39
+ ```
40
+ ANRS Framework
41
+
42
+ State (SSOT) → Orchestrator → Skills
43
+ ↑ | |
44
+ | v v
45
+ | Harness ←─── Code
46
+ | |
47
+ | [ PASS? ]
48
+ | / \
49
+ | YES NO
50
+ | | |
51
+ └── Commit Reflection → Retry
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Execution Workflow
57
+
58
+ ```
59
+ 1. READ STATE → .anrs/state.json
60
+ 2. LOAD PLAN → .anrs/plans/active/{task_id}.md
61
+ 3. SELECT SKILL → .anrs/skills/index.json
62
+ 4. EXECUTE → Follow SKILL.md checklist
63
+ 5. RUN HARNESS → L1 (Static) → L2 (Tests) → L3 (Stability)
64
+
65
+ PASS → Atomic commit → Update state → Done
66
+ FAIL → Reflect → Retry (max 3) → Escalate to human
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Quick Start
72
+
73
+ ### Option 1: Use CLI (Recommended)
74
+
75
+ ```bash
76
+ pip install anrs
77
+ cd your-project
78
+ anrs init # Standard setup
79
+ anrs adapter install cursor # Add AI adapter
80
+ ```
81
+
82
+ This creates:
83
+ ```
84
+ your-project/
85
+ ├── .anrs/
86
+ │ ├── ENTRY.md # AI reads this first
87
+ │ ├── state.json # Current state (SSOT)
88
+ │ ├── config.json # Configuration
89
+ │ ├── scratchpad.md # Temporary notes
90
+ │ └── plans/ # Task plans
91
+ │ ├── active/ # Current tasks
92
+ │ ├── backlog/ # Future tasks
93
+ │ └── templates/
94
+ └── .cursorrules # AI adapter
95
+ ```
96
+
97
+ ### Option 2: Explore the Source
98
+
99
+ ```bash
100
+ git clone https://github.com/artsyne/anrs.git
101
+ cd anrs
102
+ ls -la spec/ # Protocol specification templates
103
+ ls -la cli/ # CLI tool source code
104
+ ```
105
+
106
+ ### Option 3: Configure Your AI Platform
107
+
108
+ ANRS provides ready-to-use adapters with **multi-mode support** (build/plan/review):
109
+
110
+ | Platform | Modes | Quick Start |
111
+ |----------|-------|--------------|
112
+ | **Cursor** | build, plan | `anrs adapter install cursor` |
113
+ | **Claude Code** | build, plan, review | `anrs adapter install claude-code` |
114
+ | **Codex** | build, plan, review | `anrs adapter install codex` |
115
+ | **OpenCode** | build, plan, review | `anrs adapter install opencode` |
116
+
117
+ See [adapters documentation](cli/data/adapters/README.md) for manual setup and mode switching.
118
+
119
+ ---
120
+
121
+ ## Core Concepts
122
+
123
+ **State (SSOT)** — `.anrs/state.json` — Single Source of Truth for task state. AI reads this before any action.
124
+
125
+ **Entry Point** — `.anrs/ENTRY.md` — AI agent entry point. Defines rules, constraints, and available skills.
126
+
127
+ **Skills** — `.anrs/skills/` — Registered action templates with input/output schemas and constraints.
128
+
129
+ **Harness** — `.anrs/harness/quality_gate.py` (full level) or `anrs harness` command — Multi-layer evaluation gate (Security → L1: static → L2: tests → L3: stability).
130
+
131
+ ---
132
+
133
+ ## Key Files Reference
134
+
135
+ | File | Description |
136
+ |------|-------------|
137
+ | `.anrs/ENTRY.md` | AI agent entry point |
138
+ | `.anrs/state.json` | Current execution state |
139
+ | `.anrs/config.json` | Project configuration |
140
+ | `.anrs/plans/active/` | Active task plans |
141
+ | `.anrs/harness/` | Quality gate evaluators (full level) |
142
+
143
+ ---
144
+
145
+ ## Documentation
146
+
147
+ - [Getting Started](docs/getting-started.md) — 5-minute quick start
148
+ - [Installation Guide](docs/installation.md) — Setup options (minimal/standard/full)
149
+ - [Core Concepts](docs/concepts/overview.md) — Architecture and data flow
150
+ - [Core Beliefs](spec/core-beliefs.md) — Design principles
151
+ - [Contributing Guide](CONTRIBUTING.md) — How to contribute
152
+
153
+ ---
154
+
155
+ ## License
156
+
157
+ MIT License — See [LICENSE](LICENSE) for details.
anrs-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1 @@
1
+ include ANRS_README.md
anrs-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: anrs
3
+ Version: 0.1.0
4
+ Summary: ANRS (AI-Native Repo Spec) - A vendor-neutral specification for AI-friendly code repositories
5
+ Author: ANRS Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/artsyne/anrs
8
+ Project-URL: Documentation, https://artsyne.github.io/anrs
9
+ Keywords: ai,specification,repository,automation
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: click>=8.0
21
+ Requires-Dist: rich>=13.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
25
+ Requires-Dist: pytest-json-report>=1.5.0; extra == "dev"
26
+ Provides-Extra: lint
27
+ Requires-Dist: ruff>=0.1.0; extra == "lint"
28
+ Requires-Dist: radon>=6.0.0; extra == "lint"
29
+ Provides-Extra: security
30
+ Requires-Dist: bandit>=1.7.0; extra == "security"
31
+ Requires-Dist: pip-audit>=2.6.0; extra == "security"
32
+ Provides-Extra: validate
33
+ Requires-Dist: jsonschema>=4.0.0; extra == "validate"
34
+ Requires-Dist: pyyaml>=6.0.0; extra == "validate"
35
+ Provides-Extra: all
36
+ Requires-Dist: anrs[dev,lint,security,validate]; extra == "all"
37
+
38
+ # ANRS: AI-Native Repo Spec
39
+
40
+ > A practical specification for structuring AI-friendly code repositories.
41
+
42
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
43
+ [![Version](https://img.shields.io/badge/version-0.1-blue.svg)]()
44
+ [![Standard](https://img.shields.io/badge/AI%20Native-Repo%20Spec-green.svg)]()
45
+
46
+ [English](README.md) | [中文](README.zh.md)
47
+
48
+ ---
49
+
50
+ ## What is ANRS?
51
+
52
+ ANRS (AI-Native Repo Spec) is a vendor-neutral specification that defines how to structure a repository so that AI agents can work within it safely and effectively.
53
+
54
+ When AI agents operate in traditional codebases, they often lose track of their current task, hallucinate commands, or modify unrelated files. ANRS solves this by providing a standard set of boundaries and context:
55
+
56
+ - **Explicit State (`state.json`)** — Replaces fragile chat history. The AI always reads this file first to know "what task I am doing" and "what step I am on."
57
+ - **Defined Skills (`skills/`)** — Replaces open-ended guessing. The AI is restricted to documented checklists, preventing undefined behaviors.
58
+ - **Mandatory Harness (`.anrs/harness/`)** — Replaces blind commits. AI-generated code must pass checks and tests before task completion.
59
+
60
+ > **Note**: ANRS is a **specification**, not a runtime tool. It's a standardized folder structure (`.anrs/`) plus execution protocols that any AI tool can follow.
61
+
62
+ ---
63
+
64
+ ## Design Principles
65
+
66
+ - **Deterministic Execution** — AI follows a fixed loop: Read → Plan → Execute → Verify.
67
+ - **Atomic Changes** — Code and state update together. Always rollback-safe.
68
+ - **Vendor Neutral** — Works with Cursor, Claude, Codex, and others.
69
+ - **Layered Verification** — Security → Lint → Test → Risk. Gate before commit.
70
+ - **Learn from Failures** — Failed attempts are archived for future reference.
71
+
72
+ ---
73
+
74
+ ## Architecture Overview
75
+
76
+ ```
77
+ ANRS Framework
78
+
79
+ State (SSOT) → Orchestrator → Skills
80
+ ↑ | |
81
+ | v v
82
+ | Harness ←─── Code
83
+ | |
84
+ | [ PASS? ]
85
+ | / \
86
+ | YES NO
87
+ | | |
88
+ └── Commit Reflection → Retry
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Execution Workflow
94
+
95
+ ```
96
+ 1. READ STATE → .anrs/state.json
97
+ 2. LOAD PLAN → .anrs/plans/active/{task_id}.md
98
+ 3. SELECT SKILL → .anrs/skills/index.json
99
+ 4. EXECUTE → Follow SKILL.md checklist
100
+ 5. RUN HARNESS → L1 (Static) → L2 (Tests) → L3 (Stability)
101
+
102
+ PASS → Atomic commit → Update state → Done
103
+ FAIL → Reflect → Retry (max 3) → Escalate to human
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Quick Start
109
+
110
+ ### Option 1: Use CLI (Recommended)
111
+
112
+ ```bash
113
+ pip install anrs
114
+ cd your-project
115
+ anrs init # Standard setup
116
+ anrs adapter install cursor # Add AI adapter
117
+ ```
118
+
119
+ This creates:
120
+ ```
121
+ your-project/
122
+ ├── .anrs/
123
+ │ ├── ENTRY.md # AI reads this first
124
+ │ ├── state.json # Current state (SSOT)
125
+ │ ├── config.json # Configuration
126
+ │ ├── scratchpad.md # Temporary notes
127
+ │ └── plans/ # Task plans
128
+ │ ├── active/ # Current tasks
129
+ │ ├── backlog/ # Future tasks
130
+ │ └── templates/
131
+ └── .cursorrules # AI adapter
132
+ ```
133
+
134
+ ### Option 2: Explore the Source
135
+
136
+ ```bash
137
+ git clone https://github.com/artsyne/anrs.git
138
+ cd anrs
139
+ ls -la spec/ # Protocol specification templates
140
+ ls -la cli/ # CLI tool source code
141
+ ```
142
+
143
+ ### Option 3: Configure Your AI Platform
144
+
145
+ ANRS provides ready-to-use adapters with **multi-mode support** (build/plan/review):
146
+
147
+ | Platform | Modes | Quick Start |
148
+ |----------|-------|--------------|
149
+ | **Cursor** | build, plan | `anrs adapter install cursor` |
150
+ | **Claude Code** | build, plan, review | `anrs adapter install claude-code` |
151
+ | **Codex** | build, plan, review | `anrs adapter install codex` |
152
+ | **OpenCode** | build, plan, review | `anrs adapter install opencode` |
153
+
154
+ See [adapters documentation](cli/data/adapters/README.md) for manual setup and mode switching.
155
+
156
+ ---
157
+
158
+ ## Core Concepts
159
+
160
+ **State (SSOT)** — `.anrs/state.json` — Single Source of Truth for task state. AI reads this before any action.
161
+
162
+ **Entry Point** — `.anrs/ENTRY.md` — AI agent entry point. Defines rules, constraints, and available skills.
163
+
164
+ **Skills** — `.anrs/skills/` — Registered action templates with input/output schemas and constraints.
165
+
166
+ **Harness** — `.anrs/harness/quality_gate.py` (full level) or `anrs harness` command — Multi-layer evaluation gate (Security → L1: static → L2: tests → L3: stability).
167
+
168
+ ---
169
+
170
+ ## Key Files Reference
171
+
172
+ | File | Description |
173
+ |------|-------------|
174
+ | `.anrs/ENTRY.md` | AI agent entry point |
175
+ | `.anrs/state.json` | Current execution state |
176
+ | `.anrs/config.json` | Project configuration |
177
+ | `.anrs/plans/active/` | Active task plans |
178
+ | `.anrs/harness/` | Quality gate evaluators (full level) |
179
+
180
+ ---
181
+
182
+ ## Documentation
183
+
184
+ - [Getting Started](docs/getting-started.md) — 5-minute quick start
185
+ - [Installation Guide](docs/installation.md) — Setup options (minimal/standard/full)
186
+ - [Core Concepts](docs/concepts/overview.md) — Architecture and data flow
187
+ - [Core Beliefs](spec/core-beliefs.md) — Design principles
188
+ - [Contributing Guide](CONTRIBUTING.md) — How to contribute
189
+
190
+ ---
191
+
192
+ ## License
193
+
194
+ MIT License — See [LICENSE](LICENSE) for details.
anrs-0.1.0/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # ANRS CLI
2
+
3
+ Command-line tool for managing ANRS-compliant repositories.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # From source
9
+ cd cli
10
+ pip install -e .
11
+
12
+ # Or with dev dependencies
13
+ pip install -e ".[dev]"
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```bash
19
+ # Initialize ANRS in a repository
20
+ anrs init # Standard level
21
+ anrs init --level minimal # Minimal setup
22
+ anrs init --level full # Full setup
23
+
24
+ # Check repository status
25
+ anrs status
26
+
27
+ # Run quality checks
28
+ anrs harness # All levels
29
+ anrs harness --level L1 # Static checks only
30
+ anrs harness --strict # Fail on any error
31
+
32
+ # Manage adapters
33
+ anrs adapter list
34
+ anrs adapter install cursor
35
+ anrs adapter install claude-code
36
+ ```
37
+
38
+ ## Commands
39
+
40
+ | Command | Description |
41
+ |---------|-------------|
42
+ | `anrs init` | Initialize ANRS in a repository |
43
+ | `anrs status` | Show ANRS status and current state |
44
+ | `anrs harness` | Run quality gate checks |
45
+ | `anrs adapter` | Install and manage AI tool adapters |
46
+
47
+ ## Development
48
+
49
+ ```bash
50
+ # Install dev dependencies
51
+ pip install -e ".[dev]"
52
+
53
+ # Run tests
54
+ pytest
55
+
56
+ # Run tests with coverage
57
+ pytest --cov=anrs --cov-report=html
58
+ ```
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "anrs"
7
+ version = "0.1.0"
8
+ description = "ANRS (AI-Native Repo Spec) - A vendor-neutral specification for AI-friendly code repositories"
9
+ readme = "ANRS_README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ {name = "ANRS Contributors"}
14
+ ]
15
+ keywords = ["ai", "specification", "repository", "automation"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ ]
26
+ dependencies = [
27
+ "click>=8.0",
28
+ "rich>=13.0",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "pytest>=7.0.0",
34
+ "pytest-cov>=4.0.0",
35
+ "pytest-json-report>=1.5.0",
36
+ ]
37
+ lint = [
38
+ "ruff>=0.1.0",
39
+ "radon>=6.0.0",
40
+ ]
41
+ security = [
42
+ "bandit>=1.7.0",
43
+ "pip-audit>=2.6.0",
44
+ ]
45
+ validate = [
46
+ "jsonschema>=4.0.0",
47
+ "pyyaml>=6.0.0",
48
+ ]
49
+ all = [
50
+ "anrs[dev,lint,security,validate]",
51
+ ]
52
+
53
+ [project.scripts]
54
+ anrs = "anrs.main:cli"
55
+
56
+ [project.urls]
57
+ Homepage = "https://github.com/artsyne/anrs"
58
+ Documentation = "https://artsyne.github.io/anrs"
59
+
60
+ [tool.setuptools.packages.find]
61
+ where = ["src"]
62
+ include = ["anrs*"]
63
+
64
+ [tool.setuptools.package-data]
65
+ anrs = ["data/**/*"]
66
+
67
+ [tool.pytest.ini_options]
68
+ testpaths = ["tests"]
69
+ python_files = ["test_*.py"]
70
+ addopts = "-v --cov=anrs --cov-report=term-missing"
anrs-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
anrs-0.1.0/setup.py ADDED
@@ -0,0 +1,4 @@
1
+ """Setup script for editable installs."""
2
+ from setuptools import setup
3
+
4
+ setup()
@@ -0,0 +1,3 @@
1
+ """ANRS CLI - AI-Native Repo Spec command-line tool."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,147 @@
1
+ """ANRS adapter command - Manage AI tool adapters."""
2
+
3
+ import logging
4
+ import shutil
5
+ from pathlib import Path
6
+
7
+ import click
8
+ from rich.console import Console
9
+ from rich.table import Table
10
+
11
+ from anrs.constants import ADAPTERS_DIR, ADAPTERS, get_adapter_config_file
12
+ from anrs.backup import (
13
+ ConflictStrategy,
14
+ backup_file,
15
+ get_backup_dir,
16
+ detect_user_modifications,
17
+ prompt_conflict_resolution,
18
+ show_conflict_summary,
19
+ create_backup_id,
20
+ )
21
+
22
+ logger = logging.getLogger(__name__)
23
+ console = Console()
24
+
25
+
26
+ @click.group()
27
+ def adapter():
28
+ """Manage AI tool adapters.
29
+
30
+ Install and configure adapters for different AI tools (Cursor, Claude Code, etc.)
31
+ """
32
+ pass
33
+
34
+
35
+ @adapter.command("list")
36
+ def list_adapters():
37
+ """List available adapters."""
38
+ table = Table(title="Available Adapters")
39
+ table.add_column("Adapter", style="cyan")
40
+ table.add_column("Description")
41
+ table.add_column("Config File")
42
+
43
+ for name, info in ADAPTERS.items():
44
+ table.add_row(name, info["description"], info["config_file"])
45
+
46
+ console.print(table)
47
+
48
+
49
+ @adapter.command("install")
50
+ @click.argument("adapter_name", type=click.Choice(list(ADAPTERS.keys())))
51
+ @click.option(
52
+ "--force", "-f",
53
+ is_flag=True,
54
+ help="Overwrite existing adapter config (with automatic backup)"
55
+ )
56
+ @click.option(
57
+ "--skip",
58
+ is_flag=True,
59
+ help="Skip if adapter config already exists"
60
+ )
61
+ @click.option(
62
+ "--dry-run",
63
+ is_flag=True,
64
+ help="Show what would be done without making changes"
65
+ )
66
+ @click.argument("path", default=".", type=click.Path(exists=True))
67
+ def install_adapter(adapter_name: str, force: bool, skip: bool, dry_run: bool, path: str):
68
+ """Install an adapter for an AI tool.
69
+
70
+ Creates a trampoline config file that points to .anrs/ENTRY.md.
71
+
72
+ \b
73
+ Conflict handling:
74
+ - Default: Asks how to handle existing files
75
+ - --force: Backup existing file, then overwrite
76
+ - --skip: Skip installation if file exists
77
+ """
78
+ target_dir = Path(path).resolve()
79
+ adapter_source = ADAPTERS_DIR / adapter_name
80
+
81
+ if not adapter_source.exists():
82
+ raise click.ClickException(f"Adapter not found: {adapter_name}")
83
+
84
+ config_file = get_adapter_config_file(adapter_name)
85
+ source_path = adapter_source / config_file
86
+ target_path = target_dir / config_file
87
+
88
+ # Detect conflict
89
+ conflict = None
90
+ if target_path.exists():
91
+ has_mods, diff = detect_user_modifications(source_path, target_path)
92
+ conflict = {
93
+ "file": config_file,
94
+ "status": "modified" if has_mods else "unchanged",
95
+ "diff": diff or "",
96
+ }
97
+
98
+ if dry_run:
99
+ console.print(
100
+ "[bold yellow]Dry run mode - no changes made[/bold yellow]")
101
+ console.print(f"Would copy: [cyan]{source_path}[/cyan]")
102
+ console.print(f" to: [cyan]{target_path}[/cyan]")
103
+ if conflict:
104
+ console.print(
105
+ f"\n[yellow]Conflict:[/yellow] {config_file} already exists ({conflict['status']})")
106
+ console.print(
107
+ "[dim]Use --force to backup and overwrite, or --skip to skip[/dim]")
108
+ return
109
+
110
+ # Handle conflict
111
+ strategy = ConflictStrategy.BACKUP_AND_OVERWRITE
112
+ if conflict:
113
+ if skip:
114
+ console.print(f"[dim]Skipped: {config_file} already exists[/dim]")
115
+ return
116
+ elif force:
117
+ strategy = ConflictStrategy.BACKUP_AND_OVERWRITE
118
+ else:
119
+ show_conflict_summary(
120
+ [conflict], f"Adapter Config Conflict: {config_file}")
121
+ strategy = prompt_conflict_resolution()
122
+
123
+ if strategy == ConflictStrategy.ABORT:
124
+ raise click.Abort()
125
+ elif strategy == ConflictStrategy.SKIP:
126
+ console.print(f"[dim]Skipped: {config_file}[/dim]")
127
+ return
128
+
129
+ # Backup if overwriting
130
+ backup_id = create_backup_id()
131
+ if conflict and strategy == ConflictStrategy.BACKUP_AND_OVERWRITE:
132
+ anrs_dir = target_dir / ".anrs"
133
+ backup_dir = get_backup_dir(anrs_dir)
134
+ backup_path = backup_file(target_path, backup_dir, backup_id)
135
+ if backup_path:
136
+ console.print(f"[green]Backed up:[/green] {backup_path}")
137
+
138
+ try:
139
+ shutil.copy(source_path, target_path)
140
+ except IOError as e:
141
+ logger.error(f"Failed to install adapter: {e}")
142
+ raise click.ClickException(f"Cannot install adapter: {e}")
143
+
144
+ console.print(f"[green]Installed {adapter_name} adapter[/green]")
145
+ console.print(f"Config: [cyan]{target_path}[/cyan]")
146
+ console.print(
147
+ f"\nThe adapter will redirect AI to [cyan].anrs/ENTRY.md[/cyan]")