-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeads-helpers.ps1
More file actions
167 lines (146 loc) · 5.38 KB
/
Copy pathbeads-helpers.ps1
File metadata and controls
167 lines (146 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Beads Helper Commands
# Dot-source this script to load the 'bd' alias and all helper functions:
# . .\scripts\beads-helpers.ps1
#
# Then use bd just like the bd CLI:
# bd list
# bd create "My task" -Description "details" -Priority 2
# bd update <id> --claim
# bd close <id> --reason "done"
# bd ready
# bd stats
# -- Core bd alias -------------------------------------------------------------
function bd {
$scriptPath = Join-Path $PSScriptRoot "beads-query.ps1"
# Map lowercased flag names to the exact PowerShell param names in beads-query.ps1
$paramMap = @{
'status' = 'Status'
'description' = 'Description'
'priority' = 'Priority'
'type' = 'Type'
'reason' = 'Reason'
'deptype' = 'DepType'
'limit' = 'Limit'
'json' = 'Json'
'claim' = 'Claim'
}
$positional = @()
$namedParams = @{}
$i = 0
while ($i -lt $args.Count) {
$a = $args[$i]
if ($a -match '^--?(.+)$') {
$flagName = $Matches[1].ToLower()
$psName = if ($paramMap.Contains($flagName)) { $paramMap[$flagName] } else { $Matches[1] }
# If the next element exists and doesn't start with '-', treat it as the value
if (($i + 1) -lt $args.Count -and $args[$i + 1] -notmatch '^-') {
$namedParams[$psName] = $args[$i + 1]
$i += 2
} else {
$namedParams[$psName] = $true
$i++
}
} else {
$positional += $a
$i++
}
}
& $scriptPath @positional @namedParams
}
# -- Convenience wrappers ------------------------------------------------------
function bd-list-open { bd list --status open }
function bd-list-all { bd list }
function bd-show {
param([string]$Id)
bd show $Id
}
# Returns ALL open beads: unblocked first (P1→P2→P3), then blocked (P1→P2→P3).
# --limit 0 (default) shows every open bead. Pass -Limit <n> to cap the combined total.
function bd-ready {
param([int]$Limit = 0)
if ($Limit -gt 0) { bd ready --limit $Limit } else { bd ready --limit 0 }
}
function bd-create {
param(
[Parameter(Mandatory)][string]$Title,
[string]$Description = "",
[int] $Priority = 3,
[string]$Type = "task"
)
bd create $Title -Description $Description -Priority $Priority -Type $Type
}
function bd-update {
param(
[Parameter(Mandatory)][string]$Id,
[string]$Status = "",
[switch]$Claim,
[int] $Priority = 0
)
$extra = @()
if ($Claim) { $extra += "--claim" }
if ($Status) { $extra += "--status"; $extra += $Status }
if ($Priority) { $extra += "-Priority"; $extra += $Priority }
bd update $Id @extra
}
function bd-close {
param(
[Parameter(Mandatory)][string]$Id,
[string]$Reason = "Completed"
)
bd close $Id --reason $Reason
}
function bd-search {
param([Parameter(Mandatory)][string]$Query)
bd search $Query
}
function bd-dep { bd dep @args }
# List augment-extensions related tasks
function bd-list-augext {
Write-Host ""
Write-Host "=== Augment Extensions System Tasks ===" -ForegroundColor Cyan
Write-Host ""
bd search "augext"
}
# List character count related tasks
function bd-list-charcount {
Write-Host ""
Write-Host "=== Character Count Rule Installation Tasks ===" -ForegroundColor Cyan
Write-Host ""
bd search "charcount"
}
# Show help
function bd-help {
Write-Host ""
Write-Host "=== Beads Helper Commands ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "Core alias:" -ForegroundColor Yellow
Write-Host " bd <command> [args] # Full bd CLI parity via beads-query.ps1"
Write-Host ""
Write-Host "Convenience wrappers:" -ForegroundColor Yellow
Write-Host " bd-list-open # bd list --status open"
Write-Host " bd-list-all # bd list"
Write-Host " bd-show <id> # bd show <id>"
Write-Host " bd-ready [-Limit <n>] # all open tasks: unblocked first then blocked, priority order"
Write-Host " bd-create <title> # bd create <title> [-Description] [-Priority] [-Type]"
Write-Host " bd-update <id> # bd update <id> [-Status] [-Claim] [-Priority]"
Write-Host " bd-close <id> # bd close <id> [-Reason]"
Write-Host " bd-search <query> # bd search <query>"
Write-Host " bd-dep [args] # bd dep add|list|remove <id> [dep-id]"
Write-Host " bd-list-augext # Show augment-extensions tasks"
Write-Host " bd-list-charcount # Show character-count tasks"
Write-Host " bd-help # Show this help"
Write-Host ""
Write-Host "Examples:" -ForegroundColor Yellow
Write-Host " bd list"
Write-Host " bd create `"Fix the login bug`" -Priority 1"
Write-Host " bd update bd-a1b2 --claim"
Write-Host " bd close bd-a1b2 --reason `"Fixed in PR #42`""
Write-Host " bd stats"
Write-Host " bd ready # all open beads (unblocked first, then blocked)"
Write-Host " bd ready --limit 5 # top 5 from combined unblocked+blocked list"
Write-Host ""
}
# -- Dot-source detection ------------------------------------------------------
if ($MyInvocation.InvocationName -eq '.') {
Write-Host "Beads helper commands loaded. Run 'bd-help' for usage." -ForegroundColor Green
}