@esotech/contextuate 2.1.0 → 2.1.1
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/dist/commands/install.js +8 -24
- package/package.json +2 -2
- package/dist/templates/skills/pythia.md +0 -37
- package/dist/templates/templates/standards/go.standards.md +0 -167
- package/dist/templates/templates/standards/java.standards.md +0 -167
- package/dist/templates/templates/standards/javascript.standards.md +0 -292
- package/dist/templates/templates/standards/php.standards.md +0 -181
- package/dist/templates/templates/standards/python.standards.md +0 -175
- package/dist/templates/tools/agent-creator.tool.md +0 -252
- package/dist/templates/tools/quickref.tool.md +0 -216
- package/dist/templates/tools/spawn.tool.md +0 -31
- package/dist/templates/tools/standards-detector.tool.md +0 -301
- package/dist/templates/version.json +0 -8
- /package/dist/templates/{skills → commands}/consult.md +0 -0
- /package/dist/templates/{skills → commands}/orchestrate.md +0 -0
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
# Standards Detector Tool
|
|
2
|
-
|
|
3
|
-
> **Type:** AI Tool Guide
|
|
4
|
-
> **Purpose:** Analyze project files to detect and document coding standards
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## When to Use This Tool
|
|
9
|
-
|
|
10
|
-
Use this tool when:
|
|
11
|
-
- Setting up Contextuate in an existing project
|
|
12
|
-
- User wants coding standards documented
|
|
13
|
-
- Standards need to be inferred from existing code
|
|
14
|
-
- Creating project-specific coding standards
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Input
|
|
19
|
-
|
|
20
|
-
**Required:** Access to project source files
|
|
21
|
-
|
|
22
|
-
**Optional:**
|
|
23
|
-
- Specific languages to analyze
|
|
24
|
-
- Specific directories to focus on
|
|
25
|
-
- Existing style config files (.eslintrc, .prettierrc, phpcs.xml, etc.)
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Process
|
|
30
|
-
|
|
31
|
-
### Step 1: Detect Languages
|
|
32
|
-
|
|
33
|
-
Scan project for source files and identify languages:
|
|
34
|
-
|
|
35
|
-
| Extension | Language |
|
|
36
|
-
|-----------|----------|
|
|
37
|
-
| `.php` | PHP |
|
|
38
|
-
| `.js`, `.jsx` | JavaScript |
|
|
39
|
-
| `.ts`, `.tsx` | TypeScript |
|
|
40
|
-
| `.py` | Python |
|
|
41
|
-
| `.go` | Go |
|
|
42
|
-
| `.rb` | Ruby |
|
|
43
|
-
| `.java` | Java |
|
|
44
|
-
| `.cs` | C# |
|
|
45
|
-
| `.rs` | Rust |
|
|
46
|
-
|
|
47
|
-
### Step 2: Check for Config Files
|
|
48
|
-
|
|
49
|
-
Look for existing style configuration:
|
|
50
|
-
|
|
51
|
-
| File | Tool | Language |
|
|
52
|
-
|------|------|----------|
|
|
53
|
-
| `.eslintrc*` | ESLint | JS/TS |
|
|
54
|
-
| `.prettierrc*` | Prettier | JS/TS/CSS |
|
|
55
|
-
| `phpcs.xml` | PHP_CodeSniffer | PHP |
|
|
56
|
-
| `.php-cs-fixer.php` | PHP CS Fixer | PHP |
|
|
57
|
-
| `pyproject.toml` | Black/Ruff | Python |
|
|
58
|
-
| `.editorconfig` | EditorConfig | All |
|
|
59
|
-
| `tslint.json` | TSLint | TypeScript |
|
|
60
|
-
| `.rubocop.yml` | RuboCop | Ruby |
|
|
61
|
-
|
|
62
|
-
If config files exist, extract rules from them first.
|
|
63
|
-
|
|
64
|
-
### Step 3: Analyze Sample Files
|
|
65
|
-
|
|
66
|
-
For each detected language, read 3-5 representative files:
|
|
67
|
-
- Prefer files in `src/`, `app/`, `lib/` directories
|
|
68
|
-
- Choose files with 50-200 lines (not too short, not too long)
|
|
69
|
-
- Include different file types (classes, utilities, controllers)
|
|
70
|
-
|
|
71
|
-
### Step 4: Detect Patterns
|
|
72
|
-
|
|
73
|
-
For each file, analyze:
|
|
74
|
-
|
|
75
|
-
#### Formatting
|
|
76
|
-
- **Indentation:** Count leading whitespace characters
|
|
77
|
-
- All tabs → tabs
|
|
78
|
-
- 2 spaces → 2-space indent
|
|
79
|
-
- 4 spaces → 4-space indent
|
|
80
|
-
- **Braces:** Check if `{` appears on same line or next line
|
|
81
|
-
- **Spacing:** Check patterns inside parentheses, after keywords
|
|
82
|
-
- **Semicolons (JS):** Present at end of statements?
|
|
83
|
-
- **Quotes (JS):** Single or double quotes predominant?
|
|
84
|
-
|
|
85
|
-
#### Naming
|
|
86
|
-
- **Classes:** PascalCase, snake_case, etc.
|
|
87
|
-
- **Functions:** camelCase, snake_case, etc.
|
|
88
|
-
- **Variables:** camelCase, snake_case, etc.
|
|
89
|
-
- **Constants:** UPPER_CASE, camelCase, etc.
|
|
90
|
-
|
|
91
|
-
#### Structure
|
|
92
|
-
- **Import organization:** Grouped? Alphabetized?
|
|
93
|
-
- **File organization:** Class structure patterns
|
|
94
|
-
|
|
95
|
-
#### Documentation
|
|
96
|
-
- **DocBlocks:** Present? Format?
|
|
97
|
-
- **Comments:** Inline style?
|
|
98
|
-
|
|
99
|
-
### Step 5: Resolve Conflicts
|
|
100
|
-
|
|
101
|
-
If patterns vary across files:
|
|
102
|
-
1. Count occurrences of each pattern
|
|
103
|
-
2. Use majority pattern (60%+ agreement)
|
|
104
|
-
3. Note inconsistencies for user review
|
|
105
|
-
4. Flag if no clear majority exists
|
|
106
|
-
|
|
107
|
-
### Step 6: Generate Standards Document
|
|
108
|
-
|
|
109
|
-
Use the appropriate template from `templates/standards/`:
|
|
110
|
-
- `php.standards.md` for PHP
|
|
111
|
-
- `javascript.standards.md` for JS/TS
|
|
112
|
-
|
|
113
|
-
Fill in detected values, replacing `{placeholders}`.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## Output
|
|
118
|
-
|
|
119
|
-
Create files in `docs/ai/standards/` (user-customizable location):
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
docs/ai/standards/
|
|
123
|
-
├── php.standards.md # If PHP detected
|
|
124
|
-
├── javascript.standards.md # If JS/TS detected
|
|
125
|
-
└── {language}.standards.md # For other languages
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
These user standards take priority over framework defaults in `docs/ai/.context/templates/standards/`.
|
|
129
|
-
See [coding-standards.md](../standards/coding-standards.md) for resolution order.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Analysis Checklist
|
|
134
|
-
|
|
135
|
-
### PHP Analysis
|
|
136
|
-
|
|
137
|
-
```php
|
|
138
|
-
// Check for:
|
|
139
|
-
// 1. Indentation
|
|
140
|
-
$line = " code"; // 4 spaces
|
|
141
|
-
$line = "\tcode"; // tab
|
|
142
|
-
|
|
143
|
-
// 2. Brace style
|
|
144
|
-
class Foo { // same-line
|
|
145
|
-
class Foo // next-line
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
// 3. Parentheses spacing
|
|
149
|
-
function foo( $param ) // spaces inside
|
|
150
|
-
function foo($param) // no spaces
|
|
151
|
-
|
|
152
|
-
// 4. Array syntax
|
|
153
|
-
$arr = array(); // long syntax
|
|
154
|
-
$arr = []; // short syntax
|
|
155
|
-
|
|
156
|
-
// 5. Visibility
|
|
157
|
-
public $prop; // explicit
|
|
158
|
-
var $prop; // implicit (old style)
|
|
159
|
-
|
|
160
|
-
// 6. Type hints
|
|
161
|
-
function foo( string $a ): int // yes
|
|
162
|
-
function foo( $a ) // no
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### JavaScript Analysis
|
|
166
|
-
|
|
167
|
-
```javascript
|
|
168
|
-
// Check for:
|
|
169
|
-
// 1. Semicolons
|
|
170
|
-
const x = 1; // with semicolon
|
|
171
|
-
const x = 1 // without
|
|
172
|
-
|
|
173
|
-
// 2. Quotes
|
|
174
|
-
'single quotes'
|
|
175
|
-
"double quotes"
|
|
176
|
-
|
|
177
|
-
// 3. Variable declaration
|
|
178
|
-
const x = 1; // const preferred
|
|
179
|
-
let x = 1; // let used
|
|
180
|
-
var x = 1; // var used (legacy)
|
|
181
|
-
|
|
182
|
-
// 4. Arrow functions
|
|
183
|
-
const fn = () => {}; // arrow
|
|
184
|
-
function fn() {} // declaration
|
|
185
|
-
|
|
186
|
-
// 5. Trailing commas
|
|
187
|
-
{ a: 1, b: 2, } // trailing
|
|
188
|
-
{ a: 1, b: 2 } // no trailing
|
|
189
|
-
|
|
190
|
-
// 6. Object shorthand
|
|
191
|
-
{ name: name } // verbose
|
|
192
|
-
{ name } // shorthand
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
## Example Output
|
|
198
|
-
|
|
199
|
-
After analyzing a PHP project:
|
|
200
|
-
|
|
201
|
-
```markdown
|
|
202
|
-
# PHP Coding Standards
|
|
203
|
-
|
|
204
|
-
> **Language:** PHP
|
|
205
|
-
> **Generated:** 2024-01-15
|
|
206
|
-
> **Detected from:** src/Services/, src/Controllers/
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## Formatting
|
|
211
|
-
|
|
212
|
-
### Indentation
|
|
213
|
-
- **Style:** tabs
|
|
214
|
-
- **Size:** 1 tab
|
|
215
|
-
|
|
216
|
-
### Braces
|
|
217
|
-
- **Classes/Functions:** same-line
|
|
218
|
-
- **Control structures:** same-line
|
|
219
|
-
|
|
220
|
-
### Spacing
|
|
221
|
-
- **Inside parentheses:** yes - `function( $param )`
|
|
222
|
-
- **After keywords:** yes - `if( $x )`
|
|
223
|
-
- **Array brackets:** no-spaces - `$arr['key']`
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Naming Conventions
|
|
228
|
-
|
|
229
|
-
### Classes
|
|
230
|
-
- **Style:** PascalCase
|
|
231
|
-
- **Example:** `UserService`, `PaymentController`
|
|
232
|
-
|
|
233
|
-
### Methods
|
|
234
|
-
- **Style:** camelCase
|
|
235
|
-
- **Example:** `getUserById()`, `processPayment()`
|
|
236
|
-
|
|
237
|
-
### Variables
|
|
238
|
-
- **Style:** snake_case
|
|
239
|
-
- **Example:** `$user_name`, `$is_active`
|
|
240
|
-
|
|
241
|
-
...
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
---
|
|
245
|
-
|
|
246
|
-
## Edge Cases
|
|
247
|
-
|
|
248
|
-
### Mixed Standards
|
|
249
|
-
If project has inconsistent standards:
|
|
250
|
-
1. Document the majority pattern
|
|
251
|
-
2. Add a note about inconsistencies
|
|
252
|
-
3. Suggest the user choose one
|
|
253
|
-
|
|
254
|
-
```markdown
|
|
255
|
-
> **Note:** Mixed indentation detected (60% tabs, 40% 2-space).
|
|
256
|
-
> Documenting tabs as primary. Consider standardizing.
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### No Clear Pattern
|
|
260
|
-
If no pattern emerges:
|
|
261
|
-
1. Leave placeholder in template
|
|
262
|
-
2. Note that manual input is needed
|
|
263
|
-
|
|
264
|
-
```markdown
|
|
265
|
-
### Variables
|
|
266
|
-
- **Style:** {inconsistent - needs manual specification}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Config File Conflicts
|
|
270
|
-
If config files disagree with actual code:
|
|
271
|
-
1. Prefer config file settings (they're intentional)
|
|
272
|
-
2. Note that code may not follow config
|
|
273
|
-
3. Suggest running linter to fix
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## Reporting
|
|
278
|
-
|
|
279
|
-
After generating standards, report:
|
|
280
|
-
|
|
281
|
-
1. Languages detected
|
|
282
|
-
2. Files analyzed
|
|
283
|
-
3. Config files found
|
|
284
|
-
4. Standards documents created
|
|
285
|
-
5. Any inconsistencies or manual input needed
|
|
286
|
-
|
|
287
|
-
```
|
|
288
|
-
Standards Detection Complete
|
|
289
|
-
============================
|
|
290
|
-
Languages: PHP, JavaScript
|
|
291
|
-
Files analyzed: 12
|
|
292
|
-
Config files: .eslintrc.js, .editorconfig
|
|
293
|
-
|
|
294
|
-
Created:
|
|
295
|
-
- docs/ai/standards/php.standards.md
|
|
296
|
-
- docs/ai/standards/javascript.standards.md
|
|
297
|
-
|
|
298
|
-
Notes:
|
|
299
|
-
- PHP: Inconsistent variable naming (70% snake_case)
|
|
300
|
-
- JS: No semicolons detected, matches .eslintrc
|
|
301
|
-
```
|
|
File without changes
|
|
File without changes
|