sdtk-spec-kit 0.9.0 → 0.9.1

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  It exposes the `sdtk-spec` CLI as the primary upstream command surface.
6
6
 
7
- Package version in this source snapshot: `0.9.0`
7
+ Package version in this source snapshot: `0.9.1`
8
8
  Full usage guide: `products/sdtk-spec/governance/SDTK_SPEC_USAGE_GUIDE.md`
9
9
 
10
10
  Wraps the `SDTK-SPEC` PowerShell toolkit for portable, reproducible feature documentation scaffolding.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
2
+ "version": "0.9.1",
3
3
  "sourceCommit": "7d819293a4fe710f43582c6d7b49757713e4d76c",
4
4
  "fileCount": 100,
5
5
  "files": [
@@ -35,8 +35,8 @@
35
35
  },
36
36
  {
37
37
  "path": "toolkit/scripts/agents/run-codex-task.ps1",
38
- "sha256": "4996e8e7aa50283dbf52c473c4e315af7ee951ebddb671ff59cc4bcde9843907",
39
- "size": 29055
38
+ "sha256": "e84d86e8bd72a10875b403542c725d2c7a2e536920e501c6389ab0de9270b865",
39
+ "size": 32595
40
40
  },
41
41
  {
42
42
  "path": "toolkit/scripts/agents/validate-mailbox-formal-artifact.py",
@@ -4,7 +4,7 @@
4
4
  301a604b2daa39f85a7b9cbf4b634df5dafd16f84622ad188bc214b34da226d7 toolkit/runtimes/claude/CLAUDE_TEMPLATE.md
5
5
  6f1fd656e95906a054299312d44e63a28d948c634b6534089db3eeca9936bf70 toolkit/runtimes/codex/CODEX_TEMPLATE.md
6
6
  8616291be4aaa4fb5cb0f1f4c738c108ab79090bf767ee2b4403d6d582c150c7 toolkit/scripts/agents/run-claude-task.ps1
7
- 4996e8e7aa50283dbf52c473c4e315af7ee951ebddb671ff59cc4bcde9843907 toolkit/scripts/agents/run-codex-task.ps1
7
+ e84d86e8bd72a10875b403542c725d2c7a2e536920e501c6389ab0de9270b865 toolkit/scripts/agents/run-codex-task.ps1
8
8
  6bcebe5fdb87451a7260101eaed32c6b61a2cf07832be754790f5432e028a503 toolkit/scripts/agents/validate-mailbox-formal-artifact.py
9
9
  b9bdb2489c2881d03e965c7dd849468f797e2070d30e6730ab9ddf37b54b7879 toolkit/scripts/generate-code-handoff.ps1
10
10
  2b456e0e9ebeb948db9bdd1a905195285a8ae44839b09b5f0bbefac597cfd67a toolkit/scripts/init-feature.ps1
@@ -5,6 +5,7 @@ param(
5
5
  [string] $LogFile = '',
6
6
  [string] $Model = '',
7
7
  [switch] $FullAuto,
8
+ [switch] $ExternallySandboxed,
8
9
  [switch] $DryRun
9
10
  )
10
11
 
@@ -294,18 +295,61 @@ function New-GitTruthBlock([string] $RepoRootPath) {
294
295
  "@.TrimEnd()
295
296
  }
296
297
 
298
+ # $IsWindows is an automatic variable on PowerShell 7 (Core); on Windows
299
+ # PowerShell 5.1 it does not exist, so a null falls back to Windows behavior.
300
+ $script:IsWindowsHost = if ($null -ne $IsWindows) { [bool] $IsWindows } else { $true }
301
+
302
+ # `/.dockerenv`, an explicit env flag, or the -ExternallySandboxed switch mark a
303
+ # container/externally-sandboxed host. Codex's workspace-write sandbox needs
304
+ # unprivileged user namespaces that such hosts usually disable, so we swap
305
+ # --full-auto for --dangerously-bypass-approvals-and-sandbox there. Read-only
306
+ # sandbox does not create namespaces and keeps working, so it is left alone.
307
+ function Test-ExternallySandboxedHost([bool] $SwitchRequested) {
308
+ if ($SwitchRequested) { return $true }
309
+ if ($env:SDTK_EXTERNALLY_SANDBOXED -eq '1') { return $true }
310
+ if (Test-Path '/.dockerenv') { return $true }
311
+ return $false
312
+ }
313
+
297
314
  function Stop-ProcessTree([int] $ProcessId) {
298
- $children = @(Get-CimInstance Win32_Process -Filter "ParentProcessId=$ProcessId" -ErrorAction SilentlyContinue)
299
- foreach ($child in $children) {
300
- Stop-ProcessTree -ProcessId $child.ProcessId
315
+ if ($script:IsWindowsHost) {
316
+ $children = @(Get-CimInstance Win32_Process -Filter "ParentProcessId=$ProcessId" -ErrorAction SilentlyContinue)
317
+ foreach ($child in $children) {
318
+ Stop-ProcessTree -ProcessId $child.ProcessId
319
+ }
320
+ Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
321
+ return
322
+ }
323
+ # POSIX: enumerate children via `ps --ppid`, recurse, then SIGKILL.
324
+ $childOutput = ''
325
+ try { $childOutput = (& ps -o pid= --ppid $ProcessId 2>$null | Out-String) } catch { $childOutput = '' }
326
+ foreach ($line in ($childOutput -split "`n")) {
327
+ $pidText = $line.Trim()
328
+ if ($pidText -match '^\d+$') { Stop-ProcessTree -ProcessId ([int] $pidText) }
301
329
  }
302
- Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
330
+ try { & kill -9 $ProcessId 2>$null } catch { }
303
331
  }
304
332
 
305
333
  function Convert-ToCmdQuoted([string] $Value) {
306
334
  return '"' + ($Value -replace '"', '""') + '"'
307
335
  }
308
336
 
337
+ # POSIX single-quote escaping: wrap in '...', and render embedded single quotes
338
+ # as the classic '\'' sequence so the shell sees the literal value.
339
+ function Convert-ToShQuoted([string] $Value) {
340
+ return "'" + ($Value -replace "'", "'\''") + "'"
341
+ }
342
+
343
+ # Build the codex sandbox flag(s) for a run. Writable runs use --full-auto,
344
+ # except on an externally-sandboxed host where that sandbox cannot create
345
+ # namespaces — there we bypass Codex's own sandbox (the container is the
346
+ # boundary). Read-only runs always use the read-only sandbox.
347
+ function Get-CodexSandboxArgs([bool] $UseWorkspaceWrite, [bool] $ExternallySandboxed) {
348
+ if (-not $UseWorkspaceWrite) { return @('--sandbox', 'read-only') }
349
+ if ($ExternallySandboxed) { return @('--dangerously-bypass-approvals-and-sandbox') }
350
+ return @('--full-auto')
351
+ }
352
+
309
353
  function Invoke-CodexProcessWithWatchdog(
310
354
  [string] $RepoRootPath,
311
355
  [string] $PromptPath,
@@ -313,41 +357,46 @@ function Invoke-CodexProcessWithWatchdog(
313
357
  [string] $LogPath,
314
358
  [string] $ModelName,
315
359
  [bool] $UseWorkspaceWrite,
360
+ [bool] $ExternallySandboxed,
316
361
  [int] $WatchdogSeconds
317
362
  ) {
318
- $runnerScriptPath = Join-Path ([System.IO.Path]::GetTempPath()) ("sdtk-mailbox-codex-" + [guid]::NewGuid().ToString('N') + '.cmd')
319
- $commandParts = @(
320
- 'codex',
321
- 'exec',
322
- '-c',
323
- (Convert-ToCmdQuoted 'mcp_servers={}'),
324
- '-c',
325
- (Convert-ToCmdQuoted 'model_reasoning_effort="medium"'),
326
- '-C',
327
- (Convert-ToCmdQuoted $RepoRootPath),
328
- '--output-last-message',
329
- (Convert-ToCmdQuoted $ReportPath)
363
+ # Raw (unquoted) argument vector; each element is quoted per-platform below.
364
+ $codexArgs = @(
365
+ 'codex', 'exec',
366
+ '-c', 'mcp_servers={}',
367
+ '-c', 'model_reasoning_effort="medium"',
368
+ '-C', $RepoRootPath,
369
+ '--output-last-message', $ReportPath
330
370
  )
331
- if ($UseWorkspaceWrite) {
332
- $commandParts += '--full-auto'
371
+ $codexArgs += (Get-CodexSandboxArgs $UseWorkspaceWrite $ExternallySandboxed)
372
+ if ($ModelName) { $codexArgs += @('--model', $ModelName) }
373
+ $codexArgs += '-'
374
+
375
+ $runnerScriptPath = $null
376
+ if ($script:IsWindowsHost) {
377
+ $quoted = $codexArgs | ForEach-Object { Convert-ToCmdQuoted $_ }
378
+ $commandLine = ($quoted -join ' ') + ' < ' + (Convert-ToCmdQuoted $PromptPath)
379
+ if ($LogPath) { $commandLine += ' > ' + (Convert-ToCmdQuoted $LogPath) + ' 2>&1' }
380
+ $runnerScriptPath = Join-Path ([System.IO.Path]::GetTempPath()) ("sdtk-mailbox-codex-" + [guid]::NewGuid().ToString('N') + '.cmd')
381
+ $embedded = "@echo off`r`nsetlocal`r`n$commandLine`r`nexit /b %ERRORLEVEL%`r`n"
382
+ [System.IO.File]::WriteAllText($runnerScriptPath, $embedded, $Utf8NoBom)
383
+ $process = Start-Process -FilePath 'cmd.exe' -ArgumentList @('/d', '/c', $runnerScriptPath) -WorkingDirectory $RepoRootPath -PassThru -WindowStyle Hidden
333
384
  } else {
334
- $commandParts += @('--sandbox', 'read-only')
335
- }
336
- if ($ModelName) {
337
- $commandParts += @('--model', (Convert-ToCmdQuoted $ModelName))
338
- }
339
- $commandParts += '-'
340
-
341
- $commandLine = ($commandParts -join ' ') + ' < ' + (Convert-ToCmdQuoted $PromptPath)
342
- if ($LogPath) {
343
- $commandLine += ' > ' + (Convert-ToCmdQuoted $LogPath) + ' 2>&1'
385
+ # POSIX: write the composed command line to a temp shell script and run it
386
+ # via /bin/sh. Passing the redirect-laden command line straight through
387
+ # Start-Process -ArgumentList mangles the `<`/`>` metacharacters (the child
388
+ # then loses its stdin redirect and Codex aborts with "stdin is not a
389
+ # terminal"); a script file sidesteps all argument re-quoting. No cmd.exe
390
+ # and no -WindowStyle (unsupported on the PowerShell Linux edition).
391
+ $quoted = $codexArgs | ForEach-Object { Convert-ToShQuoted $_ }
392
+ $commandLine = ($quoted -join ' ') + ' < ' + (Convert-ToShQuoted $PromptPath)
393
+ if ($LogPath) { $commandLine += ' > ' + (Convert-ToShQuoted $LogPath) + ' 2>&1' }
394
+ $runnerScriptPath = Join-Path ([System.IO.Path]::GetTempPath()) ("sdtk-mailbox-codex-" + [guid]::NewGuid().ToString('N') + '.sh')
395
+ $embedded = "#!/bin/sh`n" + $commandLine + "`n"
396
+ [System.IO.File]::WriteAllText($runnerScriptPath, $embedded, $Utf8NoBom)
397
+ $process = Start-Process -FilePath '/bin/sh' -ArgumentList @($runnerScriptPath) -WorkingDirectory $RepoRootPath -PassThru
344
398
  }
345
399
 
346
- $embedded = "@echo off`r`nsetlocal`r`n$commandLine`r`nexit /b %ERRORLEVEL%`r`n"
347
- [System.IO.File]::WriteAllText($runnerScriptPath, $embedded, $Utf8NoBom)
348
-
349
- $process = Start-Process -FilePath 'cmd.exe' -ArgumentList @('/d', '/c', $runnerScriptPath) -WorkingDirectory $RepoRootPath -PassThru -WindowStyle Hidden
350
-
351
400
  $timedOut = $false
352
401
  try {
353
402
  if ($WatchdogSeconds -gt 0) {
@@ -364,7 +413,7 @@ function Invoke-CodexProcessWithWatchdog(
364
413
  ExitCode = if ($timedOut) { -1 } else { $process.ExitCode }
365
414
  }
366
415
  } finally {
367
- Remove-Item $runnerScriptPath -Force -ErrorAction SilentlyContinue
416
+ if ($runnerScriptPath) { Remove-Item $runnerScriptPath -Force -ErrorAction SilentlyContinue }
368
417
  }
369
418
  }
370
419
 
@@ -526,11 +575,8 @@ $watchdogSeconds = Get-StallBudgetSeconds -Phase $phase -RawValue $stallBudgetVa
526
575
  $stallBudgetSource = Get-StallBudgetSource -RawValue $stallBudgetValue -Seconds $watchdogSeconds
527
576
  $permissionAuditBlock = New-PermissionAuditBlock -DeclaredPermission $permissionMode -EffectiveMode $effectiveMode -ApprovalStatus $approvalStatus -ApprovedBy $approvedBy -ApprovalReason $approvalReason -ApprovedScope $approvedScope -ApprovalReference $approvalReference -DecisionSummary $decisionSummary
528
577
 
529
- if ($useWorkspaceWrite) {
530
- $cliArgs += '--full-auto'
531
- } else {
532
- $cliArgs += @('--sandbox', 'read-only')
533
- }
578
+ $isExternallySandboxed = [bool] (Test-ExternallySandboxedHost ([bool] $ExternallySandboxed))
579
+ $cliArgs += (Get-CodexSandboxArgs $useWorkspaceWrite $isExternallySandboxed)
534
580
  if ($Model) { $cliArgs += @('--model', $Model) }
535
581
  $cliArgs += '-'
536
582
 
@@ -550,6 +596,8 @@ if ($DryRun) {
550
596
  ApprovedWritableScope = $approvedScope
551
597
  ApprovalReference = $approvalReference
552
598
  LauncherDecisionSummary = $decisionSummary
599
+ ExternallySandboxed = $isExternallySandboxed
600
+ HostIsWindows = $script:IsWindowsHost
553
601
  RuntimeStallBudget = $stallBudgetValue
554
602
  EffectiveWatchdogSeconds = $watchdogSeconds
555
603
  PromptLength = $prompt.Length
@@ -561,7 +609,7 @@ if ($DryRun) {
561
609
  $promptPath = Join-Path ([System.IO.Path]::GetTempPath()) ("sdtk-mailbox-prompt-" + [guid]::NewGuid().ToString('N') + '.md')
562
610
  [System.IO.File]::WriteAllText($promptPath, $prompt, $Utf8NoBom)
563
611
  try {
564
- $processResult = Invoke-CodexProcessWithWatchdog -RepoRootPath $RepoRoot -PromptPath $promptPath -ReportPath $ReportFile -LogPath $LogFile -ModelName $Model -UseWorkspaceWrite:$useWorkspaceWrite -WatchdogSeconds $watchdogSeconds
612
+ $processResult = Invoke-CodexProcessWithWatchdog -RepoRootPath $RepoRoot -PromptPath $promptPath -ReportPath $ReportFile -LogPath $LogFile -ModelName $Model -UseWorkspaceWrite:$useWorkspaceWrite -ExternallySandboxed:$isExternallySandboxed -WatchdogSeconds $watchdogSeconds
565
613
  $reportStateBeforeCloseout = Get-ReportState $ReportFile
566
614
  $runtimeExitCode = if ($processResult.TimedOut) { 'timed-out' } else { [string]$processResult.ExitCode }
567
615
  $needsPartialFailureCloseout = $processResult.TimedOut -or $processResult.ExitCode -ne 0 -or $reportStateBeforeCloseout -ne 'present'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdtk-spec-kit",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "SDTK-SPEC CLI toolkit for deterministic software documentation workflows via the sdtk-spec command",
5
5
  "bin": {
6
6
  "sdtk-spec": "bin/sdtk.js"