diff --git a/docs/5-advanced/02c-agent-permissions.md b/docs/5-advanced/02c-agent-permissions.md index 00a4a11..7190415 100644 --- a/docs/5-advanced/02c-agent-permissions.md +++ b/docs/5-advanced/02c-agent-permissions.md @@ -337,7 +337,7 @@ task 权限控制 **Agent 可以调用哪些 subagent**。 Task 工具的完整参数定义如下: | 参数 | 类型 | 必需 | 说明 | -|------|------|------| +|------|------|------|------| | `description` | string | 是 | 任务描述(3-5 个词),用作子会话标题 | | `prompt` | string | 是 | 子代理要执行的任务提示 | | `subagent_type` | string | 是 | 要调用的子代理名称(必须是非 primary agent) | diff --git a/package.json b/package.json index be4a320..4631a1a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "scripts": { "dev": "bash scripts/stats.sh && vitepress dev docs", "build": "bash scripts/stats.sh && vitepress build docs", - "preview": "vitepress preview docs" + "preview": "vitepress preview docs", + "dev:win": "powershell -ExecutionPolicy Bypass -File scripts/stats.ps1 && vitepress dev docs", + "build:win": "powershell -ExecutionPolicy Bypass -File scripts/stats.ps1 && vitepress build docs" }, "keywords": [ "opencode", diff --git a/scripts/stats.ps1 b/scripts/stats.ps1 new file mode 100644 index 0000000..a118210 --- /dev/null +++ b/scripts/stats.ps1 @@ -0,0 +1,61 @@ +# Statistics Tutorial Word Count and Notes (Word-style) +# Chinese: each Han character counts as 1 word +# English: each word counts as 1 word + +function Count-Words { + param([string]$FilePath) + + # Read file content (UTF-8 encoding) + $content = Get-Content -Path $FilePath -Raw -Encoding UTF8 + + # Remove frontmatter (content between ---) + $content = $content -replace '^---\r?\n.*?\r?\n---\r?\n', '' + + # Count Chinese characters (Unicode range: \u4e00-\u9fff) + $chineseMatches = [regex]::Matches($content, '[\u4e00-\u9fff]') + $cnCount = $chineseMatches.Count + + # Remove Chinese characters + $noChinese = $content -replace '[\u4e00-\u9fff]', ' ' + + # Remove Markdown syntax and punctuation + $cleaned = $noChinese -replace '[#*|`[(){}<>:,:,.!?,,;""''''—...·\-_=+\/\\@$%^&~]', ' ' + + # Count English words + $englishMatches = [regex]::Matches($cleaned, '[a-zA-Z][a-zA-Z0-9]*') + $enCount = $englishMatches.Count + + return $cnCount + $enCount +} + +# Count all .md files under docs (excluding .vitepress directory) +$total = 0 +$mdFiles = Get-ChildItem -Path docs -Filter *.md -Recurse -File | + Where-Object { $_.FullName -notmatch '\\.vitepress\\' } + +foreach ($file in $mdFiles) { + $count = Count-Words -FilePath $file.FullName + $total += $count +} + +# Count 4K HD notes +try { + $notes = (Get-ChildItem -Path docs\public\images -Filter *-notes.jpeg -Recurse -File | + Where-Object { $_.Name -notmatch '\.mini\.jpeg$' }).Count +} catch { + $notes = 0 +} + +# Generate JSON object +$stats = @{ + wordCount = $total + notesCount = $notes +} + +# Write JSON file +$stats | ConvertTo-Json | Out-File -FilePath docs\data\stats.json -Encoding UTF8 -Force + +# Output results +Write-Host "Tutorial word count: $total" +Write-Host "4K notes: $notes images" +Write-Host "OK: docs\data\stats.json has been generated"