awsquery 0.3.2__tar.gz → 0.4.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 (90) hide show
  1. {awsquery-0.3.2 → awsquery-0.4.0}/.claude/settings.local.json +2 -1
  2. awsquery-0.4.0/CLAUDE.md +281 -0
  3. {awsquery-0.3.2 → awsquery-0.4.0}/Makefile +6 -6
  4. {awsquery-0.3.2 → awsquery-0.4.0}/PKG-INFO +125 -27
  5. {awsquery-0.3.2 → awsquery-0.4.0}/README.md +124 -26
  6. {awsquery-0.3.2 → awsquery-0.4.0}/docker-compose.yml +0 -3
  7. {awsquery-0.3.2 → awsquery-0.4.0}/pyproject.toml +1 -1
  8. awsquery-0.4.0/src/awsquery/cli.py +1009 -0
  9. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/core.py +167 -256
  10. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/default_filters.yaml +1 -1
  11. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/filters.py +45 -8
  12. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/formatters.py +7 -27
  13. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/security.py +0 -11
  14. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/utils.py +109 -14
  15. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/PKG-INFO +125 -27
  16. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/SOURCES.txt +4 -4
  17. {awsquery-0.3.2 → awsquery-0.4.0}/tests/conftest.py +9 -22
  18. {awsquery-0.3.2 → awsquery-0.4.0}/tests/fixtures/policy_samples.py +0 -51
  19. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_autocomplete_resilience.py +40 -30
  20. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_end_to_end.py +28 -32
  21. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_feature_combinations.py +3 -3
  22. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_keys_behavior.py +3 -3
  23. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_multi_level.py +8 -6
  24. awsquery-0.4.0/tests/integration/test_parameter_option_integration.py +233 -0
  25. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_session_management.py +2 -2
  26. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_cli_arg_processing.py +3 -103
  27. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_cli_flags.py +4 -4
  28. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_cli_parser.py +75 -1
  29. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_cli_session_args.py +9 -7
  30. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_column_ordering.py +0 -7
  31. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_core.py +6 -47
  32. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_filter_implementation.py +262 -0
  33. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_formatters.py +57 -181
  34. awsquery-0.4.0/tests/unit/test_input_hint_parameter.py +987 -0
  35. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_keys_display_fix.py +6 -6
  36. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_messaging_enhancements.py +6 -11
  37. awsquery-0.4.0/tests/unit/test_parameter_option.py +473 -0
  38. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_security.py +0 -12
  39. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_security_edge_cases.py +0 -45
  40. awsquery-0.4.0/tests/unit/test_smart_prefix_matching.py +219 -0
  41. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_tags_transformation.py +4 -4
  42. awsquery-0.3.2/CLAUDE.md +0 -158
  43. awsquery-0.3.2/src/awsquery/cli.py +0 -537
  44. awsquery-0.3.2/src/awsquery/policy.json +0 -2521
  45. awsquery-0.3.2/tests/unit/test_filter_matching.py +0 -276
  46. awsquery-0.3.2/tests/unit/test_filters.py +0 -737
  47. awsquery-0.3.2/tests/unit/test_filters_pattern_matching.py +0 -282
  48. {awsquery-0.3.2 → awsquery-0.4.0}/.claude/agents/code-reviewer.md +0 -0
  49. {awsquery-0.3.2 → awsquery-0.4.0}/.claude/agents/makefile-optimizer.md +0 -0
  50. {awsquery-0.3.2 → awsquery-0.4.0}/.claude/agents/python-infra-automator.md +0 -0
  51. {awsquery-0.3.2 → awsquery-0.4.0}/.claude/agents/test-writer.md +0 -0
  52. {awsquery-0.3.2 → awsquery-0.4.0}/.coveragerc +0 -0
  53. {awsquery-0.3.2 → awsquery-0.4.0}/.devcontainer/devcontainer.json +0 -0
  54. {awsquery-0.3.2 → awsquery-0.4.0}/.dockerignore +0 -0
  55. {awsquery-0.3.2 → awsquery-0.4.0}/.flake8 +0 -0
  56. {awsquery-0.3.2 → awsquery-0.4.0}/.github/workflows/quality.yml +0 -0
  57. {awsquery-0.3.2 → awsquery-0.4.0}/.github/workflows/release.yml +0 -0
  58. {awsquery-0.3.2 → awsquery-0.4.0}/.github/workflows/test.yml +0 -0
  59. {awsquery-0.3.2 → awsquery-0.4.0}/.gitignore +0 -0
  60. {awsquery-0.3.2 → awsquery-0.4.0}/Dockerfile +0 -0
  61. {awsquery-0.3.2 → awsquery-0.4.0}/Dockerfile.prod +0 -0
  62. {awsquery-0.3.2 → awsquery-0.4.0}/LICENSE +0 -0
  63. {awsquery-0.3.2 → awsquery-0.4.0}/Todo.md +0 -0
  64. {awsquery-0.3.2 → awsquery-0.4.0}/docs/DOCKER.md +0 -0
  65. {awsquery-0.3.2 → awsquery-0.4.0}/docs/mutation-testing.md +0 -0
  66. {awsquery-0.3.2 → awsquery-0.4.0}/pytest.ini +0 -0
  67. {awsquery-0.3.2 → awsquery-0.4.0}/requirements.txt +0 -0
  68. {awsquery-0.3.2 → awsquery-0.4.0}/setup.cfg +0 -0
  69. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/__init__.py +0 -0
  70. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery/config.py +0 -0
  71. {awsquery-0.3.2 → awsquery-0.4.0/src/awsquery}/policy.json +0 -0
  72. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/dependency_links.txt +0 -0
  73. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/entry_points.txt +0 -0
  74. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/requires.txt +0 -0
  75. {awsquery-0.3.2 → awsquery-0.4.0}/src/awsquery.egg-info/top_level.txt +0 -0
  76. {awsquery-0.3.2 → awsquery-0.4.0}/tests/__init__.py +0 -0
  77. {awsquery-0.3.2 → awsquery-0.4.0}/tests/fixtures/__init__.py +0 -0
  78. {awsquery-0.3.2 → awsquery-0.4.0}/tests/fixtures/aws_responses.py +0 -0
  79. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/__init__.py +0 -0
  80. {awsquery-0.3.2 → awsquery-0.4.0}/tests/integration/test_multi_level_calls.py +0 -0
  81. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/__init__.py +0 -0
  82. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_config_loading_simple.py +0 -0
  83. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_core_inference.py +0 -0
  84. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_core_string_handling.py +0 -0
  85. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_critical_mutations.py +0 -0
  86. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_default_column_filters.py +0 -0
  87. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_filter_edge_cases.py +0 -0
  88. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_filter_parameter_extraction.py +0 -0
  89. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_formatter_edge_cases.py +0 -0
  90. {awsquery-0.3.2 → awsquery-0.4.0}/tests/unit/test_formatters_data_processing.py +0 -0
@@ -3,7 +3,8 @@
3
3
  "allow": [
4
4
  "Bash(python3 -m pytest tests/ --cov=src/awsquery --cov-report=term-missing -q)",
5
5
  "Bash(mutmut show:*)",
6
- "Bash(mutmut:*)"
6
+ "Bash(mutmut:*)",
7
+ "Bash(python3:*)"
7
8
  ],
8
9
  "deny": [],
9
10
  "ask": []
@@ -0,0 +1,281 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `awsquery` is an advanced CLI tool for querying AWS APIs through boto3 with flexible filtering, automatic parameter resolution, and comprehensive security validation. The tool enforces ReadOnly AWS operations for security and provides intelligent response processing with automatic field discovery.
8
+
9
+ ## Development Philosophy
10
+
11
+ **CRITICAL: ZERO BACKWARD COMPATIBILITY REQUIREMENT**
12
+
13
+ This project has **ZERO EXTERNAL CONSUMERS** and **NO BACKWARD COMPATIBILITY OBLIGATIONS**. Internal APIs can and should be changed aggressively for code quality improvements.
14
+
15
+ **MANDATORY PRINCIPLES:**
16
+ - **NEVER maintain backward compatibility** - there are no external users
17
+ - **CLI commands must remain stable** - user-facing behavior should be consistent
18
+ - **Internal APIs are completely mutable** - change function signatures, parameters, return types freely
19
+ - **Delete deprecated code immediately** - no deprecation periods needed
20
+ - **Refactor aggressively** - prioritize clean code over any compatibility concerns
21
+ - **Break internal interfaces without hesitation** - improve designs whenever beneficial
22
+ - **Update tests to match new APIs** - test failures from API changes should be fixed by updating tests
23
+
24
+ **The only stability requirement is the CLI user experience. All internal code is fair game for radical changes.**
25
+
26
+ ## MANDATORY AGENT USAGE
27
+
28
+ **ABSOLUTE REQUIREMENT: SPECIALIZED AGENTS MUST BE USED FOR ALL DEVELOPMENT TASKS**
29
+
30
+ **ZERO TOLERANCE POLICY: MANUAL WORK IS CATEGORICALLY FORBIDDEN**
31
+
32
+ ### Test Development - MANDATORY @agent-test-writer Usage
33
+ - **MUST USE @agent-test-writer** for ALL test creation, modification, and enhancement
34
+ - **NEVER write tests manually** - always delegate to the specialized test-writer agent
35
+ - **MANDATORY for:** Unit tests, integration tests, edge case testing, test refactoring
36
+ - **REQUIRED PROCESS:** Always use test-driven development through the agent
37
+ - **NO EXCEPTIONS:** Any test-related work MUST go through @agent-test-writer
38
+
39
+ ### Python Implementation - MANDATORY @agent-python-infra-automator Usage
40
+ - **MUST USE @agent-python-infra-automator** for ALL Python code implementation
41
+ - **NEVER implement Python code manually** - always delegate to the specialized Python agent
42
+ - **MANDATORY for:** New features, bug fixes, refactoring, optimization, infrastructure code
43
+ - **REQUIRED PROCESS:** Always implement through the specialized agent for best practices
44
+ - **NO EXCEPTIONS:** Any Python development MUST go through @agent-python-infra-automator
45
+
46
+ ### Code Review - MANDATORY @agent-code-reviewer Usage
47
+ - **MUST USE @agent-code-reviewer** AUTOMATICALLY after ANY significant code changes
48
+ - **PROACTIVE REQUIREMENT:** Agent must be invoked WITHOUT user request after commits/merges
49
+ - **MANDATORY for:** All code quality reviews, security analysis, maintainability checks
50
+ - **AUTOMATIC TRIGGERS:** Post-commit, post-merge, after major refactoring
51
+ - **NO EXCEPTIONS:** ALL code changes MUST be reviewed by the specialized agent
52
+
53
+ ### Makefile Operations - MANDATORY @agent-makefile-optimizer Usage
54
+ - **MUST USE @agent-makefile-optimizer** for ANY Makefile-related work
55
+ - **AUTOMATIC TRIGGER:** ANY interaction with Makefile, makefile, GNUmakefile, *.mk files
56
+ - **MANDATORY for:** Build automation, make targets, build system optimization
57
+ - **PROACTIVE REQUIREMENT:** Agent MUST be used automatically when detecting Makefile work
58
+ - **NO EXCEPTIONS:** ALL build system work MUST go through the specialized agent
59
+
60
+ ### Configuration Management - MANDATORY @agent-statusline-setup Usage
61
+ - **MUST USE @agent-statusline-setup** for Claude Code status line configuration
62
+ - **MANDATORY for:** Status line settings, configuration management
63
+ - **NO EXCEPTIONS:** Status line work MUST go through the specialized agent
64
+
65
+ ### Output Styling - MANDATORY @agent-output-style-setup Usage
66
+ - **MUST USE @agent-output-style-setup** for Claude Code output style creation
67
+ - **MANDATORY for:** Output formatting, style configuration
68
+ - **NO EXCEPTIONS:** Output style work MUST go through the specialized agent
69
+
70
+ ### General Research - MANDATORY @agent-general-purpose Usage
71
+ - **MUST USE @agent-general-purpose** for complex multi-step research tasks
72
+ - **MANDATORY for:** Searching keywords/files, complex questions, multi-step tasks
73
+ - **REQUIRED WHEN:** Not confident about finding right match in first few tries
74
+ - **NO EXCEPTIONS:** Complex research MUST go through the specialized agent
75
+
76
+ ### Agent Usage Protocol - ABSOLUTE ENFORCEMENT
77
+ 1. **IDENTIFY TASK TYPE:** Determine which specialized agent is required
78
+ 2. **AUTOMATIC INVOCATION:** Many agents MUST be triggered proactively/automatically
79
+ 3. **PROVIDE COMPLETE CONTEXT:** Include all relevant information for the agent
80
+ 4. **FOLLOW AGENT RECOMMENDATIONS:** Implement exactly as specified by the agent
81
+ 5. **NO MANUAL OVERRIDE:** Trust the specialized agents completely
82
+ 6. **PARALLEL EXECUTION:** Use multiple agents concurrently when possible
83
+
84
+ ### PROACTIVE AGENT TRIGGERS - MANDATORY AUTOMATION
85
+ - **@agent-code-reviewer:** AUTOMATICALLY after significant code changes
86
+ - **@agent-makefile-optimizer:** AUTOMATICALLY when detecting Makefile work
87
+ - **@agent-test-writer:** PROACTIVELY when functions/classes lack test coverage
88
+ - **@agent-python-infra-automator:** PROACTIVELY for infrastructure automation needs
89
+
90
+ **VIOLATION OF AGENT USAGE IS STRICTLY FORBIDDEN - ALL DEVELOPMENT MUST GO THROUGH SPECIALIZED AGENTS**
91
+ **MANUAL IMPLEMENTATION IS CATEGORICALLY PROHIBITED - AGENTS ARE MANDATORY FOR ALL WORK**
92
+
93
+ ## Development Commands
94
+
95
+ ### Core Commands
96
+ - `make install-dev` - Install development dependencies
97
+ - `make test` - Run all tests (MANDATORY - NO SELECTIVE EXECUTION ALLOWED)
98
+ - `make test-unit` - Run unit tests only (directory-based, not marker-based)
99
+ - `make test-integration` - Run integration tests only (directory-based, not marker-based)
100
+ - `make test-critical` - Run all tests (NO SELECTIVE MARKERS PERMITTED)
101
+ - `make coverage` - Run tests with coverage report (generates htmlcov/index.html)
102
+ - `python3 -m pytest tests/ -v` - Direct pytest execution (NEVER with -m markers)
103
+
104
+ ### Code Quality
105
+ - `make lint` - Run linting checks (flake8, pylint)
106
+ - `make format` - Format code with black and isort
107
+ - `make format-check` - Check code formatting without changes
108
+ - `make type-check` - Run mypy type checking
109
+ - `make security-check` - Run security checks (bandit, safety)
110
+ - `make pre-commit` - Run pre-commit hooks on all files
111
+
112
+ ### Docker Development
113
+ - `make docker-build` - Build development container
114
+ - `make shell` - Open interactive shell in container
115
+ - `make test-in-docker` - Run tests in Docker container
116
+
117
+ ### Single Test Execution
118
+ - `python3 -m pytest tests/test_specific.py::TestClass::test_method -v` - Run specific test
119
+ - `python3 -m pytest -k "test_pattern" -v` - Run tests matching pattern
120
+ - `python3 -m pytest tests/ -m "unit" -v` - Run tests with specific markers
121
+
122
+ ## Architecture
123
+
124
+ ### Core Module Structure
125
+ - `src/awsquery/cli.py` - Main CLI interface and argument parsing
126
+ - `src/awsquery/core.py` - Core AWS query execution logic
127
+ - `src/awsquery/security.py` - Security policy validation (ReadOnly enforcement)
128
+ - `src/awsquery/filters.py` - Data filtering and column selection logic
129
+ - `src/awsquery/formatters.py` - Output formatting (table/JSON)
130
+ - `src/awsquery/utils.py` - Utility functions and debug helpers
131
+
132
+ ### Key Features
133
+ - **Smart Multi-Level Calls**: Automatically resolves missing parameters by inferring list operations
134
+ - **Security-First Design**: All operations validated against `policy.json` ReadOnly policy
135
+ - **Flexible Filtering**: Multi-level filtering with `--` separators for different filter types
136
+ - **Auto-Parameter Resolution**: Handles both specific fields and standard AWS patterns (Name, Id, Arn)
137
+ - **Intelligent Response Processing**: Clean extraction of list data, ignoring AWS metadata
138
+
139
+ ### Security Architecture
140
+ The tool enforces security through a comprehensive `policy.json` file that defines allowed ReadOnly AWS operations. All API calls are validated against this policy before execution.
141
+
142
+ ### Testing Structure
143
+ - Unit tests in `tests/unit/` with `@pytest.mark.unit`
144
+ - Integration tests in `tests/integration/` with `@pytest.mark.integration`
145
+ - Critical path tests marked with `@pytest.mark.critical`
146
+ - AWS mocks using moto library marked with `@pytest.mark.aws`
147
+
148
+ ### STRICT Testing Requirements - MUST FOLLOW
149
+
150
+ #### 🚫 PROHIBITED: Test Anti-Patterns
151
+ **NEVER CREATE:**
152
+ 1. **Duplicate Test Files**: Before creating ANY test file, search for existing tests covering the same functionality
153
+ - Flag tests: Use `test_cli_flags.py` ONLY
154
+ - Parser tests: Use `test_cli_parser.py` ONLY
155
+ - Filter tests: Use `test_filter_implementation.py` for real tests, `test_filter_matching.py` for patterns
156
+ 2. **Over-Mocked Tests**: Tests that mock the very functions they claim to test
157
+ 3. **Mock Assertion Tests**: Tests that only verify `mock.assert_called()` without testing actual behavior
158
+ 4. **Nested Mock Contexts**: More than 2 levels of `with patch()` indicates over-mocking
159
+
160
+ #### ✅ REQUIRED: Test Best Practices
161
+ **ALWAYS:**
162
+ 1. **Test Real Implementation**:
163
+ ```python
164
+ # GOOD: Tests actual function
165
+ result = filter_resources(real_data, ["filter"])
166
+ assert len(result) == expected
167
+
168
+ # BAD: Only tests mock
169
+ mock_filter.return_value = []
170
+ mock_filter.assert_called_once()
171
+ ```
172
+
173
+ 2. **Minimal Mocking**: Only mock external dependencies (boto3, file I/O, network)
174
+ ```python
175
+ # GOOD: Only mock AWS
176
+ @patch("boto3.client")
177
+ def test_feature(mock_client):
178
+ # Test real code with mocked AWS
179
+
180
+ # BAD: Mock everything
181
+ @patch("filter_resources")
182
+ @patch("format_output")
183
+ @patch("parse_args")
184
+ ```
185
+
186
+ 3. **Consolidate Related Tests**: Group similar tests in one file
187
+ - All flag position tests → `test_cli_flags.py`
188
+ - All parser tests → `test_cli_parser.py`
189
+ - All filter implementation → `test_filter_implementation.py`
190
+
191
+ 4. **Test Edge Cases**: Include malformed input, Unicode, empty values
192
+ ```python
193
+ # Test edge cases
194
+ test_cases = ["", None, "^$", "ˆ", "$^", "^^$$"]
195
+ ```
196
+
197
+ 5. **Verify Actual Output**: Check real results, not mock calls
198
+ ```python
199
+ # GOOD: Verify actual JSON
200
+ output = format_json_output(data, filters)
201
+ parsed = json.loads(output) # Ensures valid JSON
202
+
203
+ # BAD: Only check mock called
204
+ mock_json.assert_called_once()
205
+ ```
206
+
207
+ #### 📋 Test Review Checklist
208
+ Before committing ANY test:
209
+ 1. ❓ Does a test file for this feature already exist?
210
+ 2. ❓ Am I testing real code or just mocks?
211
+ 3. ❓ Do assertions verify actual behavior?
212
+ 4. ❓ Is mocking limited to external dependencies only?
213
+ 5. ❓ Are edge cases covered?
214
+
215
+ #### 🔍 Finding Duplicate Tests
216
+ ```bash
217
+ # Check for existing tests before creating new ones
218
+ grep -r "test.*flag.*position" tests/
219
+ grep -r "test.*parser" tests/
220
+ grep -r "test.*filter" tests/
221
+ ```
222
+
223
+ ### 🚫 **ABSOLUTE PROHIBITION: VERBOSE TEST COMMENTS**
224
+
225
+ **MANDATORY EDICT: UNNECESSARY TEST COMMENTS ARE CATEGORICALLY FORBIDDEN**
226
+
227
+ **NEVER WRITE THESE TYPES OF COMMENTS:**
228
+ - **TDD Placeholder Comments**: `"""Test the expected structure when -i/--input is implemented."""`
229
+ - **Obvious Restatements**: `"""Test that function returns expected value."""`
230
+ - **Implementation Descriptions**: `"""This test checks if the parser works correctly."""`
231
+ - **Future Implementation Notes**: `"""TODO: implement when feature X is ready."""`
232
+ - **Verbose Process Descriptions**: `"""First we call X, then we check Y, finally we assert Z."""`
233
+
234
+ **HARD RULES FOR TEST DOCUMENTATION:**
235
+ - **NO REDUNDANT DOCSTRINGS**: Never restate what the method name already says
236
+ - **NO TDD PLACEHOLDERS**: Delete placeholder comments immediately after implementation
237
+ - **NO OBVIOUS COMMENTS**: If the test name explains it, don't repeat in comments
238
+ - **NO VERBOSE EXPLANATIONS**: Code should be self-documenting
239
+ - **ESSENTIAL ONLY**: Comments only for complex edge cases or non-obvious logic
240
+
241
+ **ACCEPTABLE COMMENTS (RARE):**
242
+ - Complex edge case explanation: `# Unicode circumflex U+02C6 vs ASCII U+005E`
243
+ - Non-obvious assertion: `# Must check stderr, not stdout for debug output`
244
+ - External dependency note: `# Requires specific AWS policy format`
245
+
246
+ **ENFORCEMENT:**
247
+ - **IMMEDIATE DELETION** of any TDD placeholder comments
248
+ - **ZERO TOLERANCE** for verbose test documentation
249
+ - **CLEAN CODE OVER COMMENTS** - make tests readable through naming and structure
250
+
251
+ ### 🚫 **ABSOLUTE PROHIBITION: PYTEST MARKERS**
252
+
253
+ **MANDATORY EDICT: PYTEST MARKERS ARE CATEGORICALLY FORBIDDEN AND COMPLETELY BANNED**
254
+
255
+ **UNBREAKABLE RULES:**
256
+ - **NEVER, EVER, UNDER ANY CIRCUMSTANCES** add `@pytest.mark.*` decorators to tests
257
+ - **ZERO TOLERANCE** for selective test execution markers (`@pytest.mark.unit`, `@pytest.mark.integration`, `@pytest.mark.slow`, `@pytest.mark.critical`, etc.)
258
+ - **ALL TESTS MUST ALWAYS RUN** - no exceptions, no conditional execution, no selective filtering
259
+ - **IMMEDIATE DELETION** required for any pytest markers discovered in code
260
+ - **NO EXEMPTIONS** - this rule is immutable and non-negotiable
261
+
262
+ **RATIONALE:**
263
+ - Selective test execution leads to **INCOMPLETE COVERAGE** and **HIDDEN FAILURES**
264
+ - Markers create **FALSE CONFIDENCE** by allowing tests to be skipped
265
+ - **ALL TESTS ARE CRITICAL** - none should be optional or conditional
266
+ - Complete test suite execution is **MANDATORY FOR QUALITY ASSURANCE**
267
+
268
+ **ENFORCEMENT:**
269
+ - Any pytest markers found in code must be **REMOVED IMMEDIATELY**
270
+ - Makefile commands must **NEVER USE** `-m "marker"` syntax
271
+ - Test discovery must be **PURELY DIRECTORY-BASED** (tests/unit/, tests/integration/)
272
+ - **NO EXCEPTIONS** - this is an inviolable principle
273
+
274
+ **ALLOWED:** `@pytest.mark.parametrize` ONLY (for test parameterization, not selection)
275
+ **FORBIDDEN:** All other `@pytest.mark.*` decorators without exception
276
+
277
+ ### Configuration Files
278
+ - `pyproject.toml` - Main project configuration with dependencies and tool settings
279
+ - `pytest.ini` - Test configuration with coverage settings (80% minimum)
280
+ - `Makefile` - Comprehensive development and AWS sampling commands
281
+ - `.pre-commit-config.yaml` - Pre-commit hooks configuration
@@ -40,13 +40,13 @@ test: ## Run all tests
40
40
  python3 -m pytest tests/ -v
41
41
 
42
42
  test-unit: ## Run unit tests only
43
- python3 -m pytest tests/unit/ -v -m "unit"
43
+ python3 -m pytest tests/unit/ -v
44
44
 
45
45
  test-integration: ## Run integration tests only
46
- python3 -m pytest tests/integration/ -v -m "integration"
46
+ python3 -m pytest tests/integration/ -v
47
47
 
48
- test-slow: ## Run slow tests
49
- python3 -m pytest tests/ -v -m "slow"
48
+ test-slow: ## Run all tests (no selective marking allowed)
49
+ python3 -m pytest tests/ -v
50
50
 
51
51
  test-fast: ## Run all tests with parallel execution (optimized for Python 3.8-3.10)
52
52
  python3 -m pytest tests/ -n auto -q
@@ -57,8 +57,8 @@ test-unit-fast: ## Run unit tests with parallel execution (2-5 seconds)
57
57
  test-integration-fast: ## Run integration tests with parallel execution
58
58
  python3 -m pytest tests/integration/ -n auto -q
59
59
 
60
- test-critical: ## Run critical path tests
61
- python3 -m pytest tests/ -v -m "critical"
60
+ test-critical: ## Run all tests (no selective marking allowed)
61
+ python3 -m pytest tests/ -v
62
62
 
63
63
  coverage: ## Run tests with coverage report
64
64
  python3 -m pytest tests/ --cov=src/awsquery --cov-report=term-missing --cov-report=html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awsquery
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Advanced CLI tool for querying AWS APIs with flexible filtering and automatic parameter resolution
5
5
  Author-email: Florian Motlik <flo@flomotlik.me>
6
6
  License: MIT
@@ -81,9 +81,9 @@ the data you need during review, debugging or development.
81
81
  - **Flexible Filtering**: Multi-level filtering with `--` separators for resource, value, and column filters
82
82
  - **Partial Matching**: All filters use case-insensitive partial matching (both value and column filters)
83
83
  - **Keys Discovery**: Show all available fields from any API response with `-k`/`--keys` (fixed to show keys from successful responses)
84
- - **Debug Mode**: Comprehensive debug output with `-d`/`--debug`
85
- - **Security Validation**: Enforces ReadOnly AWS policy with wildcard pattern matching
86
- - **Auto-completion**: Tab completion for AWS services and actions (filtered by security policy)
84
+ - **Debug Mode**: Comprehensive debug output with `-d`/`--debug` featuring structured output with timestamps and DebugContext tracking
85
+ - **Security Validation**: Enforces ReadOnly AWS operations with comprehensive validation
86
+ - **Smart Auto-completion**: Enhanced tab completion with split matching and prefix priority for AWS services and actions
87
87
  - **Smart Parameter Extraction**: Handles both specific fields and standard AWS field patterns (Name, Id, Arn)
88
88
  - **Intelligent Response Processing**: Clean extraction of list data, ignoring metadata
89
89
  - **Tabular Output**: Customizable column display with automatic filtering
@@ -91,6 +91,8 @@ the data you need during review, debugging or development.
91
91
  - **Region/Profile Support**: AWS CLI-compatible `--region` and `--profile` arguments for session management
92
92
  - **Tag Transformation**: Automatic conversion of AWS Tags list to key-value pairs for better readability
93
93
  - **Default Column Filters**: Configuration-based default columns for common AWS queries
94
+ - **Parameter Passing**: Direct parameter passing to AWS APIs with `-p`/`--parameter` for advanced use cases
95
+ - **Hint-Based Resolution**: Function selection hints with `-i`/`--input` for multi-step calls, including field extraction targeting
94
96
 
95
97
  ## Installation
96
98
 
@@ -138,13 +140,20 @@ After adding the appropriate line to your shell configuration, restart your shel
138
140
  source ~/.bashrc # or ~/.zshrc, etc.
139
141
  ```
140
142
 
141
- Now you can use tab completion:
143
+ Now you can use enhanced tab completion with smart matching:
142
144
  ```bash
143
145
  awsquery <TAB> # Shows available services
144
146
  awsquery ec2 <TAB> # Shows available ec2 actions
145
147
  awsquery s3 list-<TAB> # Shows s3 list actions
148
+ awsquery ec2 desc-inst<TAB> # Smart completion: "desc-inst" matches "describe-instances"
149
+ awsquery cloudformation des-sta<TAB> # Matches "describe-stacks"
146
150
  ```
147
151
 
152
+ The autocomplete system now features:
153
+ - **Split matching**: "desc-inst" matches "describe-instances"
154
+ - **Prefix priority**: Exact prefix matches are prioritized over substring matches
155
+ - **Security filtering**: Only shows ReadOnly operations
156
+
148
157
  ## Usage
149
158
 
150
159
  ### Basic Query
@@ -177,14 +186,15 @@ awsquery --keys s3 list-buckets
177
186
  # List available services
178
187
  awsquery
179
188
 
180
- # Debug mode for troubleshooting
189
+ # Debug mode for troubleshooting with enhanced DebugContext output
190
+ # Shows structured debug information with timestamps and execution flow
181
191
  awsquery -d ec2 describe-instances
182
192
  ```
183
193
 
184
194
  ## Command Structure
185
195
 
186
196
  ```
187
- awsquery [-j|--json] [-k|--keys] [-d|--debug] [--region REGION] [--profile PROFILE] SERVICE ACTION [VALUE_FILTERS...] [-- TABLE_OUTPUT_FILTERS...]
197
+ awsquery [-j|--json] [-k|--keys] [-d|--debug] [-p PARAM] [-i HINT] [--region REGION] [--profile PROFILE] SERVICE ACTION [VALUE_FILTERS...] [-- TABLE_OUTPUT_FILTERS...]
188
198
  ```
189
199
 
190
200
  - **SERVICE**: AWS service name (ec2, s3, iam, etc.)
@@ -194,17 +204,18 @@ awsquery [-j|--json] [-k|--keys] [-d|--debug] [--region REGION] [--profile PROFI
194
204
  - **-j, --json**: Output results in JSON format instead of table
195
205
  - **-k, --keys**: Show all available keys for the command
196
206
  - **-d, --debug**: Enable debug output for troubleshooting
207
+ - **-p, --parameter PARAM**: Pass parameters directly to AWS API (key=value format)
208
+ - **-i, --input HINT**: Hint for multi-step function selection (e.g., "desc-clus" or "desc-clus:fieldname")
197
209
  - **--region REGION**: AWS region to use for requests (e.g., us-west-2)
198
210
  - **--profile PROFILE**: AWS profile to use from ~/.aws/credentials
199
211
 
200
212
  ## Security
201
213
 
202
- - **ReadOnly Enforcement**: Only AWS ReadOnly policy actions are permitted
214
+ - **ReadOnly Enforcement**: Only AWS ReadOnly operations are permitted
203
215
  - **Input Sanitization**: Prevents injection attacks through parameter validation
204
- - **Policy Validation**: All actions validated against policy.json before execution
216
+ - **Operation Validation**: All actions validated before execution
205
217
  - **Wildcard Matching**: Supports AWS IAM wildcard patterns (e.g., `ec2:Describe*`)
206
218
  - **Session Isolation**: Each profile/region maintains separate boto3 sessions
207
- - **Automatic Policy Updates**: Can fetch latest AWS ReadOnly policy via `make update-policy`
208
219
  - **Security Testing**: Comprehensive test suite validates security constraints
209
220
 
210
221
  ## Examples
@@ -226,13 +237,16 @@ awsquery s3 list-buckets backup
226
237
  # Filters: "prod" in stack data, columns containing "Created" or "StackName"
227
238
  awsquery cloudformation describe-stack-events prod -- Created StackName
228
239
 
240
+ # Targeted field extraction with hint for multi-step calls
241
+ awsquery elbv2 describe-tags -i desc-clus:clusterarn prod
242
+
229
243
  # Discover all available keys
230
244
  awsquery -k ec2 describe-instances
231
245
 
232
246
  # JSON output with filtering (partial column name matching)
233
247
  awsquery -j ec2 describe-instances prod -- InstanceId State.Name
234
248
 
235
- # Debug mode for troubleshooting
249
+ # Debug mode with enhanced output showing parameter resolution and API calls
236
250
  awsquery -d cloudformation describe-stack-resources workers -- EKS
237
251
 
238
252
  # Use specific AWS region
@@ -247,6 +261,47 @@ awsquery --region us-east-2 --profile dev ec2 describe-vpcs
247
261
  # View transformed tags (partial match on column names)
248
262
  # Shows any column containing "Tags.Name" or "Tags.Environment"
249
263
  awsquery ec2 describe-instances -- Tags.Name Tags.Environment
264
+
265
+ # CloudTrail LookupEvents with complex parameter structures
266
+ # Filter events by event name with automatic type conversion
267
+ awsquery cloudtrail lookup-events -p LookupAttributes=AttributeKey=EventName,AttributeValue=ConsoleLogin
268
+
269
+ # Multiple CloudTrail attributes using semicolon separation
270
+ awsquery cloudtrail lookup-events -p LookupAttributes=AttributeKey=EventName,AttributeValue=AssumeRole;AttributeKey=Username,AttributeValue=admin
271
+
272
+ # CloudTrail with time range and resource type filtering
273
+ awsquery cloudtrail lookup-events -p StartTime=2024-01-01 -p EndTime=2024-01-31 -p LookupAttributes=AttributeKey=ResourceType,AttributeValue=AWS::S3::Bucket
274
+
275
+ ### Advanced Parameter Passing
276
+
277
+ # Pass specific parameters to AWS API calls
278
+ awsquery ec2 describe-instances -p MaxResults=10
279
+ awsquery ec2 describe-instances -p InstanceIds=i-123,i-456 -p MaxResults=5
280
+
281
+ # Complex parameter structures for SSM with automatic type conversion
282
+ awsquery ssm describe-parameters -p ParameterFilters=Key=Name,Option=Contains,Values=Ubuntu,2024
283
+
284
+ # Multiple complex structures using semicolon separation
285
+ awsquery ssm describe-parameters -p ParameterFilters=Key=Name,Option=Contains,Values=Ubuntu;Key=Type,Option=Equal,Values=String
286
+
287
+ # Complex structures with nested arrays and type conversion
288
+ awsquery ec2 describe-instances -p Filters=Name=instance-state-name,Values=running,stopped;Name=tag:Environment,Values=prod,staging
289
+
290
+ ### Hint-Based Multi-Step Resolution
291
+
292
+ # Use hints to guide automatic parameter resolution
293
+ # When describe-tags needs resource ARNs, hint at using describe-clusters
294
+ awsquery elbv2 describe-tags -i desc-clus prod
295
+
296
+ # CloudFormation stack resources with hint for stack selection
297
+ awsquery cloudformation describe-stack-resources -i desc-stacks production
298
+
299
+ # ECS service details with task definition hint
300
+ awsquery ecs describe-services -i desc-task web-service
301
+
302
+ # Field-specific extraction with function:field format
303
+ awsquery elbv2 describe-tags -i desc-clus:clusterarn prod # Extract ClusterArn specifically
304
+ awsquery eks describe-fargate-profile -i desc-clus:rolearn # Extract RoleArn instead of default
250
305
  ```
251
306
 
252
307
  ## Configuration
@@ -261,8 +316,9 @@ Ensure AWS credentials are configured via:
261
316
 
262
317
  ### Default Filters Configuration
263
318
 
264
- The tool uses `default_filters.yaml` to define default columns for common queries. This file is loaded from the package directory and will
265
- provide you with standard columns if you don't add any.
319
+ The tool uses `default_filters.yaml` to define default columns for common queries. This comprehensive configuration file (3000+ lines)
320
+ provides extensive pre-configured filters for dozens of AWS services, loaded from the package directory to provide you with standard
321
+ columns if you don't add any.
266
322
 
267
323
  Example configuration:
268
324
  ```yaml
@@ -299,31 +355,27 @@ make coverage
299
355
  # Run specific test categories
300
356
  make test-unit
301
357
  make test-integration
302
- make test-critical # Run critical path tests only
358
+ make test-critical # Run all tests (comprehensive test suite)
303
359
 
304
360
  # Code formatting and linting
305
361
  make format
306
362
  make format-check # Check without modifying
307
363
  make lint
308
- make type-check
364
+ make type-check # Run mypy type checking
309
365
  make security-check # Run security analysis
310
366
 
367
+ # Mutation testing
368
+ make mutmut # Run mutation tests
369
+ make mutmut-results # Show mutation test results
370
+ make mutmut-html # Generate HTML mutation test report
371
+
311
372
  # Pre-commit hooks
312
373
  make pre-commit # Run all pre-commit hooks
313
374
 
314
375
  # Continuous Integration
315
- make ci # Run all CI checks
376
+ make ci # Run comprehensive CI pipeline (tests, linting, type-check, security)
316
377
  ```
317
378
 
318
- ### Policy Management
319
-
320
- ```bash
321
- # Update policy.json with latest AWS ReadOnly managed policy
322
- make update-policy
323
-
324
- # Validate policy.json structure
325
- make validate-policy
326
- ```
327
379
 
328
380
  ### Docker Usage
329
381
 
@@ -433,6 +485,52 @@ awsquery cloudformation describe-stack-events production
433
485
  awsquery cloudformation describe-stack-resources prod -- Lambda
434
486
  ```
435
487
 
488
+ ### Parameter Passing (`-p`/`--parameter`)
489
+
490
+ Pass parameters directly to AWS API calls using the `-p` flag. This is useful for fine-tuning API behavior:
491
+
492
+ ```bash
493
+ # Limit results for large responses
494
+ awsquery ec2 describe-instances -p MaxResults=20
495
+
496
+ # Filter specific resources by ID
497
+ awsquery ec2 describe-instances -p InstanceIds=i-1234567890abcdef0,i-0987654321fedcba0
498
+
499
+ # Multiple parameters (can use multiple -p flags)
500
+ awsquery elbv2 describe-load-balancers -p PageSize=10 -p Names=my-alb
501
+
502
+ # Complex parameter structures (for APIs like SSM)
503
+ awsquery ssm describe-parameters -p ParameterFilters=Key=Name,Option=Contains,Values=Ubuntu
504
+ ```
505
+
506
+ **Parameter Format:**
507
+ - Simple: `Key=Value`
508
+ - Lists: `Key=Value1,Value2,Value3`
509
+ - Complex structures: Use semicolons to separate multiple objects (e.g., `Key1=Val1,Val2;Key2=Val3`)
510
+ - Type conversion: Numbers and booleans are automatically converted
511
+ - Nested structures: Comma-separated values within objects, semicolon-separated objects
512
+ - CloudTrail example: `LookupAttributes=AttributeKey=EventName,AttributeValue=Login;AttributeKey=Username,AttributeValue=admin`
513
+
514
+ ### Hint-Based Resolution (`-i`/`--input`)
515
+
516
+ Guide multi-step parameter resolution with function hints:
517
+
518
+ ```bash
519
+ # Basic function hint - guides which list operation to use
520
+ awsquery cloudformation describe-stack-resources -i list-sta production
521
+
522
+ # Field extraction hint - specify exact field to extract
523
+ awsquery elbv2 describe-tags -i desc-clus:clusterarn prod
524
+
525
+ # Override default field selection
526
+ awsquery eks describe-fargate-profile -i desc-clus:rolearn my-cluster
527
+ ```
528
+
529
+ **Key Features:**
530
+ - **Smart matching**: "desc-inst" matches "describe-instances"
531
+ - **Field targeting**: Use `function:field` to extract specific fields
532
+ - **Automatic fallback**: Uses standard heuristics when no field specified
533
+
436
534
  ### Filtering Strategies
437
535
 
438
536
  ```bash
@@ -473,7 +571,7 @@ awsquery s3 list-buckets backup -- Name Creation
473
571
  **"Access Denied" errors**
474
572
  - Ensure your AWS credentials have ReadOnly permissions
475
573
  - Check if using the correct profile with `--profile`
476
- - Verify the action is in the ReadOnly policy
574
+ - Verify the operation is permitted
477
575
 
478
576
  **"Parameter validation failed"**
479
577
  - Some APIs require specific parameters
@@ -487,7 +585,7 @@ awsquery s3 list-buckets backup -- Name Creation
487
585
 
488
586
  ## Requirements
489
587
 
490
- The tool requires a `policy.json` file containing the AWS ReadOnly policy for security validation. This file is included automatically when installing via pip. The package dependencies are:
588
+ The package dependencies are:
491
589
 
492
590
  - boto3>=1.35.0
493
591
  - botocore>=1.35.0