@netoalmanca/advpl-sensei 1.1.0
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/agents/changelog-generator.md +63 -0
- package/agents/code-generator.md +215 -0
- package/agents/code-reviewer.md +145 -0
- package/agents/debugger.md +83 -0
- package/agents/doc-generator.md +67 -0
- package/agents/docs-reference.md +86 -0
- package/agents/migrator.md +84 -0
- package/agents/process-consultant.md +97 -0
- package/agents/refactorer.md +75 -0
- package/agents/sx-configurator.md +67 -0
- package/commands/changelog.md +66 -0
- package/commands/diagnose.md +67 -0
- package/commands/docs.md +81 -0
- package/commands/document.md +67 -0
- package/commands/explain.md +60 -0
- package/commands/generate.md +111 -0
- package/commands/migrate.md +81 -0
- package/commands/process.md +111 -0
- package/commands/refactor.md +65 -0
- package/commands/review.md +60 -0
- package/commands/sxgen.md +98 -0
- package/commands/test.md +103 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +143 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
- package/skills/advpl-code-generation/SKILL.md +163 -0
- package/skills/advpl-code-generation/patterns-fwformbrowse.md +485 -0
- package/skills/advpl-code-generation/patterns-jobs.md +519 -0
- package/skills/advpl-code-generation/patterns-mvc.md +765 -0
- package/skills/advpl-code-generation/patterns-pontos-entrada.md +708 -0
- package/skills/advpl-code-generation/patterns-rest.md +974 -0
- package/skills/advpl-code-generation/patterns-soap.md +639 -0
- package/skills/advpl-code-generation/patterns-treport.md +481 -0
- package/skills/advpl-code-generation/patterns-workflow.md +779 -0
- package/skills/advpl-code-generation/templates-classes.md +1096 -0
- package/skills/advpl-code-review/SKILL.md +72 -0
- package/skills/advpl-code-review/rules-best-practices.md +444 -0
- package/skills/advpl-code-review/rules-modernization.md +290 -0
- package/skills/advpl-code-review/rules-performance.md +333 -0
- package/skills/advpl-code-review/rules-security.md +302 -0
- package/skills/advpl-debugging/SKILL.md +265 -0
- package/skills/advpl-debugging/common-errors.md +1124 -0
- package/skills/advpl-debugging/performance-tips.md +768 -0
- package/skills/advpl-refactoring/SKILL.md +139 -0
- package/skills/advpl-to-tlpp-migration/SKILL.md +293 -0
- package/skills/advpl-to-tlpp-migration/migration-checklist.md +122 -0
- package/skills/advpl-to-tlpp-migration/migration-rules.md +265 -0
- package/skills/changelog-patterns/SKILL.md +99 -0
- package/skills/code-explanation/SKILL.md +66 -0
- package/skills/documentation-patterns/SKILL.md +172 -0
- package/skills/embedded-sql/SKILL.md +379 -0
- package/skills/probat-testing/SKILL.md +226 -0
- package/skills/probat-testing/patterns-unit-tests.md +614 -0
- package/skills/protheus-business/SKILL.md +92 -0
- package/skills/protheus-business/modulo-compras.md +780 -0
- package/skills/protheus-business/modulo-contabilidade.md +874 -0
- package/skills/protheus-business/modulo-estoque.md +876 -0
- package/skills/protheus-business/modulo-faturamento.md +800 -0
- package/skills/protheus-business/modulo-financeiro.md +1015 -0
- package/skills/protheus-business/modulo-fiscal.md +749 -0
- package/skills/protheus-business/modulo-manutencao.md +848 -0
- package/skills/protheus-business/modulo-pcp.md +743 -0
- package/skills/protheus-reference/SKILL.md +119 -0
- package/skills/protheus-reference/native-functions.md +7029 -0
- package/skills/protheus-reference/rest-api-reference.md +1758 -0
- package/skills/protheus-reference/restricted-functions.md +265 -0
- package/skills/protheus-reference/sx-dictionary.md +854 -0
- package/skills/sx-configuration/SKILL.md +184 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate ADVPL/TLPP code - functions, classes, MVC structures, REST APIs, Web Services, and entry points for TOTVS Protheus
|
|
3
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, Skill, WebSearch, WebFetch
|
|
4
|
+
argument-hint: "<type> [name] [--module module]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /advpl-specialist:generate
|
|
8
|
+
|
|
9
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations and suggestions to the user's language. Code comments may remain in English or match the user's language.
|
|
10
|
+
|
|
11
|
+
Generate new ADVPL or TLPP code following Protheus conventions and best practices.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:generate <type> [name] [--module <module>]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Types
|
|
20
|
+
|
|
21
|
+
| Type | Description | Output |
|
|
22
|
+
|------|------------|--------|
|
|
23
|
+
| `function` | User Function | .prw file |
|
|
24
|
+
| `class` | TLPP class | .tlpp file |
|
|
25
|
+
| `mvc` | MVC structure (MenuDef, ModelDef, ViewDef) | .prw file |
|
|
26
|
+
| `rest` | REST API endpoint | .prw or .tlpp file |
|
|
27
|
+
| `ponto-entrada` | Entry point | .prw file |
|
|
28
|
+
| `webservice` | SOAP Web Service | .prw file |
|
|
29
|
+
| `treport` | TReport report | .prw file |
|
|
30
|
+
| `fwformbrowse` | FWFormBrowse/FWExecView screen | .prw file |
|
|
31
|
+
| `job` | Batch job / scheduled process | .prw or .tlpp file |
|
|
32
|
+
| `workflow` | Approval workflow process | .prw file |
|
|
33
|
+
|
|
34
|
+
## Options
|
|
35
|
+
|
|
36
|
+
| Flag | Description | Default |
|
|
37
|
+
|------|------------|---------|
|
|
38
|
+
| `--module` | Module prefix (COM, FAT, FIN, etc.) | Ask user |
|
|
39
|
+
| `--lang` | Language: advpl or tlpp | advpl for function/mvc/pe, tlpp for class |
|
|
40
|
+
| `--output` | Output file path | Auto-generated based on name |
|
|
41
|
+
|
|
42
|
+
## Process
|
|
43
|
+
|
|
44
|
+
**MANDATORY: Always enter planning mode before generating code. Never skip planning.**
|
|
45
|
+
|
|
46
|
+
### Planning Phase (REQUIRED)
|
|
47
|
+
1. **Parse arguments** - Extract type, name, and flags
|
|
48
|
+
2. **Ask missing details** - If name or module not provided, ask the user
|
|
49
|
+
3. **Ask business requirements** - What should the code do?
|
|
50
|
+
4. **Load skill** - Invoke `advpl-code-generation` skill
|
|
51
|
+
5. **Load patterns** - Read appropriate supporting file for the type
|
|
52
|
+
6. **Search TDN for entry points** - **If the type is `ponto-entrada`**, ALWAYS search the TDN (TOTVS Developer Network) for the entry point name before generating code. Use `WebSearch` to find the official documentation page (e.g., search for `"ENTRY_POINT_NAME site:tdn.totvs.com"`). Extract from the TDN page: PARAMIXB parameters (types, positions, descriptions), expected return type and value, which standard routine calls this entry point, and any caveats or version-specific behavior. This ensures the generated code uses the correct parameters and return type as defined by TOTVS.
|
|
53
|
+
7. **Enter plan mode** - Use `EnterPlanMode` to create a structured implementation plan
|
|
54
|
+
8. **Present plan** - Show the user a clear plan including:
|
|
55
|
+
- File(s) to be created (name, path, extension)
|
|
56
|
+
- Code structure (functions, classes, methods to implement)
|
|
57
|
+
- Includes and dependencies
|
|
58
|
+
- Key patterns to apply (MVC, REST, SOAP, etc.)
|
|
59
|
+
- Naming conventions to follow (Hungarian notation, module prefix)
|
|
60
|
+
- Error handling and DB operation patterns
|
|
61
|
+
- **For entry points:** TDN documentation found (PARAMIXB parameters, return type, calling routine)
|
|
62
|
+
9. **Wait for approval** - The user must approve the plan before any code is written. If the user requests changes, revise the plan.
|
|
63
|
+
10. **Exit plan mode** - Use `ExitPlanMode` after approval
|
|
64
|
+
|
|
65
|
+
### Implementation Phase (only after approval)
|
|
66
|
+
11. **Generate code** - Create complete, production-ready code following the approved plan
|
|
67
|
+
12. **Write file** - Save with correct extension (.prw or .tlpp)
|
|
68
|
+
13. **Report** - Show what was created and key decisions
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Create a User Function for billing module
|
|
74
|
+
/advpl-specialist:generate function FATA050 --module FAT
|
|
75
|
+
|
|
76
|
+
# Create a TLPP service class
|
|
77
|
+
/advpl-specialist:generate class PedidoService
|
|
78
|
+
|
|
79
|
+
# Create complete MVC CRUD
|
|
80
|
+
/advpl-specialist:generate mvc CadProduto --module EST
|
|
81
|
+
|
|
82
|
+
# Create a REST API endpoint
|
|
83
|
+
/advpl-specialist:generate rest ClienteAPI --lang tlpp
|
|
84
|
+
|
|
85
|
+
# Create an entry point
|
|
86
|
+
/advpl-specialist:generate ponto-entrada MT100LOK
|
|
87
|
+
|
|
88
|
+
# Create a SOAP Web Service
|
|
89
|
+
/advpl-specialist:generate webservice WSPedido
|
|
90
|
+
|
|
91
|
+
# Create a TReport report
|
|
92
|
+
/advpl-specialist:generate treport RelProdutos --module EST
|
|
93
|
+
|
|
94
|
+
# Create a FWFormBrowse screen
|
|
95
|
+
/advpl-specialist:generate fwformbrowse CadFornecedores --module COM
|
|
96
|
+
|
|
97
|
+
# Create a batch processing job
|
|
98
|
+
/advpl-specialist:generate job JobProcessaNotas --module FAT
|
|
99
|
+
|
|
100
|
+
# Create an approval workflow
|
|
101
|
+
/advpl-specialist:generate workflow AprovacaoPedido --module COM
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Output
|
|
105
|
+
|
|
106
|
+
A complete, compilable source file saved to the project directory with:
|
|
107
|
+
- Protheus.doc documentation header
|
|
108
|
+
- Proper includes/namespace declarations
|
|
109
|
+
- Full implementation following conventions
|
|
110
|
+
- Error handling
|
|
111
|
+
- Area save/restore for DB operations
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Migrate ADVPL procedural code to TLPP object-oriented code with classes, namespaces, and modern patterns
|
|
3
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, Skill, WebSearch, WebFetch
|
|
4
|
+
argument-hint: "<file.prw> [--output file.tlpp] [--dry-run]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /advpl-specialist:migrate
|
|
8
|
+
|
|
9
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations and suggestions to the user's language. Code comments may remain in English or match the user's language.
|
|
10
|
+
|
|
11
|
+
Convert ADVPL procedural code to TLPP with object-oriented patterns.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:migrate <file.prw> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Flag | Description | Default |
|
|
22
|
+
|------|------------|---------|
|
|
23
|
+
| `--output` | Output .tlpp file path | Same name with .tlpp extension |
|
|
24
|
+
| `--dry-run` | Show migration plan without generating files | false |
|
|
25
|
+
| `--keep-original` | Keep the original .prw file | true |
|
|
26
|
+
| `--wrapper` | Generate backward compatibility wrapper | true |
|
|
27
|
+
| `--namespace` | Override namespace | Auto-detect from module |
|
|
28
|
+
|
|
29
|
+
## Process
|
|
30
|
+
|
|
31
|
+
**MANDATORY: Always enter planning mode before migrating code. Never skip planning.**
|
|
32
|
+
|
|
33
|
+
### Analysis Phase
|
|
34
|
+
1. **Read source file** - Read the .prw file completely
|
|
35
|
+
2. **Analyze structure** - Identify functions, dependencies, shared variables
|
|
36
|
+
3. **Search for callers** - Grep codebase for `u_FunctionName` references
|
|
37
|
+
|
|
38
|
+
### Planning Phase (REQUIRED)
|
|
39
|
+
4. **Load skill** - Invoke `advpl-to-tlpp-migration` skill for rules and checklist
|
|
40
|
+
5. **Enter plan mode** - Use `EnterPlanMode` to create a structured migration plan
|
|
41
|
+
6. **Design class structure** - Map functions to classes and methods
|
|
42
|
+
7. **Present plan** - Show the user a detailed migration plan including:
|
|
43
|
+
- Source file analysis (functions found, dependencies, shared variables)
|
|
44
|
+
- External callers that will be impacted
|
|
45
|
+
- Target class structure (class name, namespace, properties, methods)
|
|
46
|
+
- Mapping: which function becomes which method (public/private)
|
|
47
|
+
- Private/Public variables to convert to class properties
|
|
48
|
+
- Includes to update (TOTVS.CH -> tlpp-core.th, etc.)
|
|
49
|
+
- Whether a backward compatibility wrapper is needed
|
|
50
|
+
- Any risks or breaking changes
|
|
51
|
+
8. **Wait for approval** - The user must approve the plan before any code is written. If the user requests changes, revise the plan.
|
|
52
|
+
9. **If --dry-run** - Stop here after showing the plan
|
|
53
|
+
10. **Exit plan mode** - Use `ExitPlanMode` after approval
|
|
54
|
+
|
|
55
|
+
### Implementation Phase (only after approval)
|
|
56
|
+
11. **Execute migration** - Generate .tlpp file(s) following the approved plan and `advpl-to-tlpp-migration` skill
|
|
57
|
+
12. **Generate wrapper** - Create backward compatibility .prw wrapper if --wrapper
|
|
58
|
+
13. **Run checklist** - Validate against migration-checklist.md
|
|
59
|
+
14. **Report** - Show summary of changes
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Migrate a file (shows plan first, then generates)
|
|
65
|
+
/advpl-specialist:migrate src/FATA001.prw
|
|
66
|
+
|
|
67
|
+
# Preview migration without generating files
|
|
68
|
+
/advpl-specialist:migrate src/FATA001.prw --dry-run
|
|
69
|
+
|
|
70
|
+
# Specify output path and namespace
|
|
71
|
+
/advpl-specialist:migrate src/FATA001.prw --output src/tlpp/PedidoService.tlpp --namespace mycompany.faturamento
|
|
72
|
+
|
|
73
|
+
# Migrate without backward compatibility wrapper
|
|
74
|
+
/advpl-specialist:migrate src/FATA001.prw --wrapper false
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Output
|
|
78
|
+
|
|
79
|
+
- `.tlpp` file with migrated class-based code
|
|
80
|
+
- Optional `.prw` wrapper for backward compatibility
|
|
81
|
+
- Migration summary with what changed and why
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Consult Protheus ERP business processes, module workflows, routines and integrations
|
|
3
|
+
allowed-tools: Read, Glob, Grep, WebSearch, WebFetch, Skill, Bash, EnterPlanMode, ExitPlanMode, browser_navigate, browser_snapshot, browser_take_screenshot, browser_fill_form, browser_click, browser_close
|
|
4
|
+
argument-hint: "<process|routine|module> [--type process|routine|module|integration]"
|
|
5
|
+
agent: process-consultant
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# /advpl-specialist:process
|
|
9
|
+
|
|
10
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations, process descriptions, and references to the user's language.
|
|
11
|
+
|
|
12
|
+
Consult Protheus ERP business processes, module workflows, routines, and integrations.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
/advpl-specialist:process <query> [options]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Options
|
|
21
|
+
|
|
22
|
+
| Flag | Description | Default |
|
|
23
|
+
|------|------------|---------|
|
|
24
|
+
| `--type` | Query type: `process`, `routine`, `module`, `integration` | auto-detect |
|
|
25
|
+
|
|
26
|
+
## Process
|
|
27
|
+
|
|
28
|
+
1. **Load skill** - Invoke `protheus-business` skill
|
|
29
|
+
2. **Parse query** - Extract search term and options
|
|
30
|
+
3. **Classify query type** - If `--type` not specified, auto-detect:
|
|
31
|
+
- Contains routine code (e.g. MATA410, FINA040) -> routine
|
|
32
|
+
- Contains module name (Compras, Faturamento, Estoque, etc.) -> module
|
|
33
|
+
- Contains two module names or keywords like "integracao" / "integration" -> integration
|
|
34
|
+
- Otherwise -> process
|
|
35
|
+
4. **Search local reference** - Check protheus-business skill module files (modulo-compras.md, modulo-estoque.md, etc.)
|
|
36
|
+
5. **Search TDN** - If not found locally, search TDN online:
|
|
37
|
+
- Process: `site:tdn.totvs.com "<process>" protheus fluxo`
|
|
38
|
+
- Routine: `site:tdn.totvs.com "<ROUTINE_CODE>" rotina`
|
|
39
|
+
- Module: `site:tdn.totvs.com "<module>" modulo protheus`
|
|
40
|
+
- Integration: `site:tdn.totvs.com "<moduleA>" "<moduleB>" integracao`
|
|
41
|
+
6. **Playwright fallback** - If WebSearch/WebFetch fail:
|
|
42
|
+
- If URL available: `browser_navigate` -> `browser_snapshot` -> `browser_take_screenshot` if needed
|
|
43
|
+
- If no URL: `browser_navigate` to `https://tdn.totvs.com` -> `browser_fill_form` search -> `browser_click` submit -> `browser_snapshot` results -> navigate to best result
|
|
44
|
+
- **Always** `browser_close` when finished to release resources
|
|
45
|
+
7. **Deliver answer** - Format response based on query type
|
|
46
|
+
|
|
47
|
+
## Response Format
|
|
48
|
+
|
|
49
|
+
Adaptive based on query type:
|
|
50
|
+
|
|
51
|
+
**Process query:**
|
|
52
|
+
- Description of the process
|
|
53
|
+
- Step-by-step flow with routines and tables at each step
|
|
54
|
+
- Integrations with other modules
|
|
55
|
+
- Available entry points
|
|
56
|
+
|
|
57
|
+
**Routine query:**
|
|
58
|
+
- What the routine does
|
|
59
|
+
- Tables it reads/writes
|
|
60
|
+
- MV parameters it uses
|
|
61
|
+
- Which process it belongs to
|
|
62
|
+
- Available entry points
|
|
63
|
+
|
|
64
|
+
**Module query:**
|
|
65
|
+
- Module overview
|
|
66
|
+
- Main tables
|
|
67
|
+
- Main routines
|
|
68
|
+
- Key business processes
|
|
69
|
+
- Integrations with other modules
|
|
70
|
+
|
|
71
|
+
**Integration query:**
|
|
72
|
+
- Data flow between modules
|
|
73
|
+
- Linking tables
|
|
74
|
+
- Routines involved at each side
|
|
75
|
+
- Direction of data flow
|
|
76
|
+
|
|
77
|
+
## Cross-References
|
|
78
|
+
|
|
79
|
+
When the user needs more detail, load additional skills:
|
|
80
|
+
- **protheus-reference** - for native function details (syntax, parameters, return values)
|
|
81
|
+
- **advpl-code-generation** - for code examples and implementation patterns
|
|
82
|
+
- **embedded-sql** - for query examples using Embedded SQL
|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Understand a business process
|
|
88
|
+
/advpl-specialist:process fluxo de compras
|
|
89
|
+
|
|
90
|
+
# Look up a specific routine
|
|
91
|
+
/advpl-specialist:process MATA410
|
|
92
|
+
|
|
93
|
+
# Understand a module
|
|
94
|
+
/advpl-specialist:process modulo Faturamento --type module
|
|
95
|
+
|
|
96
|
+
# Understand integration between modules
|
|
97
|
+
/advpl-specialist:process integracao Compras Estoque --type integration
|
|
98
|
+
|
|
99
|
+
# Ask in natural language
|
|
100
|
+
/advpl-specialist:process como funciona o processo de faturamento no Protheus?
|
|
101
|
+
|
|
102
|
+
# Look up financial process
|
|
103
|
+
/advpl-specialist:process contas a pagar
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Output
|
|
107
|
+
|
|
108
|
+
- Clear, structured explanation adapted to query type
|
|
109
|
+
- References to routines, tables, and entry points
|
|
110
|
+
- Source citation (local reference or TDN)
|
|
111
|
+
- Suggestions for related skills when further detail is needed
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Refactor ADVPL/TLPP code - extract functions, simplify logic, remove dead code, improve naming
|
|
3
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, Skill, WebSearch, WebFetch
|
|
4
|
+
argument-hint: "<file> [--dry-run]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English.
|
|
8
|
+
|
|
9
|
+
# /advpl-specialist:refactor
|
|
10
|
+
|
|
11
|
+
Analyze and refactor ADVPL/TLPP code to improve structure without changing behavior.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:refactor <target> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
| Flag | Description | Default |
|
|
22
|
+
|------|------------|---------|
|
|
23
|
+
| `--dry-run` | Show suggestions without applying changes | false |
|
|
24
|
+
|
|
25
|
+
## Refactoring Patterns
|
|
26
|
+
|
|
27
|
+
| ID | Pattern | Risk |
|
|
28
|
+
|----|---------|------|
|
|
29
|
+
| RF-001 | Extract Function (>100 lines) | Low |
|
|
30
|
+
| RF-002 | Simplify Conditionals (>3 levels) | Low |
|
|
31
|
+
| RF-003 | Remove Dead Code | Low |
|
|
32
|
+
| RF-004 | Improve Naming (Hungarian notation) | Low |
|
|
33
|
+
| RF-005 | Eliminate Duplication | Medium |
|
|
34
|
+
| RF-006 | Reduce Parameters (>5 params) | Medium |
|
|
35
|
+
|
|
36
|
+
## Process
|
|
37
|
+
|
|
38
|
+
**MANDATORY: Always enter planning mode before applying changes. Never refactor without approval.**
|
|
39
|
+
|
|
40
|
+
1. **Parse arguments** — Identify target file(s) and flags
|
|
41
|
+
2. **Load refactoring skill** — Invoke `advpl-refactoring` skill
|
|
42
|
+
3. **Delegate to refactorer agent** — Pass target and options to the refactorer agent
|
|
43
|
+
4. **Present plan** — Structured list of refactorings with before/after for each
|
|
44
|
+
5. **Wait for approval** — User must approve before changes are applied
|
|
45
|
+
6. **Apply changes** — One refactoring at a time (unless --dry-run)
|
|
46
|
+
7. **Report** — Summary of changes applied
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Refactor a source file (interactive, with approval)
|
|
52
|
+
/advpl-specialist:refactor src/FATA001.prw
|
|
53
|
+
|
|
54
|
+
# Show suggestions without applying
|
|
55
|
+
/advpl-specialist:refactor src/FATA001.prw --dry-run
|
|
56
|
+
|
|
57
|
+
# Refactor all files in a directory
|
|
58
|
+
/advpl-specialist:refactor src/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Output
|
|
62
|
+
|
|
63
|
+
- List of refactoring opportunities found, ordered by priority
|
|
64
|
+
- Before/after code for each suggestion
|
|
65
|
+
- Summary of improvements (function count, max length, naming compliance)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review ADVPL/TLPP code for best practices, performance, security, and modernization
|
|
3
|
+
allowed-tools: Read, Glob, Grep, Bash, Agent, Skill, WebSearch, WebFetch
|
|
4
|
+
argument-hint: "<file|directory> [--focus category]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations, error descriptions, and suggestions to the user's language. Code comments may remain in English or match the user's language.
|
|
8
|
+
|
|
9
|
+
# /advpl-specialist:review
|
|
10
|
+
|
|
11
|
+
Review ADVPL/TLPP code for best practices, performance, security, and modernization opportunities.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:review <target> [--focus category]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Focus Categories
|
|
20
|
+
|
|
21
|
+
| Focus | Description |
|
|
22
|
+
|-------|------------|
|
|
23
|
+
| `boas-praticas` | Best practices: variables, locks, error handling, naming |
|
|
24
|
+
| `performance` | Performance: queries, loops, indexing |
|
|
25
|
+
| `seguranca` | Security: SQL injection, input validation, credentials |
|
|
26
|
+
| `modernizacao` | Modernization: ADVPL→TLPP, legacy patterns |
|
|
27
|
+
| `all` | All categories (default) |
|
|
28
|
+
|
|
29
|
+
## Process
|
|
30
|
+
|
|
31
|
+
1. **Parse arguments** - Identify target file(s) and optional `--focus` category
|
|
32
|
+
2. **Load review skill** - Invoke `advpl-code-review` skill and read relevant rules files
|
|
33
|
+
3. **Delegate to code-reviewer agent** - Pass targets and focus to the code-reviewer agent for systematic analysis
|
|
34
|
+
4. **Present findings** - Structured report grouped by severity with actionable fix suggestions
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Review a single source file (all categories)
|
|
40
|
+
/advpl-specialist:review src/FATA001.prw
|
|
41
|
+
|
|
42
|
+
# Review an entire directory focusing on performance
|
|
43
|
+
/advpl-specialist:review src/ --focus performance
|
|
44
|
+
|
|
45
|
+
# Review REST endpoints for security issues
|
|
46
|
+
/advpl-specialist:review src/REST/*.tlpp --focus seguranca
|
|
47
|
+
|
|
48
|
+
# Review current directory for modernization opportunities
|
|
49
|
+
/advpl-specialist:review . --focus modernizacao
|
|
50
|
+
|
|
51
|
+
# Review specific files for best practices
|
|
52
|
+
/advpl-specialist:review src/MATA010.prw --focus boas-praticas
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Output
|
|
56
|
+
|
|
57
|
+
- Findings grouped by file and severity (CRITICAL, WARNING, INFO)
|
|
58
|
+
- Each finding includes: rule ID, file:line reference, current code, suggested fix, and explanation
|
|
59
|
+
- Summary table with counts per category and severity
|
|
60
|
+
- Actionable recommendations prioritized by impact
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate Protheus SX data dictionary configuration scripts - SX3 fields, SIX indexes, SX1 questions, SX5 generic tables
|
|
3
|
+
allowed-tools: Read, Write, Glob, Grep, Bash, Agent, Skill
|
|
4
|
+
argument-hint: "[--type sx3|six|sx1|sx5] [--output path]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English.
|
|
8
|
+
|
|
9
|
+
# /advpl-specialist:sxgen
|
|
10
|
+
|
|
11
|
+
Generate Protheus data dictionary configuration scripts for SX tables.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:sxgen [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Describe what you need in natural language after the command. The agent will parse your description and generate the configuration.
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
| Flag | Description | Default |
|
|
24
|
+
|------|------------|---------|
|
|
25
|
+
| `--type` | SX type: `sx3`, `six`, `sx1`, `sx5` | Auto-detect from description |
|
|
26
|
+
| `--output` | Save script to file path | Display in chat |
|
|
27
|
+
|
|
28
|
+
## Configuration Types
|
|
29
|
+
|
|
30
|
+
| Type | What it generates |
|
|
31
|
+
|------|-------------------|
|
|
32
|
+
| `sx3` | Field definitions (X3_ARQUIVO, X3_CAMPO, X3_TIPO, etc.) + SX7 triggers |
|
|
33
|
+
| `six` | Index definitions (INDICE, ORDEM, CHAVE, NICKNAME) |
|
|
34
|
+
| `sx1` | Report question definitions (X1_GRUPO, X1_PERGUNT, X1_TIPO) |
|
|
35
|
+
| `sx5` | Generic table entries (X5_TABELA, X5_CHAVE, X5_DESCRI) |
|
|
36
|
+
|
|
37
|
+
## Auto-Validations
|
|
38
|
+
|
|
39
|
+
The command automatically:
|
|
40
|
+
- Validates field types and sizes
|
|
41
|
+
- Generates pictures based on type (currency, date, code)
|
|
42
|
+
- Adds NaoVazio() for required fields
|
|
43
|
+
- Adds ExistCpo() for fields with F3 lookup
|
|
44
|
+
- Adds Pertence() for fields with combo options
|
|
45
|
+
- Generates SX7 triggers for F3 lookup fields
|
|
46
|
+
- Includes 3-language support (pt-BR, es, en)
|
|
47
|
+
- Ensures FILIAL is first in indexes
|
|
48
|
+
|
|
49
|
+
## Process
|
|
50
|
+
|
|
51
|
+
1. **Parse input** — Identify type and field specifications from natural language
|
|
52
|
+
2. **Load SX configuration skill** — Invoke `sx-configuration` skill
|
|
53
|
+
3. **Delegate to sx-configurator agent** — Pass parsed requirements
|
|
54
|
+
4. **Validate** — Check types, sizes, pictures, validations
|
|
55
|
+
5. **Generate script** — Formatted key-value blocks with all fields
|
|
56
|
+
6. **Deliver** — Display or save to output file
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Generate SX3 field definitions from description
|
|
62
|
+
/advpl-specialist:sxgen --type sx3
|
|
63
|
+
Criar campos para tabela ZA1 - Ordens de Servico:
|
|
64
|
+
- ZA1_CODIGO: codigo da OS, char 6, obrigatorio
|
|
65
|
+
- ZA1_DESCRI: descricao do servico, char 40, obrigatorio
|
|
66
|
+
- ZA1_CLIENT: codigo do cliente, char 6, valida na SA1
|
|
67
|
+
- ZA1_STATUS: status, char 1, combo 1=Aberta;2=Em Andamento;3=Concluida;4=Cancelada
|
|
68
|
+
|
|
69
|
+
# Generate SIX index definitions
|
|
70
|
+
/advpl-specialist:sxgen --type six
|
|
71
|
+
Indices para ZA1:
|
|
72
|
+
- Indice 1: filial + codigo (unico)
|
|
73
|
+
- Indice 2: filial + cliente + data abertura
|
|
74
|
+
|
|
75
|
+
# Generate SX1 report questions
|
|
76
|
+
/advpl-specialist:sxgen --type sx1
|
|
77
|
+
Perguntas para relatorio de OS (grupo ZA1):
|
|
78
|
+
- Data abertura de/ate
|
|
79
|
+
- Status de/ate
|
|
80
|
+
- Cliente de/ate
|
|
81
|
+
|
|
82
|
+
# Generate SX5 generic table
|
|
83
|
+
/advpl-specialist:sxgen --type sx5
|
|
84
|
+
Tabela generica ZZ para tipos de servico:
|
|
85
|
+
01=Preventiva, 02=Corretiva, 03=Instalacao
|
|
86
|
+
|
|
87
|
+
# Save to file
|
|
88
|
+
/advpl-specialist:sxgen --type sx3 --output config/ZA1-campos.txt
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Output
|
|
92
|
+
|
|
93
|
+
Formatted configuration script with:
|
|
94
|
+
- Header with table name, date, and generator info
|
|
95
|
+
- Complete field definitions with all required attributes
|
|
96
|
+
- Auto-generated validations and pictures
|
|
97
|
+
- SX7 triggers (for SX3 with F3 lookups)
|
|
98
|
+
- Ready for manual input in Configurador or reference for APSDU/UPDDISTR import
|
package/commands/test.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate ProBat unit tests for TLPP classes and functions
|
|
3
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent, Skill, WebSearch, WebFetch
|
|
4
|
+
argument-hint: "<file.tlpp|function> [--type unit|api] [--output path]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /advpl-specialist:test
|
|
8
|
+
|
|
9
|
+
**IMPORTANT:** Always respond in the same language the user is writing in. If the user writes in Portuguese, respond in Portuguese. If in English, respond in English. Adapt all explanations and suggestions to the user's language. Code comments may remain in English or match the user's language.
|
|
10
|
+
|
|
11
|
+
Generate ProBat unit tests for TLPP classes and functions on TOTVS Protheus.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
/advpl-specialist:test <target> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Where `<target>` is a `.tlpp` file path or a function/class name.
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
|
|
23
|
+
| Type | Description | Output |
|
|
24
|
+
|------|------------|--------|
|
|
25
|
+
| `unit` | Unit test for functions or class methods | `.tlpp` file with `@TestFixture` and assertions |
|
|
26
|
+
| `api` | REST API endpoint test | `.tlpp` file using `tlpp.rest.runTestSimple` |
|
|
27
|
+
|
|
28
|
+
## Options
|
|
29
|
+
|
|
30
|
+
| Flag | Description | Default |
|
|
31
|
+
|------|------------|---------|
|
|
32
|
+
| `--type` | Test type: `unit` or `api` | `unit` |
|
|
33
|
+
| `--output` | Output file path | `test/unit/test_<name>.tlpp` |
|
|
34
|
+
| `--suite` | Suite name for grouped execution | None |
|
|
35
|
+
| `--owner` | Team/author identifier for `@TestFixture` | Ask user |
|
|
36
|
+
|
|
37
|
+
## Important: ProBat is TLPP Only
|
|
38
|
+
|
|
39
|
+
ProBat only works with TLPP (`.tlpp` files). If a `.prw` file is passed:
|
|
40
|
+
|
|
41
|
+
1. Inform the user that ProBat requires TLPP
|
|
42
|
+
2. Suggest using `/advpl-specialist:migrate` first to convert the source to TLPP
|
|
43
|
+
3. The test file itself is always `.tlpp`, even when testing ADVPL functions
|
|
44
|
+
|
|
45
|
+
## Process
|
|
46
|
+
|
|
47
|
+
1. **Parse arguments** - Extract target file/function, type, and flags
|
|
48
|
+
2. **Read target source** - Analyze the file or function to understand what to test
|
|
49
|
+
3. **Load skill** - Invoke `probat-testing` skill
|
|
50
|
+
4. **Load patterns** - Read `patterns-unit-tests.md` for the appropriate template
|
|
51
|
+
5. **Identify test cases** - Determine:
|
|
52
|
+
- Functions/methods to test
|
|
53
|
+
- Input parameters and expected outputs
|
|
54
|
+
- Edge cases (NIL values, empty strings, invalid types, boundary values)
|
|
55
|
+
- Error scenarios
|
|
56
|
+
6. **Present plan** - Show the user:
|
|
57
|
+
- Test file name and path
|
|
58
|
+
- Test class/function name
|
|
59
|
+
- List of test methods with descriptions
|
|
60
|
+
- Assertions to be used
|
|
61
|
+
- Setup/TearDown needs (if any)
|
|
62
|
+
7. **Wait for approval** - The user must approve before generating code
|
|
63
|
+
8. **Generate test code** - Create the `.tlpp` test file following ProBat conventions:
|
|
64
|
+
- `#include "tlpp-probat.th"` (and `"tlpp-core.th"` if needed)
|
|
65
|
+
- Proper namespace (`test.<module>` or `custom.tests.<module>`)
|
|
66
|
+
- `@TestFixture` with `owner` and `target` properties
|
|
67
|
+
- `@Test` with descriptive mandatory descriptions
|
|
68
|
+
- Typed variable declarations
|
|
69
|
+
- Appropriate assertions from the ProBat assertion library
|
|
70
|
+
9. **Write file** - Save with `.tlpp` extension
|
|
71
|
+
10. **Report** - Show what was created and how to run the tests
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Generate unit tests for a TLPP file
|
|
77
|
+
/advpl-specialist:test src/calculadora.tlpp
|
|
78
|
+
|
|
79
|
+
# Generate API tests for a REST endpoint
|
|
80
|
+
/advpl-specialist:test src/customer_api.tlpp --type api
|
|
81
|
+
|
|
82
|
+
# Generate tests with a specific output path
|
|
83
|
+
/advpl-specialist:test src/pedido_service.tlpp --output test/unit/test_pedido.tlpp
|
|
84
|
+
|
|
85
|
+
# Generate tests for a specific function
|
|
86
|
+
/advpl-specialist:test U_calculateTotal --type unit
|
|
87
|
+
|
|
88
|
+
# Generate tests grouped in a suite
|
|
89
|
+
/advpl-specialist:test src/financeiro/ --suite financeiro
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Output
|
|
93
|
+
|
|
94
|
+
A complete, compilable `.tlpp` test file saved to the project with:
|
|
95
|
+
|
|
96
|
+
- `#include "tlpp-probat.th"` header
|
|
97
|
+
- Proper namespace declaration
|
|
98
|
+
- `@TestFixture` with owner and target metadata
|
|
99
|
+
- Test methods with `@Test` annotations and descriptive names
|
|
100
|
+
- Typed local variables
|
|
101
|
+
- Appropriate assertions (`assertEquals`, `assertTrue`, etc.)
|
|
102
|
+
- Setup/TearDown methods when needed (`@OneTimeSetUp`, `@Setup`, `@TearDown`, `@OneTimeTearDown`)
|
|
103
|
+
- Return `.T.` from all test functions/methods
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|