codex-flow 2.1.13__py3-none-any.whl

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 (113) hide show
  1. codex_flow/__init__.py +28 -0
  2. codex_flow/__main__.py +9 -0
  3. codex_flow/cli.py +242 -0
  4. codex_flow/data/LICENSE +21 -0
  5. codex_flow/data/README.en.md +303 -0
  6. codex_flow/data/README.md +305 -0
  7. codex_flow/data/VERSION +1 -0
  8. codex_flow/data/apps/chatgpt-mcp/README.md +86 -0
  9. codex_flow/data/apps/chatgpt-mcp/__init__.py +1 -0
  10. codex_flow/data/apps/chatgpt-mcp/adapter.py +458 -0
  11. codex_flow/data/apps/chatgpt-mcp/server.py +358 -0
  12. codex_flow/data/apps/chatgpt-mcp/widget.html +927 -0
  13. codex_flow/data/apps/macos-overlay/README.en.md +121 -0
  14. codex_flow/data/apps/macos-overlay/README.md +123 -0
  15. codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayRuntimeState.swift +126 -0
  16. codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayScreenGeometry.swift +82 -0
  17. codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayWindowController.swift +1052 -0
  18. codex_flow/data/apps/macos-overlay/Sources/Localization.swift +197 -0
  19. codex_flow/data/apps/macos-overlay/Sources/Models/TelemetryData.swift +1557 -0
  20. codex_flow/data/apps/macos-overlay/Sources/Services/AccountSnapshotService.swift +1101 -0
  21. codex_flow/data/apps/macos-overlay/Sources/Services/FlowPilotInstanceLock.swift +153 -0
  22. codex_flow/data/apps/macos-overlay/Sources/Services/IPCServer.swift +298 -0
  23. codex_flow/data/apps/macos-overlay/Sources/Services/TelemetryQueryEngine.swift +800 -0
  24. codex_flow/data/apps/macos-overlay/Sources/Services/TelemetryWatcher.swift +135 -0
  25. codex_flow/data/apps/macos-overlay/Sources/Services/UpdateService.swift +610 -0
  26. codex_flow/data/apps/macos-overlay/Sources/Views/AccountView.swift +610 -0
  27. codex_flow/data/apps/macos-overlay/Sources/Views/AnalyticsView.swift +566 -0
  28. codex_flow/data/apps/macos-overlay/Sources/Views/AutostartView.swift +293 -0
  29. codex_flow/data/apps/macos-overlay/Sources/Views/BubbleView.swift +317 -0
  30. codex_flow/data/apps/macos-overlay/Sources/Views/HistoryView.swift +1124 -0
  31. codex_flow/data/apps/macos-overlay/Sources/Views/HoverRevealText.swift +165 -0
  32. codex_flow/data/apps/macos-overlay/Sources/Views/InspectorSkillsToolsView.swift +121 -0
  33. codex_flow/data/apps/macos-overlay/Sources/Views/LogoView.swift +182 -0
  34. codex_flow/data/apps/macos-overlay/Sources/Views/SleekSwitch.swift +117 -0
  35. codex_flow/data/apps/macos-overlay/Sources/Views/StrategyModeView.swift +561 -0
  36. codex_flow/data/apps/macos-overlay/Sources/Views/SummaryView.swift +1273 -0
  37. codex_flow/data/apps/macos-overlay/Sources/Views/UpdateView.swift +352 -0
  38. codex_flow/data/apps/macos-overlay/Sources/main.swift +340 -0
  39. codex_flow/data/apps/macos-overlay/Tests/OverlayScreenGeometryTests.swift +163 -0
  40. codex_flow/data/apps/macos-overlay/Tests/TelemetryPhase1ContractTests.swift +357 -0
  41. codex_flow/data/apps/macos-overlay/Tests/TelemetryQueryEngineConcurrencyTests.swift +221 -0
  42. codex_flow/data/apps/macos-overlay/Tests/TelemetryQuotaSelectionTests.swift +158 -0
  43. codex_flow/data/apps/macos-overlay/Tests/TelemetryWorkerTokenTests.swift +122 -0
  44. codex_flow/data/apps/macos-overlay/build.sh +75 -0
  45. codex_flow/data/benchmark/corpus.json +103 -0
  46. codex_flow/data/benchmark/manifest.example.json +41 -0
  47. codex_flow/data/benchmark/manifest.schema.json +137 -0
  48. codex_flow/data/benchmark/prices/gpt-5.6-2026-08-30.json +5 -0
  49. codex_flow/data/benchmark/profiles.json +90 -0
  50. codex_flow/data/benchmark/schema.json +77 -0
  51. codex_flow/data/benchmark/tasks.json +50 -0
  52. codex_flow/data/completions/codex-flow.bash +34 -0
  53. codex_flow/data/completions/codex-flow.zsh +52 -0
  54. codex_flow/data/glama.json +6 -0
  55. codex_flow/data/install-release.ps1 +126 -0
  56. codex_flow/data/install-release.sh +155 -0
  57. codex_flow/data/install.ps1 +349 -0
  58. codex_flow/data/install.sh +362 -0
  59. codex_flow/data/policy/benchmark.toml +49 -0
  60. codex_flow/data/policy/defaults.toml +70 -0
  61. codex_flow/data/scripts/analyze-benchmark.py +510 -0
  62. codex_flow/data/scripts/benchmark-local.py +171 -0
  63. codex_flow/data/scripts/check-recommendation.py +277 -0
  64. codex_flow/data/scripts/doctor.py +449 -0
  65. codex_flow/data/scripts/generate-release-manifest.py +74 -0
  66. codex_flow/data/scripts/localization.py +192 -0
  67. codex_flow/data/scripts/manage-hooks.py +448 -0
  68. codex_flow/data/scripts/manage-instructions.py +389 -0
  69. codex_flow/data/scripts/manage-shell.py +151 -0
  70. codex_flow/data/scripts/materialize-corpus.py +193 -0
  71. codex_flow/data/scripts/menu.py +646 -0
  72. codex_flow/data/scripts/migrations/0001_update_settings.py +80 -0
  73. codex_flow/data/scripts/package-release.py +132 -0
  74. codex_flow/data/scripts/render-benchmark-report.py +292 -0
  75. codex_flow/data/scripts/run-benchmark.py +829 -0
  76. codex_flow/data/scripts/strategies/__init__.py +28 -0
  77. codex_flow/data/scripts/strategies/balanced.py +115 -0
  78. codex_flow/data/scripts/strategies/base.py +363 -0
  79. codex_flow/data/scripts/strategies/efficient.py +158 -0
  80. codex_flow/data/scripts/strategies/lifecycle_runtime.py +590 -0
  81. codex_flow/data/scripts/strategies/quality.py +209 -0
  82. codex_flow/data/scripts/strategies/speed.py +108 -0
  83. codex_flow/data/scripts/strategies/task_budget_runtime.py +644 -0
  84. codex_flow/data/scripts/strategies/task_phase_runtime.py +341 -0
  85. codex_flow/data/scripts/strategies/work_unit_runtime.py +421 -0
  86. codex_flow/data/scripts/strategy_runtime.py +1091 -0
  87. codex_flow/data/scripts/telemetry.py +400 -0
  88. codex_flow/data/scripts/telemetry_core/__init__.py +192 -0
  89. codex_flow/data/scripts/telemetry_core/app_server.py +1192 -0
  90. codex_flow/data/scripts/telemetry_core/collector.py +1247 -0
  91. codex_flow/data/scripts/telemetry_core/common.py +421 -0
  92. codex_flow/data/scripts/telemetry_core/latency.py +593 -0
  93. codex_flow/data/scripts/telemetry_core/query.py +427 -0
  94. codex_flow/data/scripts/telemetry_core/quota_ledger.py +598 -0
  95. codex_flow/data/scripts/telemetry_core/render.py +460 -0
  96. codex_flow/data/scripts/telemetry_core/repair.py +223 -0
  97. codex_flow/data/scripts/ui.py +266 -0
  98. codex_flow/data/scripts/update-homebrew-formula.py +146 -0
  99. codex_flow/data/scripts/update_runtime_config.py +134 -0
  100. codex_flow/data/scripts/updater.py +1718 -0
  101. codex_flow/data/smithery.yaml +18 -0
  102. codex_flow/data/templates/agents/worker-explorer.toml +24 -0
  103. codex_flow/data/templates/agents/worker-implementer.toml +49 -0
  104. codex_flow/data/templates/agents/worker-reviewer.toml +25 -0
  105. codex_flow/data/templates/flow-pilot-instructions.md +35 -0
  106. codex_flow/data/templates/skills/flow-pilot/SKILL.md +577 -0
  107. codex_flow/mcp.py +35 -0
  108. codex_flow-2.1.13.dist-info/METADATA +342 -0
  109. codex_flow-2.1.13.dist-info/RECORD +113 -0
  110. codex_flow-2.1.13.dist-info/WHEEL +5 -0
  111. codex_flow-2.1.13.dist-info/entry_points.txt +3 -0
  112. codex_flow-2.1.13.dist-info/licenses/LICENSE +21 -0
  113. codex_flow-2.1.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,349 @@
1
+ $ErrorActionPreference = 'Stop'
2
+
3
+ function New-Utf8NoBomEncoding { return New-Object -TypeName System.Text.UTF8Encoding -ArgumentList $false }
4
+ function Read-Utf8NoBom([string]$Path) { return [System.IO.File]::ReadAllText($Path, (New-Utf8NoBomEncoding)) }
5
+ function Write-Utf8NoBom([string]$Path, [string]$Value) { [System.IO.File]::WriteAllText($Path, $Value, (New-Utf8NoBomEncoding)) }
6
+
7
+ $RootDir = Split-Path -Parent $MyInvocation.MyCommand.Path
8
+ $CodexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME '.codex' }
9
+ $Config = Join-Path $CodexHome 'config.toml'
10
+ $Policy = Join-Path $CodexHome 'codex-flow.toml'
11
+ $Hooks = Join-Path $CodexHome 'hooks.json'
12
+ $Defaults = Join-Path $RootDir 'policy/defaults.toml'
13
+ $Localization = Join-Path $RootDir 'scripts/localization.py'
14
+ $StateDir = Join-Path $CodexHome 'codex-flow'
15
+ $BinDirState = Join-Path $StateDir 'bin_dir'
16
+ $PersistedBinDir = if (Test-Path $BinDirState) { (Read-Utf8NoBom $BinDirState).Trim() } else { '' }
17
+ $PreviousBinDir = $PersistedBinDir
18
+ $BinDir = if ($env:CODEX_FLOW_BIN_DIR) { $env:CODEX_FLOW_BIN_DIR } elseif ($PersistedBinDir) { $PersistedBinDir } else { Join-Path $HOME '.local/bin' }
19
+ $BinDir = [System.IO.Path]::GetFullPath($BinDir)
20
+ $Stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
21
+ $Version = if (Test-Path (Join-Path $RootDir 'VERSION')) { (Read-Utf8NoBom (Join-Path $RootDir 'VERSION')).Trim() } else { 'dev' }
22
+
23
+ function Get-TomlValue([string]$Text, [string]$Section, [string]$Key) {
24
+ $m = [regex]::Match($Text, '(?ms)^\[' + [regex]::Escape($Section) + '\]\s*(.*?)(?=^\[[^\r\n]+\]|\z)')
25
+ if (-not $m.Success) { return '' }
26
+ $k = [regex]::Match($m.Groups[1].Value, '(?m)^\s*' + [regex]::Escape($Key) + '\s*=\s*(.*?)\s*$')
27
+ if (-not $k.Success) { return '' }
28
+ $value = [regex]::Replace($k.Groups[1].Value, '\s+#.*$', '').Trim()
29
+ if ($value.Length -ge 2 -and $value[0] -eq '"' -and $value[$value.Length - 1] -eq '"') {
30
+ return $value.Substring(1, $value.Length - 2)
31
+ }
32
+ return $value
33
+ }
34
+ function Existing-OrDefault([string]$Text, [string]$Section, [string]$Key, [string]$Fallback) {
35
+ $value = Get-TomlValue $Text $Section $Key
36
+ if ($value) { return $value }
37
+ return $Fallback
38
+ }
39
+
40
+ if (-not (Get-Command python3 -ErrorAction SilentlyContinue)) { throw 'python3 is required' }
41
+ $defaultsText = Read-Utf8NoBom $Defaults
42
+ $existingText = if (Test-Path $Policy) { Read-Utf8NoBom $Policy } else { '' }
43
+
44
+ $DefaultWorkerModel = Get-TomlValue $defaultsText 'models' 'worker_model'
45
+ $DefaultWorkerPolicy = Get-TomlValue $defaultsText 'models' 'worker_policy'
46
+ $DefaultParentPolicy = Get-TomlValue $defaultsText 'models' 'parent_policy'
47
+ $DefaultParentMinModel = Get-TomlValue $defaultsText 'models' 'parent_min_model'
48
+ $DefaultStrategyEnabled = Get-TomlValue $defaultsText 'strategy' 'enabled'
49
+ $DefaultStrategy = Get-TomlValue $defaultsText 'strategy' 'profile'
50
+ $DefaultRoutingMode = Get-TomlValue $defaultsText 'routing' 'mode'
51
+ $DefaultReviewModifier = Get-TomlValue $defaultsText 'modifiers' 'review'
52
+ $DefaultFanoutModifier = Get-TomlValue $defaultsText 'modifiers' 'fanout'
53
+ $DefaultParentMinEffort = Get-TomlValue $defaultsText 'reasoning.parent' 'minimum'
54
+ $DefaultParentRoutineEffort = Get-TomlValue $defaultsText 'reasoning.parent' 'routine'
55
+ $DefaultParentComplexEffort = Get-TomlValue $defaultsText 'reasoning.parent' 'complex'
56
+ $DefaultParentCriticalEffort = Get-TomlValue $defaultsText 'reasoning.parent' 'critical'
57
+ $DefaultWorkerMinEffort = Get-TomlValue $defaultsText 'reasoning.worker' 'minimum'
58
+ $DefaultWorkerRoutineEffort = Get-TomlValue $defaultsText 'reasoning.worker' 'routine'
59
+ $DefaultWorkerComplexEffort = Get-TomlValue $defaultsText 'reasoning.worker' 'complex'
60
+ $DefaultWorkerCriticalEffort = Get-TomlValue $defaultsText 'reasoning.worker' 'critical'
61
+ $DefaultRolloutMode = Get-TomlValue $defaultsText 'reasoning.rollout' 'mode'
62
+ $DefaultRolloutMinimum = Get-TomlValue $defaultsText 'reasoning.rollout' 'minimum'
63
+ $DefaultRolloutRoutine = Get-TomlValue $defaultsText 'reasoning.rollout' 'routine'
64
+ $DefaultRolloutComplex = Get-TomlValue $defaultsText 'reasoning.rollout' 'complex'
65
+ $DefaultRolloutCritical = Get-TomlValue $defaultsText 'reasoning.rollout' 'critical'
66
+ $DefaultMaxThreads = Get-TomlValue $defaultsText 'runtime' 'max_concurrent_threads'
67
+ $DefaultMaxRepairs = Get-TomlValue $defaultsText 'runtime' 'max_repair_cycles'
68
+ $DefaultTelemetryEnabled = Get-TomlValue $defaultsText 'telemetry' 'enabled'
69
+ $DefaultTelemetryNotifications = Get-TomlValue $defaultsText 'telemetry' 'notifications'
70
+ $DefaultTelemetryRetentionDays = Get-TomlValue $defaultsText 'telemetry' 'retention_days'
71
+
72
+ $ExistingStrategyEnabled = Existing-OrDefault $existingText 'strategy' 'enabled' $DefaultStrategyEnabled
73
+ $ExistingStrategy = Existing-OrDefault $existingText 'strategy' 'profile' $DefaultStrategy
74
+ $ExistingRouting = Existing-OrDefault $existingText 'routing' 'mode' $DefaultRoutingMode
75
+ $ExistingReview = Existing-OrDefault $existingText 'modifiers' 'review' $DefaultReviewModifier
76
+ $ExistingFanout = Existing-OrDefault $existingText 'modifiers' 'fanout' $DefaultFanoutModifier
77
+ $ExistingParentPolicy = Existing-OrDefault $existingText 'parent' 'model_policy' $DefaultParentPolicy
78
+ $ExistingParentMinModel = Existing-OrDefault $existingText 'parent' 'min_model' $DefaultParentMinModel
79
+ $ExistingParentMinEffort = Existing-OrDefault $existingText 'parent' 'min_reasoning_effort' $DefaultParentMinEffort
80
+ $ExistingParentRoutineEffort = Existing-OrDefault $existingText 'parent' 'routine_effort' $DefaultParentRoutineEffort
81
+ $ExistingParentComplexEffort = Existing-OrDefault $existingText 'parent' 'complex_effort' $DefaultParentComplexEffort
82
+ $ExistingParentCriticalEffort = Existing-OrDefault $existingText 'parent' 'critical_effort' $DefaultParentCriticalEffort
83
+ $ExistingWorkerPolicy = Existing-OrDefault $existingText 'worker' 'model_policy' $DefaultWorkerPolicy
84
+ $ExistingWorkerModel = Existing-OrDefault $existingText 'worker' 'model' 'auto'
85
+ $ExistingWorkerMinEffort = Existing-OrDefault $existingText 'worker' 'min_reasoning_effort' $DefaultWorkerMinEffort
86
+ $ExistingWorkerRoutineEffort = Existing-OrDefault $existingText 'worker' 'routine_effort' $DefaultWorkerRoutineEffort
87
+ $ExistingWorkerComplexEffort = Existing-OrDefault $existingText 'worker' 'complex_effort' $DefaultWorkerComplexEffort
88
+ $ExistingWorkerCriticalEffort = Existing-OrDefault $existingText 'worker' 'critical_effort' $DefaultWorkerCriticalEffort
89
+ $ExistingRolloutMode = Existing-OrDefault $existingText 'reasoning.rollout' 'mode' $DefaultRolloutMode
90
+ $ExistingRolloutMinimum = Existing-OrDefault $existingText 'reasoning.rollout' 'minimum' $DefaultRolloutMinimum
91
+ $ExistingRolloutRoutine = Existing-OrDefault $existingText 'reasoning.rollout' 'routine' $DefaultRolloutRoutine
92
+ $ExistingRolloutComplex = Existing-OrDefault $existingText 'reasoning.rollout' 'complex' $DefaultRolloutComplex
93
+ $ExistingRolloutCritical = Existing-OrDefault $existingText 'reasoning.rollout' 'critical' $DefaultRolloutCritical
94
+ $ExistingMaxThreads = Existing-OrDefault $existingText 'runtime' 'max_concurrent_threads' $DefaultMaxThreads
95
+ $ExistingMaxRepairs = Existing-OrDefault $existingText 'runtime' 'max_repair_cycles' $DefaultMaxRepairs
96
+ $ExistingTelemetryEnabled = Existing-OrDefault $existingText 'telemetry' 'enabled' $DefaultTelemetryEnabled
97
+ $ExistingTelemetryNotifications = Existing-OrDefault $existingText 'telemetry' 'notifications' $DefaultTelemetryNotifications
98
+ $ExistingTelemetryRetentionDays = Existing-OrDefault $existingText 'telemetry' 'retention_days' $DefaultTelemetryRetentionDays
99
+ $ExistingUpdateChannel = Existing-OrDefault $existingText 'update' 'channel' 'stable'
100
+ $ExistingUpdateCheck = Existing-OrDefault $existingText 'update' 'check' 'true'
101
+ $ExistingUpdateInterval = Existing-OrDefault $existingText 'update' 'check_interval_hours' '24'
102
+ $ExistingUpdateNotifyCli = Existing-OrDefault $existingText 'update' 'notify_cli' 'true'
103
+ $ExistingUpdateNotifyApp = Existing-OrDefault $existingText 'update' 'notify_app' 'true'
104
+ $ExistingUpdateAutoInstall = Existing-OrDefault $existingText 'update' 'auto_install' 'true'
105
+
106
+ $StrategyEnabled = if ($env:CODEX_FLOW_STRATEGY_ENABLED) { $env:CODEX_FLOW_STRATEGY_ENABLED } else { $ExistingStrategyEnabled }
107
+ $StrategyProfile = if ($env:CODEX_FLOW_STRATEGY) { $env:CODEX_FLOW_STRATEGY } else { $ExistingStrategy }
108
+ $RoutingMode = if ($env:CODEX_FLOW_ROUTING_MODE) { $env:CODEX_FLOW_ROUTING_MODE } else { $ExistingRouting }
109
+ $ReviewModifier = if ($env:CODEX_FLOW_REVIEW_MODIFIER) { $env:CODEX_FLOW_REVIEW_MODIFIER } else { $ExistingReview }
110
+ $FanoutModifier = if ($env:CODEX_FLOW_FANOUT_MODIFIER) { $env:CODEX_FLOW_FANOUT_MODIFIER } else { $ExistingFanout }
111
+ $ParentModelPolicy = if ($env:CODEX_FLOW_PARENT_MODEL_POLICY) { $env:CODEX_FLOW_PARENT_MODEL_POLICY } else { $ExistingParentPolicy }
112
+ $ParentMinModel = if ($env:CODEX_FLOW_PARENT_MIN_MODEL) { $env:CODEX_FLOW_PARENT_MIN_MODEL } else { $ExistingParentMinModel }
113
+ $ParentMinEffort = if ($env:CODEX_FLOW_PARENT_MIN_EFFORT) { $env:CODEX_FLOW_PARENT_MIN_EFFORT } else { $ExistingParentMinEffort }
114
+ $ParentRoutineEffort = if ($env:CODEX_FLOW_PARENT_ROUTINE_EFFORT) { $env:CODEX_FLOW_PARENT_ROUTINE_EFFORT } else { $ExistingParentRoutineEffort }
115
+ $ParentComplexEffort = if ($env:CODEX_FLOW_PARENT_COMPLEX_EFFORT) { $env:CODEX_FLOW_PARENT_COMPLEX_EFFORT } else { $ExistingParentComplexEffort }
116
+ $ParentCriticalEffort = if ($env:CODEX_FLOW_PARENT_CRITICAL_EFFORT) { $env:CODEX_FLOW_PARENT_CRITICAL_EFFORT } else { $ExistingParentCriticalEffort }
117
+ $WorkerModelPolicy = if ($env:CODEX_FLOW_WORKER_MODEL_POLICY) { $env:CODEX_FLOW_WORKER_MODEL_POLICY } else { $ExistingWorkerPolicy }
118
+ $WorkerRequested = if ($env:CODEX_FLOW_WORKER_MODEL) { $env:CODEX_FLOW_WORKER_MODEL } else { $ExistingWorkerModel }
119
+ $WorkerModel = if ($WorkerRequested -eq 'auto') { $DefaultWorkerModel } else { $WorkerRequested }
120
+ $WorkerMinEffort = if ($env:CODEX_FLOW_WORKER_MIN_EFFORT) { $env:CODEX_FLOW_WORKER_MIN_EFFORT } else { $ExistingWorkerMinEffort }
121
+ $WorkerRoutineEffort = if ($env:CODEX_FLOW_WORKER_ROUTINE_EFFORT) { $env:CODEX_FLOW_WORKER_ROUTINE_EFFORT } else { $ExistingWorkerRoutineEffort }
122
+ $WorkerComplexEffort = if ($env:CODEX_FLOW_WORKER_COMPLEX_EFFORT) { $env:CODEX_FLOW_WORKER_COMPLEX_EFFORT } else { $ExistingWorkerComplexEffort }
123
+ $WorkerCriticalEffort = if ($env:CODEX_FLOW_WORKER_CRITICAL_EFFORT) { $env:CODEX_FLOW_WORKER_CRITICAL_EFFORT } else { $ExistingWorkerCriticalEffort }
124
+ $RolloutMode = if ($env:CODEX_FLOW_REASONING_ROLLOUT_MODE) { $env:CODEX_FLOW_REASONING_ROLLOUT_MODE } else { $ExistingRolloutMode }
125
+ $RolloutMinimum = if ($env:CODEX_FLOW_REASONING_ROLLOUT_MINIMUM) { $env:CODEX_FLOW_REASONING_ROLLOUT_MINIMUM } else { $ExistingRolloutMinimum }
126
+ $RolloutRoutine = if ($env:CODEX_FLOW_REASONING_ROLLOUT_ROUTINE) { $env:CODEX_FLOW_REASONING_ROLLOUT_ROUTINE } else { $ExistingRolloutRoutine }
127
+ $RolloutComplex = if ($env:CODEX_FLOW_REASONING_ROLLOUT_COMPLEX) { $env:CODEX_FLOW_REASONING_ROLLOUT_COMPLEX } else { $ExistingRolloutComplex }
128
+ $RolloutCritical = if ($env:CODEX_FLOW_REASONING_ROLLOUT_CRITICAL) { $env:CODEX_FLOW_REASONING_ROLLOUT_CRITICAL } else { $ExistingRolloutCritical }
129
+ $MaxThreads = if ($env:CODEX_FLOW_MAX_THREADS) { $env:CODEX_FLOW_MAX_THREADS } else { $ExistingMaxThreads }
130
+ $MaxRepairs = if ($env:CODEX_FLOW_MAX_REPAIR_CYCLES) { $env:CODEX_FLOW_MAX_REPAIR_CYCLES } else { $ExistingMaxRepairs }
131
+ $TelemetryEnabled = if ($env:CODEX_FLOW_TELEMETRY_ENABLED) { $env:CODEX_FLOW_TELEMETRY_ENABLED } else { $ExistingTelemetryEnabled }
132
+ $TelemetryNotifications = if ($env:CODEX_FLOW_TELEMETRY_NOTIFICATIONS) { $env:CODEX_FLOW_TELEMETRY_NOTIFICATIONS } else { $ExistingTelemetryNotifications }
133
+ $TelemetryRetentionDays = if ($env:CODEX_FLOW_TELEMETRY_RETENTION_DAYS) { $env:CODEX_FLOW_TELEMETRY_RETENTION_DAYS } else { $ExistingTelemetryRetentionDays }
134
+ $UpdateChannel = if ($env:CODEX_FLOW_UPDATE_CHANNEL) { $env:CODEX_FLOW_UPDATE_CHANNEL } else { $ExistingUpdateChannel }
135
+ $UpdateCheck = if ($env:CODEX_FLOW_UPDATE_CHECK) { $env:CODEX_FLOW_UPDATE_CHECK } else { $ExistingUpdateCheck }
136
+ $UpdateInterval = if ($env:CODEX_FLOW_UPDATE_CHECK_INTERVAL_HOURS) { $env:CODEX_FLOW_UPDATE_CHECK_INTERVAL_HOURS } else { $ExistingUpdateInterval }
137
+ $UpdateNotifyCli = if ($env:CODEX_FLOW_UPDATE_NOTIFY_CLI) { $env:CODEX_FLOW_UPDATE_NOTIFY_CLI } else { $ExistingUpdateNotifyCli }
138
+ $UpdateNotifyApp = if ($env:CODEX_FLOW_UPDATE_NOTIFY_APP) { $env:CODEX_FLOW_UPDATE_NOTIFY_APP } else { $ExistingUpdateNotifyApp }
139
+ $UpdateAutoInstall = if ($env:CODEX_FLOW_UPDATE_AUTO_INSTALL) { $env:CODEX_FLOW_UPDATE_AUTO_INSTALL } else { $ExistingUpdateAutoInstall }
140
+ $UiLanguage = 'auto'
141
+ if (Test-Path $Policy) {
142
+ try { $UiLanguage = (& python3 $Localization --policy $Policy --configured 2>$null | Out-String).Trim() } catch { $UiLanguage = 'auto' }
143
+ }
144
+ $UiLanguage = (& python3 $Localization --normalize $UiLanguage | Out-String).Trim()
145
+
146
+ if ($StrategyEnabled -notin @('true','false')) { throw 'CODEX_FLOW_STRATEGY_ENABLED must be true or false' }
147
+ if ($StrategyProfile -notin @('efficient','balanced','quality','speed')) { throw 'CODEX_FLOW_STRATEGY must be efficient, balanced, quality, or speed' }
148
+ if ($RoutingMode -notin @('adaptive','direct','delegate')) { throw 'CODEX_FLOW_ROUTING_MODE must be adaptive, direct, or delegate' }
149
+ if ($ReviewModifier -notin @('auto','standard','strict')) { throw 'CODEX_FLOW_REVIEW_MODIFIER must be auto, standard, or strict' }
150
+ if ($FanoutModifier -notin @('auto','conservative','aggressive')) { throw 'CODEX_FLOW_FANOUT_MODIFIER must be auto, conservative, or aggressive' }
151
+ foreach ($effort in @($ParentMinEffort,$ParentRoutineEffort,$ParentComplexEffort,$ParentCriticalEffort,$WorkerMinEffort,$WorkerRoutineEffort,$WorkerComplexEffort,$WorkerCriticalEffort)) {
152
+ if ($effort -notin @('high','xhigh','max')) { throw 'reasoning efforts must be high, xhigh, or max' }
153
+ }
154
+ if ($RolloutMode -notin @('legacy','shadow','adaptive')) { throw 'CODEX_FLOW_REASONING_ROLLOUT_MODE must be legacy, shadow, or adaptive' }
155
+ foreach ($effort in @($RolloutMinimum,$RolloutRoutine,$RolloutComplex,$RolloutCritical)) {
156
+ if ($effort -notin @('high','xhigh','max')) { throw 'reasoning rollout efforts must be high, xhigh, or max' }
157
+ }
158
+ if ($MaxThreads -notmatch '^[1-9][0-9]*$') { throw 'CODEX_FLOW_MAX_THREADS must be a positive integer' }
159
+ if ($MaxRepairs -notmatch '^[0-9]+$') { throw 'CODEX_FLOW_MAX_REPAIR_CYCLES must be a non-negative integer' }
160
+ if ($TelemetryEnabled -notin @('true','false')) { throw 'CODEX_FLOW_TELEMETRY_ENABLED must be true or false' }
161
+ if ($TelemetryNotifications -notin @('true','false')) { throw 'CODEX_FLOW_TELEMETRY_NOTIFICATIONS must be true or false' }
162
+ if ($TelemetryRetentionDays -notmatch '^[1-9][0-9]*$') { throw 'CODEX_FLOW_TELEMETRY_RETENTION_DAYS must be a positive integer' }
163
+ if ($UpdateChannel -notin @('stable','beta','nightly')) { throw 'CODEX_FLOW_UPDATE_CHANNEL must be stable, beta, or nightly' }
164
+ if ($UpdateCheck -notin @('true','false')) { throw 'CODEX_FLOW_UPDATE_CHECK must be true or false' }
165
+ if ($UpdateNotifyCli -notin @('true','false')) { throw 'CODEX_FLOW_UPDATE_NOTIFY_CLI must be true or false' }
166
+ if ($UpdateNotifyApp -notin @('true','false')) { throw 'CODEX_FLOW_UPDATE_NOTIFY_APP must be true or false' }
167
+ if ($UpdateAutoInstall -notin @('true','false')) { throw 'CODEX_FLOW_UPDATE_AUTO_INSTALL must be true or false' }
168
+ if ($UpdateInterval -notmatch '^[1-9][0-9]*$') { throw 'CODEX_FLOW_UPDATE_CHECK_INTERVAL_HOURS must be a positive integer' }
169
+
170
+ New-Item -ItemType Directory -Force -Path (Join-Path $CodexHome 'agents'),(Join-Path $CodexHome 'skills/flow-pilot'),$StateDir,(Join-Path $StateDir 'state'),(Join-Path $StateDir 'versions'),$BinDir | Out-Null
171
+ $InstructionHelper = Join-Path $StateDir 'manage-instructions.py'
172
+ $InstructionTemplate = Join-Path $StateDir 'flow-pilot-instructions.md'
173
+ Copy-Item (Join-Path $RootDir 'scripts/manage-instructions.py') $InstructionHelper -Force
174
+ Copy-Item (Join-Path $RootDir 'templates/flow-pilot-instructions.md') $InstructionTemplate -Force
175
+ & python3 $InstructionHelper --codex-home $CodexHome --template $InstructionTemplate install | Out-Null
176
+ if ($LASTEXITCODE -ne 0) { throw 'FlowPilot entry instruction installation failed; existing AGENTS files were not safely updated' }
177
+ if (Test-Path $Config) { Copy-Item $Config "$Config.codex-flow.$Stamp.bak" } else { New-Item -ItemType File -Force -Path $Config | Out-Null }
178
+
179
+ $text = Read-Utf8NoBom $Config
180
+ $managed = [ordered]@{
181
+ enabled = 'true'
182
+ max_concurrent_threads_per_session = $MaxThreads
183
+ default_subagent_model = '"' + $WorkerModel + '"'
184
+ default_subagent_reasoning_effort = '"' + $WorkerMinEffort + '"'
185
+ }
186
+ $pattern = '(?ms)^\[agents\]\s*\r?\n(.*?)(?=^\[[^\r\n]+\]\s*$|\z)'
187
+ $match = [regex]::Match($text, $pattern)
188
+ if ($match.Success) {
189
+ $body = $match.Groups[1].Value
190
+ foreach ($entry in $managed.GetEnumerator()) {
191
+ $keyPattern = '(?m)^\s*' + [regex]::Escape($entry.Key) + '\s*=.*$'
192
+ $line = "$($entry.Key) = $($entry.Value)"
193
+ if ([regex]::IsMatch($body, $keyPattern)) { $body = [regex]::Replace($body, $keyPattern, $line) }
194
+ else { if ($body.Length -gt 0 -and -not $body.EndsWith("`n")) { $body += "`n" }; $body += "$line`n" }
195
+ }
196
+ $text = $text.Substring(0, $match.Groups[1].Index) + $body + $text.Substring($match.Groups[1].Index + $match.Groups[1].Length)
197
+ } else {
198
+ if ($text.Length -gt 0 -and -not $text.EndsWith("`n")) { $text += "`n" }
199
+ if ($text.Length -gt 0 -and -not $text.EndsWith("`n`n")) { $text += "`n" }
200
+ $text += "[agents]`n"
201
+ foreach ($entry in $managed.GetEnumerator()) { $text += "$($entry.Key) = $($entry.Value)`n" }
202
+ }
203
+ Write-Utf8NoBom $Config $text
204
+
205
+ $PolicyText = @"
206
+ schema_version = 4
207
+
208
+ [ui]
209
+ language = "$UiLanguage"
210
+
211
+ [strategy]
212
+ enabled = $StrategyEnabled
213
+ profile = "$StrategyProfile"
214
+
215
+ [routing]
216
+ mode = "$RoutingMode"
217
+
218
+ [modifiers]
219
+ review = "$ReviewModifier"
220
+ fanout = "$FanoutModifier"
221
+
222
+ [parent]
223
+ model_policy = "$ParentModelPolicy"
224
+ min_model = "$ParentMinModel"
225
+ min_reasoning_effort = "$ParentMinEffort"
226
+ reasoning_policy = "adaptive"
227
+ routine_effort = "$ParentRoutineEffort"
228
+ complex_effort = "$ParentComplexEffort"
229
+ critical_effort = "$ParentCriticalEffort"
230
+
231
+ [worker]
232
+ model_policy = "$WorkerModelPolicy"
233
+ model = "$WorkerRequested"
234
+ resolved_model = "$WorkerModel"
235
+ min_reasoning_effort = "$WorkerMinEffort"
236
+ reasoning_policy = "adaptive"
237
+ routine_effort = "$WorkerRoutineEffort"
238
+ complex_effort = "$WorkerComplexEffort"
239
+ critical_effort = "$WorkerCriticalEffort"
240
+
241
+ [reasoning.rollout]
242
+ mode = "$RolloutMode"
243
+ minimum = "$RolloutMinimum"
244
+ routine = "$RolloutRoutine"
245
+ complex = "$RolloutComplex"
246
+ critical = "$RolloutCritical"
247
+
248
+ [runtime]
249
+ max_concurrent_threads = $MaxThreads
250
+ max_repair_cycles = $MaxRepairs
251
+
252
+ [telemetry]
253
+ enabled = $TelemetryEnabled
254
+ summary = true
255
+ notifications = $TelemetryNotifications
256
+ retention_days = $TelemetryRetentionDays
257
+ source = "hooks+app-server"
258
+
259
+ [update]
260
+ channel = "$UpdateChannel"
261
+ check = $UpdateCheck
262
+ check_interval_hours = $UpdateInterval
263
+ notify_cli = $UpdateNotifyCli
264
+ notify_app = $UpdateNotifyApp
265
+ auto_install = $UpdateAutoInstall
266
+ "@
267
+ Write-Utf8NoBom $Policy $PolicyText
268
+
269
+ Copy-Item (Join-Path $RootDir 'templates/agents/worker-explorer.toml') (Join-Path $CodexHome 'agents/worker-explorer.toml') -Force
270
+ Copy-Item (Join-Path $RootDir 'templates/agents/worker-implementer.toml') (Join-Path $CodexHome 'agents/worker-implementer.toml') -Force
271
+ Copy-Item (Join-Path $RootDir 'templates/agents/worker-reviewer.toml') (Join-Path $CodexHome 'agents/worker-reviewer.toml') -Force
272
+ Copy-Item (Join-Path $RootDir 'templates/skills/flow-pilot/SKILL.md') (Join-Path $CodexHome 'skills/flow-pilot/SKILL.md') -Force
273
+ Remove-Item (Join-Path $CodexHome 'agents/luna-explorer.toml') -Force -ErrorAction SilentlyContinue
274
+ Remove-Item (Join-Path $CodexHome 'agents/luna-implementer.toml') -Force -ErrorAction SilentlyContinue
275
+
276
+ Write-Utf8NoBom (Join-Path $StateDir 'source') $RootDir
277
+ Write-Utf8NoBom (Join-Path $StateDir 'version') $Version
278
+ Write-Utf8NoBom $BinDirState $BinDir
279
+ Copy-Item $Defaults (Join-Path $StateDir 'defaults.toml') -Force
280
+ foreach ($name in @('updater.py','update_runtime_config.py','telemetry.py','manage-hooks.py','manage-instructions.py','menu.py','localization.py','ui.py','doctor.py','strategy_runtime.py')) { Copy-Item (Join-Path $RootDir "scripts/$name") (Join-Path $StateDir $name) -Force }
281
+ Copy-Item (Join-Path $RootDir 'templates/flow-pilot-instructions.md') (Join-Path $StateDir 'flow-pilot-instructions.md') -Force
282
+ Remove-Item (Join-Path $StateDir 'strategies') -Recurse -Force -ErrorAction SilentlyContinue
283
+ Remove-Item (Join-Path $StateDir 'telemetry_core') -Recurse -Force -ErrorAction SilentlyContinue
284
+ Copy-Item (Join-Path $RootDir 'scripts/strategies') (Join-Path $StateDir 'strategies') -Recurse -Force
285
+ Copy-Item (Join-Path $RootDir 'scripts/telemetry_core') (Join-Path $StateDir 'telemetry_core') -Recurse -Force
286
+ if ($TelemetryEnabled -eq 'true') { & python3 (Join-Path $StateDir 'manage-hooks.py') install --hooks $Hooks --script (Join-Path $StateDir 'telemetry.py') }
287
+ else { & python3 (Join-Path $StateDir 'manage-hooks.py') uninstall --hooks $Hooks }
288
+
289
+ Copy-Item (Join-Path $RootDir 'bin/codex-flow.ps1') (Join-Path $BinDir 'codex-flow.ps1') -Force
290
+ Copy-Item (Join-Path $RootDir 'bin/codex-flow.cmd') (Join-Path $BinDir 'codex-flow.cmd') -Force
291
+ if ($PreviousBinDir) {
292
+ $previousFullPath = [System.IO.Path]::GetFullPath($PreviousBinDir); $currentFullPath = [System.IO.Path]::GetFullPath($BinDir)
293
+ if (-not [string]::Equals($previousFullPath, $currentFullPath, [System.StringComparison]::OrdinalIgnoreCase)) {
294
+ Remove-Item (Join-Path $PreviousBinDir 'codex-flow.ps1') -Force -ErrorAction SilentlyContinue
295
+ Remove-Item (Join-Path $PreviousBinDir 'codex-flow.cmd') -Force -ErrorAction SilentlyContinue
296
+ }
297
+ }
298
+
299
+ $UiLang = (& python3 $Localization --policy $Policy --resolved | Out-String).Trim()
300
+ function L([string]$English,[string]$Chinese) { if ($UiLang -eq 'zh') { return $Chinese } else { return $English } }
301
+ $dispPolicy = $Policy.Replace($HOME, '~'); $dispBin = (Join-Path $BinDir 'codex-flow.cmd').Replace($HOME, '~')
302
+
303
+ Write-Host ""
304
+ Write-Host (L "codex-flow v$Version installed successfully" "codex-flow v$Version 安装成功") -ForegroundColor Green
305
+ Write-Host ""
306
+ Write-Host (L ' +-- Summary ---------------------------------------------------------+' ' +-- 安装摘要 --------------------------------------------------------+') -ForegroundColor DarkGray
307
+ Write-Host " | * Policy: $dispPolicy"
308
+ Write-Host " | * CLI: $dispBin"
309
+ Write-Host " | * Skill: FlowPilot (flow-pilot)"
310
+ Write-Host " | * Strategy: $StrategyProfile / $RoutingMode (enabled=$StrategyEnabled)"
311
+ Write-Host " | * Reasoning rollout: $RolloutMode ($RolloutMinimum / $RolloutRoutine / $RolloutComplex / $RolloutCritical)"
312
+ Write-Host " | * Modifiers: review=$ReviewModifier / fanout=$FanoutModifier"
313
+ Write-Host " | * Models: parent ($ParentModelPolicy) -> worker ($WorkerModel)"
314
+ Write-Host " | * Language: $UiLanguage (effective: $UiLang)"
315
+ if ($TelemetryEnabled -eq 'true') { Write-Host " | * Telemetry: [+] enabled (hooks + app-server; ${TelemetryRetentionDays}d retention)" } else { Write-Host ' | * Telemetry: [-] disabled' }
316
+ Write-Host ' +--------------------------------------------------------------------+' -ForegroundColor DarkGray
317
+ Write-Host ""
318
+
319
+ if ($UiLang -eq 'zh') {
320
+ Write-Host ' +-- [!] 必须完成的后续步骤 ------------------------------------------+' -ForegroundColor Yellow
321
+ Write-Host " | [1/3] CLI 可用性:确认 $BinDir 已加入用户 PATH"
322
+ Write-Host ' | [2/3] 完整重启 Codex:完全退出并重新启动,仅新建任务不够。'
323
+ if ($TelemetryEnabled -eq 'true') { Write-Host ' | [3/3] 授权 Hooks:在 Codex 中运行 /hooks 并批准 FlowPilot telemetry。' }
324
+ else { Write-Host ' | [3/3] Hooks:遥测已关闭,无需授权。' }
325
+ Write-Host ' +--------------------------------------------------------------------+' -ForegroundColor Yellow
326
+ } else {
327
+ Write-Host ' +-- [!] REQUIRED NEXT STEPS -----------------------------------------+' -ForegroundColor Yellow
328
+ $userPath = [Environment]::GetEnvironmentVariable('Path','User')
329
+ if (($userPath -split ';') -contains $BinDir) {
330
+ Write-Host ' | [1/3] CLI Availability'
331
+ Write-Host ' | Run: codex-flow status'
332
+ } else {
333
+ Write-Host ' | [1/3] PATH Configuration'
334
+ Write-Host " | Add $BinDir to your user PATH"
335
+ }
336
+ Write-Host ' | [2/3] Complete Codex Restart'
337
+ Write-Host ' | Fully quit Codex and relaunch it. Starting a new task'
338
+ Write-Host ' | alone is NOT enough to load new hooks and snapshots.'
339
+ if ($TelemetryEnabled -eq 'true') {
340
+ Write-Host ' | [3/3] Authorize Hooks'
341
+ Write-Host ' | Run /hooks in Codex and approve FlowPilot telemetry'
342
+ Write-Host ' | if it is pending approval.'
343
+ } else {
344
+ Write-Host ' | [3/3] Hooks Status'
345
+ Write-Host ' | Telemetry is disabled: no hook authorization is required.'
346
+ }
347
+ Write-Host ' +--------------------------------------------------------------------+' -ForegroundColor Yellow
348
+ }
349
+ Write-Host ""