@try-works/dsh-recursive-mode 0.1.4 → 0.1.6

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 (90) hide show
  1. package/lib/bootstrap.d.ts +6 -3
  2. package/lib/client/board.d.ts +4 -1
  3. package/lib/client/open-state.d.ts +20 -0
  4. package/lib/client/slots.d.ts +7 -1
  5. package/lib/client.js +135 -47
  6. package/lib/fs-intent.d.ts +34 -0
  7. package/lib/index.d.ts +1 -0
  8. package/lib/index.js +3429 -911
  9. package/lib/policy.d.ts +1 -1
  10. package/lib/runtime.d.ts +12 -5
  11. package/lib/ts-lint.d.ts +205 -0
  12. package/package.json +1 -1
  13. package/src/bootstrap.ts +338 -331
  14. package/src/client/board.tsx +0 -0
  15. package/src/client/open-state.ts +46 -0
  16. package/src/client/slots.ts +41 -20
  17. package/src/commands.ts +11 -0
  18. package/src/fs-intent.ts +84 -0
  19. package/src/index.ts +238 -226
  20. package/src/policy.ts +1 -1
  21. package/src/runtime.ts +19 -23
  22. package/src/ts-lint.ts +2110 -0
  23. package/references/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
  24. package/references/scripts/lint-recursive-run.ps1 +0 -25
  25. package/references/scripts/lint-recursive-run.py +0 -2870
  26. package/references/scripts/recursive-closeout.ps1 +0 -38
  27. package/references/scripts/recursive-closeout.py +0 -541
  28. package/references/scripts/recursive-init.ps1 +0 -515
  29. package/references/scripts/recursive-init.py +0 -356
  30. package/references/scripts/recursive-lock.ps1 +0 -26
  31. package/references/scripts/recursive-lock.py +0 -302
  32. package/references/scripts/recursive-review-bundle.ps1 +0 -58
  33. package/references/scripts/recursive-review-bundle.py +0 -503
  34. package/references/scripts/recursive-router-cli-configure.ps1 +0 -2
  35. package/references/scripts/recursive-router-cli-configure.py +0 -9
  36. package/references/scripts/recursive-router-cli-init.ps1 +0 -2
  37. package/references/scripts/recursive-router-cli-init.py +0 -9
  38. package/references/scripts/recursive-router-cli-invoke.ps1 +0 -2
  39. package/references/scripts/recursive-router-cli-invoke.py +0 -9
  40. package/references/scripts/recursive-router-cli-probe.ps1 +0 -2
  41. package/references/scripts/recursive-router-cli-probe.py +0 -9
  42. package/references/scripts/recursive-router-cli-resolve.ps1 +0 -2
  43. package/references/scripts/recursive-router-cli-resolve.py +0 -9
  44. package/references/scripts/recursive-router-cli-validate.ps1 +0 -2
  45. package/references/scripts/recursive-router-cli-validate.py +0 -9
  46. package/references/scripts/recursive-router-configure.ps1 +0 -27
  47. package/references/scripts/recursive-router-configure.py +0 -74
  48. package/references/scripts/recursive-router-init.ps1 +0 -17
  49. package/references/scripts/recursive-router-init.py +0 -29
  50. package/references/scripts/recursive-router-invoke.ps1 +0 -47
  51. package/references/scripts/recursive-router-invoke.py +0 -103
  52. package/references/scripts/recursive-router-probe.ps1 +0 -25
  53. package/references/scripts/recursive-router-probe.py +0 -44
  54. package/references/scripts/recursive-router-resolve.ps1 +0 -26
  55. package/references/scripts/recursive-router-resolve.py +0 -46
  56. package/references/scripts/recursive-router-validate.ps1 +0 -17
  57. package/references/scripts/recursive-router-validate.py +0 -27
  58. package/references/scripts/recursive-status.ps1 +0 -23
  59. package/references/scripts/recursive-status.py +0 -2124
  60. package/references/scripts/recursive-subagent-action.ps1 +0 -98
  61. package/references/scripts/recursive-subagent-action.py +0 -197
  62. package/references/scripts/recursive-training-extract.ps1 +0 -23
  63. package/references/scripts/recursive-training-extract.py +0 -99
  64. package/references/scripts/recursive-training-grpo.ps1 +0 -52
  65. package/references/scripts/recursive-training-grpo.py +0 -1341
  66. package/references/scripts/recursive-training-loader.ps1 +0 -78
  67. package/references/scripts/recursive-training-loader.py +0 -558
  68. package/references/scripts/recursive-training-mcp.ps1 +0 -29
  69. package/references/scripts/recursive-training-mcp.py +0 -261
  70. package/references/scripts/recursive-training-phase8-trigger.ps1 +0 -55
  71. package/references/scripts/recursive-training-phase8-trigger.py +0 -137
  72. package/references/scripts/recursive-training-sync.ps1 +0 -29
  73. package/references/scripts/recursive-training-sync.py +0 -183
  74. package/references/scripts/recursive_phase_rules.py +0 -367
  75. package/references/scripts/recursive_router_cli_lib.py +0 -2
  76. package/references/scripts/recursive_router_lib.py +0 -2282
  77. package/references/scripts/verify-locks.ps1 +0 -25
  78. package/references/scripts/verify-locks.py +0 -353
  79. package/scripts/__pycache__/lint-recursive-run.cpython-314.pyc +0 -0
  80. package/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
  81. package/scripts/install-recursive-mode.ps1 +0 -956
  82. package/scripts/install-recursive-mode.py +0 -750
  83. package/scripts/lint-recursive-run.py +0 -2870
  84. package/scripts/recursive-closeout.py +0 -541
  85. package/scripts/recursive-init.py +0 -356
  86. package/scripts/recursive-lock.py +0 -302
  87. package/scripts/recursive-status.py +0 -2124
  88. package/scripts/recursive_phase_rules.py +0 -367
  89. package/scripts/recursive_router_lib.py +0 -2282
  90. package/scripts/verify-locks.py +0 -353
@@ -1,515 +0,0 @@
1
- [CmdletBinding()]
2
- param(
3
- [Parameter(Mandatory = $true)][string]$RunId,
4
- [string]$RepoRoot = (Get-Location).Path,
5
- [ValidateSet("feature", "bugfix", "refactor")][string]$Template = "feature",
6
- [string]$FromIssue = "",
7
- [switch]$Force
8
- )
9
-
10
- Set-StrictMode -Version Latest
11
- $ErrorActionPreference = "Stop"
12
-
13
- function Write-Utf8NoBom {
14
- param(
15
- [Parameter(Mandatory = $true)][string]$Path,
16
- [Parameter(Mandatory = $true)][AllowEmptyString()][string]$Content
17
- )
18
-
19
- $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
20
- [System.IO.File]::WriteAllText($Path, $Content, $utf8NoBom)
21
- }
22
-
23
- function Ensure-Directory {
24
- param([Parameter(Mandatory = $true)][string]$Path)
25
-
26
- if (-not (Test-Path -LiteralPath $Path)) {
27
- New-Item -Path $Path -ItemType Directory -Force | Out-Null
28
- Write-Host ("[OK] Created directory: {0}" -f $Path)
29
- } else {
30
- Write-Host ("[OK] Directory exists: {0}" -f $Path)
31
- }
32
- }
33
-
34
- function Run-Git {
35
- param(
36
- [Parameter(Mandatory = $true)][string]$RepoRoot,
37
- [Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments
38
- )
39
-
40
- $output = & git -C $RepoRoot @Arguments 2>&1
41
- if ($LASTEXITCODE -ne 0) {
42
- return [pscustomobject]@{
43
- Success = $false
44
- Output = (($output | Out-String).Trim())
45
- }
46
- }
47
-
48
- return [pscustomobject]@{
49
- Success = $true
50
- Output = (($output | Out-String).Trim())
51
- }
52
- }
53
-
54
- function Get-MdFieldValue {
55
- param(
56
- [Parameter(Mandatory = $true)][string]$Content,
57
- [Parameter(Mandatory = $true)][string]$FieldName
58
- )
59
-
60
- $pattern = "(?m)^[ \t]*(?:[-*][ \t]+)?{0}:\s*(.+?)\s*$" -f [regex]::Escape($FieldName)
61
- $match = [regex]::Match($Content, $pattern)
62
- if (-not $match.Success) {
63
- return $null
64
- }
65
- return ($match.Groups[1].Value.Trim() -replace '^[`"'']+|[`"'']+$', "")
66
- }
67
-
68
- function Normalize-BaselineType {
69
- param([string]$Value)
70
-
71
- if ([string]::IsNullOrWhiteSpace($Value)) {
72
- return $null
73
- }
74
-
75
- $compact = ((($Value.Trim() -replace '^[`"'']+|[`"'']+$', "")).ToLowerInvariant() -replace "-", " ")
76
- $compact = [regex]::Replace($compact, "\s+", " ")
77
- $aliases = @{
78
- "commit" = "local commit"
79
- "branch" = "local branch"
80
- "remote" = "remote ref"
81
- "remote branch" = "remote ref"
82
- "merge base" = "merge-base derived"
83
- }
84
- $allowed = @("local commit", "local branch", "remote ref", "merge-base derived")
85
- if ($allowed -contains $compact) {
86
- return $compact
87
- }
88
- if ($aliases.ContainsKey($compact)) {
89
- return $aliases[$compact]
90
- }
91
- return $null
92
- }
93
-
94
- function Normalize-ComparisonReference {
95
- param([string]$Value)
96
-
97
- if ([string]::IsNullOrWhiteSpace($Value)) {
98
- return $null
99
- }
100
-
101
- $compact = ($Value.Trim() -replace '^[`"'']+|[`"'']+$', "")
102
- if (@("working-tree", "working-tree@head", "worktree", "working-tree+head") -contains $compact.ToLowerInvariant()) {
103
- return "working-tree"
104
- }
105
- return $compact
106
- }
107
-
108
- function New-RequirementsContent {
109
- param(
110
- [Parameter(Mandatory = $true)][string]$RunId,
111
- [Parameter(Mandatory = $true)][string]$Template,
112
- [string]$FromIssue
113
- )
114
-
115
- $inputs = @("- [chat summary or source notes if captured in repo]")
116
- if (-not [string]::IsNullOrWhiteSpace($FromIssue)) {
117
- $inputs += "- Source: $FromIssue"
118
- }
119
- $inputsBlock = ($inputs -join "`r`n")
120
-
121
- return (@'
122
- Run: `/.recursive/run/{0}/`
123
- Phase: `00 Requirements`
124
- Status: `DRAFT`
125
- Workflow version: `recursive-mode-audit-v2`
126
- Inputs:
127
- {1}
128
- Outputs:
129
- - `/.recursive/run/{0}/00-requirements.md`
130
- Scope note: This document defines stable requirement identifiers and acceptance criteria. (Template: {2})
131
-
132
- ## TODO
133
-
134
- - [ ] Elicit requirements from user/context
135
- - [ ] Define requirement identifiers (R1, R2, ...)
136
- - [ ] Write acceptance criteria for each requirement
137
- - [ ] Document out of scope items (OOS1, OOS2, ...)
138
- - [ ] List constraints and assumptions
139
- - [ ] Complete Coverage Gate checklist
140
- - [ ] Complete Approval Gate checklist
141
-
142
- ## Requirements
143
-
144
- ### `R1` <short title>
145
-
146
- Description:
147
- Acceptance criteria:
148
- - [observable condition 1]
149
- - [observable condition 2]
150
-
151
- ## Out of Scope
152
-
153
- - `OOS1`: ...
154
-
155
- ## Constraints
156
-
157
- - ...
158
-
159
- ## Coverage Gate
160
- ...
161
- Coverage: FAIL
162
-
163
- ## Approval Gate
164
- ...
165
- Approval: FAIL
166
- '@) -f $RunId, $inputsBlock, $Template
167
- }
168
-
169
- function Get-GitContext {
170
- param([Parameter(Mandatory = $true)][string]$RepoRoot)
171
-
172
- $headResult = Run-Git -RepoRoot $RepoRoot "rev-parse" "--verify" "HEAD^{commit}"
173
- if (-not $headResult.Success -or [string]::IsNullOrWhiteSpace($headResult.Output)) {
174
- return [pscustomobject]@{
175
- Context = $null
176
- Error = "Unable to resolve HEAD commit for Phase 0 diff basis prefill: $($headResult.Output)"
177
- }
178
- }
179
-
180
- $branchResult = Run-Git -RepoRoot $RepoRoot "symbolic-ref" "--quiet" "--short" "HEAD"
181
- $branchName = if ($branchResult.Success -and -not [string]::IsNullOrWhiteSpace($branchResult.Output)) {
182
- $branchResult.Output
183
- } else {
184
- "(detached HEAD)"
185
- }
186
-
187
- $headSha = $headResult.Output
188
- return [pscustomobject]@{
189
- Context = [pscustomobject]@{
190
- baseline_type = "local commit"
191
- baseline_reference = $headSha
192
- comparison_reference = "working-tree"
193
- normalized_baseline = $headSha
194
- normalized_comparison = "working-tree"
195
- normalized_diff_command = "git diff --name-only $headSha"
196
- base_branch = $branchName
197
- worktree_branch = $branchName
198
- base_commit = $headSha
199
- notes = "recursive-init prefilled this executable diff basis from the current HEAD commit. If Phase 0 later changes the chosen baseline, update every diff-basis field and rerun lint before locking."
200
- }
201
- Error = $null
202
- }
203
- }
204
-
205
- function New-WorktreeContent {
206
- param(
207
- [Parameter(Mandatory = $true)][string]$RunId,
208
- [Parameter(Mandatory = $true)][string]$RepoRoot,
209
- [pscustomobject]$GitContext,
210
- [string]$PrefillError
211
- )
212
-
213
- $baseBranch = if ($GitContext) { $GitContext.base_branch } else { "(resolve during Phase 0)" }
214
- $worktreeBranch = if ($GitContext) { $GitContext.worktree_branch } else { "(resolve during Phase 0)" }
215
- $baseCommit = if ($GitContext) { $GitContext.base_commit } else { "<resolve-before-locking>" }
216
- $baselineType = if ($GitContext) { $GitContext.baseline_type } else { "local commit" }
217
- $baselineReference = if ($GitContext) { $GitContext.baseline_reference } else { "<resolve-before-locking>" }
218
- $comparisonReference = if ($GitContext) { $GitContext.comparison_reference } else { "working-tree" }
219
- $normalizedBaseline = if ($GitContext) { $GitContext.normalized_baseline } else { "<resolve-before-locking>" }
220
- $normalizedComparison = if ($GitContext) { $GitContext.normalized_comparison } else { "working-tree" }
221
- $normalizedDiffCommand = if ($GitContext) { $GitContext.normalized_diff_command } else { "git diff --name-only <resolve-before-locking>" }
222
- $notes = if ($GitContext) {
223
- $GitContext.notes
224
- } else {
225
- "Populate an executable diff basis before locking Phase 0. Lint and lock will fail until the normalized basis matches live git state."
226
- }
227
-
228
- $setupNote = if ([string]::IsNullOrWhiteSpace($PrefillError)) {
229
- "recursive-init detected the current repository context and prefilled the Phase 0 diff basis."
230
- } else {
231
- "recursive-init could not prefill the Phase 0 diff basis automatically: $PrefillError"
232
- }
233
-
234
- return (@'
235
- Run: `/.recursive/run/{0}/`
236
- Phase: `00 Worktree`
237
- Status: `DRAFT`
238
- Inputs:
239
- - `/.recursive/run/{0}/00-requirements.md`
240
- - Current git repository state
241
- Outputs:
242
- - `/.recursive/run/{0}/00-worktree.md`
243
- Scope note: This document records the Phase 0 worktree context and the executable diff basis that all later audited phases must reuse.
244
-
245
- ## TODO
246
-
247
- - [ ] Confirm the selected worktree location and isolation approach
248
- - [ ] Confirm the base branch and worktree branch values
249
- - [ ] Run setup and verify the clean test baseline
250
- - [ ] Confirm the diff basis fields still match live git state
251
- - [ ] Complete Coverage Gate checklist
252
- - [ ] Complete Approval Gate checklist
253
-
254
- ## Directory Selection
255
-
256
- - Repository root: `{1}`
257
- - Preferred worktree location: `.worktrees/{0}/`
258
- - Update this section with the actual selected location before locking Phase 0.
259
-
260
- ## Safety Verification
261
-
262
- - Original branch / repo state observed at init time: `{2}`
263
- - Isolation still must be confirmed after the actual worktree is created.
264
-
265
- ## Worktree Creation
266
-
267
- - Intended worktree branch: `{3}`
268
- - Record the actual worktree creation command and output before locking.
269
-
270
- ## Main Branch Protection
271
-
272
- - Base branch source of truth at init time: `{2}`
273
- - Explicitly document any deviation from isolated worktree execution before locking.
274
-
275
- ## Project Setup
276
-
277
- - Init-time note: {4}
278
- - Replace this section with the actual setup commands and results during Phase 0.
279
-
280
- ## Test Baseline Verification
281
-
282
- - Record the baseline commands and results after setup completes.
283
-
284
- ## Worktree Context
285
-
286
- - Base branch: `{2}`
287
- - Worktree branch: `{3}`
288
- - Base commit: `{5}`
289
-
290
- ## Diff Basis For Later Audits
291
-
292
- - Baseline type: `{6}`
293
- - Baseline reference: `{7}`
294
- - Comparison reference: `{8}`
295
- - Normalized baseline: `{9}`
296
- - Normalized comparison: `{10}`
297
- - Normalized diff command: `{11}`
298
- - Base branch: `{2}`
299
- - Worktree branch: `{3}`
300
- - Diff basis notes: `{12}`
301
-
302
- ## Traceability
303
-
304
- - Recursive workflow safety -> Phase 0 records a reusable executable diff basis before audited phases begin.
305
-
306
- ## Coverage Gate
307
-
308
- - [ ] Worktree location and branch context are recorded
309
- - [ ] Setup and clean baseline verification are recorded
310
- - [ ] Diff basis fields are executable against live git state
311
-
312
- Coverage: FAIL
313
-
314
- ## Approval Gate
315
-
316
- - [ ] Phase 0 context is ready for downstream audited phases
317
- - [ ] No unresolved setup or diff-basis inconsistencies remain
318
-
319
- Approval: FAIL
320
- '@) -f $RunId, $RepoRoot, $baseBranch, $worktreeBranch, $setupNote, $baseCommit, $baselineType, $baselineReference, $comparisonReference, $normalizedBaseline, $normalizedComparison, $normalizedDiffCommand, $notes
321
- }
322
-
323
- function Test-Phase0DiffBasis {
324
- param(
325
- [Parameter(Mandatory = $true)][string]$RepoRoot,
326
- [Parameter(Mandatory = $true)][string]$RunDir
327
- )
328
-
329
- $worktreePath = Join-Path $RunDir "00-worktree.md"
330
- if (-not (Test-Path -LiteralPath $worktreePath)) {
331
- return "00-worktree.md is missing."
332
- }
333
-
334
- $content = Get-Content -LiteralPath $worktreePath -Raw -Encoding UTF8
335
- $baselineType = Normalize-BaselineType (Get-MdFieldValue -Content $content -FieldName "Baseline type")
336
- $baselineReference = Get-MdFieldValue -Content $content -FieldName "Baseline reference"
337
- $comparisonReference = Normalize-ComparisonReference (Get-MdFieldValue -Content $content -FieldName "Comparison reference")
338
- $normalizedBaseline = Get-MdFieldValue -Content $content -FieldName "Normalized baseline"
339
- $normalizedComparison = Normalize-ComparisonReference (Get-MdFieldValue -Content $content -FieldName "Normalized comparison")
340
- $normalizedDiffCommand = Get-MdFieldValue -Content $content -FieldName "Normalized diff command"
341
-
342
- $missingFields = @()
343
- if (-not $baselineType) { $missingFields += "Baseline type" }
344
- if ([string]::IsNullOrWhiteSpace($baselineReference)) { $missingFields += "Baseline reference" }
345
- if (-not $comparisonReference) { $missingFields += "Comparison reference" }
346
- if ([string]::IsNullOrWhiteSpace($normalizedBaseline)) { $missingFields += "Normalized baseline" }
347
- if (-not $normalizedComparison) { $missingFields += "Normalized comparison" }
348
- if ([string]::IsNullOrWhiteSpace($normalizedDiffCommand)) { $missingFields += "Normalized diff command" }
349
- if ($missingFields.Count -gt 0) {
350
- return "Diff basis is missing required field(s): {0}" -f ($missingFields -join ", ")
351
- }
352
-
353
- $comparisonGitRef = if ($normalizedComparison -eq "working-tree") { "HEAD" } else { $normalizedComparison }
354
- if ($baselineType -eq "merge-base derived") {
355
- $baselineResult = Run-Git -RepoRoot $RepoRoot "merge-base" $comparisonGitRef $baselineReference
356
- if (-not $baselineResult.Success) {
357
- return "Unable to compute merge-base for diff basis: $($baselineResult.Output)"
358
- }
359
- $computedBaseline = $baselineResult.Output
360
- } else {
361
- $baselineResult = Run-Git -RepoRoot $RepoRoot "rev-parse" "--verify" "$baselineReference^{commit}"
362
- if (-not $baselineResult.Success) {
363
- return "Unable to resolve baseline reference '$baselineReference': $($baselineResult.Output)"
364
- }
365
- $computedBaseline = $baselineResult.Output
366
- }
367
-
368
- if ($normalizedBaseline -ne $computedBaseline) {
369
- return "Recorded Normalized baseline does not match the executable diff basis ($normalizedBaseline != $computedBaseline)"
370
- }
371
-
372
- if ($normalizedComparison -eq "working-tree") {
373
- $expectedCommand = "git diff --name-only $computedBaseline"
374
- } else {
375
- $comparisonResult = Run-Git -RepoRoot $RepoRoot "rev-parse" "--verify" "$normalizedComparison^{commit}"
376
- if (-not $comparisonResult.Success) {
377
- return "Unable to resolve comparison reference '$normalizedComparison': $($comparisonResult.Output)"
378
- }
379
- $computedComparison = $comparisonResult.Output
380
- if ($normalizedComparison -ne $computedComparison) {
381
- return "Recorded Normalized comparison does not match the executable diff basis ($normalizedComparison != $computedComparison)"
382
- }
383
- $expectedCommand = "git diff --name-only $computedBaseline..$computedComparison"
384
- }
385
-
386
- if ($normalizedDiffCommand -ne $expectedCommand) {
387
- return "Recorded Normalized diff command does not match the executable diff basis ($normalizedDiffCommand != $expectedCommand)"
388
- }
389
-
390
- return $null
391
- }
392
-
393
- function Get-TrainingLoaderQuery {
394
- param(
395
- [Parameter(Mandatory = $true)][string]$RunId,
396
- [Parameter(Mandatory = $true)][string]$Template,
397
- [string]$FromIssue
398
- )
399
-
400
- $runPhrase = (($RunId -replace '[-_]+', ' ').Trim())
401
- $parts = @()
402
- $base = ("{0} recursive run" -f $Template).Trim()
403
- if (-not [string]::IsNullOrWhiteSpace($base)) {
404
- $parts += $base
405
- }
406
- if (-not [string]::IsNullOrWhiteSpace($runPhrase)) {
407
- $parts += $runPhrase
408
- }
409
- if (-not [string]::IsNullOrWhiteSpace($FromIssue)) {
410
- $parts += $FromIssue.Trim()
411
- }
412
- return ($parts -join " ")
413
- }
414
-
415
- function Invoke-TrainingLoader {
416
- param(
417
- [Parameter(Mandatory = $true)][string]$RepoRoot,
418
- [Parameter(Mandatory = $true)][string]$RunId,
419
- [Parameter(Mandatory = $true)][string]$Template,
420
- [string]$FromIssue
421
- )
422
-
423
- $loaderPath = Join-Path $RepoRoot ".recursive\scripts\recursive-training-loader.py"
424
- if (-not (Test-Path -LiteralPath $loaderPath)) {
425
- Write-Host "[INFO] recursive-training loader not installed; skipping experiential memory load."
426
- return $true
427
- }
428
-
429
- $python = if ($env:PYTHON) { $env:PYTHON } elseif (Get-Command python -ErrorAction SilentlyContinue) { "python" } else { $null }
430
- if (-not $python) {
431
- Write-Host "[WARN] Python executable not found; cannot run recursive-training loader."
432
- Write-Host "[WARN] Continuing without loaded experiential memory."
433
- return $true
434
- }
435
-
436
- $query = Get-TrainingLoaderQuery -RunId $RunId -Template $Template -FromIssue $FromIssue
437
- $output = & $python $loaderPath "--repo-root" $RepoRoot "--query" $query 2>&1
438
- if ($LASTEXITCODE -ne 0) {
439
- $details = (($output | Out-String).Trim())
440
- if ([string]::IsNullOrWhiteSpace($details)) {
441
- $details = "no diagnostics emitted"
442
- }
443
- Write-Host ("[WARN] recursive-training loader failed: {0}" -f $details)
444
- Write-Host "[WARN] Continuing without loaded experiential memory."
445
- return $true
446
- }
447
-
448
- Write-Host "[OK] Loaded repository memory context via recursive-training."
449
- $rendered = (($output | Out-String).Trim())
450
- if (-not [string]::IsNullOrWhiteSpace($rendered)) {
451
- Write-Host $rendered
452
- }
453
- return $true
454
- }
455
-
456
- $resolvedRepoRoot = [System.IO.Path]::GetFullPath($RepoRoot)
457
- Write-Host ("[INFO] Repo root: {0}" -f $resolvedRepoRoot)
458
-
459
- $runRoot = Join-Path $resolvedRepoRoot ".recursive/run"
460
- $runDir = Join-Path $runRoot $RunId
461
-
462
- Ensure-Directory -Path $runRoot
463
- Ensure-Directory -Path $runDir
464
- Ensure-Directory -Path (Join-Path $runDir "addenda")
465
- Ensure-Directory -Path (Join-Path $runDir "subagents")
466
- Ensure-Directory -Path (Join-Path $runDir "router-prompts")
467
-
468
- $evidenceDir = Join-Path $runDir "evidence"
469
- Ensure-Directory -Path $evidenceDir
470
- Ensure-Directory -Path (Join-Path $evidenceDir "screenshots")
471
- Ensure-Directory -Path (Join-Path $evidenceDir "logs")
472
- Ensure-Directory -Path (Join-Path $evidenceDir "perf")
473
- Ensure-Directory -Path (Join-Path $evidenceDir "traces")
474
- Ensure-Directory -Path (Join-Path $evidenceDir "review-bundles")
475
- Ensure-Directory -Path (Join-Path $evidenceDir "router")
476
- Ensure-Directory -Path (Join-Path $evidenceDir "other")
477
-
478
- $requirementsPath = Join-Path $runDir "00-requirements.md"
479
- if ((Test-Path -LiteralPath $requirementsPath) -and (-not $Force)) {
480
- Write-Host ("[INFO] Requirements file exists, not overwriting: {0}" -f $requirementsPath)
481
- } else {
482
- $content = New-RequirementsContent -RunId $RunId -Template $Template -FromIssue $FromIssue
483
- Write-Utf8NoBom -Path $requirementsPath -Content $content
484
- Write-Host ("[OK] Wrote requirements template: {0}" -f $requirementsPath)
485
- }
486
-
487
- $gitContextResult = Get-GitContext -RepoRoot $resolvedRepoRoot
488
- if ($gitContextResult.Error) {
489
- Write-Host ("[WARN] {0}" -f $gitContextResult.Error)
490
- }
491
-
492
- $worktreePath = Join-Path $runDir "00-worktree.md"
493
- if ((Test-Path -LiteralPath $worktreePath) -and (-not $Force)) {
494
- Write-Host ("[INFO] Worktree file exists, not overwriting: {0}" -f $worktreePath)
495
- } else {
496
- $worktreeContent = New-WorktreeContent -RunId $RunId -RepoRoot $resolvedRepoRoot -GitContext $gitContextResult.Context -PrefillError $gitContextResult.Error
497
- Write-Utf8NoBom -Path $worktreePath -Content $worktreeContent
498
- Write-Host ("[OK] Wrote Phase 0 worktree template: {0}" -f $worktreePath)
499
- }
500
-
501
- $diffBasisError = Test-Phase0DiffBasis -RepoRoot $resolvedRepoRoot -RunDir $runDir
502
- if ($diffBasisError) {
503
- Write-Host ("[FAIL] 00-worktree.md diff basis is not executable yet: {0}" -f $diffBasisError)
504
- Write-Host " Fix the Phase 0 diff-basis fields before locking or relying on downstream audit tooling."
505
- exit 1
506
- }
507
-
508
- Write-Host "[OK] Phase 0 diff basis is executable against live git state."
509
- [void](Invoke-TrainingLoader -RepoRoot $resolvedRepoRoot -RunId $RunId -Template $Template -FromIssue $FromIssue)
510
- Write-Host ""
511
- Write-Host "Next steps:"
512
- Write-Host ("1) Edit: .recursive/run/{0}/00-requirements.md" -f $RunId)
513
- Write-Host ("2) Edit: .recursive/run/{0}/00-worktree.md" -f $RunId)
514
- Write-Host ("3) Run: Implement requirement '{0}'" -f $RunId)
515
- Write-Host "4) Complete the run through the audited Phase 8 closeout before considering it done."