@drfed/drfed 0.0.0-stage → 0.1.0-dev.561

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.
Files changed (165) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1198 -2
  3. package/bin/drfed-account.mjs +20 -0
  4. package/bin/drfed-migrate.mjs +20 -0
  5. package/bin/drfed-server.mjs +20 -0
  6. package/bin/drfed-web.mjs +20 -0
  7. package/completions/bash/drfed-account +219 -0
  8. package/completions/bash/drfed-migrate +219 -0
  9. package/completions/bash/drfed-server +219 -0
  10. package/completions/bash/drfed-web +219 -0
  11. package/completions/fish/drfed-account.fish +264 -0
  12. package/completions/fish/drfed-migrate.fish +264 -0
  13. package/completions/fish/drfed-server.fish +264 -0
  14. package/completions/fish/drfed-web.fish +264 -0
  15. package/completions/nu/drfed-account.nu +293 -0
  16. package/completions/nu/drfed-migrate.nu +293 -0
  17. package/completions/nu/drfed-server.nu +293 -0
  18. package/completions/nu/drfed-web.nu +293 -0
  19. package/completions/pwsh/drfed-account.ps1 +183 -0
  20. package/completions/pwsh/drfed-migrate.ps1 +183 -0
  21. package/completions/pwsh/drfed-server.ps1 +183 -0
  22. package/completions/pwsh/drfed-web.ps1 +183 -0
  23. package/completions/zsh/_drfed-account +145 -0
  24. package/completions/zsh/_drfed-migrate +145 -0
  25. package/completions/zsh/_drfed-server +145 -0
  26. package/completions/zsh/_drfed-web +145 -0
  27. package/dist/api-mail-parser.d.mts +106 -0
  28. package/dist/api-mail-parser.d.mts.map +1 -0
  29. package/dist/api-mail-parser.mjs +145 -0
  30. package/dist/api-mail-parser.mjs.map +1 -0
  31. package/dist/api-mail-settings-BcGaqQ9f.d.mts +142 -0
  32. package/dist/api-mail-settings-BcGaqQ9f.d.mts.map +1 -0
  33. package/dist/api-mail-settings.d.mts +2 -0
  34. package/dist/api-mail-settings.mjs +272 -0
  35. package/dist/api-mail-settings.mjs.map +1 -0
  36. package/dist/bounded-mail-runtime.d.mts +9 -0
  37. package/dist/bounded-mail-runtime.d.mts.map +1 -0
  38. package/dist/bounded-mail-runtime.mjs +66 -0
  39. package/dist/bounded-mail-runtime.mjs.map +1 -0
  40. package/dist/commands/account-create.d.mts +37 -0
  41. package/dist/commands/account-create.d.mts.map +1 -0
  42. package/dist/commands/account-create.mjs +87 -0
  43. package/dist/commands/account-create.mjs.map +1 -0
  44. package/dist/commands/account-program.d.mts +223 -0
  45. package/dist/commands/account-program.d.mts.map +1 -0
  46. package/dist/commands/account-program.mjs +116 -0
  47. package/dist/commands/account-program.mjs.map +1 -0
  48. package/dist/commands/account.d.mts +6 -0
  49. package/dist/commands/account.d.mts.map +1 -0
  50. package/dist/commands/account.mjs +91 -0
  51. package/dist/commands/account.mjs.map +1 -0
  52. package/dist/commands/migrate-program.d.mts +219 -0
  53. package/dist/commands/migrate-program.d.mts.map +1 -0
  54. package/dist/commands/migrate-program.mjs +116 -0
  55. package/dist/commands/migrate-program.mjs.map +1 -0
  56. package/dist/commands/migrate.d.mts +6 -0
  57. package/dist/commands/migrate.d.mts.map +1 -0
  58. package/dist/commands/migrate.mjs +85 -0
  59. package/dist/commands/migrate.mjs.map +1 -0
  60. package/dist/commands/web-program.d.mts +213 -0
  61. package/dist/commands/web-program.d.mts.map +1 -0
  62. package/dist/commands/web-program.mjs +112 -0
  63. package/dist/commands/web-program.mjs.map +1 -0
  64. package/dist/commands/web.d.mts +6 -0
  65. package/dist/commands/web.d.mts.map +1 -0
  66. package/dist/commands/web.mjs +184 -0
  67. package/dist/commands/web.mjs.map +1 -0
  68. package/dist/configuration-DVVF7xNv.d.mts +432 -0
  69. package/dist/configuration-DVVF7xNv.d.mts.map +1 -0
  70. package/dist/configuration.d.mts +2 -0
  71. package/dist/configuration.mjs +469 -0
  72. package/dist/configuration.mjs.map +1 -0
  73. package/dist/data-path.d.mts +9 -0
  74. package/dist/data-path.d.mts.map +1 -0
  75. package/dist/data-path.mjs +21 -0
  76. package/dist/data-path.mjs.map +1 -0
  77. package/dist/database-runtime.d.mts +26 -0
  78. package/dist/database-runtime.d.mts.map +1 -0
  79. package/dist/database-runtime.mjs +92 -0
  80. package/dist/database-runtime.mjs.map +1 -0
  81. package/dist/database-settings.d.mts +36 -0
  82. package/dist/database-settings.d.mts.map +1 -0
  83. package/dist/database-settings.mjs +67 -0
  84. package/dist/database-settings.mjs.map +1 -0
  85. package/dist/diagnostics.d.mts +29 -0
  86. package/dist/diagnostics.d.mts.map +1 -0
  87. package/dist/diagnostics.mjs +61 -0
  88. package/dist/diagnostics.mjs.map +1 -0
  89. package/dist/index.d.mts +5 -0
  90. package/dist/index.d.mts.map +1 -0
  91. package/dist/index.mjs +344 -0
  92. package/dist/index.mjs.map +1 -0
  93. package/dist/jmap-parser.d.mts +35 -0
  94. package/dist/jmap-parser.d.mts.map +1 -0
  95. package/dist/jmap-parser.mjs +42 -0
  96. package/dist/jmap-parser.mjs.map +1 -0
  97. package/dist/jmap-runtime.d.mts +10 -0
  98. package/dist/jmap-runtime.d.mts.map +1 -0
  99. package/dist/jmap-runtime.mjs +17 -0
  100. package/dist/jmap-runtime.mjs.map +1 -0
  101. package/dist/jmap-settings-BXNAF1ep.d.mts +41 -0
  102. package/dist/jmap-settings-BXNAF1ep.d.mts.map +1 -0
  103. package/dist/jmap-settings.d.mts +2 -0
  104. package/dist/jmap-settings.mjs +104 -0
  105. package/dist/jmap-settings.mjs.map +1 -0
  106. package/dist/logging.d.mts +33 -0
  107. package/dist/logging.d.mts.map +1 -0
  108. package/dist/logging.mjs +56 -0
  109. package/dist/logging.mjs.map +1 -0
  110. package/dist/mail-parser-DyI4wuQp.d.mts +246 -0
  111. package/dist/mail-parser-DyI4wuQp.d.mts.map +1 -0
  112. package/dist/mail-parser.d.mts +2 -0
  113. package/dist/mail-parser.mjs +100 -0
  114. package/dist/mail-parser.mjs.map +1 -0
  115. package/dist/mail-runtime-YROIQ8up.mjs +314 -0
  116. package/dist/mail-runtime-YROIQ8up.mjs.map +1 -0
  117. package/dist/mail-runtime.d.mts +68 -0
  118. package/dist/mail-runtime.d.mts.map +1 -0
  119. package/dist/mail-runtime.mjs +2 -0
  120. package/dist/mail-settings-BD1TQ0rt.mjs +427 -0
  121. package/dist/mail-settings-BD1TQ0rt.mjs.map +1 -0
  122. package/dist/mail-settings-DjWMAUaE.d.mts +80 -0
  123. package/dist/mail-settings-DjWMAUaE.d.mts.map +1 -0
  124. package/dist/mail-settings.d.mts +2 -0
  125. package/dist/mail-settings.mjs +2 -0
  126. package/dist/operations.d.mts +32 -0
  127. package/dist/operations.d.mts.map +1 -0
  128. package/dist/operations.mjs +55 -0
  129. package/dist/operations.mjs.map +1 -0
  130. package/dist/package-D1pbtLwn.mjs +6 -0
  131. package/dist/package-D1pbtLwn.mjs.map +1 -0
  132. package/dist/parser-DGIQTgS7.mjs +178 -0
  133. package/dist/parser-DGIQTgS7.mjs.map +1 -0
  134. package/dist/parser-TANGHRjL.d.mts +305 -0
  135. package/dist/parser-TANGHRjL.d.mts.map +1 -0
  136. package/dist/postgres-settings.d.mts +20 -0
  137. package/dist/postgres-settings.d.mts.map +1 -0
  138. package/dist/postgres-settings.mjs +60 -0
  139. package/dist/postgres-settings.mjs.map +1 -0
  140. package/dist/query-logger.d.mts +9 -0
  141. package/dist/query-logger.d.mts.map +1 -0
  142. package/dist/query-logger.mjs +17 -0
  143. package/dist/query-logger.mjs.map +1 -0
  144. package/dist/resources.d.mts +20 -0
  145. package/dist/resources.d.mts.map +1 -0
  146. package/dist/resources.mjs +34 -0
  147. package/dist/resources.mjs.map +1 -0
  148. package/dist/secret-source-BeZx72Ue.d.mts +21 -0
  149. package/dist/secret-source-BeZx72Ue.d.mts.map +1 -0
  150. package/dist/secret-source.d.mts +2 -0
  151. package/dist/secret-source.mjs +58 -0
  152. package/dist/secret-source.mjs.map +1 -0
  153. package/dist/serving.d.mts +82 -0
  154. package/dist/serving.d.mts.map +1 -0
  155. package/dist/serving.mjs +138 -0
  156. package/dist/serving.mjs.map +1 -0
  157. package/dist/smtp-settings.d.mts +11 -0
  158. package/dist/smtp-settings.d.mts.map +1 -0
  159. package/dist/smtp-settings.mjs +38 -0
  160. package/dist/smtp-settings.mjs.map +1 -0
  161. package/dist/valueparser.d.mts +46 -0
  162. package/dist/valueparser.d.mts.map +1 -0
  163. package/dist/valueparser.mjs +121 -0
  164. package/dist/valueparser.mjs.map +1 -0
  165. package/package.json +287 -3
@@ -0,0 +1,183 @@
1
+
2
+ Register-ArgumentCompleter -Native -CommandName drfed-account -ScriptBlock {
3
+ param($wordToComplete, $commandAst, $cursorPosition)
4
+
5
+ # Extract arguments from AST (handles quoted strings properly)
6
+ $arguments = @()
7
+ $commandElements = $commandAst.CommandElements
8
+
9
+ # Determine the range of elements to extract
10
+ # Exclude the last element if it matches wordToComplete (partial input case)
11
+ $maxIndex = $commandElements.Count - 1
12
+ if ($commandElements.Count -gt 1) {
13
+ $lastElement = $commandElements[$commandElements.Count - 1]
14
+ $lastText = if ($lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
15
+ $lastElement.Value
16
+ } else {
17
+ $lastElement.Extent.Text
18
+ }
19
+ if ($lastText -eq $wordToComplete) {
20
+ $maxIndex = $commandElements.Count - 2
21
+ }
22
+ }
23
+
24
+ for ($i = 1; $i -le $maxIndex; $i++) {
25
+ $element = $commandElements[$i]
26
+
27
+ if ($element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
28
+ $arguments += $element.Value
29
+ } else {
30
+ $arguments += $element.Extent.Text
31
+ }
32
+ }
33
+
34
+ # Build arguments array for completion command
35
+ $completionArgs = @()
36
+ $completionArgs += @('completion', 'pwsh')
37
+ $completionArgs += $arguments
38
+ $completionArgs += $wordToComplete
39
+
40
+ # Call completion command and capture output
41
+ try {
42
+ $output = & drfed-account $completionArgs 2>$null
43
+ if (-not $output) { return }
44
+
45
+ # Parse tab-separated output and create CompletionResult objects
46
+ $output -split "`n" | ForEach-Object {
47
+ $line = $_.Trim()
48
+ if (-not $line) { return }
49
+
50
+ if ($line -match '^__FILE__:') {
51
+ # Parse file completion directive: __FILE__:type:extensions:pattern:hidden
52
+ $directive = ($line -split "`t")[0]
53
+ $parts = $directive -split ':', 5
54
+ $type = $parts[1]
55
+ $extensions = $parts[2]
56
+ $pattern = $parts[3] -replace '%3A', ':' -replace '%25', '%'
57
+ $hidden = $parts[4] -eq '1'
58
+
59
+ # When a pattern is specified, use it as the file matching
60
+ # prefix instead of the current word. If the user has
61
+ # already typed beyond the pattern, keep their input for
62
+ # incremental narrowing. Normalize path separators before
63
+ # comparing so that Windows backslashes match forward slashes
64
+ # in the transported pattern.
65
+ $normalizedPattern = if ($pattern) { $pattern.Replace('\', '/') -replace '^\./','' } else { '' }
66
+ $normalizedWord = if ($wordToComplete) { $wordToComplete.Replace('\', '/') -replace '^\./','' } else { '' }
67
+ $comparison = if ($IsWindows) { [System.StringComparison]::OrdinalIgnoreCase } else { [System.StringComparison]::Ordinal }
68
+ # For wildcard patterns, compare only the directory prefix
69
+ $comparePattern = $normalizedPattern
70
+ if ($comparePattern -match '[*?]') {
71
+ $beforeWild = $comparePattern -replace '[*?].*', ''
72
+ if ($beforeWild.Contains('/')) {
73
+ $comparePattern = $beforeWild.Substring(0, $beforeWild.LastIndexOf('/') + 1)
74
+ } else {
75
+ $comparePattern = ''
76
+ }
77
+ }
78
+ $prefix = if (($comparePattern -or $normalizedWord) -and $normalizedWord -and $normalizedWord.StartsWith($comparePattern, $comparison) -and $normalizedWord.Length -ge $comparePattern.Length -and $wordToComplete -ne $pattern) {
79
+ $wordToComplete
80
+ } elseif ($pattern) {
81
+ $pattern
82
+ } elseif ($wordToComplete) {
83
+ $wordToComplete
84
+ } else { '' }
85
+
86
+ # Use -Force to include hidden files when requested, or when
87
+ # the prefix basename targets dotfiles (e.g., src/.e)
88
+ $prefixBasename = if ($prefix) { Split-Path -Leaf $prefix } else { '' }
89
+ $forceParam = if ($hidden -or ($prefixBasename -and $prefixBasename.StartsWith('.'))) { @{Force = $true} } else { @{} }
90
+
91
+ # If prefix is a directory without trailing slash, append
92
+ # one so Get-ChildItem lists its contents
93
+ if ($prefix -and (Test-Path -Path $prefix -PathType Container) -and -not $prefix.EndsWith('/') -and -not $prefix.EndsWith('\')) {
94
+ $prefix = $prefix + '/'
95
+ }
96
+
97
+ # Build the glob path—when the prefix contains wildcard
98
+ # characters, use it as-is; otherwise append *
99
+ $globPath = if ($prefix -match '[*?]') { $prefix } else { "${prefix}*" }
100
+
101
+ # Get file system items based on type
102
+ $items = @()
103
+ switch ($type) {
104
+ 'file' {
105
+ if ($extensions) {
106
+ # Filter by extensions, always include directories
107
+ $extList = ($extensions -split ',') -replace '^\.',''
108
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
109
+ Where-Object {
110
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
111
+ }
112
+ } else {
113
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
114
+ }
115
+ }
116
+ 'directory' {
117
+ $items = Get-ChildItem @forceParam -Directory -Path $globPath -ErrorAction SilentlyContinue
118
+ }
119
+ 'any' {
120
+ if ($extensions) {
121
+ # Filter by extensions, always include directories
122
+ $extList = ($extensions -split ',') -replace '^\.',''
123
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
124
+ Where-Object {
125
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
126
+ }
127
+ } else {
128
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
129
+ }
130
+ }
131
+ }
132
+
133
+ # For file/any modes with glob patterns, also add directories
134
+ # from the base directory for navigation
135
+ if ($prefix -match '[*?]' -and $type -ne 'directory') {
136
+ $globDir = Split-Path -Parent $prefix
137
+ if (-not $globDir) { $globDir = '.' }
138
+ $extraDirs = Get-ChildItem @forceParam -Directory -Path "$globDir/*" -ErrorAction SilentlyContinue
139
+ if ($extraDirs) { $items = @($items) + @($extraDirs) | Select-Object -Unique }
140
+ }
141
+
142
+ # Filter hidden files unless requested or the prefix targets dotfiles
143
+ if (-not $hidden -and -not ($prefixBasename -and $prefixBasename.StartsWith('.'))) {
144
+ $items = $items | Where-Object { -not $_.Attributes.HasFlag([System.IO.FileAttributes]::Hidden) }
145
+ }
146
+
147
+ # Extract directory prefix to preserve in completion text
148
+ $dirPrefix = if ($prefix -and ($prefix.Contains('/') -or $prefix.Contains('\'))) {
149
+ $slashIdx = [Math]::Max($prefix.LastIndexOf('/'), $prefix.LastIndexOf('\'))
150
+ $prefix.Substring(0, $slashIdx + 1)
151
+ } else { '' }
152
+
153
+ # Create completion results for files
154
+ $items | ForEach-Object {
155
+ $completionText = if ($_.PSIsContainer) { "$dirPrefix$($_.Name)/" } else { "$dirPrefix$($_.Name)" }
156
+ $itemType = if ($_.PSIsContainer) { 'Directory' } else { 'File' }
157
+ [System.Management.Automation.CompletionResult]::new(
158
+ $completionText,
159
+ $completionText,
160
+ 'ParameterValue',
161
+ $itemType
162
+ )
163
+ }
164
+ } else {
165
+ # Parse literal completion: text\tlistItemText\tdescription
166
+ $parts = $line -split "`t", 3
167
+ $completionText = $parts[0]
168
+ $listItemText = if ($parts.Length -gt 1 -and $parts[1]) { $parts[1] } else { $completionText }
169
+ $toolTip = if ($parts.Length -gt 2 -and $parts[2]) { $parts[2] } else { $completionText }
170
+
171
+ [System.Management.Automation.CompletionResult]::new(
172
+ $completionText,
173
+ $listItemText,
174
+ 'ParameterValue',
175
+ $toolTip
176
+ )
177
+ }
178
+ }
179
+ } catch {
180
+ # Silently ignore errors
181
+ }
182
+ }
183
+
@@ -0,0 +1,183 @@
1
+
2
+ Register-ArgumentCompleter -Native -CommandName drfed-migrate -ScriptBlock {
3
+ param($wordToComplete, $commandAst, $cursorPosition)
4
+
5
+ # Extract arguments from AST (handles quoted strings properly)
6
+ $arguments = @()
7
+ $commandElements = $commandAst.CommandElements
8
+
9
+ # Determine the range of elements to extract
10
+ # Exclude the last element if it matches wordToComplete (partial input case)
11
+ $maxIndex = $commandElements.Count - 1
12
+ if ($commandElements.Count -gt 1) {
13
+ $lastElement = $commandElements[$commandElements.Count - 1]
14
+ $lastText = if ($lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
15
+ $lastElement.Value
16
+ } else {
17
+ $lastElement.Extent.Text
18
+ }
19
+ if ($lastText -eq $wordToComplete) {
20
+ $maxIndex = $commandElements.Count - 2
21
+ }
22
+ }
23
+
24
+ for ($i = 1; $i -le $maxIndex; $i++) {
25
+ $element = $commandElements[$i]
26
+
27
+ if ($element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
28
+ $arguments += $element.Value
29
+ } else {
30
+ $arguments += $element.Extent.Text
31
+ }
32
+ }
33
+
34
+ # Build arguments array for completion command
35
+ $completionArgs = @()
36
+ $completionArgs += @('completion', 'pwsh')
37
+ $completionArgs += $arguments
38
+ $completionArgs += $wordToComplete
39
+
40
+ # Call completion command and capture output
41
+ try {
42
+ $output = & drfed-migrate $completionArgs 2>$null
43
+ if (-not $output) { return }
44
+
45
+ # Parse tab-separated output and create CompletionResult objects
46
+ $output -split "`n" | ForEach-Object {
47
+ $line = $_.Trim()
48
+ if (-not $line) { return }
49
+
50
+ if ($line -match '^__FILE__:') {
51
+ # Parse file completion directive: __FILE__:type:extensions:pattern:hidden
52
+ $directive = ($line -split "`t")[0]
53
+ $parts = $directive -split ':', 5
54
+ $type = $parts[1]
55
+ $extensions = $parts[2]
56
+ $pattern = $parts[3] -replace '%3A', ':' -replace '%25', '%'
57
+ $hidden = $parts[4] -eq '1'
58
+
59
+ # When a pattern is specified, use it as the file matching
60
+ # prefix instead of the current word. If the user has
61
+ # already typed beyond the pattern, keep their input for
62
+ # incremental narrowing. Normalize path separators before
63
+ # comparing so that Windows backslashes match forward slashes
64
+ # in the transported pattern.
65
+ $normalizedPattern = if ($pattern) { $pattern.Replace('\', '/') -replace '^\./','' } else { '' }
66
+ $normalizedWord = if ($wordToComplete) { $wordToComplete.Replace('\', '/') -replace '^\./','' } else { '' }
67
+ $comparison = if ($IsWindows) { [System.StringComparison]::OrdinalIgnoreCase } else { [System.StringComparison]::Ordinal }
68
+ # For wildcard patterns, compare only the directory prefix
69
+ $comparePattern = $normalizedPattern
70
+ if ($comparePattern -match '[*?]') {
71
+ $beforeWild = $comparePattern -replace '[*?].*', ''
72
+ if ($beforeWild.Contains('/')) {
73
+ $comparePattern = $beforeWild.Substring(0, $beforeWild.LastIndexOf('/') + 1)
74
+ } else {
75
+ $comparePattern = ''
76
+ }
77
+ }
78
+ $prefix = if (($comparePattern -or $normalizedWord) -and $normalizedWord -and $normalizedWord.StartsWith($comparePattern, $comparison) -and $normalizedWord.Length -ge $comparePattern.Length -and $wordToComplete -ne $pattern) {
79
+ $wordToComplete
80
+ } elseif ($pattern) {
81
+ $pattern
82
+ } elseif ($wordToComplete) {
83
+ $wordToComplete
84
+ } else { '' }
85
+
86
+ # Use -Force to include hidden files when requested, or when
87
+ # the prefix basename targets dotfiles (e.g., src/.e)
88
+ $prefixBasename = if ($prefix) { Split-Path -Leaf $prefix } else { '' }
89
+ $forceParam = if ($hidden -or ($prefixBasename -and $prefixBasename.StartsWith('.'))) { @{Force = $true} } else { @{} }
90
+
91
+ # If prefix is a directory without trailing slash, append
92
+ # one so Get-ChildItem lists its contents
93
+ if ($prefix -and (Test-Path -Path $prefix -PathType Container) -and -not $prefix.EndsWith('/') -and -not $prefix.EndsWith('\')) {
94
+ $prefix = $prefix + '/'
95
+ }
96
+
97
+ # Build the glob path—when the prefix contains wildcard
98
+ # characters, use it as-is; otherwise append *
99
+ $globPath = if ($prefix -match '[*?]') { $prefix } else { "${prefix}*" }
100
+
101
+ # Get file system items based on type
102
+ $items = @()
103
+ switch ($type) {
104
+ 'file' {
105
+ if ($extensions) {
106
+ # Filter by extensions, always include directories
107
+ $extList = ($extensions -split ',') -replace '^\.',''
108
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
109
+ Where-Object {
110
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
111
+ }
112
+ } else {
113
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
114
+ }
115
+ }
116
+ 'directory' {
117
+ $items = Get-ChildItem @forceParam -Directory -Path $globPath -ErrorAction SilentlyContinue
118
+ }
119
+ 'any' {
120
+ if ($extensions) {
121
+ # Filter by extensions, always include directories
122
+ $extList = ($extensions -split ',') -replace '^\.',''
123
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
124
+ Where-Object {
125
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
126
+ }
127
+ } else {
128
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
129
+ }
130
+ }
131
+ }
132
+
133
+ # For file/any modes with glob patterns, also add directories
134
+ # from the base directory for navigation
135
+ if ($prefix -match '[*?]' -and $type -ne 'directory') {
136
+ $globDir = Split-Path -Parent $prefix
137
+ if (-not $globDir) { $globDir = '.' }
138
+ $extraDirs = Get-ChildItem @forceParam -Directory -Path "$globDir/*" -ErrorAction SilentlyContinue
139
+ if ($extraDirs) { $items = @($items) + @($extraDirs) | Select-Object -Unique }
140
+ }
141
+
142
+ # Filter hidden files unless requested or the prefix targets dotfiles
143
+ if (-not $hidden -and -not ($prefixBasename -and $prefixBasename.StartsWith('.'))) {
144
+ $items = $items | Where-Object { -not $_.Attributes.HasFlag([System.IO.FileAttributes]::Hidden) }
145
+ }
146
+
147
+ # Extract directory prefix to preserve in completion text
148
+ $dirPrefix = if ($prefix -and ($prefix.Contains('/') -or $prefix.Contains('\'))) {
149
+ $slashIdx = [Math]::Max($prefix.LastIndexOf('/'), $prefix.LastIndexOf('\'))
150
+ $prefix.Substring(0, $slashIdx + 1)
151
+ } else { '' }
152
+
153
+ # Create completion results for files
154
+ $items | ForEach-Object {
155
+ $completionText = if ($_.PSIsContainer) { "$dirPrefix$($_.Name)/" } else { "$dirPrefix$($_.Name)" }
156
+ $itemType = if ($_.PSIsContainer) { 'Directory' } else { 'File' }
157
+ [System.Management.Automation.CompletionResult]::new(
158
+ $completionText,
159
+ $completionText,
160
+ 'ParameterValue',
161
+ $itemType
162
+ )
163
+ }
164
+ } else {
165
+ # Parse literal completion: text\tlistItemText\tdescription
166
+ $parts = $line -split "`t", 3
167
+ $completionText = $parts[0]
168
+ $listItemText = if ($parts.Length -gt 1 -and $parts[1]) { $parts[1] } else { $completionText }
169
+ $toolTip = if ($parts.Length -gt 2 -and $parts[2]) { $parts[2] } else { $completionText }
170
+
171
+ [System.Management.Automation.CompletionResult]::new(
172
+ $completionText,
173
+ $listItemText,
174
+ 'ParameterValue',
175
+ $toolTip
176
+ )
177
+ }
178
+ }
179
+ } catch {
180
+ # Silently ignore errors
181
+ }
182
+ }
183
+
@@ -0,0 +1,183 @@
1
+
2
+ Register-ArgumentCompleter -Native -CommandName drfed-server -ScriptBlock {
3
+ param($wordToComplete, $commandAst, $cursorPosition)
4
+
5
+ # Extract arguments from AST (handles quoted strings properly)
6
+ $arguments = @()
7
+ $commandElements = $commandAst.CommandElements
8
+
9
+ # Determine the range of elements to extract
10
+ # Exclude the last element if it matches wordToComplete (partial input case)
11
+ $maxIndex = $commandElements.Count - 1
12
+ if ($commandElements.Count -gt 1) {
13
+ $lastElement = $commandElements[$commandElements.Count - 1]
14
+ $lastText = if ($lastElement -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
15
+ $lastElement.Value
16
+ } else {
17
+ $lastElement.Extent.Text
18
+ }
19
+ if ($lastText -eq $wordToComplete) {
20
+ $maxIndex = $commandElements.Count - 2
21
+ }
22
+ }
23
+
24
+ for ($i = 1; $i -le $maxIndex; $i++) {
25
+ $element = $commandElements[$i]
26
+
27
+ if ($element -is [System.Management.Automation.Language.StringConstantExpressionAst]) {
28
+ $arguments += $element.Value
29
+ } else {
30
+ $arguments += $element.Extent.Text
31
+ }
32
+ }
33
+
34
+ # Build arguments array for completion command
35
+ $completionArgs = @()
36
+ $completionArgs += @('completion', 'pwsh')
37
+ $completionArgs += $arguments
38
+ $completionArgs += $wordToComplete
39
+
40
+ # Call completion command and capture output
41
+ try {
42
+ $output = & drfed-server $completionArgs 2>$null
43
+ if (-not $output) { return }
44
+
45
+ # Parse tab-separated output and create CompletionResult objects
46
+ $output -split "`n" | ForEach-Object {
47
+ $line = $_.Trim()
48
+ if (-not $line) { return }
49
+
50
+ if ($line -match '^__FILE__:') {
51
+ # Parse file completion directive: __FILE__:type:extensions:pattern:hidden
52
+ $directive = ($line -split "`t")[0]
53
+ $parts = $directive -split ':', 5
54
+ $type = $parts[1]
55
+ $extensions = $parts[2]
56
+ $pattern = $parts[3] -replace '%3A', ':' -replace '%25', '%'
57
+ $hidden = $parts[4] -eq '1'
58
+
59
+ # When a pattern is specified, use it as the file matching
60
+ # prefix instead of the current word. If the user has
61
+ # already typed beyond the pattern, keep their input for
62
+ # incremental narrowing. Normalize path separators before
63
+ # comparing so that Windows backslashes match forward slashes
64
+ # in the transported pattern.
65
+ $normalizedPattern = if ($pattern) { $pattern.Replace('\', '/') -replace '^\./','' } else { '' }
66
+ $normalizedWord = if ($wordToComplete) { $wordToComplete.Replace('\', '/') -replace '^\./','' } else { '' }
67
+ $comparison = if ($IsWindows) { [System.StringComparison]::OrdinalIgnoreCase } else { [System.StringComparison]::Ordinal }
68
+ # For wildcard patterns, compare only the directory prefix
69
+ $comparePattern = $normalizedPattern
70
+ if ($comparePattern -match '[*?]') {
71
+ $beforeWild = $comparePattern -replace '[*?].*', ''
72
+ if ($beforeWild.Contains('/')) {
73
+ $comparePattern = $beforeWild.Substring(0, $beforeWild.LastIndexOf('/') + 1)
74
+ } else {
75
+ $comparePattern = ''
76
+ }
77
+ }
78
+ $prefix = if (($comparePattern -or $normalizedWord) -and $normalizedWord -and $normalizedWord.StartsWith($comparePattern, $comparison) -and $normalizedWord.Length -ge $comparePattern.Length -and $wordToComplete -ne $pattern) {
79
+ $wordToComplete
80
+ } elseif ($pattern) {
81
+ $pattern
82
+ } elseif ($wordToComplete) {
83
+ $wordToComplete
84
+ } else { '' }
85
+
86
+ # Use -Force to include hidden files when requested, or when
87
+ # the prefix basename targets dotfiles (e.g., src/.e)
88
+ $prefixBasename = if ($prefix) { Split-Path -Leaf $prefix } else { '' }
89
+ $forceParam = if ($hidden -or ($prefixBasename -and $prefixBasename.StartsWith('.'))) { @{Force = $true} } else { @{} }
90
+
91
+ # If prefix is a directory without trailing slash, append
92
+ # one so Get-ChildItem lists its contents
93
+ if ($prefix -and (Test-Path -Path $prefix -PathType Container) -and -not $prefix.EndsWith('/') -and -not $prefix.EndsWith('\')) {
94
+ $prefix = $prefix + '/'
95
+ }
96
+
97
+ # Build the glob path—when the prefix contains wildcard
98
+ # characters, use it as-is; otherwise append *
99
+ $globPath = if ($prefix -match '[*?]') { $prefix } else { "${prefix}*" }
100
+
101
+ # Get file system items based on type
102
+ $items = @()
103
+ switch ($type) {
104
+ 'file' {
105
+ if ($extensions) {
106
+ # Filter by extensions, always include directories
107
+ $extList = ($extensions -split ',') -replace '^\.',''
108
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
109
+ Where-Object {
110
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
111
+ }
112
+ } else {
113
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
114
+ }
115
+ }
116
+ 'directory' {
117
+ $items = Get-ChildItem @forceParam -Directory -Path $globPath -ErrorAction SilentlyContinue
118
+ }
119
+ 'any' {
120
+ if ($extensions) {
121
+ # Filter by extensions, always include directories
122
+ $extList = ($extensions -split ',') -replace '^\.',''
123
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue |
124
+ Where-Object {
125
+ $_.PSIsContainer -or (($_.Extension -replace '^\.','' ) -in $extList)
126
+ }
127
+ } else {
128
+ $items = Get-ChildItem @forceParam -Path $globPath -ErrorAction SilentlyContinue
129
+ }
130
+ }
131
+ }
132
+
133
+ # For file/any modes with glob patterns, also add directories
134
+ # from the base directory for navigation
135
+ if ($prefix -match '[*?]' -and $type -ne 'directory') {
136
+ $globDir = Split-Path -Parent $prefix
137
+ if (-not $globDir) { $globDir = '.' }
138
+ $extraDirs = Get-ChildItem @forceParam -Directory -Path "$globDir/*" -ErrorAction SilentlyContinue
139
+ if ($extraDirs) { $items = @($items) + @($extraDirs) | Select-Object -Unique }
140
+ }
141
+
142
+ # Filter hidden files unless requested or the prefix targets dotfiles
143
+ if (-not $hidden -and -not ($prefixBasename -and $prefixBasename.StartsWith('.'))) {
144
+ $items = $items | Where-Object { -not $_.Attributes.HasFlag([System.IO.FileAttributes]::Hidden) }
145
+ }
146
+
147
+ # Extract directory prefix to preserve in completion text
148
+ $dirPrefix = if ($prefix -and ($prefix.Contains('/') -or $prefix.Contains('\'))) {
149
+ $slashIdx = [Math]::Max($prefix.LastIndexOf('/'), $prefix.LastIndexOf('\'))
150
+ $prefix.Substring(0, $slashIdx + 1)
151
+ } else { '' }
152
+
153
+ # Create completion results for files
154
+ $items | ForEach-Object {
155
+ $completionText = if ($_.PSIsContainer) { "$dirPrefix$($_.Name)/" } else { "$dirPrefix$($_.Name)" }
156
+ $itemType = if ($_.PSIsContainer) { 'Directory' } else { 'File' }
157
+ [System.Management.Automation.CompletionResult]::new(
158
+ $completionText,
159
+ $completionText,
160
+ 'ParameterValue',
161
+ $itemType
162
+ )
163
+ }
164
+ } else {
165
+ # Parse literal completion: text\tlistItemText\tdescription
166
+ $parts = $line -split "`t", 3
167
+ $completionText = $parts[0]
168
+ $listItemText = if ($parts.Length -gt 1 -and $parts[1]) { $parts[1] } else { $completionText }
169
+ $toolTip = if ($parts.Length -gt 2 -and $parts[2]) { $parts[2] } else { $completionText }
170
+
171
+ [System.Management.Automation.CompletionResult]::new(
172
+ $completionText,
173
+ $listItemText,
174
+ 'ParameterValue',
175
+ $toolTip
176
+ )
177
+ }
178
+ }
179
+ } catch {
180
+ # Silently ignore errors
181
+ }
182
+ }
183
+