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:
Nick Shirokov
2026-03-15 19:21:51 +03:00
parent 9cffa81bcc
commit 1479f944f5
3 changed files with 58 additions and 16 deletions
+12 -1
View File
@@ -23,6 +23,7 @@ allowed-tools:
| Параметр | Обязательный | По умолчанию | Описание |
|-----------|:------------:|--------------|---------------------------------------------|
| FormPath | да | — | Путь к файлу Form.xml |
| Expand | нет | — | Раскрыть свёрнутую секцию по имени, `*` — все |
| Limit | нет | `150` | Макс. строк вывода (защита от переполнения) |
| 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
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.exe -NoProfile -File .claude/skills/form-info/scripts/form-info.ps1 -FormPath "<путь>" -Offset 150
@@ -112,7 +123,7 @@ Elements:
| `[Button]` | Button |
| `[CmdBar]` | CommandBar |
| `[Pages]` | Pages |
| `[Page]` | Page (показывает кол-во элементов вместо раскрытия) |
| `[Page]` | Page (свёрнут — показывает кол-во элементов; раскрывается через `-Expand`) |
| `[Popup]` | Popup |
| `[BtnGroup]` | ButtonGroup |
+23 -7
View File
@@ -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
param(
[Parameter(Mandatory=$true)]
[string]$FormPath,
[int]$Limit = 150,
[int]$Offset = 0
[int]$Offset = 0,
[string]$Expand
)
$ErrorActionPreference = "Stop"
@@ -232,6 +233,7 @@ function Count-SignificantChildren($childItemsNode) {
# --- Build element tree recursively ---
$treeLines = [System.Collections.Generic.List[string]]::new()
$script:hasCollapsed = $false
function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
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"
$treeLines.Add($line)
# Recurse into containers (but not Page — show summary)
# Recurse into containers (but not Page — show summary unless expanded)
$localName = $child.LocalName
if ($localName -eq "Page") {
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
$cnt = Count-SignificantChildren $ci
# Append count to last line
$idx = $treeLines.Count - 1
$treeLines[$idx] = $treeLines[$idx] + " ($cnt items)"
$pageName = $child.GetAttribute("name")
$pageTitle = Test-TitleDiffers $child $pageName
$shouldExpand = ($Expand -eq "*") -or ($Expand -eq $pageName) -or ($pageTitle -and $Expand -eq $pageTitle)
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")) {
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
if ($ci) {
@@ -540,6 +549,13 @@ if ($isExtension) {
$lines += "BaseForm: $bfStr"
}
# --- Expand hint ---
if ($script:hasCollapsed) {
$lines += ""
$lines += "Hint: use -Expand <name> to expand a collapsed section, -Expand * for all"
}
# --- Truncation protection ---
$totalLines = $lines.Count
+23 -8
View File
@@ -1,5 +1,5 @@
#!/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
import argparse
@@ -264,7 +264,7 @@ def count_significant_children(child_items_node):
# --- 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:
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}"
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
if local_name == "Page":
ci = child.find("d:ChildItems", NSMAP)
cnt = count_significant_children(ci)
# Append count to last line
tree_lines[-1] = tree_lines[-1] + f" ({cnt} items)"
page_name = child.get("name", "")
page_title = test_title_differs(child, page_name)
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"):
ci = child.find("d:ChildItems", NSMAP)
if ci is not None:
build_tree(ci, prefix + continuation, tree_lines)
build_tree(ci, prefix + continuation, tree_lines, expand, state)
# --- Main ---
@@ -338,11 +345,13 @@ def main():
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("-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()
form_path = args.FormPath
limit = args.Limit
offset = args.Offset
expand = args.Expand
# --- Validate path ---
if not os.path.isfile(form_path):
@@ -456,12 +465,13 @@ def main():
lines.append(f" {e_name}{ct_str} -> {e_handler}")
# --- Element tree ---
tree_state = {"has_collapsed": False}
child_items = root.find("d:ChildItems", NSMAP)
if child_items is not None:
lines.append("")
lines.append("Elements:")
tree_lines = []
build_tree(child_items, " ", tree_lines)
build_tree(child_items, " ", tree_lines, expand, tree_state)
lines.extend(tree_lines)
# --- Attributes ---
@@ -576,6 +586,11 @@ def main():
lines.append("")
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 ---
total_lines = len(lines)