mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-17 08:15:16 +03:00
feat(form-info): add -Expand parameter for collapsed page drill-down
Pages are collapsed by default showing "(N items)". The new -Expand parameter allows expanding by name, title, or * for all. A hint line is shown when collapsed sections exist. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ allowed-tools:
|
|||||||
| Параметр | Обязательный | По умолчанию | Описание |
|
| Параметр | Обязательный | По умолчанию | Описание |
|
||||||
|-----------|:------------:|--------------|---------------------------------------------|
|
|-----------|:------------:|--------------|---------------------------------------------|
|
||||||
| FormPath | да | — | Путь к файлу Form.xml |
|
| FormPath | да | — | Путь к файлу Form.xml |
|
||||||
|
| Expand | нет | — | Раскрыть свёрнутую секцию по имени, `*` — все |
|
||||||
| Limit | нет | `150` | Макс. строк вывода (защита от переполнения) |
|
| Limit | нет | `150` | Макс. строк вывода (защита от переполнения) |
|
||||||
| Offset | нет | `0` | Пропустить N строк (для пагинации) |
|
| Offset | нет | `0` | Пропустить N строк (для пагинации) |
|
||||||
|
|
||||||
@@ -32,6 +33,16 @@ allowed-tools:
|
|||||||
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь к Form.xml>"
|
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь к Form.xml>"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Раскрыть содержимое страницы:
|
||||||
|
```powershell
|
||||||
|
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь>" -Expand "Основное"
|
||||||
|
```
|
||||||
|
|
||||||
|
Раскрыть все свёрнутые секции:
|
||||||
|
```powershell
|
||||||
|
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь>" -Expand "*"
|
||||||
|
```
|
||||||
|
|
||||||
С пагинацией:
|
С пагинацией:
|
||||||
```powershell
|
```powershell
|
||||||
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь>" -Offset 150
|
powershell.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь>" -Offset 150
|
||||||
@@ -112,7 +123,7 @@ Elements:
|
|||||||
| `[Button]` | Button |
|
| `[Button]` | Button |
|
||||||
| `[CmdBar]` | CommandBar |
|
| `[CmdBar]` | CommandBar |
|
||||||
| `[Pages]` | Pages |
|
| `[Pages]` | Pages |
|
||||||
| `[Page]` | Page (показывает кол-во элементов вместо раскрытия) |
|
| `[Page]` | Page (свёрнут — показывает кол-во элементов; раскрывается через `-Expand`) |
|
||||||
| `[Popup]` | Popup |
|
| `[Popup]` | Popup |
|
||||||
| `[BtnGroup]` | ButtonGroup |
|
| `[BtnGroup]` | ButtonGroup |
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
# form-info v1.0 — Analyze 1C managed form structure
|
# form-info v1.1 — Analyze 1C managed form structure
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$FormPath,
|
[string]$FormPath,
|
||||||
[int]$Limit = 150,
|
[int]$Limit = 150,
|
||||||
[int]$Offset = 0
|
[int]$Offset = 0,
|
||||||
|
[string]$Expand
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
@@ -232,6 +233,7 @@ function Count-SignificantChildren($childItemsNode) {
|
|||||||
# --- Build element tree recursively ---
|
# --- Build element tree recursively ---
|
||||||
|
|
||||||
$treeLines = [System.Collections.Generic.List[string]]::new()
|
$treeLines = [System.Collections.Generic.List[string]]::new()
|
||||||
|
$script:hasCollapsed = $false
|
||||||
|
|
||||||
function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
|
function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
|
||||||
if (-not $childItemsNode) { return }
|
if (-not $childItemsNode) { return }
|
||||||
@@ -282,14 +284,21 @@ function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
|
|||||||
$line = "$prefix$connector $tag $name$binding$flags$titleStr$events"
|
$line = "$prefix$connector $tag $name$binding$flags$titleStr$events"
|
||||||
$treeLines.Add($line)
|
$treeLines.Add($line)
|
||||||
|
|
||||||
# Recurse into containers (but not Page — show summary)
|
# Recurse into containers (but not Page — show summary unless expanded)
|
||||||
$localName = $child.LocalName
|
$localName = $child.LocalName
|
||||||
if ($localName -eq "Page") {
|
if ($localName -eq "Page") {
|
||||||
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
|
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
|
||||||
$cnt = Count-SignificantChildren $ci
|
$pageName = $child.GetAttribute("name")
|
||||||
# Append count to last line
|
$pageTitle = Test-TitleDiffers $child $pageName
|
||||||
$idx = $treeLines.Count - 1
|
$shouldExpand = ($Expand -eq "*") -or ($Expand -eq $pageName) -or ($pageTitle -and $Expand -eq $pageTitle)
|
||||||
$treeLines[$idx] = $treeLines[$idx] + " ($cnt items)"
|
if ($shouldExpand -and $ci) {
|
||||||
|
Build-Tree $ci "$prefix$continuation" $last
|
||||||
|
} else {
|
||||||
|
$cnt = Count-SignificantChildren $ci
|
||||||
|
$idx = $treeLines.Count - 1
|
||||||
|
$treeLines[$idx] = $treeLines[$idx] + " ($cnt items)"
|
||||||
|
$script:hasCollapsed = $true
|
||||||
|
}
|
||||||
} elseif ($localName -in @("UsualGroup", "Pages", "Table", "CommandBar", "ButtonGroup", "Popup")) {
|
} elseif ($localName -in @("UsualGroup", "Pages", "Table", "CommandBar", "ButtonGroup", "Popup")) {
|
||||||
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
|
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
|
||||||
if ($ci) {
|
if ($ci) {
|
||||||
@@ -540,6 +549,13 @@ if ($isExtension) {
|
|||||||
$lines += "BaseForm: $bfStr"
|
$lines += "BaseForm: $bfStr"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --- Expand hint ---
|
||||||
|
|
||||||
|
if ($script:hasCollapsed) {
|
||||||
|
$lines += ""
|
||||||
|
$lines += "Hint: use -Expand <name> to expand a collapsed section, -Expand * for all"
|
||||||
|
}
|
||||||
|
|
||||||
# --- Truncation protection ---
|
# --- Truncation protection ---
|
||||||
|
|
||||||
$totalLines = $lines.Count
|
$totalLines = $lines.Count
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# form-info v1.0 — Analyze 1C managed form structure
|
# form-info v1.1 — Analyze 1C managed form structure
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -264,7 +264,7 @@ def count_significant_children(child_items_node):
|
|||||||
|
|
||||||
# --- Build element tree recursively ---
|
# --- Build element tree recursively ---
|
||||||
|
|
||||||
def build_tree(child_items_node, prefix, tree_lines):
|
def build_tree(child_items_node, prefix, tree_lines, expand="", state=None):
|
||||||
if child_items_node is None:
|
if child_items_node is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -316,17 +316,24 @@ def build_tree(child_items_node, prefix, tree_lines):
|
|||||||
line = f"{prefix}{connector} {tag} {name}{binding}{flags}{title_str}{events}"
|
line = f"{prefix}{connector} {tag} {name}{binding}{flags}{title_str}{events}"
|
||||||
tree_lines.append(line)
|
tree_lines.append(line)
|
||||||
|
|
||||||
# Recurse into containers (but not Page -- show summary)
|
# Recurse into containers (but not Page -- show summary unless expanded)
|
||||||
local_name = etree.QName(child.tag).localname
|
local_name = etree.QName(child.tag).localname
|
||||||
if local_name == "Page":
|
if local_name == "Page":
|
||||||
ci = child.find("d:ChildItems", NSMAP)
|
ci = child.find("d:ChildItems", NSMAP)
|
||||||
cnt = count_significant_children(ci)
|
page_name = child.get("name", "")
|
||||||
# Append count to last line
|
page_title = test_title_differs(child, page_name)
|
||||||
tree_lines[-1] = tree_lines[-1] + f" ({cnt} items)"
|
should_expand = (expand == "*") or (expand == page_name) or (page_title and expand == page_title)
|
||||||
|
if should_expand and ci is not None:
|
||||||
|
build_tree(ci, prefix + continuation, tree_lines, expand, state)
|
||||||
|
else:
|
||||||
|
cnt = count_significant_children(ci)
|
||||||
|
tree_lines[-1] = tree_lines[-1] + f" ({cnt} items)"
|
||||||
|
if state is not None:
|
||||||
|
state["has_collapsed"] = True
|
||||||
elif local_name in ("UsualGroup", "Pages", "Table", "CommandBar", "ButtonGroup", "Popup"):
|
elif local_name in ("UsualGroup", "Pages", "Table", "CommandBar", "ButtonGroup", "Popup"):
|
||||||
ci = child.find("d:ChildItems", NSMAP)
|
ci = child.find("d:ChildItems", NSMAP)
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
build_tree(ci, prefix + continuation, tree_lines)
|
build_tree(ci, prefix + continuation, tree_lines, expand, state)
|
||||||
|
|
||||||
|
|
||||||
# --- Main ---
|
# --- Main ---
|
||||||
@@ -338,11 +345,13 @@ def main():
|
|||||||
parser.add_argument("-FormPath", required=True, help="Path to Form.xml")
|
parser.add_argument("-FormPath", required=True, help="Path to Form.xml")
|
||||||
parser.add_argument("-Limit", type=int, default=150, help="Max lines to show")
|
parser.add_argument("-Limit", type=int, default=150, help="Max lines to show")
|
||||||
parser.add_argument("-Offset", type=int, default=0, help="Line offset for pagination")
|
parser.add_argument("-Offset", type=int, default=0, help="Line offset for pagination")
|
||||||
|
parser.add_argument("-Expand", default="", help="Expand collapsed section by name, or * for all")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
form_path = args.FormPath
|
form_path = args.FormPath
|
||||||
limit = args.Limit
|
limit = args.Limit
|
||||||
offset = args.Offset
|
offset = args.Offset
|
||||||
|
expand = args.Expand
|
||||||
|
|
||||||
# --- Validate path ---
|
# --- Validate path ---
|
||||||
if not os.path.isfile(form_path):
|
if not os.path.isfile(form_path):
|
||||||
@@ -456,12 +465,13 @@ def main():
|
|||||||
lines.append(f" {e_name}{ct_str} -> {e_handler}")
|
lines.append(f" {e_name}{ct_str} -> {e_handler}")
|
||||||
|
|
||||||
# --- Element tree ---
|
# --- Element tree ---
|
||||||
|
tree_state = {"has_collapsed": False}
|
||||||
child_items = root.find("d:ChildItems", NSMAP)
|
child_items = root.find("d:ChildItems", NSMAP)
|
||||||
if child_items is not None:
|
if child_items is not None:
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append("Elements:")
|
lines.append("Elements:")
|
||||||
tree_lines = []
|
tree_lines = []
|
||||||
build_tree(child_items, " ", tree_lines)
|
build_tree(child_items, " ", tree_lines, expand, tree_state)
|
||||||
lines.extend(tree_lines)
|
lines.extend(tree_lines)
|
||||||
|
|
||||||
# --- Attributes ---
|
# --- Attributes ---
|
||||||
@@ -576,6 +586,11 @@ def main():
|
|||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append(f"BaseForm: {bf_str}")
|
lines.append(f"BaseForm: {bf_str}")
|
||||||
|
|
||||||
|
# --- Expand hint ---
|
||||||
|
if tree_state["has_collapsed"]:
|
||||||
|
lines.append("")
|
||||||
|
lines.append("Hint: use -Expand <name> to expand a collapsed section, -Expand * for all")
|
||||||
|
|
||||||
# --- Truncation protection ---
|
# --- Truncation protection ---
|
||||||
total_lines = len(lines)
|
total_lines = len(lines)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user