@paradigma-inc/flywheel 0.1.115 → 0.1.134

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 (623) hide show
  1. package/README.md +67 -10
  2. package/package.json +14 -6
  3. package/skills/flywheel/SKILL.md +9 -6
  4. package/skills/flywheel/example-workflows/organizing-exploring-and-iterating-on-a-research-topic.md +38 -46
  5. package/skills/flywheel/example-workflows/reproducing-papers-on-a-budget.md +34 -36
  6. package/skills/flywheel/getting-started/flywheel-quickstart.md +2 -5
  7. package/skills/flywheel/references/INTERFACES.md +2 -2
  8. package/skills/flywheel/references/experiment-design-protocol.md +32 -25
  9. package/skills/flywheel/references/flywheel-cli-tool-map.md +120 -76
  10. package/skills/flywheel/references/flywheel-mcp-tool-map.md +42 -32
  11. package/skills/flywheel/setting-up-flywheel/claude-code-cli-installation.md +1 -1
  12. package/skills/flywheel/setting-up-flywheel/codex-cli-installation.md +1 -1
  13. package/skills/flywheel/setting-up-flywheel/installation-overview.md +2 -6
  14. package/skills/flywheel/setting-up-flywheel/other-hosts-installation.md +45 -25
  15. package/skills/flywheel/setting-up-flywheel/updating-flywheel-mcp.md +34 -11
  16. package/skills/flywheel-auto/SKILL.md +40 -23
  17. package/skills/flywheel-auto/evals/evals.json +1 -1
  18. package/skills/flywheel-auto/references/INTERFACES.md +2 -2
  19. package/skills/flywheel-auto/references/experiment-design-protocol.md +31 -23
  20. package/skills/flywheel-auto/references/flywheel-cli-tool-map.md +172 -127
  21. package/skills/flywheel-auto/references/flywheel-mcp-tool-map.md +22 -24
  22. package/skills/flywheel-lookahead/SKILL.md +47 -28
  23. package/skills/flywheel-lookahead/agents/openai.yaml +1 -1
  24. package/skills/flywheel-lookahead/evals/evals.json +6 -6
  25. package/skills/flywheel-lookahead/references/INTERFACES.md +2 -2
  26. package/skills/flywheel-lookahead/references/flywheel-cli-tool-map.md +172 -127
  27. package/skills/flywheel-lookahead/references/flywheel-mcp-tool-map.md +22 -24
  28. package/skills/flywheel-prove/SKILL.md +2 -2
  29. package/skills/flywheel-prove/references/workflow.md +21 -2
  30. package/skills/flywheel-reproduce/SKILL.md +39 -19
  31. package/skills/flywheel-reproduce/evals/evals.json +1 -1
  32. package/skills/flywheel-reproduce/references/INTERFACES.md +2 -2
  33. package/skills/flywheel-reproduce/references/experiment-design-protocol.md +31 -23
  34. package/skills/flywheel-reproduce/references/flywheel-cli-tool-map.md +172 -127
  35. package/skills/flywheel-reproduce/references/flywheel-mcp-tool-map.md +22 -24
  36. package/skills/flywheel-to-graph/SKILL.md +37 -17
  37. package/skills/flywheel-to-graph/references/INTERFACES.md +2 -2
  38. package/skills/flywheel-to-graph/references/flywheel-cli-tool-map.md +172 -127
  39. package/skills/flywheel-to-graph/references/flywheel-mcp-tool-map.md +22 -24
  40. package/skills/flywheel-tree/references/workflow.md +6 -37
  41. package/src/cli.mjs +1145 -1141
  42. package/src/mcp-writer.mjs +413 -435
  43. package/src/public-command-metadata.mjs +28 -5
  44. package/src/runtime/delegate.mjs +2 -19
  45. package/src/runtime/required-runtime-commands.json +80 -28
  46. package/src/runtime/runtime-config.mjs +39 -60
  47. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js +330 -0
  48. package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js.map +1 -0
  49. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js +90 -139
  50. package/src/runtime/vendor/flywheel-cli-dist/auth/login.js.map +1 -1
  51. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js +1 -1
  52. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js.map +1 -1
  53. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js +116 -0
  54. package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js.map +1 -0
  55. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js +248 -1
  56. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js.map +1 -1
  57. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js +65 -1
  58. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js.map +1 -1
  59. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js +17 -0
  60. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js.map +1 -0
  61. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js +3 -7
  62. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js.map +1 -1
  63. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js +12 -0
  64. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js.map +1 -0
  65. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js +29 -0
  66. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js.map +1 -0
  67. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js +12 -0
  68. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js.map +1 -1
  69. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js +46 -10
  70. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js.map +1 -1
  71. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js +17 -40
  72. package/src/runtime/vendor/flywheel-cli-dist/commands/env.js.map +1 -1
  73. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js +305 -0
  74. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js.map +1 -0
  75. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js +72 -0
  76. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js.map +1 -0
  77. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js +286 -0
  78. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js.map +1 -0
  79. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js +30 -5
  80. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js.map +1 -1
  81. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js +27 -12
  82. package/src/runtime/vendor/flywheel-cli-dist/commands/help.js.map +1 -1
  83. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js +284 -0
  84. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js.map +1 -0
  85. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +169 -0
  86. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -0
  87. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js +13 -0
  88. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js.map +1 -0
  89. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +227 -0
  90. package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -0
  91. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js +21 -51
  92. package/src/runtime/vendor/flywheel-cli-dist/commands/index.js.map +1 -1
  93. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js +25 -0
  94. package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js.map +1 -0
  95. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js +11 -9
  96. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js.map +1 -1
  97. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js +38 -45
  98. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js.map +1 -1
  99. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js +14 -17
  100. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js.map +1 -1
  101. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js +13 -8
  102. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js.map +1 -1
  103. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js +34 -3
  104. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js.map +1 -1
  105. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js +9 -9
  106. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js.map +1 -1
  107. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js +76 -0
  108. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js.map +1 -0
  109. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js +4 -138
  110. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js.map +1 -1
  111. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js +8 -13
  112. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js.map +1 -1
  113. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +362 -0
  114. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -0
  115. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js +45 -183
  116. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js.map +1 -1
  117. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +47 -0
  118. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -0
  119. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +181 -0
  120. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -0
  121. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +163 -0
  122. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -0
  123. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js +79 -0
  124. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js.map +1 -0
  125. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js +80 -0
  126. package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js.map +1 -0
  127. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js +78 -0
  128. package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js.map +1 -0
  129. package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
  130. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js +3 -2
  131. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js.map +1 -1
  132. package/src/runtime/vendor/flywheel-cli-dist/config/index.js +5 -0
  133. package/src/runtime/vendor/flywheel-cli-dist/config/index.js.map +1 -0
  134. package/src/runtime/vendor/flywheel-cli-dist/config/io.js +139 -0
  135. package/src/runtime/vendor/flywheel-cli-dist/config/io.js.map +1 -0
  136. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js +299 -0
  137. package/src/runtime/vendor/flywheel-cli-dist/config/migration.js.map +1 -0
  138. package/src/runtime/vendor/flywheel-cli-dist/config/model.js +214 -0
  139. package/src/runtime/vendor/flywheel-cli-dist/config/model.js.map +1 -0
  140. package/src/runtime/vendor/flywheel-cli-dist/config/path.js +30 -0
  141. package/src/runtime/vendor/flywheel-cli-dist/config/path.js.map +1 -0
  142. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js +29 -0
  143. package/src/runtime/vendor/flywheel-cli-dist/credential-output.js.map +1 -0
  144. package/src/runtime/vendor/flywheel-cli-dist/errors.js +1 -16
  145. package/src/runtime/vendor/flywheel-cli-dist/errors.js.map +1 -1
  146. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js +3 -3
  147. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js.map +1 -1
  148. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js +19 -9
  149. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js.map +1 -1
  150. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js +33 -4
  151. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js.map +1 -1
  152. package/src/runtime/vendor/flywheel-cli-dist/http/client.js +322 -304
  153. package/src/runtime/vendor/flywheel-cli-dist/http/client.js.map +1 -1
  154. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js +1 -21
  155. package/src/runtime/vendor/flywheel-cli-dist/http/debug.js.map +1 -1
  156. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js +1 -0
  157. package/src/runtime/vendor/flywheel-cli-dist/http/retry.js.map +1 -1
  158. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +244 -0
  159. package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -0
  160. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js +7 -0
  161. package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js.map +1 -0
  162. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js +35 -0
  163. package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js.map +1 -0
  164. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js +42 -0
  165. package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js.map +1 -0
  166. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js +179 -0
  167. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js.map +1 -0
  168. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js +152 -0
  169. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js.map +1 -0
  170. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js +71 -0
  171. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js.map +1 -0
  172. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js +73 -0
  173. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js.map +1 -0
  174. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js +82 -0
  175. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js.map +1 -0
  176. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js +345 -0
  177. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js.map +1 -0
  178. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +57 -0
  179. package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -0
  180. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +149 -0
  181. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -0
  182. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js +115 -0
  183. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js.map +1 -0
  184. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +44 -0
  185. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -0
  186. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +159 -0
  187. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -0
  188. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +346 -0
  189. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -0
  190. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +37 -0
  191. package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -0
  192. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js +203 -0
  193. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js.map +1 -0
  194. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js +207 -0
  195. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js.map +1 -0
  196. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js +109 -0
  197. package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js.map +1 -0
  198. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js +61 -0
  199. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js.map +1 -0
  200. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js +46 -0
  201. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js.map +1 -0
  202. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js +203 -0
  203. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js.map +1 -0
  204. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js +44 -0
  205. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js.map +1 -0
  206. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js +188 -0
  207. package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js.map +1 -0
  208. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js +54 -0
  209. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js.map +1 -0
  210. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js +25 -0
  211. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js.map +1 -0
  212. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js +2 -0
  213. package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js.map +1 -0
  214. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js +7 -0
  215. package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js.map +1 -0
  216. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js +129 -0
  217. package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js.map +1 -0
  218. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +277 -0
  219. package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -0
  220. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +183 -0
  221. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -0
  222. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js +2 -0
  223. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js.map +1 -0
  224. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +121 -0
  225. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -0
  226. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js +16 -0
  227. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js.map +1 -0
  228. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js +72 -0
  229. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js.map +1 -0
  230. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +59 -0
  231. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -0
  232. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +125 -0
  233. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -0
  234. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js +129 -0
  235. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js.map +1 -0
  236. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js +31 -0
  237. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js.map +1 -0
  238. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js +49 -0
  239. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js.map +1 -0
  240. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js +30 -0
  241. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js.map +1 -0
  242. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js +12 -0
  243. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js.map +1 -0
  244. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js +18 -0
  245. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js.map +1 -0
  246. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js +125 -0
  247. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js.map +1 -0
  248. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js +37 -0
  249. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js.map +1 -0
  250. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js +44 -0
  251. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js.map +1 -0
  252. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js +58 -0
  253. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js.map +1 -0
  254. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +118 -0
  255. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -0
  256. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js +277 -0
  257. package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js.map +1 -0
  258. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js +132 -0
  259. package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js.map +1 -0
  260. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js +372 -0
  261. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js.map +1 -0
  262. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js +210 -0
  263. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js.map +1 -0
  264. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +278 -0
  265. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -0
  266. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js +192 -0
  267. package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js.map +1 -0
  268. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js +114 -0
  269. package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js.map +1 -0
  270. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js +65 -0
  271. package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js.map +1 -0
  272. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js +145 -0
  273. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js.map +1 -0
  274. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js +218 -0
  275. package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js.map +1 -0
  276. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js +71 -0
  277. package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js.map +1 -0
  278. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js +298 -0
  279. package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js.map +1 -0
  280. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js +121 -0
  281. package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js.map +1 -0
  282. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js +69 -0
  283. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js.map +1 -0
  284. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js +49 -0
  285. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js.map +1 -0
  286. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js +424 -0
  287. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js.map +1 -0
  288. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js +10 -0
  289. package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js.map +1 -0
  290. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/001_initial.sql +319 -0
  291. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/002_staged_latest_values.sql +8 -0
  292. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/003_remove_cli_editing_lease.sql +21 -0
  293. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/004_hosted_association.sql +7 -0
  294. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/005_artifact_properties.sql +68 -0
  295. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js +12 -0
  296. package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js.map +1 -0
  297. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js +410 -0
  298. package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js.map +1 -0
  299. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js +77 -0
  300. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js.map +1 -0
  301. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +240 -0
  302. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -0
  303. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js +127 -0
  304. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js.map +1 -0
  305. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js +107 -0
  306. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js.map +1 -0
  307. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js +80 -0
  308. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js.map +1 -0
  309. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +219 -0
  310. package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -0
  311. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +164 -0
  312. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -0
  313. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js +20 -0
  314. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js.map +1 -0
  315. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js +41 -0
  316. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js.map +1 -0
  317. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +22 -0
  318. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -0
  319. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js +188 -0
  320. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js.map +1 -0
  321. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js +5 -0
  322. package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js.map +1 -0
  323. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js +214 -0
  324. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js.map +1 -0
  325. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +4 -0
  326. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -0
  327. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js +44 -0
  328. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js.map +1 -0
  329. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js +38 -0
  330. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js.map +1 -0
  331. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js +284 -0
  332. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js.map +1 -0
  333. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js +133 -0
  334. package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js.map +1 -0
  335. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js +98 -0
  336. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js.map +1 -0
  337. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +161 -0
  338. package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -0
  339. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js +97 -0
  340. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js.map +1 -0
  341. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +69 -0
  342. package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -0
  343. package/src/runtime/vendor/flywheel-cli-dist/main.js +651 -376
  344. package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
  345. package/src/runtime/vendor/flywheel-cli-dist/output/format.js +18 -11
  346. package/src/runtime/vendor/flywheel-cli-dist/output/format.js.map +1 -1
  347. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
  348. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
  349. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
  350. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.musl.node +0 -0
  351. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  352. package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.musl.node +0 -0
  353. package/src/runtime/vendor/manifest.json +246 -257
  354. package/src/setup/command.mjs +5 -0
  355. package/src/setup/io/patchers/json.mjs +1 -1
  356. package/src/setup/io/patchers/toml.mjs +3 -1
  357. package/src/setup/io/patchers/yaml.mjs +1 -1
  358. package/src/setup/modes/cli.mjs +76 -7
  359. package/src/setup/modes/mcp-command.mjs +802 -793
  360. package/src/setup/modes/mcp.mjs +7 -3
  361. package/src/setup/shared/prior-mode-detect.mjs +18 -21
  362. package/src/setup/test-seams.mjs +25 -0
  363. package/src/setup-auth.mjs +76 -10
  364. package/src/toml-lines.mjs +52 -0
  365. package/src/unified-cli.mjs +31 -16
  366. package/skills/flywheel-llm-proof-paper/scripts/__pycache__/check_paper.cpython-312.pyc +0 -0
  367. package/src/runtime/vendor/flywheel-cli-dist/auth/active-key-id.d.ts +0 -1
  368. package/src/runtime/vendor/flywheel-cli-dist/auth/baseurl.d.ts +0 -35
  369. package/src/runtime/vendor/flywheel-cli-dist/auth/config.d.ts +0 -34
  370. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js +0 -92
  371. package/src/runtime/vendor/flywheel-cli-dist/auth/config.js.map +0 -1
  372. package/src/runtime/vendor/flywheel-cli-dist/auth/fingerprint.d.ts +0 -5
  373. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.d.ts +0 -4
  374. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js +0 -31
  375. package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js.map +0 -1
  376. package/src/runtime/vendor/flywheel-cli-dist/auth/login.d.ts +0 -24
  377. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.d.ts +0 -15
  378. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js +0 -150
  379. package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js.map +0 -1
  380. package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.d.ts +0 -27
  381. package/src/runtime/vendor/flywheel-cli-dist/commands/_admin-auth.d.ts +0 -27
  382. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.d.ts +0 -32
  383. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js +0 -213
  384. package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js.map +0 -1
  385. package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.d.ts +0 -35
  386. package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.d.ts +0 -2
  387. package/src/runtime/vendor/flywheel-cli-dist/commands/_secret-param.d.ts +0 -7
  388. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-file-out.d.ts +0 -39
  389. package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-writer.d.ts +0 -34
  390. package/src/runtime/vendor/flywheel-cli-dist/commands/_wait-polling.d.ts +0 -50
  391. package/src/runtime/vendor/flywheel-cli-dist/commands/account-detach.d.ts +0 -2
  392. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-add.d.ts +0 -2
  393. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-remove.d.ts +0 -2
  394. package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-set-primary.d.ts +0 -2
  395. package/src/runtime/vendor/flywheel-cli-dist/commands/account-get.d.ts +0 -2
  396. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-preview.d.ts +0 -2
  397. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-proof.d.ts +0 -2
  398. package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge.d.ts +0 -2
  399. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-get.d.ts +0 -2
  400. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-set.d.ts +0 -2
  401. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export-stream.d.ts +0 -2
  402. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export.d.ts +0 -2
  403. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-list.d.ts +0 -4
  404. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-nodes-audit-list.d.ts +0 -2
  405. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.d.ts +0 -2
  406. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.d.ts +0 -2
  407. package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.d.ts +0 -2
  408. package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.d.ts +0 -13
  409. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-create.d.ts +0 -2
  410. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-delete.d.ts +0 -2
  411. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-list.d.ts +0 -18
  412. package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-rotate.d.ts +0 -2
  413. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-expire.d.ts +0 -2
  414. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-heartbeat.d.ts +0 -2
  415. package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-list.d.ts +0 -2
  416. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.d.ts +0 -2
  417. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js +0 -22
  418. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js.map +0 -1
  419. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.d.ts +0 -2
  420. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js +0 -8
  421. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js.map +0 -1
  422. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-get.d.ts +0 -2
  423. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-list.d.ts +0 -2
  424. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.d.ts +0 -2
  425. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js +0 -9
  426. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js.map +0 -1
  427. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.d.ts +0 -2
  428. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js +0 -7
  429. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js.map +0 -1
  430. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.d.ts +0 -2
  431. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js +0 -15
  432. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js.map +0 -1
  433. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.d.ts +0 -2
  434. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js +0 -5
  435. package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js.map +0 -1
  436. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.d.ts +0 -2
  437. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js +0 -8
  438. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js.map +0 -1
  439. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.d.ts +0 -2
  440. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js +0 -30
  441. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js.map +0 -1
  442. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.d.ts +0 -2
  443. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-mode.d.ts +0 -4
  444. package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.d.ts +0 -2
  445. package/src/runtime/vendor/flywheel-cli-dist/commands/blobs-get.d.ts +0 -2
  446. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-create.d.ts +0 -2
  447. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-list.d.ts +0 -1
  448. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-revoke.d.ts +0 -1
  449. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-update.d.ts +0 -2
  450. package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-snapshot.d.ts +0 -1
  451. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-acquire.d.ts +0 -2
  452. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-budgets.d.ts +0 -2
  453. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-connection.d.ts +0 -2
  454. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-funding.d.ts +0 -2
  455. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-list.d.ts +0 -2
  456. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-request-approval.d.ts +0 -2
  457. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-options.d.ts +0 -2
  458. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release-all.d.ts +0 -2
  459. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release.d.ts +0 -2
  460. package/src/runtime/vendor/flywheel-cli-dist/commands/compute-status.d.ts +0 -2
  461. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-balance.d.ts +0 -1
  462. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-billing-portal.d.ts +0 -2
  463. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-purchase.d.ts +0 -2
  464. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral-claim.d.ts +0 -2
  465. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral.d.ts +0 -1
  466. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscribe.d.ts +0 -2
  467. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscription.d.ts +0 -1
  468. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-transactions.d.ts +0 -2
  469. package/src/runtime/vendor/flywheel-cli-dist/commands/credits-usage.d.ts +0 -2
  470. package/src/runtime/vendor/flywheel-cli-dist/commands/destructive-confirmation.d.ts +0 -2
  471. package/src/runtime/vendor/flywheel-cli-dist/commands/enums.d.ts +0 -22
  472. package/src/runtime/vendor/flywheel-cli-dist/commands/env.d.ts +0 -8
  473. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-launch.d.ts +0 -2
  474. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-list.d.ts +0 -1
  475. package/src/runtime/vendor/flywheel-cli-dist/commands/executions-terminate.d.ts +0 -2
  476. package/src/runtime/vendor/flywheel-cli-dist/commands/export-history.d.ts +0 -2
  477. package/src/runtime/vendor/flywheel-cli-dist/commands/export-subgraph.d.ts +0 -2
  478. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-pdf.d.ts +0 -2
  479. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-render-pdf.d.ts +0 -2
  480. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-stream.d.ts +0 -2
  481. package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary.d.ts +0 -2
  482. package/src/runtime/vendor/flywheel-cli-dist/commands/feedback-create.d.ts +0 -2
  483. package/src/runtime/vendor/flywheel-cli-dist/commands/files-list.d.ts +0 -2
  484. package/src/runtime/vendor/flywheel-cli-dist/commands/github-disconnect.d.ts +0 -1
  485. package/src/runtime/vendor/flywheel-cli-dist/commands/github-link.d.ts +0 -2
  486. package/src/runtime/vendor/flywheel-cli-dist/commands/github-refresh-repos.d.ts +0 -1
  487. package/src/runtime/vendor/flywheel-cli-dist/commands/github-status.d.ts +0 -1
  488. package/src/runtime/vendor/flywheel-cli-dist/commands/graph-get.d.ts +0 -2
  489. package/src/runtime/vendor/flywheel-cli-dist/commands/handler-factory.d.ts +0 -22
  490. package/src/runtime/vendor/flywheel-cli-dist/commands/help-format.d.ts +0 -31
  491. package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.d.ts +0 -36
  492. package/src/runtime/vendor/flywheel-cli-dist/commands/help.d.ts +0 -17
  493. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-create.d.ts +0 -2
  494. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-delete.d.ts +0 -1
  495. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-list.d.ts +0 -2
  496. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-runs-list.d.ts +0 -2
  497. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-create.d.ts +0 -2
  498. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-delete.d.ts +0 -1
  499. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-list.d.ts +0 -1
  500. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-update.d.ts +0 -2
  501. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-set-enabled.d.ts +0 -2
  502. package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-update.d.ts +0 -2
  503. package/src/runtime/vendor/flywheel-cli-dist/commands/import-subgraph.d.ts +0 -2
  504. package/src/runtime/vendor/flywheel-cli-dist/commands/index.d.ts +0 -23
  505. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-remove.d.ts +0 -1
  506. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-set.d.ts +0 -2
  507. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-status.d.ts +0 -1
  508. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-remove.d.ts +0 -1
  509. package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-set.d.ts +0 -2
  510. package/src/runtime/vendor/flywheel-cli-dist/commands/machines-list.d.ts +0 -1
  511. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.d.ts +0 -2
  512. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js +0 -15
  513. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js.map +0 -1
  514. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.d.ts +0 -2
  515. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js +0 -10
  516. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js.map +0 -1
  517. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.d.ts +0 -2
  518. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js +0 -8
  519. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js.map +0 -1
  520. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.d.ts +0 -2
  521. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js +0 -6
  522. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js.map +0 -1
  523. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.d.ts +0 -2
  524. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js +0 -7
  525. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js.map +0 -1
  526. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.d.ts +0 -2
  527. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js +0 -6
  528. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js.map +0 -1
  529. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.d.ts +0 -2
  530. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js +0 -16
  531. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js.map +0 -1
  532. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.d.ts +0 -2
  533. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js +0 -11
  534. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js.map +0 -1
  535. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-files.d.ts +0 -1
  536. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-get.d.ts +0 -2
  537. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-list.d.ts +0 -2
  538. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.d.ts +0 -2
  539. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js +0 -33
  540. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js.map +0 -1
  541. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.d.ts +0 -2
  542. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js +0 -8
  543. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js.map +0 -1
  544. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.d.ts +0 -2
  545. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js +0 -15
  546. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js.map +0 -1
  547. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-ancestry.d.ts +0 -2
  548. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-summary.d.ts +0 -2
  549. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-tree.d.ts +0 -2
  550. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-resolve-slug.d.ts +0 -2
  551. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-get.d.ts +0 -1
  552. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set-bulk.d.ts +0 -2
  553. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set.d.ts +0 -2
  554. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-summaries.d.ts +0 -2
  555. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-acquire.d.ts +0 -2
  556. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-heartbeat.d.ts +0 -2
  557. package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-release.d.ts +0 -2
  558. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.d.ts +0 -2
  559. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.d.ts +0 -2
  560. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.d.ts +0 -2
  561. package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.d.ts +0 -2
  562. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/account.d.ts +0 -2
  563. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.d.ts +0 -8
  564. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/api-keys.d.ts +0 -2
  565. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/approval.d.ts +0 -2
  566. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.d.ts +0 -2
  567. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js +0 -140
  568. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js.map +0 -1
  569. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.d.ts +0 -2
  570. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/budgets.d.ts +0 -2
  571. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/compute.d.ts +0 -2
  572. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/credits.d.ts +0 -2
  573. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/env.d.ts +0 -2
  574. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/executions.d.ts +0 -2
  575. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/export.d.ts +0 -2
  576. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/github.d.ts +0 -2
  577. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/graph.d.ts +0 -2
  578. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hooks.d.ts +0 -2
  579. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/integrations.d.ts +0 -2
  580. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.d.ts +0 -2
  581. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.d.ts +0 -2
  582. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/resources.d.ts +0 -2
  583. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/sharing.d.ts +0 -2
  584. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.d.ts +0 -2
  585. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js +0 -98
  586. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js.map +0 -1
  587. package/src/runtime/vendor/flywheel-cli-dist/commands/registry/updates.d.ts +0 -2
  588. package/src/runtime/vendor/flywheel-cli-dist/commands/registry.d.ts +0 -27
  589. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-refresh.d.ts +0 -2
  590. package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-resolve.d.ts +0 -2
  591. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.d.ts +0 -2
  592. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js +0 -25
  593. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js.map +0 -1
  594. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.d.ts +0 -2
  595. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js +0 -25
  596. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js.map +0 -1
  597. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.d.ts +0 -2
  598. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js +0 -11
  599. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js.map +0 -1
  600. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.d.ts +0 -2
  601. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js +0 -28
  602. package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js.map +0 -1
  603. package/src/runtime/vendor/flywheel-cli-dist/commands/types.d.ts +0 -30
  604. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide-all-active.d.ts +0 -1
  605. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide.d.ts +0 -2
  606. package/src/runtime/vendor/flywheel-cli-dist/commands/updates-list.d.ts +0 -2
  607. package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.d.ts +0 -6
  608. package/src/runtime/vendor/flywheel-cli-dist/commands/utils.d.ts +0 -11
  609. package/src/runtime/vendor/flywheel-cli-dist/errors.d.ts +0 -86
  610. package/src/runtime/vendor/flywheel-cli-dist/exit-codes.d.ts +0 -8
  611. package/src/runtime/vendor/flywheel-cli-dist/generatedFeedbackContract.d.ts +0 -41
  612. package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.d.ts +0 -13
  613. package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.d.ts +0 -26
  614. package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.d.ts +0 -17
  615. package/src/runtime/vendor/flywheel-cli-dist/http/client.d.ts +0 -91
  616. package/src/runtime/vendor/flywheel-cli-dist/http/debug.d.ts +0 -5
  617. package/src/runtime/vendor/flywheel-cli-dist/http/poll.d.ts +0 -18
  618. package/src/runtime/vendor/flywheel-cli-dist/http/retry.d.ts +0 -30
  619. package/src/runtime/vendor/flywheel-cli-dist/main.d.ts +0 -33
  620. package/src/runtime/vendor/flywheel-cli-dist/output/format.d.ts +0 -9
  621. package/src/runtime/vendor/flywheel-cli-dist/runtime-entry.d.ts +0 -1
  622. package/src/runtime/vendor/flywheel-cli-dist/version.d.ts +0 -3
  623. package/src/secure-write.mjs +0 -43
@@ -1,27 +1,37 @@
1
1
  #!/usr/bin/env node
2
- import { randomUUID } from 'node:crypto';
3
- import { access, writeFile } from 'node:fs/promises';
4
- import os from 'node:os';
5
- import { resolve } from 'node:path';
6
- import { pathToFileURL } from 'node:url';
7
- import { loadAuthConfig, DEFAULT_BASE_URL, resolveConfigPath, saveAuthConfig, } from './auth/config.js';
8
- import { baseUrlsEqual } from './auth/baseurl.js';
9
- import { getKey } from './auth/keychain.js';
10
- import { loadProfile } from './auth/profile.js';
11
- import { RUNTIME_ALIASES } from './commands/aliases.js';
12
- import { BUILTIN_PROFILE_NAMES, isBuiltinProfileName, resolveBuiltinBaseUrl, } from './auth/profiles.js';
13
- import { renderCommandHelp, renderCommandHelpAsJson, renderHelp, renderHelpAsJson, } from './commands/help.js';
14
- import { renderUsageSpec } from './commands/usage-spec.js';
15
- import { getCommandByName } from './commands/registry.js';
16
- import { MVP_COMMAND_HANDLERS } from './commands/index.js';
17
- import { CliApprovalPendingError, CliAuthRequirementError, CliFinalizeFailedError, CliUsageError, CliWaitTimeoutError, } from './errors.js';
18
- import { EXIT_TRANSPORT, EXIT_USAGE } from './exit-codes.js';
19
- import { extractGlobals, GLOBAL_FLAG_NAMES } from './grammar/globals.js';
20
- import { parseCliArgs } from './grammar/parse.js';
21
- import { CliHttpError, createHttpClient, } from './http/client.js';
22
- import { maskSensitiveForOutput } from './http/debug.js';
23
- import { renderOutput } from './output/format.js';
24
- import { CLI_VERSION } from './version.js';
2
+ import { randomUUID } from "node:crypto";
3
+ import { access, writeFile } from "node:fs/promises";
4
+ import os from "node:os";
5
+ import { resolve } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ import { processStdoutIsPipe, writeCredentialStream } from "./credential-output.js";
8
+ import { loadFlywheelConfig, saveFlywheelConfig, FlywheelConfigError, resolveFlywheelConfigPath, } from "./config/index.js";
9
+ import { baseUrlsEqual } from "./auth/baseurl.js";
10
+ import { CredentialStoreError, readCredential, resolveCredentialFilePath, } from "./auth/credentials.js";
11
+ import { RUNTIME_ALIASES } from "./commands/aliases.js";
12
+ import { BUILTIN_PROFILE_NAMES, isBuiltinProfileName, resolveBuiltinBaseUrl, } from "./auth/profiles.js";
13
+ import { renderCommandHelp, renderCommandHelpAsJson, renderHelp, renderHelpAsJson, } from "./commands/help.js";
14
+ import { renderUsageSpec } from "./commands/usage-spec.js";
15
+ import { getCommandByName } from "./commands/registry.js";
16
+ import { MVP_COMMAND_HANDLERS } from "./commands/index.js";
17
+ import { repositoryLocalOperationNames } from "./commands/repository-operation.js";
18
+ import { repositoryProjectionNames } from "./commands/repository-projection.js";
19
+ import { repositoryEditNames } from "./commands/repository-edit.js";
20
+ import { hostedGraphMutationNames } from "./commands/hosted-graph.js";
21
+ import { NODE_CREATE_SCHEMA } from "./commands/node-create-schema.js";
22
+ import { RETIRED_COMMAND_NAMES } from "./commands/retired-command-names.js";
23
+ import { renderRepositoryHumanOutput } from "./commands/repository-output.js";
24
+ import { RepositorySelectionError, resolveRepositorySelection, shellQuote, } from "./commands/repository-selection.js";
25
+ import { CliApprovalPendingError, CliAuthRequirementError, CliUsageError, CliWaitTimeoutError, } from "./errors.js";
26
+ import { EXIT_TRANSPORT, EXIT_USAGE } from "./exit-codes.js";
27
+ import { extractGlobals, GLOBAL_BOOLEAN_FLAG_NAMES, GLOBAL_FLAG_NAMES } from "./grammar/globals.js";
28
+ import { parseCliArgs } from "./grammar/parse.js";
29
+ import { CliHttpError, createHttpClient, } from "./http/client.js";
30
+ import { maskSensitiveForOutput } from "./http/debug.js";
31
+ import { renderOutput } from "./output/format.js";
32
+ import { CLI_VERSION } from "./version.js";
33
+ import { LocalRepositoryAdapter } from "./local/adapter.js";
34
+ const DEFAULT_BASE_URL = "http://localhost:8000";
25
35
  function defaultStdout(chunk) {
26
36
  process.stdout.write(chunk);
27
37
  }
@@ -29,140 +39,132 @@ function defaultStderr(chunk) {
29
39
  process.stderr.write(chunk);
30
40
  }
31
41
  function writeLine(writer, text) {
32
- if (text.endsWith('\n')) {
42
+ if (text.endsWith("\n")) {
33
43
  writer(text);
34
44
  return;
35
45
  }
36
46
  writer(`${text}\n`);
37
47
  }
38
- /**
39
- * Derive the active built-in profile state from the already-loaded
40
- * AuthConfig. Reading from `config` (instead of re-reading the file at
41
- * `configPath`) keeps the injectable `loadConfig` dependency
42
- * authoritative tests and programmatic embedders that hand the CLI an
43
- * in-memory config must not be silently overridden by stale on-disk
44
- * state.
45
- */
48
+ function requestsJsonOutput(argv) {
49
+ return argv.some((token, index) => token === "--format=json" ||
50
+ (token === "--format" && argv[index + 1] === "json"));
51
+ }
52
+ function emitRetiredCommandName(command, argv, stderr) {
53
+ const remediation = RETIRED_COMMAND_NAMES[command];
54
+ if (!remediation)
55
+ return undefined;
56
+ const message = `${command} is retired. Use: ${remediation}`;
57
+ if (requestsJsonOutput(argv)) {
58
+ writeLine(stderr, JSON.stringify({
59
+ error: {
60
+ code: "retired_command_name",
61
+ message,
62
+ remediation,
63
+ exit_code: 1,
64
+ },
65
+ }));
66
+ }
67
+ else {
68
+ writeLine(stderr, message);
69
+ }
70
+ return 1;
71
+ }
46
72
  function activeBuiltinFromConfig(config) {
47
- const empty = {
48
- name: undefined,
49
- baseUrl: undefined,
50
- apiKey: undefined,
51
- };
52
73
  const rawName = config.activeProfile;
53
- if (typeof rawName !== 'string' || !rawName.trim())
54
- return empty;
74
+ if (typeof rawName !== "string" ||
75
+ !rawName.trim() ||
76
+ !isBuiltinProfileName(rawName.trim())) {
77
+ return { name: undefined, baseUrl: undefined };
78
+ }
55
79
  const name = rawName.trim();
56
- if (!isBuiltinProfileName(name))
57
- return empty;
58
- const baseUrl = resolveBuiltinBaseUrl(name);
59
- const bucket = config.profileKeys?.[name];
60
- const candidate = bucket?.apiKey;
61
- const apiKey = typeof candidate === 'string' && candidate.trim() ? candidate : undefined;
62
- return { name, baseUrl, apiKey };
80
+ return { name, baseUrl: resolveBuiltinBaseUrl(name) };
81
+ }
82
+ function assertRepositoryTransportOrigin(baseUrl) {
83
+ let parsed;
84
+ try {
85
+ parsed = new URL(baseUrl);
86
+ }
87
+ catch {
88
+ throw new CliHttpError("repository remotes require HTTPS or loopback HTTP", EXIT_TRANSPORT);
89
+ }
90
+ const loopbackHttp = parsed.protocol === "http:" &&
91
+ ["localhost", "127.0.0.1", "[::1]", "::1"].includes(parsed.hostname.toLowerCase());
92
+ if (parsed.protocol === "https:" || loopbackHttp)
93
+ return;
94
+ throw new CliHttpError("repository remotes require HTTPS or loopback HTTP", EXIT_TRANSPORT);
63
95
  }
64
- async function resolveRuntimeAuthConfig(config, profile, resolveEnvApiKey) {
96
+ async function resolveRuntimeAuthConfig(config, profile, resolveEnvApiKey, resolveCredentialFile, credentialLookupEnabled, readStoredCredential, repositoryRemote = false) {
65
97
  const envBaseUrl = process.env.FLYWHEEL_BASE_URL?.trim();
66
- // Resolution order:
67
- // FLYWHEEL_BASE_URL → --env=<name>'s profile.baseUrl → active built-in
68
- // profile pointer in config.activeProfile → legacy config.baseUrl →
69
- // DEFAULT_BASE_URL. Built-in baseUrls are ephemeral constants — they are
70
- // never written into config.baseUrl, so upstream URL changes flow through
71
- // automatically.
72
98
  const activeBuiltin = activeBuiltinFromConfig(config);
73
- const baseUrl = envBaseUrl ||
74
- profile?.baseUrl ||
75
- activeBuiltin.baseUrl ||
76
- config.baseUrl ||
77
- DEFAULT_BASE_URL;
78
- let apiKey = process.env.FLYWHEEL_API_KEY?.trim() || undefined;
79
- // Token-scoping guard: a profile's `api_key_env` / `api_key_keychain`
80
- // credentials are minted for the profile's declared baseUrl. If the
81
- // resolved baseUrl has since moved off that origin (typically via
82
- // FLYWHEEL_BASE_URL override), the profile's credential must NOT ride
83
- // along to a different host — that would leak the token across
84
- // environments. Every other credential source in this resolver is
85
- // already baseUrl-scoped; these two sources were the last hole.
86
- const profileBindsToResolvedBaseUrl = profile !== null &&
87
- profile.baseUrl !== undefined &&
88
- baseUrlsEqual(baseUrl, profile.baseUrl);
89
- if (!apiKey && profile?.apiKeyEnv && profileBindsToResolvedBaseUrl) {
99
+ const activeProfile = typeof config.activeProfile === "string" && config.activeProfile.trim()
100
+ ? config.activeProfile.trim()
101
+ : undefined;
102
+ const baseUrl = envBaseUrl || profile?.baseUrl || activeBuiltin.baseUrl || DEFAULT_BASE_URL;
103
+ if (repositoryRemote)
104
+ assertRepositoryTransportOrigin(baseUrl);
105
+ const credentialProfile = profile?.name ?? activeBuiltin.name ?? activeProfile ?? "default";
106
+ const credentialBaseUrl = profile?.baseUrl ?? activeBuiltin.baseUrl ??
107
+ (credentialProfile === "default" ? baseUrl : DEFAULT_BASE_URL);
108
+ const environmentApiKey = process.env.FLYWHEEL_API_KEY?.trim() || undefined;
109
+ if (repositoryRemote &&
110
+ environmentApiKey &&
111
+ (!envBaseUrl || !baseUrlsEqual(baseUrl, envBaseUrl))) {
112
+ throw new CliHttpError("credential_store_unavailable", EXIT_TRANSPORT);
113
+ }
114
+ let apiKey = environmentApiKey;
115
+ if (!apiKey &&
116
+ profile?.apiKeyEnv &&
117
+ profile.baseUrl &&
118
+ baseUrlsEqual(baseUrl, profile.baseUrl)) {
90
119
  apiKey = resolveEnvApiKey(profile.apiKeyEnv);
91
120
  }
92
- if (!apiKey && profile?.apiKeyKeychain && profileBindsToResolvedBaseUrl) {
93
- const stored = await getKey('flywheel-cli', profile.name);
94
- if (stored) {
95
- apiKey = stored;
96
- }
121
+ let credentialReadiness;
122
+ if (apiKey || !credentialLookupEnabled) {
123
+ credentialReadiness = "not_checked";
97
124
  }
98
- // `--env=<builtin>` selects a built-in profile for this invocation.
99
- // Pull its stored apiKey from `config.profileKeys[name]` so the
100
- // one-shot override gets the same auth a persisted `env switch` would.
101
- // Tied to the built-in's baseUrl so a manual baseUrl override (e.g.
102
- // FLYWHEEL_BASE_URL) doesn't carry the per-profile token to a
103
- // different origin.
104
- if (!apiKey &&
105
- profile !== null &&
106
- isBuiltinProfileName(profile.name) &&
107
- baseUrlsEqual(baseUrl, resolveBuiltinBaseUrl(profile.name))) {
108
- const candidate = config.profileKeys?.[profile.name]?.apiKey;
109
- if (typeof candidate === 'string' && candidate.trim()) {
110
- apiKey = candidate;
111
- }
125
+ else if (baseUrlsEqual(baseUrl, credentialBaseUrl)) {
126
+ const storedCredential = await readStoredCredential(credentialProfile, credentialBaseUrl, resolveCredentialFile());
127
+ credentialReadiness = storedCredential ? "ready" : "missing";
128
+ apiKey = storedCredential ?? undefined;
112
129
  }
113
- // Prefer the per-profile apiKey stored by `auth:login` while a built-in
114
- // profile is active — but only when the resolved baseUrl is still that
115
- // built-in's origin. A `FLYWHEEL_BASE_URL` override or `--env=<legacy>`
116
- // flag moves the request to a different host; attaching the stored
117
- // prod/staging bearer there would leak credentials across environments.
118
- // The legacy flat `config.apiKey` is intentionally left unset under
119
- // active-profile logins (so the built-in baseUrl never bleeds into
120
- // config.json); consult it only when no per-profile key is present.
121
- if (!apiKey &&
122
- activeBuiltin.apiKey &&
123
- baseUrlsEqual(baseUrl, activeBuiltin.baseUrl)) {
124
- apiKey = activeBuiltin.apiKey;
125
- }
126
- // The legacy `config.apiKey` belongs to `config.baseUrl` and only to
127
- // that origin. Every path that resolves `baseUrl` to anything else
128
- // (built-in profile pointer, `--env=<legacy-profile>`, or
129
- // `FLYWHEEL_BASE_URL` override) must NOT have the legacy key ride
130
- // along: that single stored key would otherwise leak across any target
131
- // origin the user points the CLI at.
132
- // Canonical equality so `FLYWHEEL_BASE_URL=<config.baseUrl>/` (and
133
- // other RFC 3986 §6.2.2-equivalent variants) still binds the legacy
134
- // flat key to its origin instead of being treated as an unrelated
135
- // host. See `auth/baseurl.ts` for the normalisation rules.
136
- if (!apiKey && baseUrlsEqual(config.baseUrl, baseUrl)) {
137
- apiKey = config.apiKey ?? undefined;
130
+ else {
131
+ credentialReadiness = "not_checked";
132
+ }
133
+ if (repositoryRemote && !apiKey) {
134
+ throw new CliHttpError("credential_store_unavailable", EXIT_TRANSPORT);
138
135
  }
139
136
  return {
140
137
  baseUrl,
138
+ credentialBaseUrl: environmentApiKey
139
+ ? baseUrl
140
+ : credentialBaseUrl,
141
141
  apiKey,
142
+ credentialReadiness,
142
143
  defaultFormat: profile?.defaultFormat,
143
144
  };
144
145
  }
145
- const HELP_TOKENS = new Set(['--help', '-h']);
146
- const USAGE_TOKENS = new Set(['--usage', '--usage-spec']);
147
- const SCHEMA_TOKEN = '--schema';
148
- const HELP_EXTRAS_PREFIX = '--_help_extras=';
149
- const USAGE_EXTRAS_PREFIX = '--_usage_extras=';
150
- const USAGE_VERSION_PREFIX = '--_usage_version=';
146
+ const HELP_TOKENS = new Set(["--help", "-h"]);
147
+ const USAGE_TOKENS = new Set(["--usage", "--usage-spec"]);
148
+ const SCHEMA_TOKEN = "--schema";
149
+ const HELP_EXTRAS_PREFIX = "--_help_extras=";
150
+ const USAGE_EXTRAS_PREFIX = "--_usage_extras=";
151
+ const USAGE_VERSION_PREFIX = "--_usage_version=";
151
152
  const VALID_TOPIC_IDS = new Set([
152
- 'setup-admin',
153
- 'auth',
154
- 'profile',
155
- 'nodes-graph',
156
- 'artifacts-files',
157
- 'hooks',
158
- 'compute-executions',
159
- 'approvals-budgets',
160
- 'export-import',
161
- 'updates-resources',
162
- 'account-credits',
163
- 'integrations',
164
- 'api-keys',
165
- 'admin',
153
+ "setup-admin",
154
+ "auth",
155
+ "profile",
156
+ "nodes-graph",
157
+ "repo-workflow",
158
+ "hosted-graph",
159
+ "hooks",
160
+ "compute-executions",
161
+ "approvals-budgets",
162
+ "export-import",
163
+ "updates-resources",
164
+ "account-credits",
165
+ "integrations",
166
+ "api-keys",
167
+ "admin",
166
168
  ]);
167
169
  function parseHelpExtras(argv) {
168
170
  let raw;
@@ -173,79 +175,83 @@ function parseHelpExtras(argv) {
173
175
  }
174
176
  }
175
177
  if (raw === undefined)
176
- return { kind: 'absent' };
178
+ return { kind: "absent" };
177
179
  let decoded;
178
180
  try {
179
181
  decoded = JSON.parse(raw);
180
182
  }
181
183
  catch {
182
- return { kind: 'invalid' };
184
+ return { kind: "invalid" };
183
185
  }
184
186
  if (!Array.isArray(decoded))
185
- return { kind: 'invalid' };
187
+ return { kind: "invalid" };
186
188
  const extras = [];
187
189
  for (const entry of decoded) {
188
190
  if (!entry ||
189
- typeof entry !== 'object' ||
190
- typeof entry.group !== 'string' ||
191
- typeof entry.name !== 'string' ||
192
- typeof entry.summary !== 'string') {
193
- return { kind: 'invalid' };
191
+ typeof entry !== "object" ||
192
+ typeof entry.group !== "string" ||
193
+ typeof entry.name !== "string" ||
194
+ typeof entry.summary !== "string") {
195
+ return { kind: "invalid" };
194
196
  }
195
197
  const group = entry.group;
196
198
  if (!VALID_TOPIC_IDS.has(group))
197
- return { kind: 'invalid' };
199
+ return { kind: "invalid" };
198
200
  extras.push({
199
201
  group,
200
202
  name: entry.name,
201
203
  summary: entry.summary,
202
204
  });
203
205
  }
204
- return { kind: 'ok', extras };
206
+ return { kind: "ok", extras };
205
207
  }
206
208
  function stripHelpExtras(argv) {
207
209
  return argv.filter((t) => !t.startsWith(HELP_EXTRAS_PREFIX));
208
210
  }
209
211
  function isStringArray(value) {
210
- return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
212
+ return (Array.isArray(value) && value.every((entry) => typeof entry === "string"));
211
213
  }
212
214
  function isCommandParamArray(value) {
213
215
  return (Array.isArray(value) &&
214
216
  value.every((entry) => {
215
- if (!entry || typeof entry !== 'object')
217
+ if (!entry || typeof entry !== "object")
216
218
  return false;
217
219
  const candidate = entry;
218
- return (typeof candidate.name === 'string' &&
219
- ['string', 'integer', 'json', 'boolean'].includes(String(candidate.type)) &&
220
- typeof candidate.description === 'string' &&
221
- (candidate.default === undefined || typeof candidate.default === 'string'));
220
+ return (typeof candidate.name === "string" &&
221
+ ["string", "integer", "json", "boolean"].includes(String(candidate.type)) &&
222
+ typeof candidate.description === "string" &&
223
+ (candidate.default === undefined ||
224
+ typeof candidate.default === "string"));
222
225
  }));
223
226
  }
224
227
  function isCommandExampleArray(value) {
225
228
  return (Array.isArray(value) &&
226
229
  value.every((entry) => {
227
- if (!entry || typeof entry !== 'object')
230
+ if (!entry || typeof entry !== "object")
228
231
  return false;
229
232
  const candidate = entry;
230
- return (typeof candidate.description === 'string' &&
231
- typeof candidate.invocation === 'string');
233
+ return (typeof candidate.description === "string" &&
234
+ typeof candidate.invocation === "string");
232
235
  }));
233
236
  }
234
237
  function isUsageExtra(value) {
235
- if (!value || typeof value !== 'object')
238
+ if (!value || typeof value !== "object")
236
239
  return false;
237
240
  const candidate = value;
238
- return (typeof candidate.name === 'string' &&
239
- typeof candidate.group === 'string' &&
241
+ return (typeof candidate.name === "string" &&
242
+ typeof candidate.group === "string" &&
240
243
  VALID_TOPIC_IDS.has(candidate.group) &&
241
- typeof candidate.summary === 'string' &&
244
+ typeof candidate.summary === "string" &&
242
245
  (candidate.endpoints === undefined || isStringArray(candidate.endpoints)) &&
243
- (candidate.required === undefined || isCommandParamArray(candidate.required)) &&
244
- (candidate.optional === undefined || isCommandParamArray(candidate.optional)) &&
245
- (candidate.examples === undefined || isCommandExampleArray(candidate.examples)) &&
246
+ (candidate.required === undefined ||
247
+ isCommandParamArray(candidate.required)) &&
248
+ (candidate.optional === undefined ||
249
+ isCommandParamArray(candidate.optional)) &&
250
+ (candidate.examples === undefined ||
251
+ isCommandExampleArray(candidate.examples)) &&
246
252
  (candidate.related === undefined || isStringArray(candidate.related)) &&
247
- (candidate.schema === undefined || typeof candidate.schema === 'string') &&
248
- (candidate.hidden === undefined || typeof candidate.hidden === 'boolean'));
253
+ (candidate.schema === undefined || typeof candidate.schema === "string") &&
254
+ (candidate.hidden === undefined || typeof candidate.hidden === "boolean"));
249
255
  }
250
256
  function parseUsageExtras(argv) {
251
257
  const rawValues = argv
@@ -255,15 +261,15 @@ function parseUsageExtras(argv) {
255
261
  .filter((token) => token.startsWith(USAGE_VERSION_PREFIX))
256
262
  .map((token) => token.slice(USAGE_VERSION_PREFIX.length));
257
263
  if (rawValues.length === 0 && rawVersionValues.length === 0) {
258
- return { kind: 'ok', extras: [] };
264
+ return { kind: "ok", extras: [] };
259
265
  }
260
266
  if (rawValues.length > 1)
261
- return { kind: 'invalid' };
267
+ return { kind: "invalid" };
262
268
  if (rawVersionValues.length > 1)
263
- return { kind: 'invalid' };
269
+ return { kind: "invalid" };
264
270
  const version = rawVersionValues[0];
265
- if (version !== undefined && version.trim() === '')
266
- return { kind: 'invalid' };
271
+ if (version !== undefined && version.trim() === "")
272
+ return { kind: "invalid" };
267
273
  let extras = [];
268
274
  if (rawValues.length === 1) {
269
275
  let decoded;
@@ -271,45 +277,60 @@ function parseUsageExtras(argv) {
271
277
  decoded = JSON.parse(rawValues[0]);
272
278
  }
273
279
  catch {
274
- return { kind: 'invalid' };
280
+ return { kind: "invalid" };
275
281
  }
276
282
  if (!Array.isArray(decoded) || !decoded.every(isUsageExtra)) {
277
- return { kind: 'invalid' };
283
+ return { kind: "invalid" };
278
284
  }
279
285
  extras = decoded;
280
286
  }
281
- return { kind: 'ok', extras, version };
287
+ return { kind: "ok", extras, version };
282
288
  }
283
- // Commands that do not touch the HTTP runtime and therefore must run even
284
- // when ~/.config/flywheel-cli/config.json is absent. These are purely local
285
- // state operations (profile bookkeeping, keychain reads/writes) plus the
286
- // bootstrap auth:login flow, so gating them on runtime config would break the
287
- // exact recovery paths a user needs when the config is missing.
288
- const RUNTIME_CONFIG_OPTIONAL_COMMANDS = new Set([
289
- 'profile:list',
290
- 'profile:show',
291
- 'profile:set',
292
- 'profile:unset',
293
- 'auth:login',
294
- 'auth:keychain:set',
295
- 'auth:keychain:clear',
296
- 'env:list',
297
- 'env:switch',
298
- ]);
289
+ const LOCAL_REPOSITORY_REMOTE_COMMANDS = [
290
+ "repo:clone",
291
+ "repo:pull",
292
+ "repo:push",
293
+ "repo:purge",
294
+ ];
295
+ const LOCAL_REPOSITORY_OFFLINE_COMMANDS = [
296
+ ...repositoryLocalOperationNames.filter((command) => !LOCAL_REPOSITORY_REMOTE_COMMANDS.includes(command)),
297
+ ...repositoryProjectionNames,
298
+ ...repositoryEditNames,
299
+ ];
300
+ // Offline repository commands do not need credential resolution. Remote
301
+ // repository operations use the ordinary CLI HTTP client as their auth boundary.
302
+ const CREDENTIAL_LOOKUP_SKIPPED_COMMANDS = [
303
+ "profile:list",
304
+ "profile:show",
305
+ "profile:set",
306
+ "profile:unset",
307
+ "auth:login",
308
+ "auth:credentials:set",
309
+ "auth:credentials:clear",
310
+ "env:list",
311
+ "env:switch",
312
+ ...LOCAL_REPOSITORY_OFFLINE_COMMANDS,
313
+ ];
314
+ // Commands that can recover or inspect configuration without requiring the
315
+ // runtime config file. auth:status still resolves the selected credential.
316
+ const RUNTIME_CONFIG_OPTIONAL_COMMANDS = [
317
+ ...CREDENTIAL_LOOKUP_SKIPPED_COMMANDS,
318
+ "auth:status",
319
+ ];
299
320
  const API_KEY_BOUND_BROWSER_AND_INTEGRATION_COMMANDS = new Set([
300
- 'credits:purchase',
301
- 'credits:subscribe',
302
- 'credits:billing-portal',
303
- 'github:link',
304
- 'github:refresh-repos',
305
- 'github:disconnect',
306
- 'integrations:wandb:set',
307
- 'integrations:wandb:remove',
308
- 'integrations:huggingface:set',
309
- 'integrations:huggingface:remove',
321
+ "credits:purchase",
322
+ "credits:subscribe",
323
+ "credits:billing-portal",
324
+ "github:link",
325
+ "github:refresh-repos",
326
+ "github:disconnect",
327
+ "integrations:wandb:set",
328
+ "integrations:wandb:remove",
329
+ "integrations:huggingface:set",
330
+ "integrations:huggingface:remove",
310
331
  ]);
311
- const RAW_API_KEY_ALLOWLIST_DETAIL = 'API key authentication is not allowed on this endpoint';
312
- const CLI_API_KEY_BOUND_ALLOWLIST_DETAIL = 'API-key access is unavailable for this command. Update the server API-key route allowlist for this endpoint.';
332
+ const RAW_API_KEY_ALLOWLIST_DETAIL = "API key authentication is not allowed on this endpoint";
333
+ const CLI_API_KEY_BOUND_ALLOWLIST_DETAIL = "API-key access is unavailable for this command. Update the server API-key route allowlist for this endpoint.";
313
334
  function isHelpToken(token) {
314
335
  return HELP_TOKENS.has(token);
315
336
  }
@@ -327,7 +348,7 @@ function rewriteAlias(argv) {
327
348
  if (argv.length === 0)
328
349
  return argv;
329
350
  const head = argv[0];
330
- if (head === 'help' || head === '--help' || head === '-h')
351
+ if (head === "help" || head === "--help" || head === "-h")
331
352
  return argv;
332
353
  if (!Object.prototype.hasOwnProperty.call(RUNTIME_ALIASES, head))
333
354
  return argv;
@@ -335,24 +356,24 @@ function rewriteAlias(argv) {
335
356
  return [canonical, ...argv.slice(1)];
336
357
  }
337
358
  function parseHelpFormat(argv) {
338
- let result = { kind: 'absent' };
359
+ let result = { kind: "absent" };
339
360
  for (let i = 0; i < argv.length; i += 1) {
340
361
  const token = argv[i];
341
362
  let value;
342
- if (token.startsWith('--format=')) {
343
- value = token.slice('--format='.length);
363
+ if (token.startsWith("--format=")) {
364
+ value = token.slice("--format=".length);
344
365
  }
345
- else if (token === '--format') {
366
+ else if (token === "--format") {
346
367
  value = argv[i + 1];
347
368
  }
348
369
  else {
349
370
  continue;
350
371
  }
351
- if (value === 'json') {
352
- result = { kind: 'json' };
372
+ if (value === "json") {
373
+ result = { kind: "json" };
353
374
  }
354
375
  else {
355
- return { kind: 'invalid', value: value ?? '' };
376
+ return { kind: "invalid", value: value ?? "" };
356
377
  }
357
378
  }
358
379
  return result;
@@ -368,9 +389,9 @@ function stripFormatTokens(argv) {
368
389
  const out = [];
369
390
  for (let i = 0; i < argv.length; i += 1) {
370
391
  const token = argv[i];
371
- if (token.startsWith('--format='))
392
+ if (token.startsWith("--format="))
372
393
  continue;
373
- if (token === '--format') {
394
+ if (token === "--format") {
374
395
  i += 1; // skip the value
375
396
  continue;
376
397
  }
@@ -387,7 +408,7 @@ function normalizeCommandHelpArgs(argv) {
387
408
  schema = true;
388
409
  continue;
389
410
  }
390
- if (token === '--aliases' || token === '-a') {
411
+ if (token === "--aliases" || token === "-a") {
391
412
  aliases = true;
392
413
  continue;
393
414
  }
@@ -398,7 +419,7 @@ function normalizeCommandHelpArgs(argv) {
398
419
  function renderAliasesHelp() {
399
420
  return `${Object.entries(RUNTIME_ALIASES)
400
421
  .map(([aliasCommand, canonicalCommand]) => ` ${aliasCommand} → ${canonicalCommand}`)
401
- .join('\n')}\n`;
422
+ .join("\n")}\n`;
402
423
  }
403
424
  function emitCommandHelp(stdout, stderr, commandName, schema, asJson) {
404
425
  if (asJson) {
@@ -412,7 +433,7 @@ function emitCommandHelp(stdout, stderr, commandName, schema, asJson) {
412
433
  return 0;
413
434
  }
414
435
  const helpText = renderCommandHelp(commandName, { schema });
415
- if (helpText.startsWith('unknown command:')) {
436
+ if (helpText.startsWith("unknown command:")) {
416
437
  writeLine(stderr, helpText.trim());
417
438
  return 1;
418
439
  }
@@ -426,91 +447,95 @@ function buildMissingParamHint(commandName, message) {
426
447
  }
427
448
  const lines = [message];
428
449
  if (command.required.length > 0) {
429
- lines.push('Required:');
450
+ lines.push("Required:");
430
451
  for (const param of command.required) {
431
- const typeHint = param.type === 'boolean' ? '' : ` <${param.type}>`;
452
+ const typeHint = param.type === "boolean" ? "" : ` <${param.type}>`;
432
453
  lines.push(` --${param.name}${typeHint} ${param.description}`);
433
454
  }
434
455
  }
435
456
  if (command.examples.length > 0) {
436
- lines.push('Example:');
457
+ lines.push("Example:");
437
458
  lines.push(` ${command.examples[0].invocation}`);
438
459
  }
439
- return lines.join('\n');
460
+ return lines.join("\n");
461
+ }
462
+ function bindCommandPositionals(commandName, positionals, params) {
463
+ const command = getCommandByName(commandName);
464
+ const definitions = command?.positionals ?? [];
465
+ for (const [index, definition] of definitions.entries()) {
466
+ const value = positionals[index];
467
+ if (value === undefined) {
468
+ if (command?.required.some((param) => param.name === definition.name)) {
469
+ throw new CliUsageError(`missing positional argument: ${definition.name}`);
470
+ }
471
+ continue;
472
+ }
473
+ if (params[definition.name] !== undefined) {
474
+ throw new CliUsageError(`duplicate argument: ${definition.name}`);
475
+ }
476
+ params[definition.name] = value;
477
+ }
440
478
  }
441
479
  function validateCommandSpecificFlags(commandName, params) {
442
480
  const command = getCommandByName(commandName);
443
481
  if (!command) {
444
482
  return;
445
483
  }
446
- const allowed = new Set([
447
- ...command.required.map((param) => param.name),
448
- ...command.optional.map((param) => param.name),
449
- ]);
484
+ const positionals = new Set((command.positionals ?? []).map((param) => param.name));
485
+ const allowed = new Map([...command.required, ...command.optional]
486
+ .filter((param) => !positionals.has(param.name))
487
+ .map((param) => [param.name, param]));
450
488
  for (const flagName of Object.keys(params)) {
451
489
  if (GLOBAL_FLAG_NAMES.has(flagName)) {
452
490
  continue;
453
491
  }
454
- if (!allowed.has(flagName)) {
492
+ const definition = allowed.get(flagName);
493
+ if (!definition) {
455
494
  throw new CliUsageError(`unknown flag for ${commandName}: --${flagName}`);
456
495
  }
496
+ if (definition.type !== "boolean" && typeof params[flagName] !== "string") {
497
+ throw new CliUsageError(`missing value for --${flagName}`);
498
+ }
457
499
  }
458
500
  }
459
- function buildCommitSchemaHint(commandName, message) {
460
- const command = getCommandByName(commandName);
461
- if (!command?.schema) {
462
- return message;
463
- }
464
- const lines = [message];
465
- lines.push(`hint: payload rejected by server. Run \`flywheel help ${commandName} --schema\` to see the required JSON shape.`);
466
- lines.push('Required payload keys (see schema for full shape):');
467
- const keyMatches = command.schema.match(/^\s*"([^"]+)"\s*:/gm) ?? [];
468
- const topLevelKeys = Array.from(new Set(keyMatches
469
- .map((line) => line.match(/"([^"]+)"/)?.[1])
470
- .filter((key) => Boolean(key)))).slice(0, 6);
471
- for (const key of topLevelKeys) {
472
- lines.push(` ${key}`);
473
- }
474
- return lines.join('\n');
475
- }
476
501
  function buildLocalhostTransportHint(message, baseUrl) {
477
- if (!message.includes('transport error')) {
502
+ if (!message.includes("transport error")) {
478
503
  return message;
479
504
  }
480
- const normalizedBase = baseUrl.replace(/\/+$/, '');
481
- if (normalizedBase !== DEFAULT_BASE_URL.replace(/\/+$/, '')) {
505
+ const normalizedBase = baseUrl.replace(/\/+$/, "");
506
+ if (normalizedBase !== DEFAULT_BASE_URL.replace(/\/+$/, "")) {
482
507
  return message;
483
508
  }
484
509
  const lines = [message];
485
510
  lines.push(`hint: runtime is pointing at the default localhost fallback (${DEFAULT_BASE_URL}).`);
486
- // Only --mode cli provisions ~/.config/flywheel-cli/config.json; --mode mcp
511
+ // Only --mode cli provisions ~/.config/flywheel/config.toml; --mode mcp
487
512
  // writes host MCP entries and cannot fix a stale runtime base URL, so do not
488
513
  // offer it as an alternative here.
489
- lines.push(' Run `npx --yes @paradigma-inc/flywheel setup --mode cli` to configure Flywheel.');
490
- return lines.join('\n');
514
+ lines.push(" Run `npx --yes @paradigma-inc/flywheel setup --mode cli` to configure Flywheel.");
515
+ return lines.join("\n");
491
516
  }
492
517
  function looksLikeNodeSlug(value) {
493
518
  return /^[a-z][a-z0-9]*-[a-z][a-z0-9]*-\d{4}$/.test(value);
494
519
  }
495
520
  function buildNodeSlugMissHint(args) {
496
521
  const { commandName, status, params, message } = args;
497
- if (commandName !== 'nodes:get' || status !== 404) {
522
+ if (commandName !== "hosted:node:get" || status !== 404) {
498
523
  return message;
499
524
  }
500
525
  const nodeId = params.node_id;
501
- if (typeof nodeId !== 'string' || !looksLikeNodeSlug(nodeId.trim())) {
526
+ if (typeof nodeId !== "string" || !looksLikeNodeSlug(nodeId.trim())) {
502
527
  return message;
503
528
  }
504
529
  return [
505
530
  message,
506
531
  `hint: node_id looks like a slug. Use \`flywheel nodes:resolve-slug --slug_name ${nodeId.trim()}\` to resolve it.`,
507
- ].join('\n');
532
+ ].join("\n");
508
533
  }
509
534
  function formatConfigPathForMessage(configPath) {
510
535
  const homeDir = os.homedir();
511
536
  const withSlash = `${homeDir}/`;
512
537
  if (configPath === homeDir) {
513
- return '~';
538
+ return "~";
514
539
  }
515
540
  if (configPath.startsWith(withSlash)) {
516
541
  return `~/${configPath.slice(withSlash.length)}`;
@@ -519,23 +544,23 @@ function formatConfigPathForMessage(configPath) {
519
544
  }
520
545
  function buildMissingRuntimeConfigMessage(configPath) {
521
546
  const displayPath = formatConfigPathForMessage(configPath);
522
- // Only --mode cli writes ~/.config/flywheel-cli/config.json. Pointing at
547
+ // Only --mode cli writes ~/.config/flywheel/config.toml. Pointing at
523
548
  // --mode mcp as a fix would loop users back to this same error because MCP
524
549
  // setup only touches host MCP entries, not the runtime CLI config.
525
550
  return `Flywheel CLI runtime config not found at ${displayPath}. Run \`npx --yes @paradigma-inc/flywheel setup --mode cli\` to configure Flywheel.`;
526
551
  }
527
552
  function isPolicyBlockedResponseBody(body) {
528
- if (!body || typeof body !== 'object') {
553
+ if (!body || typeof body !== "object") {
529
554
  return false;
530
555
  }
531
556
  const detail = body.detail;
532
- if (!detail || typeof detail !== 'object') {
557
+ if (!detail || typeof detail !== "object") {
533
558
  return false;
534
559
  }
535
- return detail.type === 'policy_blocked';
560
+ return detail.type === "policy_blocked";
536
561
  }
537
562
  function isRawApiKeyAllowlistResponseBody(body) {
538
- if (!body || typeof body !== 'object') {
563
+ if (!body || typeof body !== "object") {
539
564
  return false;
540
565
  }
541
566
  return body.detail === RAW_API_KEY_ALLOWLIST_DETAIL;
@@ -595,18 +620,22 @@ async function defaultConfigExists(filePath) {
595
620
  }
596
621
  }
597
622
  export async function runCli(argv, dependencies = {}) {
623
+ const credentialMode = argv[0] === "admin:test-users:login" &&
624
+ argv.some((arg) => /^--(?:headless|credential-stdout)(?:=|$)/.test(arg));
598
625
  const stdout = dependencies.stdout ?? defaultStdout;
599
626
  const stderr = dependencies.stderr ?? defaultStderr;
627
+ const credentialOutput = credentialMode && !dependencies.stdout && processStdoutIsPipe()
628
+ ? "pipe" : undefined;
600
629
  if (argv.length === 0) {
601
- writeLine(stderr, 'usage: flywheel <command> [options]');
630
+ writeLine(stderr, "usage: flywheel <command> [options]");
602
631
  return EXIT_USAGE;
603
632
  }
604
633
  argv = rewriteAlias(argv);
605
634
  const [first, ...rest] = argv;
606
635
  if (USAGE_TOKENS.has(first)) {
607
636
  const extrasParsed = parseUsageExtras(argv);
608
- if (extrasParsed.kind === 'invalid') {
609
- writeLine(stderr, 'invalid --_usage_extras payload');
637
+ if (extrasParsed.kind === "invalid") {
638
+ writeLine(stderr, "invalid --_usage_extras payload");
610
639
  return EXIT_USAGE;
611
640
  }
612
641
  stdout(renderUsageSpec({
@@ -619,21 +648,21 @@ export async function runCli(argv, dependencies = {}) {
619
648
  token.startsWith(USAGE_VERSION_PREFIX));
620
649
  if (usagePrivateFlag !== undefined) {
621
650
  writeLine(stderr, usagePrivateFlag.startsWith(USAGE_VERSION_PREFIX)
622
- ? 'unknown flag: --_usage_version'
623
- : 'unknown flag: --_usage_extras');
651
+ ? "unknown flag: --_usage_version"
652
+ : "unknown flag: --_usage_extras");
624
653
  return EXIT_USAGE;
625
654
  }
626
655
  // Help-format validation intentionally runs only inside the help branches
627
656
  // below. Non-help commands let `parseCliArgs` validate --format against the
628
657
  // full json|tsv|csv|table set; validating here would reject legitimate
629
- // runtime formats like `flywheel nodes:list --format=csv`.
658
+ // runtime formats like `flywheel hosted:node:list --format=csv`.
630
659
  function resolveHelpFormat() {
631
660
  const fmt = parseHelpFormat(argv);
632
- if (fmt.kind === 'invalid') {
661
+ if (fmt.kind === "invalid") {
633
662
  writeLine(stderr, `invalid --format=${fmt.value}: help supports --format=json or no --format (text)`);
634
663
  return EXIT_USAGE;
635
664
  }
636
- return { json: fmt.kind === 'json' };
665
+ return { json: fmt.kind === "json" };
637
666
  }
638
667
  // Top-level help / `help ...` dispatcher runs BEFORE parseCliArgs because
639
668
  // `flywheel --help` and `flywheel help ...` aren't valid command tokens —
@@ -644,31 +673,31 @@ export async function runCli(argv, dependencies = {}) {
644
673
  // does not incorrectly drop into help mode on the `-h` value token.
645
674
  if (isHelpToken(first)) {
646
675
  const resolved = resolveHelpFormat();
647
- if (typeof resolved === 'number')
676
+ if (typeof resolved === "number")
648
677
  return resolved;
649
678
  const extrasParsed = parseHelpExtras(argv);
650
- if (extrasParsed.kind === 'invalid') {
651
- writeLine(stderr, 'invalid --_help_extras payload');
679
+ if (extrasParsed.kind === "invalid") {
680
+ writeLine(stderr, "invalid --_help_extras payload");
652
681
  return EXIT_USAGE;
653
682
  }
654
- const extras = extrasParsed.kind === 'ok' ? extrasParsed.extras : [];
683
+ const extras = extrasParsed.kind === "ok" ? extrasParsed.extras : [];
655
684
  stdout(resolved.json ? renderHelpAsJson(extras) : renderHelp(extras));
656
685
  return 0;
657
686
  }
658
- if (first === 'help') {
687
+ if (first === "help") {
659
688
  const resolved = resolveHelpFormat();
660
- if (typeof resolved === 'number')
689
+ if (typeof resolved === "number")
661
690
  return resolved;
662
691
  // Strip --format and --_help_extras tokens so the positional <command>
663
692
  // lookup isn't fooled by them occupying rest[0].
664
- const { commandArgs: helpArgs, schema, aliases } = normalizeCommandHelpArgs(stripHelpExtras(stripFormatTokens(rest)));
693
+ const { commandArgs: helpArgs, schema, aliases, } = normalizeCommandHelpArgs(stripHelpExtras(stripFormatTokens(rest)));
665
694
  const extrasParsed = parseHelpExtras(argv);
666
- if (extrasParsed.kind === 'invalid') {
667
- writeLine(stderr, 'invalid --_help_extras payload');
695
+ if (extrasParsed.kind === "invalid") {
696
+ writeLine(stderr, "invalid --_help_extras payload");
668
697
  return EXIT_USAGE;
669
698
  }
670
699
  if (schema && helpArgs.length === 0) {
671
- writeLine(stderr, '--schema requires a command name');
700
+ writeLine(stderr, "--schema requires a command name");
672
701
  return EXIT_USAGE;
673
702
  }
674
703
  if (aliases) {
@@ -676,14 +705,14 @@ export async function runCli(argv, dependencies = {}) {
676
705
  return 0;
677
706
  }
678
707
  if (helpArgs.length === 0) {
679
- const extras = extrasParsed.kind === 'ok' ? extrasParsed.extras : [];
708
+ const extras = extrasParsed.kind === "ok" ? extrasParsed.extras : [];
680
709
  stdout(resolved.json ? renderHelpAsJson(extras) : renderHelp(extras));
681
710
  return 0;
682
711
  }
683
712
  // --_help_extras is only valid on top-level help. Surface mis-use
684
713
  // as a usage error rather than silently ignoring it.
685
- if (extrasParsed.kind === 'ok') {
686
- writeLine(stderr, 'unknown flag: --_help_extras');
714
+ if (extrasParsed.kind === "ok") {
715
+ writeLine(stderr, "unknown flag: --_help_extras");
687
716
  return EXIT_USAGE;
688
717
  }
689
718
  // `help <alias>` must resolve the same alias map used by the SHORTCUTS
@@ -692,16 +721,35 @@ export async function runCli(argv, dependencies = {}) {
692
721
  const commandName = Object.prototype.hasOwnProperty.call(RUNTIME_ALIASES, rawCommandName)
693
722
  ? RUNTIME_ALIASES[rawCommandName]
694
723
  : rawCommandName;
724
+ const retiredExitCode = emitRetiredCommandName(commandName, argv, stderr);
725
+ if (retiredExitCode !== undefined)
726
+ return retiredExitCode;
695
727
  return emitCommandHelp(stdout, stderr, commandName, schema, resolved.json);
696
728
  }
697
729
  // --_help_extras is reserved for top-level help dispatch only. Reject it
698
730
  // when seen on any other command path so it cannot leak into runtime
699
731
  // argument parsing downstream.
700
732
  if (argv.some((t) => t.startsWith(HELP_EXTRAS_PREFIX))) {
701
- writeLine(stderr, 'unknown flag: --_help_extras');
733
+ writeLine(stderr, "unknown flag: --_help_extras");
702
734
  return EXIT_USAGE;
703
735
  }
704
- const parsed = parseCliArgs(argv);
736
+ const retiredExitCode = emitRetiredCommandName(argv[0] ?? "", argv, stderr);
737
+ if (retiredExitCode !== undefined)
738
+ return retiredExitCode;
739
+ const commandDefinition = getCommandByName(argv[0] ?? "");
740
+ const positionalLimit = commandDefinition?.positionals?.length ?? 0;
741
+ const booleanFlags = [...GLOBAL_BOOLEAN_FLAG_NAMES];
742
+ if (commandDefinition) {
743
+ for (const parameter of commandDefinition.required) {
744
+ if (parameter.type === "boolean")
745
+ booleanFlags.push(parameter.name);
746
+ }
747
+ for (const parameter of commandDefinition.optional) {
748
+ if (parameter.type === "boolean")
749
+ booleanFlags.push(parameter.name);
750
+ }
751
+ }
752
+ const parsed = parseCliArgs(argv, positionalLimit, booleanFlags);
705
753
  if (!parsed.ok) {
706
754
  writeLine(stderr, parsed.message);
707
755
  return parsed.exitCode;
@@ -714,49 +762,85 @@ export async function runCli(argv, dependencies = {}) {
714
762
  const schemaRequested = parsed.params.schema === true;
715
763
  if (helpRequested) {
716
764
  const resolved = resolveHelpFormat();
717
- if (typeof resolved === 'number')
765
+ if (typeof resolved === "number")
718
766
  return resolved;
719
767
  return emitCommandHelp(stdout, stderr, parsed.command, schemaRequested, resolved.json);
720
768
  }
721
- if (schemaRequested) {
722
- writeLine(stderr, '--schema is only valid with --help');
769
+ if (schemaRequested && parsed.command !== "repo:node:create") {
770
+ writeLine(stderr, "--schema is only valid with --help");
723
771
  return 1;
724
772
  }
725
773
  if (!getCommandByName(parsed.command)) {
726
774
  writeLine(stderr, `unknown command: ${parsed.command}`);
727
775
  return 1;
728
776
  }
777
+ const commandName = parsed.command;
729
778
  const handler = MVP_COMMAND_HANDLERS[parsed.command];
730
779
  if (!handler) {
731
780
  writeLine(stderr, `unknown command: ${parsed.command}`);
732
781
  return 1;
733
782
  }
734
- const commandName = parsed.command;
735
- const configPath = dependencies.configPath ?? resolveConfigPath();
736
- const loadConfig = dependencies.loadConfig ?? loadAuthConfig;
737
- const configExists = dependencies.configExists ?? defaultConfigExists;
738
- const saveConfig = dependencies.saveConfig ?? saveAuthConfig;
739
- const profileLoader = dependencies.loadProfile ?? loadProfile;
740
- const resolveEnvApiKey = dependencies.resolveEnvApiKey ??
741
- ((envVar) => process.env[envVar]?.trim() || undefined);
783
+ const localRepositoryCommand = repositoryLocalOperationNames.includes(commandName) ||
784
+ repositoryProjectionNames.includes(commandName) ||
785
+ repositoryEditNames.includes(commandName);
786
+ const localRepositoryRemoteCommand = LOCAL_REPOSITORY_REMOTE_COMMANDS.includes(commandName);
787
+ const humanGraphCommand = localRepositoryCommand || hostedGraphMutationNames.includes(commandName);
742
788
  const writeOutputFile = dependencies.writeOutputFile ??
743
789
  (async (path, contents) => {
744
790
  await writeFile(path, contents);
745
791
  });
746
792
  let effectiveBaseUrl = DEFAULT_BASE_URL;
747
793
  let globals = {};
794
+ let repositorySelection;
795
+ let repositoryInitPersonal = false;
796
+ const nodeCreateSchemaRequested = parsed.command === "repo:node:create" && parsed.params.schema === true;
797
+ let missingCredentialRemediation;
748
798
  try {
749
799
  validateCommandSpecificFlags(commandName, parsed.params);
800
+ bindCommandPositionals(commandName, parsed.positionals, parsed.params);
750
801
  const extracted = extractGlobals(parsed.params);
751
- globals = { ...extracted.globals, format: parsed.format, formatExplicit: parsed.formatExplicit };
802
+ globals = {
803
+ ...extracted.globals,
804
+ format: extracted.globals.format ?? parsed.format,
805
+ formatExplicit: parsed.formatExplicit || extracted.globals.formatExplicit,
806
+ };
752
807
  const { handlerParams, flagNames } = extracted;
753
- // `--env=<name>` accepts both legacy TOML profiles AND built-in
754
- // profile names (prod / staging). Built-ins synthesise a minimal
755
- // Profile so the rest of the pipeline (baseUrl resolution,
756
- // per-profile keychain lookups, etc.) treats them uniformly. The
757
- // built-in baseUrl is the runtime source of truth (never written to
758
- // config.json); the `--env=<builtin>` invocation effectively flips
759
- // the active profile for this one call without mutating disk state.
808
+ if (nodeCreateSchemaRequested) {
809
+ if (Object.keys(handlerParams).some((name) => name !== "schema")) {
810
+ throw new CliUsageError("--schema cannot be combined with node authoring flags");
811
+ }
812
+ const rendered = renderOutput(NODE_CREATE_SCHEMA, globals.format ?? parsed.format);
813
+ if (globals.outPath && globals.outPath !== "-") {
814
+ await writeOutputFile(globals.outPath, rendered);
815
+ }
816
+ else {
817
+ stdout(rendered);
818
+ }
819
+ return 0;
820
+ }
821
+ const configPath = dependencies.configPath ??
822
+ (dependencies.resolveConfigPath ?? resolveFlywheelConfigPath)();
823
+ const loadConfig = dependencies.loadConfig ??
824
+ (dependencies.configPath
825
+ ? (filePath) => loadFlywheelConfig({
826
+ env: { ...process.env, FLYWHEEL_CLI_CONFIG_PATH: filePath },
827
+ })
828
+ : async () => loadFlywheelConfig());
829
+ const configExists = dependencies.configExists ?? defaultConfigExists;
830
+ const saveConfig = dependencies.saveConfig ??
831
+ (async (filePath, config) => saveFlywheelConfig(config, filePath));
832
+ const resolveEnvApiKey = dependencies.resolveEnvApiKey ??
833
+ ((envVar) => process.env[envVar]?.trim() || undefined);
834
+ const config = await loadConfig(configPath);
835
+ const runtimeConfigExists = dependencies.loadConfig === undefined
836
+ ? await configExists(configPath)
837
+ : true;
838
+ // `--env=<name>` accepts a unified TOML profile or a built-in profile name
839
+ // (prod / staging). Built-ins synthesise a minimal Profile so the rest of
840
+ // the pipeline (base URL resolution and per-profile keychain lookups) treats
841
+ // them uniformly. The built-in base URL is the runtime source of truth
842
+ // (never written to config.toml); `--env=<builtin>` selects it for one call
843
+ // without mutating disk state.
760
844
  let profile = null;
761
845
  if (globals.env) {
762
846
  // Built-in names (`prod` / `staging`) are reserved and must always
@@ -775,18 +859,31 @@ export async function runCli(argv, dependencies = {}) {
775
859
  }
776
860
  }
777
861
  else {
778
- const fromToml = await profileLoader(globals.env);
862
+ const fromToml = config.profiles && Object.hasOwn(config.profiles, globals.env)
863
+ ? { name: globals.env, ...config.profiles[globals.env] }
864
+ : null;
779
865
  if (fromToml) {
780
866
  profile = fromToml;
781
867
  }
868
+ if (!profile) {
869
+ const available = BUILTIN_PROFILE_NAMES.join(", ");
870
+ throw new CliUsageError(`unknown profile: ${globals.env}. Built-in profiles: ${available}`);
871
+ }
782
872
  }
783
- if (!profile) {
784
- const available = BUILTIN_PROFILE_NAMES.join(', ');
785
- throw new CliUsageError(`unknown profile: ${globals.env}. Built-in profiles: ${available}`);
786
- }
787
873
  }
874
+ if (!profile &&
875
+ config.activeProfile &&
876
+ !isBuiltinProfileName(config.activeProfile)) {
877
+ const active = config.profiles && Object.hasOwn(config.profiles, config.activeProfile)
878
+ ? config.profiles[config.activeProfile]
879
+ : undefined;
880
+ if (active)
881
+ profile = { name: config.activeProfile, ...active };
882
+ }
883
+ let credentialFile = dependencies.credentialFile;
884
+ const resolveCredentialFile = () => credentialFile ??= resolveCredentialFilePath();
788
885
  if (dependencies.loadConfig === undefined &&
789
- !RUNTIME_CONFIG_OPTIONAL_COMMANDS.has(commandName)) {
886
+ !RUNTIME_CONFIG_OPTIONAL_COMMANDS.includes(commandName)) {
790
887
  // Env-only execution (CI/containers, scripted health checks) and
791
888
  // profile-based auth resolve runtime config without the file on
792
889
  // disk. Once `FLYWHEEL_BASE_URL` is set the CLI has enough to
@@ -799,58 +896,137 @@ export async function runCli(argv, dependencies = {}) {
799
896
  // needs auth and none is available.
800
897
  const envBaseUrl = process.env.FLYWHEEL_BASE_URL?.trim();
801
898
  const hasEnvBaseUrl = Boolean(envBaseUrl);
802
- if (!profile && !hasEnvBaseUrl) {
803
- const runtimeConfigExists = await configExists(configPath);
804
- if (!runtimeConfigExists) {
805
- writeLine(stderr, buildMissingRuntimeConfigMessage(configPath));
806
- return EXIT_USAGE;
807
- }
899
+ if (!profile && !hasEnvBaseUrl && !runtimeConfigExists) {
900
+ writeLine(stderr, buildMissingRuntimeConfigMessage(configPath));
901
+ return EXIT_USAGE;
808
902
  }
809
903
  }
810
- const config = await loadConfig(configPath);
811
- const runtimeConfig = await resolveRuntimeAuthConfig(config, profile, resolveEnvApiKey);
904
+ const authLocalConfigReadiness = dependencies.loadConfig === undefined
905
+ ? runtimeConfigExists
906
+ ? "ready"
907
+ : "missing"
908
+ : "ready";
909
+ const authRemoteProbeAllowed = authLocalConfigReadiness === "ready" ||
910
+ profile !== null ||
911
+ Boolean(process.env.FLYWHEEL_BASE_URL?.trim());
912
+ const runtimeConfig = await resolveRuntimeAuthConfig(config, profile, resolveEnvApiKey, resolveCredentialFile, !CREDENTIAL_LOOKUP_SKIPPED_COMMANDS.includes(commandName), dependencies.readCredential ?? readCredential, localRepositoryRemoteCommand);
913
+ const selectedProfileName = profile?.name ??
914
+ (typeof config.activeProfile === "string" && config.activeProfile.trim()
915
+ ? config.activeProfile.trim()
916
+ : "default");
917
+ missingCredentialRemediation = runtimeConfig.apiKey
918
+ ? undefined
919
+ : selectedProfileName === "default"
920
+ ? "flywheel auth:login"
921
+ : `flywheel auth:login --env ${selectedProfileName}`;
812
922
  effectiveBaseUrl = runtimeConfig.baseUrl;
813
- const commandDefaultFormat = commandName === 'api-keys:list' ? 'table' : parsed.format;
814
- const effectiveFormat = parsed.formatExplicit
815
- ? parsed.format
816
- : commandName === 'api-keys:list'
923
+ const selectedFormat = globals.format ?? parsed.format;
924
+ const commandDefaultFormat = commandName === "api-keys:list" ||
925
+ localRepositoryCommand ||
926
+ commandDefinition?.group === "hosted-graph"
927
+ ? "table"
928
+ : selectedFormat;
929
+ const effectiveFormat = globals.formatExplicit
930
+ ? selectedFormat
931
+ : commandName === "api-keys:list"
817
932
  ? commandDefaultFormat
818
933
  : (runtimeConfig.defaultFormat ?? commandDefaultFormat);
819
- const profileTimeoutS = typeof profile?.defaultTimeoutS === 'number' ? profile.defaultTimeoutS : undefined;
820
- const effectiveTimeoutMs = typeof globals.timeoutS === 'number'
934
+ const profileTimeoutS = typeof profile?.defaultTimeoutS === "number"
935
+ ? profile.defaultTimeoutS
936
+ : undefined;
937
+ const effectiveTimeoutMs = typeof globals.timeoutS === "number"
821
938
  ? globals.timeoutS * 1000
822
- : typeof profileTimeoutS === 'number'
939
+ : typeof profileTimeoutS === "number"
823
940
  ? profileTimeoutS * 1000
824
941
  : undefined;
825
- const buildClient = dependencies.createHttpClient ?? createHttpClient;
826
- const client = buildClient({
827
- baseUrl: runtimeConfig.baseUrl,
828
- apiKey: runtimeConfig.apiKey,
829
- cliVersion: CLI_VERSION,
830
- commandName,
831
- flagNames,
832
- invocationId: randomUUID(),
833
- retryMax: globals.retryMax,
834
- retryEnabled: globals.retryEnabled,
835
- waitRequested: globals.wait === true,
836
- waitTimeoutS: globals.waitTimeoutS,
837
- debug: globals.debug,
838
- timeoutMs: effectiveTimeoutMs,
839
- idempotencyKey: globals.idempotencyKey,
840
- });
942
+ const invocationId = randomUUID();
943
+ repositoryInitPersonal =
944
+ commandName === "repo:init" && handlerParams.personal === true;
945
+ repositorySelection = undefined;
946
+ if (localRepositoryCommand &&
947
+ !["repo:init", "repo:clone", "repo:restore"].includes(commandName)) {
948
+ repositorySelection = await resolveRepositorySelection({
949
+ params: handlerParams,
950
+ loadConfig: async () => config,
951
+ });
952
+ }
953
+ if (localRepositoryCommand) {
954
+ delete handlerParams.repo;
955
+ delete handlerParams.personal;
956
+ }
957
+ const client = !localRepositoryCommand || localRepositoryRemoteCommand
958
+ ? (dependencies.createHttpClient ?? createHttpClient)({
959
+ baseUrl: runtimeConfig.baseUrl,
960
+ apiKey: runtimeConfig.apiKey,
961
+ cliVersion: CLI_VERSION,
962
+ commandName,
963
+ flagNames,
964
+ invocationId,
965
+ retryMax: globals.retryMax,
966
+ retryEnabled: globals.retryEnabled,
967
+ waitRequested: globals.wait === true,
968
+ waitTimeoutS: globals.waitTimeoutS,
969
+ debug: globals.debug,
970
+ timeoutMs: effectiveTimeoutMs,
971
+ idempotencyKey: globals.idempotencyKey,
972
+ })
973
+ : undefined;
974
+ if (credentialFile === undefined &&
975
+ (commandName === "auth:login" ||
976
+ commandName === "auth:credentials:set" ||
977
+ commandName === "auth:credentials:clear")) {
978
+ resolveCredentialFile();
979
+ }
980
+ const connection = localRepositoryRemoteCommand && client
981
+ ? {
982
+ client,
983
+ baseUrl: runtimeConfig.baseUrl,
984
+ profile: profile?.name ??
985
+ (typeof config.activeProfile === "string" && config.activeProfile.trim()
986
+ ? config.activeProfile.trim()
987
+ : "default"),
988
+ }
989
+ : undefined;
990
+ const localAdapter = localRepositoryCommand
991
+ ? new LocalRepositoryAdapter({ connection })
992
+ : undefined;
841
993
  const payload = await handler({
842
994
  params: handlerParams,
843
- requestJson: client.requestJson,
844
- requestRaw: client.requestRaw,
845
- requestRawExternal: client.requestRawExternal,
995
+ requestJson: client?.requestJson ??
996
+ (async () => {
997
+ throw new Error("hosted HTTP transport is unavailable for local repository commands");
998
+ }),
999
+ requestRaw: client?.requestRaw,
846
1000
  saveConfig,
1001
+ config,
847
1002
  configPath,
1003
+ authProfile: selectedProfileName,
1004
+ authCredentialBaseUrl: runtimeConfig.credentialBaseUrl,
1005
+ authProfileBaseUrl: profile?.baseUrl,
1006
+ authDefaultBaseUrl: process.env.FLYWHEEL_BASE_URL?.trim() || DEFAULT_BASE_URL,
1007
+ authApiKeyEnv: profile?.apiKeyEnv,
1008
+ authLocalConfigReadiness,
1009
+ authRemoteProbeAllowed,
1010
+ authCredentialReadiness: runtimeConfig.credentialReadiness,
1011
+ authCredentialFile: credentialFile,
848
1012
  baseUrl: runtimeConfig.baseUrl,
849
1013
  apiKey: runtimeConfig.apiKey,
850
1014
  globals,
851
- stderr,
852
- stdout,
1015
+ stderr: credentialMode && !dependencies.stderr
1016
+ ? (chunk) => writeCredentialStream(process.stderr, chunk)
1017
+ : stderr,
1018
+ stdout: credentialMode && !dependencies.stdout
1019
+ ? (chunk) => writeCredentialStream(process.stdout, chunk)
1020
+ : stdout,
1021
+ credentialOutput,
853
1022
  writeOutputFile,
1023
+ requestLocalJson: localAdapter?.requestJson,
1024
+ repositoryBootstrap: localAdapter?.bootstrap.bind(localAdapter),
1025
+ localRepositoryId: localAdapter?.repositoryId.bind(localAdapter),
1026
+ installLocalObject: localAdapter?.installObject.bind(localAdapter),
1027
+ stageLocalOperations: localAdapter?.stageOperations.bind(localAdapter),
1028
+ repositoryInitPersonal,
1029
+ repositorySelection,
854
1030
  });
855
1031
  if (payload === undefined || payload === null) {
856
1032
  return 0;
@@ -860,7 +1036,7 @@ export async function runCli(argv, dependencies = {}) {
860
1036
  writeLine(stderr, `${commandName} returns binary output; pass --out=<path> or --out=- to write to stdout`);
861
1037
  return EXIT_USAGE;
862
1038
  }
863
- if (globals.outPath === '-') {
1039
+ if (globals.outPath === "-") {
864
1040
  // Route binary bytes through the injected stdout writer so
865
1041
  // programmatic runCli callers can capture them, matching the
866
1042
  // text-output path.
@@ -871,9 +1047,16 @@ export async function runCli(argv, dependencies = {}) {
871
1047
  }
872
1048
  return 0;
873
1049
  }
874
- const rendered = renderOutput(payload, effectiveFormat);
1050
+ const outputOptions = localRepositoryCommand
1051
+ ? { repositoryJson: true }
1052
+ : undefined;
1053
+ const rendered = humanGraphCommand &&
1054
+ !globals.formatExplicit &&
1055
+ effectiveFormat === "table"
1056
+ ? (renderRepositoryHumanOutput(commandName, payload, repositorySelection, repositoryInitPersonal) ?? renderOutput(payload, effectiveFormat, outputOptions))
1057
+ : renderOutput(payload, effectiveFormat, outputOptions);
875
1058
  if (globals.outPath) {
876
- if (globals.outPath === '-') {
1059
+ if (globals.outPath === "-") {
877
1060
  stdout(rendered);
878
1061
  }
879
1062
  else {
@@ -886,6 +1069,18 @@ export async function runCli(argv, dependencies = {}) {
886
1069
  return 0;
887
1070
  }
888
1071
  catch (error) {
1072
+ if (credentialMode && error instanceof CliHttpError) {
1073
+ try {
1074
+ const message = `${error.message}\n`;
1075
+ await (dependencies.stderr
1076
+ ? stderr(message)
1077
+ : writeCredentialStream(process.stderr, message));
1078
+ }
1079
+ catch {
1080
+ // A failed receipt/error sink must never cause credential emission.
1081
+ }
1082
+ return error.exitCode;
1083
+ }
889
1084
  if (error instanceof CliAuthRequirementError) {
890
1085
  const envelope = {
891
1086
  error: {
@@ -905,8 +1100,39 @@ export async function runCli(argv, dependencies = {}) {
905
1100
  writeLine(stderr, JSON.stringify(envelope));
906
1101
  return error.exitCode;
907
1102
  }
1103
+ if (error instanceof RepositorySelectionError) {
1104
+ writeLine(stderr, `${error.code}: ${error.message}`);
1105
+ return EXIT_USAGE;
1106
+ }
1107
+ if (error instanceof FlywheelConfigError) {
1108
+ if ((globals.format ?? parsed.format) !== "json") {
1109
+ writeLine(stderr, error.message);
1110
+ return EXIT_USAGE;
1111
+ }
1112
+ const details = {
1113
+ code: error.code,
1114
+ message: error.message,
1115
+ exit_code: EXIT_USAGE,
1116
+ };
1117
+ if (error.configPath)
1118
+ details.config_path = error.configPath;
1119
+ if (error.field)
1120
+ details.field = error.field;
1121
+ if (error.sourcePaths)
1122
+ details.source_paths = error.sourcePaths;
1123
+ if (error.platform)
1124
+ details.platform = error.platform;
1125
+ if (error.environmentVariable)
1126
+ details.environment_variable = error.environmentVariable;
1127
+ if (error.override)
1128
+ details.override = error.override;
1129
+ if (error.schemaVersion !== undefined)
1130
+ details.schema_version = error.schemaVersion;
1131
+ writeLine(stderr, JSON.stringify({ error: details }));
1132
+ return EXIT_USAGE;
1133
+ }
908
1134
  if (error instanceof CliUsageError) {
909
- const augmented = error.message.startsWith('missing required parameter')
1135
+ const augmented = error.message.startsWith("missing required parameter")
910
1136
  ? buildMissingParamHint(commandName, error.message)
911
1137
  : error.message;
912
1138
  writeLine(stderr, augmented);
@@ -915,7 +1141,7 @@ export async function runCli(argv, dependencies = {}) {
915
1141
  if (error instanceof CliApprovalPendingError) {
916
1142
  const envelope = {
917
1143
  error: {
918
- code: 'approval_required',
1144
+ code: "approval_required",
919
1145
  message: error.message,
920
1146
  exit_code: error.exitCode,
921
1147
  },
@@ -942,33 +1168,20 @@ export async function runCli(argv, dependencies = {}) {
942
1168
  writeLine(stderr, JSON.stringify(envelope));
943
1169
  return error.exitCode;
944
1170
  }
945
- if (error instanceof CliFinalizeFailedError) {
946
- const code = error.request?.failureKind === 'timeout' ? 'timeout' : 'finalize_failed';
947
- const envelope = {
1171
+ if (error instanceof CredentialStoreError) {
1172
+ writeLine(stderr, JSON.stringify({
948
1173
  error: {
949
- code,
1174
+ code: error.code,
950
1175
  message: error.message,
951
- exit_code: error.exitCode,
952
- orphan_blob_ids: error.orphanBlobIds,
1176
+ exit_code: 1,
953
1177
  },
954
- };
955
- const inner = envelope.error;
956
- if (typeof error.status === 'number') {
957
- inner.server_response = {
958
- status: error.status,
959
- body: responseBodyForCliError(commandName, error.body),
960
- };
961
- }
962
- if (error.request) {
963
- inner.request = requestForCliHttpEnvelope(error.request);
964
- }
965
- writeLine(stderr, JSON.stringify(envelope));
966
- return error.exitCode;
1178
+ }));
1179
+ return 1;
967
1180
  }
968
1181
  if (error instanceof CliWaitTimeoutError) {
969
1182
  const envelope = {
970
1183
  error: {
971
- code: 'wait_timeout',
1184
+ code: "wait_timeout",
972
1185
  message: error.message,
973
1186
  exit_code: error.exitCode,
974
1187
  last_state: error.lastState,
@@ -979,10 +1192,6 @@ export async function runCli(argv, dependencies = {}) {
979
1192
  }
980
1193
  if (error instanceof CliHttpError) {
981
1194
  let message = error.message;
982
- if (error.status === 422 &&
983
- (commandName === 'nodes:commit-new' || commandName === 'nodes:commit')) {
984
- message = buildCommitSchemaHint(commandName, message);
985
- }
986
1195
  message = buildLocalhostTransportHint(message, effectiveBaseUrl);
987
1196
  message = buildNodeSlugMissHint({
988
1197
  commandName,
@@ -990,15 +1199,65 @@ export async function runCli(argv, dependencies = {}) {
990
1199
  params: parsed.params,
991
1200
  message,
992
1201
  });
993
- const code = error.request?.failureKind === 'timeout'
994
- ? 'timeout'
995
- : error.status === 403 && isPolicyBlockedResponseBody(error.body)
996
- ? 'policy_blocked'
997
- : error.status === 401 || error.status === 403
998
- ? 'auth_error'
999
- : error.status === undefined
1000
- ? 'transport_error'
1001
- : 'http_error';
1202
+ if (error.status === 401 && missingCredentialRemediation) {
1203
+ message = `${message} Run ${missingCredentialRemediation}.`;
1204
+ }
1205
+ const localRuntimeError = localRuntimeErrorType(error.body);
1206
+ const invalidRepositorySelection = localRuntimeError === "repository_runtime_state_invalid"
1207
+ ? repositorySelection
1208
+ : undefined;
1209
+ const personalRepositoryInvalid = invalidRepositorySelection?.source === "personal";
1210
+ const personalRepositoryAdoptionInvalid = localRuntimeError === "repository_adoption_invalid" &&
1211
+ repositoryInitPersonal;
1212
+ let repositoryRoot;
1213
+ let repositorySource;
1214
+ if (invalidRepositorySelection) {
1215
+ repositoryRoot = invalidRepositorySelection.root;
1216
+ repositorySource = invalidRepositorySelection.source;
1217
+ if (personalRepositoryInvalid) {
1218
+ message =
1219
+ `The configured personal repository is invalid: ${repositoryRoot}. ` +
1220
+ `Run flywheel repo:init --personal ${shellQuote(repositoryRoot)} to repair it.`;
1221
+ }
1222
+ else {
1223
+ message =
1224
+ `The Flywheel repository selected from ${repositorySource} is invalid: ` +
1225
+ `${repositoryRoot}.`;
1226
+ }
1227
+ }
1228
+ else if (personalRepositoryAdoptionInvalid) {
1229
+ const input = typeof parsed.params.directory === "string"
1230
+ ? parsed.params.directory
1231
+ : resolve(os.homedir(), "Flywheel");
1232
+ repositoryRoot =
1233
+ input === "~"
1234
+ ? os.homedir()
1235
+ : input.startsWith("~/")
1236
+ ? resolve(os.homedir(), input.slice(2))
1237
+ : resolve(input);
1238
+ repositorySource = "personal";
1239
+ message =
1240
+ `Unable to adopt the personal Flywheel repository at ${repositoryRoot}. ` +
1241
+ `Fix the repository, then retry: flywheel repo:init --personal ${shellQuote(repositoryRoot)}.`;
1242
+ }
1243
+ const code = personalRepositoryInvalid
1244
+ ? "personal_repository_invalid"
1245
+ : invalidRepositorySelection !== undefined ||
1246
+ personalRepositoryAdoptionInvalid
1247
+ ? localRuntimeError
1248
+ : localRuntimeError === "repository_locked"
1249
+ ? localRuntimeError
1250
+ : error.request?.failureKind === "timeout"
1251
+ ? "timeout"
1252
+ : error.request?.failureKind === "response_body"
1253
+ ? "response_error"
1254
+ : error.status === 403 && isPolicyBlockedResponseBody(error.body)
1255
+ ? "policy_blocked"
1256
+ : error.status === 401 || error.status === 403
1257
+ ? "auth_error"
1258
+ : error.status === undefined
1259
+ ? "transport_error"
1260
+ : "http_error";
1002
1261
  const envelope = {
1003
1262
  error: {
1004
1263
  code,
@@ -1007,7 +1266,11 @@ export async function runCli(argv, dependencies = {}) {
1007
1266
  },
1008
1267
  };
1009
1268
  const inner = envelope.error;
1010
- if (typeof error.status === 'number') {
1269
+ if (repositoryRoot)
1270
+ inner.repository_root = repositoryRoot;
1271
+ if (repositorySource)
1272
+ inner.repository_source = repositorySource;
1273
+ if (typeof error.status === "number") {
1011
1274
  inner.server_response = {
1012
1275
  status: error.status,
1013
1276
  body: responseBodyForCliError(commandName, error.body),
@@ -1023,13 +1286,25 @@ export async function runCli(argv, dependencies = {}) {
1023
1286
  writeLine(stderr, error.message);
1024
1287
  return EXIT_TRANSPORT;
1025
1288
  }
1026
- writeLine(stderr, 'runtime error');
1289
+ writeLine(stderr, "runtime error");
1027
1290
  return EXIT_TRANSPORT;
1028
1291
  }
1029
1292
  finally {
1030
1293
  void globals;
1031
1294
  }
1032
1295
  }
1296
+ function localRuntimeErrorType(body) {
1297
+ if (typeof body !== "object" ||
1298
+ body === null ||
1299
+ !("detail" in body) ||
1300
+ typeof body.detail !== "object" ||
1301
+ body.detail === null ||
1302
+ !("type" in body.detail) ||
1303
+ typeof body.detail.type !== "string") {
1304
+ return undefined;
1305
+ }
1306
+ return body.detail.type;
1307
+ }
1033
1308
  async function main() {
1034
1309
  const exitCode = await runCli(process.argv.slice(2), {});
1035
1310
  process.exitCode = exitCode;