@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,265 @@
|
|
|
1
|
+
# ADVPL to TLPP Migration Rules
|
|
2
|
+
|
|
3
|
+
Complete mapping reference for converting ADVPL procedural constructs to their TLPP object-oriented equivalents.
|
|
4
|
+
|
|
5
|
+
## Preprocessor Directives
|
|
6
|
+
|
|
7
|
+
| ADVPL | TLPP | Notes |
|
|
8
|
+
|-------|------|-------|
|
|
9
|
+
| `#Include "TOTVS.CH"` | `#Include "tlpp-core.th"` | Main TLPP include; `Protheus.ch` is obsolete, use `TOTVS.CH` for `.prw` files. Do NOT add `using namespace tlpp.core`, `tlpp.rest`, `tlpp.log` -- use the `.th` includes instead |
|
|
10
|
+
| `#Include "TopConn.ch"` | `#Include "tlpp-core.th"` | Database connectivity is available via tlpp-core.th |
|
|
11
|
+
| `#Include "RestFul.ch"` | `#Include "tlpp-rest.th"` | For REST with TLPP annotations (`@RestService`, `@Get`, `@Post`) |
|
|
12
|
+
| `#Include "FWMVCDef.ch"` | `#Include "tlpp-core.th"` | MVC framework functions available via tlpp-core.th |
|
|
13
|
+
| `#Define CONST_NAME value` | `static data CONST_NAME := value` | Define constants as static class data, or use `#define` if purely compile-time |
|
|
14
|
+
| `#ifdef TOP_HAS_FEATURE` | Conditional compilation preserved | `#ifdef` / `#ifndef` blocks remain valid in `.tlpp` for compile-time branching |
|
|
15
|
+
| `#ifndef` | Conditional compilation preserved | Same as `#ifdef` -- unchanged in TLPP |
|
|
16
|
+
|
|
17
|
+
**Notes:**
|
|
18
|
+
- In TLPP, use the specific `.th` includes instead of the `.ch` ADVPL includes:
|
|
19
|
+
- `#Include "tlpp-core.th"` -- main include for TLPP (replaces TOTVS.CH/Protheus.ch, TopConn.ch)
|
|
20
|
+
- `#Include "tlpp-rest.th"` -- for REST annotations (@RestService, @Get, @Post)
|
|
21
|
+
- `#Include "tlpp-object.th"` -- for advanced object features
|
|
22
|
+
- `#Include "tlpp-probat.th"` -- for automated testing (ProBat framework)
|
|
23
|
+
- Do NOT use `using namespace tlpp.core`, `tlpp.rest`, `tlpp.log`, `tlpp.data`, etc. Those are NOT needed -- always use the `.th` includes instead.
|
|
24
|
+
- Only add the project's own `namespace` declaration following the official TOTVS convention (see Namespace Conventions below).
|
|
25
|
+
- `#Define` constants used only within a class can become `static data` properties. Constants shared across files should remain as `#define` in a shared `.ch` file.
|
|
26
|
+
|
|
27
|
+
## Namespace Conventions (Official TOTVS Standard - TDN)
|
|
28
|
+
|
|
29
|
+
All namespace names must be **lowercase**, separated by **dots**, with **no underscores**.
|
|
30
|
+
|
|
31
|
+
**For TOTVS product code:**
|
|
32
|
+
```
|
|
33
|
+
totvs.protheus.<segmento>.<agrupador/servico>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Available segments: agrobusiness, backoffice, construction, distribution, educational, financial, health, hospitality, legal, manufacturing, retail, services
|
|
37
|
+
|
|
38
|
+
Examples: `totvs.protheus.backoffice.customer`, `totvs.protheus.financial.payment.receive`
|
|
39
|
+
|
|
40
|
+
**For client customizations (most common):**
|
|
41
|
+
```
|
|
42
|
+
custom.<agrupador>.<servico>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Start with `custom.`, the rest is free. Examples: `custom.cadastros.cliente`, `custom.faturamento.pedido`
|
|
46
|
+
|
|
47
|
+
**File naming convention:**
|
|
48
|
+
- Product: `<segmento>.<agrupador>.<funcionalidade>.tlpp` (e.g., `backoffice.tgv.contact.controller.tlpp`)
|
|
49
|
+
- Customizations: `custom.<agrupador>.<funcionalidade>.tlpp` (e.g., `custom.cadastros.cliente.tlpp`)
|
|
50
|
+
|
|
51
|
+
**Classes, functions, and methods naming:**
|
|
52
|
+
- Classes: **PascalCase** (e.g., `ContactsController`, `PedidoService`)
|
|
53
|
+
- Functions and methods: **camelCase** (e.g., `validName()`, `calcTotal()`)
|
|
54
|
+
- **No underscores** in any identifier
|
|
55
|
+
|
|
56
|
+
## Variable Scope
|
|
57
|
+
|
|
58
|
+
| ADVPL Scope | TLPP Equivalent | Migration Action |
|
|
59
|
+
|-------------|-----------------|------------------|
|
|
60
|
+
| `Private cVar := "x"` | `data cVar as character` | Convert to class property; initialize in constructor |
|
|
61
|
+
| `Public nGlobal` | Remove entirely | Pass value via constructor parameters or method arguments; never use Public |
|
|
62
|
+
| `Local aArray := {}` | `local aArray := {}` | Unchanged -- keep Local variables as-is inside methods |
|
|
63
|
+
| `Static cShared := ""` | `static data cShared as character` | Convert to static class data if shared across instances; otherwise use instance `data` |
|
|
64
|
+
|
|
65
|
+
**Key rules:**
|
|
66
|
+
- If a `Private` variable is used across multiple functions in the same file, it becomes a class `data` property accessed via `::cVar`.
|
|
67
|
+
- If a `Private` variable is only used in one function, convert it to `Local` inside the corresponding method.
|
|
68
|
+
- `Public` variables must always be eliminated. Identify all consumers and pass the value explicitly.
|
|
69
|
+
- `Static` file-level variables become `static data` on the class when the value must be shared across all instances.
|
|
70
|
+
|
|
71
|
+
## Functions
|
|
72
|
+
|
|
73
|
+
| ADVPL | TLPP | Migration Action |
|
|
74
|
+
|-------|------|------------------|
|
|
75
|
+
| `User Function Name(params)` | `public method execute(params)` | Primary public method on the class; keep a `.prw` wrapper for backward compatibility |
|
|
76
|
+
| `Static Function Helper(params)` | `private method helper(params)` | Internal functions become private methods |
|
|
77
|
+
| `Main Function` | Constructor (`method new()`) | Initialization logic moves to the constructor |
|
|
78
|
+
| Multiple User Functions in one `.prw` | Separate classes or methods | Each User Function should map to its own class, or become a public method if logically related |
|
|
79
|
+
|
|
80
|
+
**Wrapper pattern for User Function:**
|
|
81
|
+
|
|
82
|
+
```advpl
|
|
83
|
+
// Original .prw file -- preserved as wrapper
|
|
84
|
+
#Include "TOTVS.CH"
|
|
85
|
+
|
|
86
|
+
User Function OriginalName(cParam1, nParam2)
|
|
87
|
+
Local oService := custom.mymodule.OriginalNameService():new()
|
|
88
|
+
Return oService:execute(cParam1, nParam2)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Database Operations
|
|
92
|
+
|
|
93
|
+
Database operations remain functionally identical but are encapsulated within class methods. The critical rule is that every method performing database access must save and restore the work area.
|
|
94
|
+
|
|
95
|
+
| Pattern | ADVPL | TLPP (within method) |
|
|
96
|
+
|---------|-------|----------------------|
|
|
97
|
+
| Save area | `Local aArea := GetArea()` | `local aArea := GetArea()` -- unchanged |
|
|
98
|
+
| Restore area | `RestArea(aArea)` | `RestArea(aArea)` -- unchanged |
|
|
99
|
+
| Select area | `DbSelectArea("SA1")` | `DbSelectArea(::cAlias)` -- use class property for alias |
|
|
100
|
+
| Set order | `DbSetOrder(1)` | `DbSetOrder(1)` -- unchanged |
|
|
101
|
+
| Seek | `DbSeek(xFilial("SA1") + cKey)` | `DbSeek(xFilial(::cAlias) + cKey)` -- use class property |
|
|
102
|
+
| Record lock | `RecLock("SA1", .T.)` | `RecLock(::cAlias, .T.)` -- use class property |
|
|
103
|
+
| Unlock | `MsUnlock("SA1")` | `MsUnlock(::cAlias)` -- use class property |
|
|
104
|
+
|
|
105
|
+
**Best practice:** Store alias names as class `data` properties so they can be easily changed or injected for testing.
|
|
106
|
+
|
|
107
|
+
```tlpp
|
|
108
|
+
class ClienteRepository
|
|
109
|
+
data cAlias as character
|
|
110
|
+
|
|
111
|
+
public method new(cAlias as character) as object
|
|
112
|
+
public method findByCod(cCod as character) as logical
|
|
113
|
+
|
|
114
|
+
endclass
|
|
115
|
+
|
|
116
|
+
method new(cAlias as character) class ClienteRepository
|
|
117
|
+
::cAlias := iif(empty(cAlias), "SA1", cAlias)
|
|
118
|
+
return self
|
|
119
|
+
|
|
120
|
+
method findByCod(cCod as character) class ClienteRepository
|
|
121
|
+
local aArea := GetArea()
|
|
122
|
+
local lFound := .F.
|
|
123
|
+
|
|
124
|
+
DbSelectArea(::cAlias)
|
|
125
|
+
DbSetOrder(1)
|
|
126
|
+
lFound := DbSeek(xFilial(::cAlias) + cCod)
|
|
127
|
+
|
|
128
|
+
RestArea(aArea)
|
|
129
|
+
return lFound
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Error Handling
|
|
133
|
+
|
|
134
|
+
| ADVPL | TLPP | Notes |
|
|
135
|
+
|-------|------|-------|
|
|
136
|
+
| `Begin Sequence` | `begin sequence` | Preserved -- same syntax |
|
|
137
|
+
| `Recover Using oError` | `recover using oError` | Preserved -- same syntax |
|
|
138
|
+
| `End Sequence` | `end sequence` | Preserved -- same syntax |
|
|
139
|
+
| `ErrorBlock({...})` | `ErrorBlock({...})` | Preserved -- optionally enhanced |
|
|
140
|
+
| `Conout("Erro: " + ...)` | `FWLogMsg("ERROR", ...)` or `FWLogError(...)` | Prefer structured logging in TLPP |
|
|
141
|
+
| `Break` | `break` | Preserved |
|
|
142
|
+
|
|
143
|
+
**Enhanced error handling in TLPP:**
|
|
144
|
+
|
|
145
|
+
```tlpp
|
|
146
|
+
method processOrder(cOrder as character) class OrderService
|
|
147
|
+
local lRet := .T.
|
|
148
|
+
local oError
|
|
149
|
+
|
|
150
|
+
begin sequence
|
|
151
|
+
|
|
152
|
+
// Business logic here
|
|
153
|
+
::validateOrder(cOrder)
|
|
154
|
+
::saveOrder(cOrder)
|
|
155
|
+
|
|
156
|
+
recover using oError
|
|
157
|
+
lRet := .F.
|
|
158
|
+
FWLogMsg("ERROR", , "OrderService", "processOrder", , , ;
|
|
159
|
+
"Erro ao processar pedido " + cOrder + ": " + oError:Description)
|
|
160
|
+
end sequence
|
|
161
|
+
|
|
162
|
+
return lRet
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Code Blocks
|
|
166
|
+
|
|
167
|
+
Code blocks remain syntactically unchanged in TLPP. When used inside class methods, they follow the same rules:
|
|
168
|
+
|
|
169
|
+
| ADVPL | TLPP | Notes |
|
|
170
|
+
|-------|------|-------|
|
|
171
|
+
| `bBlock := {\|x\| x * 2}` | `local bBlock := {\|x\| x * 2}` | Unchanged syntax |
|
|
172
|
+
| `Eval(bBlock, nValue)` | `Eval(bBlock, nValue)` | Unchanged |
|
|
173
|
+
| `aEval(aArray, bBlock)` | `aEval(aArray, bBlock)` | Unchanged |
|
|
174
|
+
| `DbEval(bBlock)` | `DbEval(bBlock)` | Unchanged |
|
|
175
|
+
|
|
176
|
+
**Note:** Code blocks referencing class properties must use `self` explicitly when the block will be evaluated outside the method scope:
|
|
177
|
+
|
|
178
|
+
```tlpp
|
|
179
|
+
// Inside a method:
|
|
180
|
+
local oSelf := self
|
|
181
|
+
local bFilter := {|| (oSelf:cAlias)->(C6_NUM) == oSelf:cPedido}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Array and String Handling
|
|
185
|
+
|
|
186
|
+
Array and string operations are unchanged in TLPP. They are native language features and do not require migration.
|
|
187
|
+
|
|
188
|
+
| Operation | ADVPL | TLPP | Notes |
|
|
189
|
+
|-----------|-------|------|-------|
|
|
190
|
+
| Array creation | `aArr := {}` | `local aArr := {}` | Unchanged |
|
|
191
|
+
| Array add | `aAdd(aArr, cVal)` | `aAdd(aArr, cVal)` | Unchanged |
|
|
192
|
+
| Array scan | `aScan(aArr, cVal)` | `aScan(aArr, cVal)` | Unchanged |
|
|
193
|
+
| Array size | `Len(aArr)` | `Len(aArr)` | Unchanged |
|
|
194
|
+
| String trim | `Alltrim(cStr)` | `Alltrim(cStr)` | Unchanged |
|
|
195
|
+
| String replace | `StrTran(cStr, cOld, cNew)` | `StrTran(cStr, cOld, cNew)` | Unchanged |
|
|
196
|
+
| String pad | `PadR(cStr, nLen)` | `PadR(cStr, nLen)` | Unchanged |
|
|
197
|
+
|
|
198
|
+
**The only change:** arrays and strings that were stored in `Private`/`Public` variables must now be stored as class `data` properties or passed as parameters.
|
|
199
|
+
|
|
200
|
+
## UI Elements
|
|
201
|
+
|
|
202
|
+
Dialog creation and UI element handling require special consideration when migrating to classes. The dialogs themselves are unchanged, but the structure around them moves into methods.
|
|
203
|
+
|
|
204
|
+
| ADVPL Pattern | TLPP Pattern | Notes |
|
|
205
|
+
|--------------|-------------|-------|
|
|
206
|
+
| UI logic mixed with business logic | Separate into View and Service classes | Apply SRP (Single Responsibility Principle) |
|
|
207
|
+
| `DEFINE MSDIALOG` inside User Function | `method buildDialog()` on a View/Controller class | Dialog construction moves to a dedicated method |
|
|
208
|
+
| `ACTIVATE MSDIALOG` | Same -- `ACTIVATE MSDIALOG` | Dialog activation unchanged |
|
|
209
|
+
| `@ ... MSGET ...` controls | Same -- placed inside `buildDialog()` method | Control creation syntax unchanged |
|
|
210
|
+
| Button actions calling Static Functions | Button actions calling `::methodName()` | Replace function references with method calls |
|
|
211
|
+
| `FWExecView(...)` / `Enchoice(...)` | Same -- called from within a method | Framework UI functions unchanged |
|
|
212
|
+
|
|
213
|
+
**Example -- UI migration:**
|
|
214
|
+
|
|
215
|
+
```tlpp
|
|
216
|
+
class ClienteView
|
|
217
|
+
data oDlg as object
|
|
218
|
+
data cCodigo as character
|
|
219
|
+
data cNome as character
|
|
220
|
+
|
|
221
|
+
public method new() as object
|
|
222
|
+
public method show() as logical
|
|
223
|
+
private method buildDialog() as object
|
|
224
|
+
private method onConfirm() as logical
|
|
225
|
+
|
|
226
|
+
endclass
|
|
227
|
+
|
|
228
|
+
method new() class ClienteView
|
|
229
|
+
::cCodigo := Space(6)
|
|
230
|
+
::cNome := Space(40)
|
|
231
|
+
return self
|
|
232
|
+
|
|
233
|
+
method show() class ClienteView
|
|
234
|
+
::buildDialog()
|
|
235
|
+
ACTIVATE MSDIALOG ::oDlg CENTERED
|
|
236
|
+
return ::onConfirm()
|
|
237
|
+
|
|
238
|
+
method buildDialog() class ClienteView
|
|
239
|
+
DEFINE MSDIALOG ::oDlg TITLE "Cadastro de Cliente" FROM 0,0 TO 300,500
|
|
240
|
+
|
|
241
|
+
@ 10, 10 MSGET ::cCodigo SIZE 100, 20 OF ::oDlg
|
|
242
|
+
@ 40, 10 MSGET ::cNome SIZE 200, 20 OF ::oDlg
|
|
243
|
+
|
|
244
|
+
@ 80, 10 BUTTON "Confirmar" SIZE 80, 25 OF ::oDlg ;
|
|
245
|
+
ACTION (::oDlg:End())
|
|
246
|
+
|
|
247
|
+
return ::oDlg
|
|
248
|
+
|
|
249
|
+
method onConfirm() class ClienteView
|
|
250
|
+
if Empty(::cCodigo) .Or. Empty(::cNome)
|
|
251
|
+
MsgAlert("Preencha todos os campos")
|
|
252
|
+
return .F.
|
|
253
|
+
endif
|
|
254
|
+
return .T.
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Summary
|
|
258
|
+
|
|
259
|
+
The fundamental principle of ADVPL-to-TLPP migration is **structure changes, syntax mostly stays the same**. The language constructs (arrays, strings, database commands, error handling, code blocks, UI elements) are identical. What changes is:
|
|
260
|
+
|
|
261
|
+
1. **Organization** -- functions become methods on classes
|
|
262
|
+
2. **Scope** -- Private/Public variables become class properties
|
|
263
|
+
3. **Imports** -- ADVPL `.ch` includes are replaced by TLPP `.th` includes (`tlpp-core.th`, `tlpp-rest.th`, etc.); add your own `namespace` declaration following TOTVS convention (`custom.<agrupador>.<servico>` for customizations or `totvs.protheus.<segmento>.<agrupador>` for product)
|
|
264
|
+
4. **Naming** -- files follow `<namespace>.<funcionalidade>.tlpp` convention, classes use PascalCase, methods use camelCase, no underscores
|
|
265
|
+
5. **Encapsulation** -- internal helpers become private methods instead of Static Functions
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: changelog-patterns
|
|
3
|
+
description: Use when generating changelogs from code changes - git diffs, file comparisons, release notes
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Changelog Patterns
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Patterns for generating structured changelogs from ADVPL/TLPP code changes on TOTVS Protheus. Analyzes diffs, identifies change types, and produces formatted release notes.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Generating changelog for a delivery to the client
|
|
15
|
+
- Creating release notes for a patch or update
|
|
16
|
+
- Documenting what changed between versions
|
|
17
|
+
- Auditing code changes for compliance
|
|
18
|
+
|
|
19
|
+
## Change Types
|
|
20
|
+
|
|
21
|
+
| Type | Label | Description |
|
|
22
|
+
|------|-------|-------------|
|
|
23
|
+
| NEW | [NOVO] | Nova funcionalidade ou rotina |
|
|
24
|
+
| FIX | [CORRECAO] | Correcao de bug |
|
|
25
|
+
| CHANGE | [ALTERACAO] | Melhoria ou modificacao de comportamento existente |
|
|
26
|
+
| REMOVE | [REMOCAO] | Funcionalidade ou codigo removido |
|
|
27
|
+
| REFACTOR | [REFATORACAO] | Mudanca estrutural sem alterar comportamento |
|
|
28
|
+
|
|
29
|
+
## Impact Levels
|
|
30
|
+
|
|
31
|
+
| Level | Description |
|
|
32
|
+
|-------|-------------|
|
|
33
|
+
| ALTO | Altera fluxo de negocio, tabelas, ou integracao entre modulos |
|
|
34
|
+
| MEDIO | Altera validacoes, calculos, ou comportamento de rotina existente |
|
|
35
|
+
| BAIXO | Mudanca cosmetica, refatoracao, ou correcao pontual |
|
|
36
|
+
|
|
37
|
+
## Changelog Format — Markdown
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
# Changelog — [Nome do Projeto/Pacote]
|
|
41
|
+
Data: DD/MM/YYYY
|
|
42
|
+
Versao: X.Y.Z
|
|
43
|
+
|
|
44
|
+
## Resumo
|
|
45
|
+
[1-2 frases descrevendo o escopo das mudancas]
|
|
46
|
+
|
|
47
|
+
## Alteracoes
|
|
48
|
+
|
|
49
|
+
### [NOVO] Descricao da nova funcionalidade
|
|
50
|
+
- **Arquivo:** CadOrdemServico.prw
|
|
51
|
+
- **Impacto:** ALTO
|
|
52
|
+
- **Detalhes:** Cadastro MVC de Ordens de Servico com tabela customizada ZA1
|
|
53
|
+
- **Tabelas afetadas:** ZA1 (nova)
|
|
54
|
+
|
|
55
|
+
### [CORRECAO] Descricao do bug corrigido
|
|
56
|
+
- **Arquivo:** MATA461.prw:145
|
|
57
|
+
- **Impacto:** MEDIO
|
|
58
|
+
- **Detalhes:** RecLock sem MsUnlock causava lock permanente na SF2
|
|
59
|
+
- **Tabelas afetadas:** SF2
|
|
60
|
+
|
|
61
|
+
### [ALTERACAO] Descricao da melhoria
|
|
62
|
+
- **Arquivo:** RelVendas.prw
|
|
63
|
+
- **Impacto:** BAIXO
|
|
64
|
+
- **Detalhes:** Adicionada coluna de desconto no relatorio
|
|
65
|
+
- **Tabelas afetadas:** SC6 (leitura)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Changelog Format — TXT (plain text)
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
CHANGELOG — [Nome do Projeto/Pacote]
|
|
72
|
+
Data: DD/MM/YYYY | Versao: X.Y.Z
|
|
73
|
+
============================================
|
|
74
|
+
|
|
75
|
+
RESUMO: [1-2 frases]
|
|
76
|
+
|
|
77
|
+
[NOVO] Descricao
|
|
78
|
+
Arquivo: CadOrdemServico.prw
|
|
79
|
+
Impacto: ALTO
|
|
80
|
+
Tabelas: ZA1 (nova)
|
|
81
|
+
|
|
82
|
+
[CORRECAO] Descricao
|
|
83
|
+
Arquivo: MATA461.prw:145
|
|
84
|
+
Impacto: MEDIO
|
|
85
|
+
Tabelas: SF2
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Analysis Process
|
|
89
|
+
|
|
90
|
+
1. Get the list of changed files (git diff, file list, or user input)
|
|
91
|
+
2. For each changed file:
|
|
92
|
+
a. Read the current version
|
|
93
|
+
b. If git available, get the diff (git diff <since> -- <file>)
|
|
94
|
+
c. Identify what changed: new functions, modified functions, removed functions
|
|
95
|
+
d. Detect tables affected (DBSelectArea, RecLock, BeginSQL patterns)
|
|
96
|
+
e. Classify the change type (NEW, FIX, CHANGE, REMOVE, REFACTOR)
|
|
97
|
+
f. Assess impact level (ALTO, MEDIO, BAIXO)
|
|
98
|
+
3. Group changes by type
|
|
99
|
+
4. Generate changelog in the requested format
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-explanation
|
|
3
|
+
description: Use when explaining ADVPL/TLPP code in plain language for developers and functional consultants
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Explanation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Methodology for explaining ADVPL/TLPP code in plain language. Adapts the explanation depth based on the audience level: junior developer, senior developer, or functional consultant.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- User asks to explain what a piece of code does
|
|
15
|
+
- User wants to understand legacy code
|
|
16
|
+
- Functional consultant needs to understand a customization
|
|
17
|
+
- Junior developer needs line-by-line explanation
|
|
18
|
+
- Code documentation is missing or unclear
|
|
19
|
+
|
|
20
|
+
## Explanation Levels
|
|
21
|
+
|
|
22
|
+
| Level | Audience | Depth | Focus |
|
|
23
|
+
|-------|----------|-------|-------|
|
|
24
|
+
| `junior` | Dev iniciante | Linha por linha | Sintaxe, funcoes, fluxo de execucao |
|
|
25
|
+
| `senior` | Dev experiente | Resumido | Logica de negocio, decisoes de design, riscos |
|
|
26
|
+
| `funcional` | Consultor funcional | Sem termos tecnicos | O que a rotina faz do ponto de vista do negocio |
|
|
27
|
+
|
|
28
|
+
## Explanation Structure
|
|
29
|
+
|
|
30
|
+
### For --level junior
|
|
31
|
+
|
|
32
|
+
1. **Objetivo** — O que essa rotina faz em uma frase
|
|
33
|
+
2. **Includes e dependencias** — O que cada include traz
|
|
34
|
+
3. **Variaveis** — Lista de variaveis com tipo e proposito
|
|
35
|
+
4. **Fluxo passo a passo** — O que cada bloco de codigo faz, na ordem
|
|
36
|
+
5. **Funcoes nativas usadas** — Breve explicacao de cada funcao do Protheus usada
|
|
37
|
+
6. **Tabelas acessadas** — Quais tabelas sao lidas/gravadas e por que
|
|
38
|
+
7. **Pontos de atencao** — Armadilhas, erros comuns, trechos criticos
|
|
39
|
+
|
|
40
|
+
### For --level senior
|
|
41
|
+
|
|
42
|
+
1. **Objetivo** — O que essa rotina faz em uma frase
|
|
43
|
+
2. **Logica de negocio** — Regras implementadas e decisoes de design
|
|
44
|
+
3. **Tabelas e campos** — Resumo das operacoes de banco
|
|
45
|
+
4. **Dependencias externas** — Funcoes chamadas, includes, pontos de entrada
|
|
46
|
+
5. **Riscos e debitos tecnicos** — Problemas potenciais, melhorias sugeridas
|
|
47
|
+
|
|
48
|
+
### For --level funcional
|
|
49
|
+
|
|
50
|
+
1. **O que essa rotina faz** — Em linguagem de negocio, sem codigo
|
|
51
|
+
2. **Quando ela e executada** — Contexto de uso (menu, schedule, trigger)
|
|
52
|
+
3. **Quais dados ela consulta** — Tabelas e informacoes lidas (em linguagem de negocio)
|
|
53
|
+
4. **Quais dados ela altera** — O que muda no sistema quando ela roda
|
|
54
|
+
5. **Regras de negocio** — Validacoes, calculos, condicoes
|
|
55
|
+
6. **Impacto em outros modulos** — Se altera dados usados por outros processos
|
|
56
|
+
|
|
57
|
+
## Process
|
|
58
|
+
|
|
59
|
+
1. Read the target file or code snippet completely
|
|
60
|
+
2. Determine the explanation level (--level flag or ask)
|
|
61
|
+
3. Load `protheus-reference` skill if native functions need lookup
|
|
62
|
+
4. Load `protheus-business` skill if business context is needed
|
|
63
|
+
5. Load `embedded-sql` skill if SQL queries are present
|
|
64
|
+
6. Analyze the code structure, identify functions, variables, DB operations
|
|
65
|
+
7. Generate explanation following the level-appropriate structure
|
|
66
|
+
8. Use the user's language (Portuguese or English)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-patterns
|
|
3
|
+
description: Use when generating technical documentation for ADVPL/TLPP code - Protheus.doc headers, routine docs, API docs
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation Patterns
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Patterns and templates for generating technical documentation from ADVPL/TLPP source code on TOTVS Protheus.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Generating Protheus.doc headers for functions/classes
|
|
15
|
+
- Creating routine documentation (tables, parameters, entry points, flow)
|
|
16
|
+
- Documenting REST API endpoints
|
|
17
|
+
- Adding documentation to undocumented legacy code
|
|
18
|
+
|
|
19
|
+
## Documentation Types
|
|
20
|
+
|
|
21
|
+
### Type: header — Protheus.doc Header
|
|
22
|
+
|
|
23
|
+
Standard documentation header following TOTVS conventions:
|
|
24
|
+
|
|
25
|
+
```advpl
|
|
26
|
+
/*/{Protheus.doc} NomeFuncao
|
|
27
|
+
Descricao breve do que a funcao faz.
|
|
28
|
+
|
|
29
|
+
@type User Function | Static Function | Method
|
|
30
|
+
@author Nome do autor
|
|
31
|
+
@since DD/MM/YYYY
|
|
32
|
+
@version 1.0
|
|
33
|
+
|
|
34
|
+
@param cParam1, Character, Descricao do parametro 1
|
|
35
|
+
@param nParam2, Numeric, Descricao do parametro 2
|
|
36
|
+
|
|
37
|
+
@return Tipo, Descricao do retorno
|
|
38
|
+
|
|
39
|
+
@example
|
|
40
|
+
cResult := NomeFuncao("ABC", 123)
|
|
41
|
+
|
|
42
|
+
@see FuncaoRelacionada1, FuncaoRelacionada2
|
|
43
|
+
|
|
44
|
+
@obs Observacoes adicionais
|
|
45
|
+
|
|
46
|
+
@history DD/MM/YYYY, Autor, Descricao da alteracao
|
|
47
|
+
/*/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Fields:
|
|
51
|
+
- **@type**: User Function, Static Function, Method, Main Function
|
|
52
|
+
- **@author**: Extracted from git blame or user input
|
|
53
|
+
- **@since**: Date of creation (from git log or current date)
|
|
54
|
+
- **@param**: One line per parameter with name, type, description
|
|
55
|
+
- **@return**: Return type and description
|
|
56
|
+
- **@example**: Usage example
|
|
57
|
+
- **@see**: Related functions (detected from function calls in code)
|
|
58
|
+
- **@history**: Change history (from git log if available)
|
|
59
|
+
|
|
60
|
+
### Type: full — Complete Routine Documentation
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
# NomeDaRotina
|
|
64
|
+
|
|
65
|
+
## Objetivo
|
|
66
|
+
[O que essa rotina faz em 1-2 frases]
|
|
67
|
+
|
|
68
|
+
## Tipo
|
|
69
|
+
[User Function | Static Function | Class Method | Job | Entry Point]
|
|
70
|
+
|
|
71
|
+
## Modulo
|
|
72
|
+
[COM | FAT | FIN | EST | CTB | FIS | PCP | MNT]
|
|
73
|
+
|
|
74
|
+
## Tabelas
|
|
75
|
+
|
|
76
|
+
### Leitura
|
|
77
|
+
| Alias | Descricao | Campos usados |
|
|
78
|
+
|-------|-----------|---------------|
|
|
79
|
+
| SA1 | Clientes | A1_COD, A1_NOME, A1_CGC |
|
|
80
|
+
|
|
81
|
+
### Gravacao
|
|
82
|
+
| Alias | Descricao | Campos gravados |
|
|
83
|
+
|-------|-----------|-----------------|
|
|
84
|
+
| SC5 | Pedidos de venda | C5_NUM, C5_EMISSAO, C5_VALOR |
|
|
85
|
+
|
|
86
|
+
## Parametros MV_*
|
|
87
|
+
| Parametro | Descricao | Impacto |
|
|
88
|
+
|-----------|-----------|---------|
|
|
89
|
+
| MV_ESTADO | UF padrao | Define UF quando nao informada |
|
|
90
|
+
|
|
91
|
+
## Pontos de Entrada
|
|
92
|
+
| Nome | Momento | O que permite |
|
|
93
|
+
|------|---------|---------------|
|
|
94
|
+
| MT100LOK | Apos validacao do modelo | Validacao customizada |
|
|
95
|
+
|
|
96
|
+
## Fluxo de Execucao
|
|
97
|
+
1. Valida parametros de entrada
|
|
98
|
+
2. Posiciona na tabela SA1
|
|
99
|
+
3. Calcula valores
|
|
100
|
+
4. Grava na SC5
|
|
101
|
+
5. Retorna resultado
|
|
102
|
+
|
|
103
|
+
## Dependencias
|
|
104
|
+
| Funcao | Arquivo | Tipo |
|
|
105
|
+
|--------|---------|------|
|
|
106
|
+
| fCalcImposto | MATA461.prw | Static Function |
|
|
107
|
+
|
|
108
|
+
## Historico de Alteracoes
|
|
109
|
+
| Data | Autor | Descricao |
|
|
110
|
+
|------|-------|-----------|
|
|
111
|
+
| 01/01/2026 | Thalys Augusto | Criacao |
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Type: api — REST API Documentation
|
|
115
|
+
|
|
116
|
+
````markdown
|
|
117
|
+
# API: NomeDoEndpoint
|
|
118
|
+
|
|
119
|
+
## Endpoint
|
|
120
|
+
`METHOD /api/v1/recurso`
|
|
121
|
+
|
|
122
|
+
## Autenticacao
|
|
123
|
+
Bearer Token (Authorization header)
|
|
124
|
+
|
|
125
|
+
## Parametros
|
|
126
|
+
|
|
127
|
+
### Path Parameters
|
|
128
|
+
| Nome | Tipo | Obrigatorio | Descricao |
|
|
129
|
+
|------|------|-------------|-----------|
|
|
130
|
+
|
|
131
|
+
### Query Parameters
|
|
132
|
+
| Nome | Tipo | Obrigatorio | Descricao |
|
|
133
|
+
|------|------|-------------|-----------|
|
|
134
|
+
|
|
135
|
+
### Request Body
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"campo1": "string",
|
|
139
|
+
"campo2": 0
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Response
|
|
144
|
+
|
|
145
|
+
### 200 OK
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"success": true,
|
|
149
|
+
"data": {}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 400 Bad Request
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"success": false,
|
|
157
|
+
"error": "descricao do erro"
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
````
|
|
161
|
+
|
|
162
|
+
## Process
|
|
163
|
+
|
|
164
|
+
1. Read the target file completely
|
|
165
|
+
2. Identify all functions/methods and their signatures
|
|
166
|
+
3. Analyze variable types from declarations and usage
|
|
167
|
+
4. Detect tables accessed (DBSelectArea, RecLock, BeginSQL, %table:%)
|
|
168
|
+
5. Detect MV_* parameters (GetMV, SuperGetMV)
|
|
169
|
+
6. Detect entry points (if the code IS an entry point, or calls them)
|
|
170
|
+
7. Map function call dependencies (Grep for function names)
|
|
171
|
+
8. Check git log for history if available
|
|
172
|
+
9. Generate documentation following the requested type template
|