@senators/bifrost-cli 0.0.0-stage → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +180 -2
- package/out/accountEditor-CQB91PVf.js +2 -0
- package/out/accountEditor-CQB91PVf.js.map +1 -0
- package/out/achievements-Df5qqpYQ.js +2 -0
- package/out/achievements-Df5qqpYQ.js.map +1 -0
- package/out/active-CnUKpiEo.js +2 -0
- package/out/active-CnUKpiEo.js.map +1 -0
- package/out/alliance-BsPnhi7w.js +2 -0
- package/out/alliance-BsPnhi7w.js.map +1 -0
- package/out/allianceAdmin-Bkyl6ev4.js +2 -0
- package/out/allianceAdmin-Bkyl6ev4.js.map +1 -0
- package/out/arsenal-BMCmAHzv.js +2 -0
- package/out/arsenal-BMCmAHzv.js.map +1 -0
- package/out/ban-BXNvHPMq.js +2 -0
- package/out/ban-BXNvHPMq.js.map +1 -0
- package/out/banList-3DbCToEy.js +2 -0
- package/out/banList-3DbCToEy.js.map +1 -0
- package/out/banList-dT5GF5eO.js +2 -0
- package/out/banList-dT5GF5eO.js.map +1 -0
- package/out/battleHall-C4BALP6S.js +2 -0
- package/out/battleHall-C4BALP6S.js.map +1 -0
- package/out/battleHall-P7Co1jS5.js +2 -0
- package/out/battleHall-P7Co1jS5.js.map +1 -0
- package/out/battleReport-BG0-S-bF.js +2 -0
- package/out/battleReport-BG0-S-bF.js.map +1 -0
- package/out/battleReport-C3PQTXxc.js +2 -0
- package/out/battleReport-C3PQTXxc.js.map +1 -0
- package/out/battleSimulator-BOySErLn.js +2 -0
- package/out/battleSimulator-BOySErLn.js.map +1 -0
- package/out/board-CsNgDx4j.js +2 -0
- package/out/board-CsNgDx4j.js.map +1 -0
- package/out/board-DSCl8eU8.js +2 -0
- package/out/board-DSCl8eU8.js.map +1 -0
- package/out/bonusSummary-Dmm646zj.js +2 -0
- package/out/bonusSummary-Dmm646zj.js.map +1 -0
- package/out/buddyList-B50t-9_g.js +2 -0
- package/out/buddyList-B50t-9_g.js.map +1 -0
- package/out/buildings-CXrMgFyb.js +2 -0
- package/out/buildings-CXrMgFyb.js.map +1 -0
- package/out/catalog-DmSXp_YG.js +2 -0
- package/out/catalog-DmSXp_YG.js.map +1 -0
- package/out/chat-BvtMl-I7.js +2 -0
- package/out/chat-BvtMl-I7.js.map +1 -0
- package/out/clearCache-79cjREI0.js +2 -0
- package/out/clearCache-79cjREI0.js.map +1 -0
- package/out/cli.js +3 -0
- package/out/cli.js.map +1 -0
- package/out/containers-BhguCCkz.js +2 -0
- package/out/containers-BhguCCkz.js.map +1 -0
- package/out/control-IJRy1LDx.js +2 -0
- package/out/control-IJRy1LDx.js.map +1 -0
- package/out/create-D-IygCER.js +2 -0
- package/out/create-D-IygCER.js.map +1 -0
- package/out/createMoon-BMWjdwO0.js +2 -0
- package/out/createMoon-BMWjdwO0.js.map +1 -0
- package/out/cronjob-CCJKDSuv.js +2 -0
- package/out/cronjob-CCJKDSuv.js.map +1 -0
- package/out/dailyBonus-2UwWD4D0.js +2 -0
- package/out/dailyBonus-2UwWD4D0.js.map +1 -0
- package/out/delivery-d8NKP-f1.js +2 -0
- package/out/delivery-d8NKP-f1.js.map +1 -0
- package/out/disclaimer-BmejHZqk.js +2 -0
- package/out/disclaimer-BmejHZqk.js.map +1 -0
- package/out/dump--mJa5m3e.js +2 -0
- package/out/dump--mJa5m3e.js.map +1 -0
- package/out/endpoints-CbZGTbF-.js +2 -0
- package/out/endpoints-CbZGTbF-.js.map +1 -0
- package/out/externalAuth-Dwl3VAHa.js +2 -0
- package/out/externalAuth-Dwl3VAHa.js.map +1 -0
- package/out/findDebris-DOMvMC1l.js +2 -0
- package/out/findDebris-DOMvMC1l.js.map +1 -0
- package/out/fleet-DyITa_Xu.js +2 -0
- package/out/fleet-DyITa_Xu.js.map +1 -0
- package/out/fleetAjax-BGxyUtdi.js +2 -0
- package/out/fleetAjax-BGxyUtdi.js.map +1 -0
- package/out/fleetDealer-n6LM_8IT.js +2 -0
- package/out/fleetDealer-n6LM_8IT.js.map +1 -0
- package/out/fleetMissile-CucQvNmZ.js +2 -0
- package/out/fleetMissile-CucQvNmZ.js.map +1 -0
- package/out/fleetStep1-wp-NgTsC.js +2 -0
- package/out/fleetStep1-wp-NgTsC.js.map +1 -0
- package/out/fleetStep2-C-GzHXyn.js +2 -0
- package/out/fleetStep2-C-GzHXyn.js.map +1 -0
- package/out/fleetStep3-D_fqImWm.js +2 -0
- package/out/fleetStep3-D_fqImWm.js.map +1 -0
- package/out/fleetTable-BpWLh0R1.js +2 -0
- package/out/fleetTable-BpWLh0R1.js.map +1 -0
- package/out/flyingFleet-ClIrGPJz.js +2 -0
- package/out/flyingFleet-ClIrGPJz.js.map +1 -0
- package/out/galaxy-B12wKQUU.js +2 -0
- package/out/galaxy-B12wKQUU.js.map +1 -0
- package/out/get-Cn2hFvGS.js +2 -0
- package/out/get-Cn2hFvGS.js.map +1 -0
- package/out/giveaway-CDWEArOF.js +2 -0
- package/out/giveaway-CDWEArOF.js.map +1 -0
- package/out/growth-C_-C8rLD.js +2 -0
- package/out/growth-C_-C8rLD.js.map +1 -0
- package/out/index.d.ts +29 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +1 -0
- package/out/information-CqfqYCH1.js +2 -0
- package/out/information-CqfqYCH1.js.map +1 -0
- package/out/information-DK93hgyE.js +2 -0
- package/out/information-DK93hgyE.js.map +1 -0
- package/out/log-BBE1Jt9i.js +2 -0
- package/out/log-BBE1Jt9i.js.map +1 -0
- package/out/login--4vqysQx.js +2 -0
- package/out/login--4vqysQx.js.map +1 -0
- package/out/login-C_DqRApn.js +2 -0
- package/out/login-C_DqRApn.js.map +1 -0
- package/out/logout-BYnLiMja.js +2 -0
- package/out/logout-BYnLiMja.js.map +1 -0
- package/out/logout-BsCSXzv8.js +2 -0
- package/out/logout-BsCSXzv8.js.map +1 -0
- package/out/lostPassword-Pc_1CUBD.js +2 -0
- package/out/lostPassword-Pc_1CUBD.js.map +1 -0
- package/out/market-DN8cY1tr.js +2 -0
- package/out/market-DN8cY1tr.js.map +1 -0
- package/out/messageList-k_zW_D0G.js +2 -0
- package/out/messageList-k_zW_D0G.js.map +1 -0
- package/out/messages-D461yIe6.js +2 -0
- package/out/messages-D461yIe6.js.map +1 -0
- package/out/missions-5zZtlLIm.js +2 -0
- package/out/missions-5zZtlLIm.js.map +1 -0
- package/out/module-BEPeTBhK.js +2 -0
- package/out/module-BEPeTBhK.js.map +1 -0
- package/out/multiIp-CP3lub1T.js +2 -0
- package/out/multiIp-CP3lub1T.js.map +1 -0
- package/out/new-star-BaVTTcIn.js +2 -0
- package/out/new-star-BaVTTcIn.js.map +1 -0
- package/out/news-BdDDcd-M.js +2 -0
- package/out/news-BdDDcd-M.js.map +1 -0
- package/out/news-Dd1C9JDl.js +2 -0
- package/out/news-Dd1C9JDl.js.map +1 -0
- package/out/notes-DLngBta3.js +2 -0
- package/out/notes-DLngBta3.js.map +1 -0
- package/out/overview-CzcSTNla.js +2 -0
- package/out/overview-CzcSTNla.js.map +1 -0
- package/out/overview-wQWIR_CB.js +2 -0
- package/out/overview-wQWIR_CB.js.map +1 -0
- package/out/password-ZA_1lStC.js +2 -0
- package/out/password-ZA_1lStC.js.map +1 -0
- package/out/phalanx-DaMaoJCT.js +2 -0
- package/out/phalanx-DaMaoJCT.js.map +1 -0
- package/out/planet-CecZ2cAZ.js +2 -0
- package/out/planet-CecZ2cAZ.js.map +1 -0
- package/out/playerCard-BG711xQi.js +2 -0
- package/out/playerCard-BG711xQi.js.map +1 -0
- package/out/post-C_ywAss7.js +2 -0
- package/out/post-C_ywAss7.js.map +1 -0
- package/out/production-D8SZfez8.js +2 -0
- package/out/production-D8SZfez8.js.map +1 -0
- package/out/public-TVVf75qu.js +2 -0
- package/out/public-TVVf75qu.js.map +1 -0
- package/out/questions-NwzZ5_fL.js +2 -0
- package/out/questions-NwzZ5_fL.js.map +1 -0
- package/out/quickEditor-DEJQFH0f.js +2 -0
- package/out/quickEditor-DEJQFH0f.js.map +1 -0
- package/out/records-CDVglYGy.js +2 -0
- package/out/records-CDVglYGy.js.map +1 -0
- package/out/records-Djjz9kxk.js +2 -0
- package/out/records-Djjz9kxk.js.map +1 -0
- package/out/reduceFleet-y8p89weR.js +2 -0
- package/out/reduceFleet-y8p89weR.js.map +1 -0
- package/out/reduceResources-CnGJ9fuf.js +2 -0
- package/out/reduceResources-CnGJ9fuf.js.map +1 -0
- package/out/refreshStatistics-CjGWyNc_.js +2 -0
- package/out/refreshStatistics-CjGWyNc_.js.map +1 -0
- package/out/register-4x5hZcWe.js +2 -0
- package/out/register-4x5hZcWe.js.map +1 -0
- package/out/research-dTK3-tOW.js +2 -0
- package/out/research-dTK3-tOW.js.map +1 -0
- package/out/reset-CHiMI9rj.js +2 -0
- package/out/reset-CHiMI9rj.js.map +1 -0
- package/out/resources-CjnevA41.js +2 -0
- package/out/resources-CjnevA41.js.map +1 -0
- package/out/rights-WPf-j_YF.js +2 -0
- package/out/rights-WPf-j_YF.js.map +1 -0
- package/out/rules-E29jtQRj.js +2 -0
- package/out/rules-E29jtQRj.js.map +1 -0
- package/out/runner-C2bQQS2G.js +43 -0
- package/out/runner-C2bQQS2G.js.map +1 -0
- package/out/scan-RvWZeyyM.js +2 -0
- package/out/scan-RvWZeyyM.js.map +1 -0
- package/out/screens-CZ4g-KNp.js +2 -0
- package/out/screens-CZ4g-KNp.js.map +1 -0
- package/out/search-BYvqiUBF.js +2 -0
- package/out/search-BYvqiUBF.js.map +1 -0
- package/out/search-auPbK2Xc.js +2 -0
- package/out/search-auPbK2Xc.js.map +1 -0
- package/out/sendMessages-B2Uj3PW4.js +2 -0
- package/out/sendMessages-B2Uj3PW4.js.map +1 -0
- package/out/settings-DFFa6Ush.js +2 -0
- package/out/settings-DFFa6Ush.js.map +1 -0
- package/out/settings-Ddez5x9U.js +2 -0
- package/out/settings-Ddez5x9U.js.map +1 -0
- package/out/shared-DoaW4mlX.js +2 -0
- package/out/shared-DoaW4mlX.js.map +1 -0
- package/out/shipyard-DXr745hR.js +2 -0
- package/out/shipyard-DXr745hR.js.map +1 -0
- package/out/shops-CEE02c0g.js +2 -0
- package/out/shops-CEE02c0g.js.map +1 -0
- package/out/snapshot-CrJ8l50N.js +2 -0
- package/out/snapshot-CrJ8l50N.js.map +1 -0
- package/out/social-1Gdni-jZ.js +2 -0
- package/out/social-1Gdni-jZ.js.map +1 -0
- package/out/spec-CrkWB0BN.js +2 -0
- package/out/spec-CrkWB0BN.js.map +1 -0
- package/out/statistics-zg3aVAvW.js +2 -0
- package/out/statistics-zg3aVAvW.js.map +1 -0
- package/out/store-dXG7NoB4.js +2 -0
- package/out/store-dXG7NoB4.js.map +1 -0
- package/out/support-DisUQr57.js +2 -0
- package/out/support-DisUQr57.js.map +1 -0
- package/out/techtree-Ba3FEH5_.js +2 -0
- package/out/techtree-Ba3FEH5_.js.map +1 -0
- package/out/ticket-O_8jTKW8.js +2 -0
- package/out/ticket-O_8jTKW8.js.map +1 -0
- package/out/trader-zFDGaHZ9.js +2 -0
- package/out/trader-zFDGaHZ9.js.map +1 -0
- package/out/universe-DO32RnLQ.js +2 -0
- package/out/universe-DO32RnLQ.js.map +1 -0
- package/out/universeSettings-S7enRJR4.js +2 -0
- package/out/universeSettings-S7enRJR4.js.map +1 -0
- package/out/values-gwcnIHXs.js +2 -0
- package/out/values-gwcnIHXs.js.map +1 -0
- package/out/verify-sYnZ9juV.js +2 -0
- package/out/verify-sYnZ9juV.js.map +1 -0
- package/out/version-Cgs-grc5.js +2 -0
- package/out/version-Cgs-grc5.js.map +1 -0
- package/package.json +65 -4
- package/src/admin.ts +317 -0
- package/src/arguments.ts +323 -0
- package/src/catalog.ts +117 -0
- package/src/cli.ts +29 -0
- package/src/commands/admin/accountEditor.ts +33 -0
- package/src/commands/admin/active.ts +25 -0
- package/src/commands/admin/ban.ts +59 -0
- package/src/commands/admin/clearCache.ts +12 -0
- package/src/commands/admin/create.ts +59 -0
- package/src/commands/admin/cronjob.ts +94 -0
- package/src/commands/admin/dump.ts +25 -0
- package/src/commands/admin/flyingFleet.ts +25 -0
- package/src/commands/admin/giveaway.ts +37 -0
- package/src/commands/admin/information.ts +12 -0
- package/src/commands/admin/log.ts +37 -0
- package/src/commands/admin/login.ts +15 -0
- package/src/commands/admin/logout.ts +12 -0
- package/src/commands/admin/messageList.ts +19 -0
- package/src/commands/admin/module.ts +25 -0
- package/src/commands/admin/multiIp.ts +25 -0
- package/src/commands/admin/news.ts +40 -0
- package/src/commands/admin/overview.ts +12 -0
- package/src/commands/admin/password.ts +18 -0
- package/src/commands/admin/quickEditor.ts +30 -0
- package/src/commands/admin/refreshStatistics.ts +12 -0
- package/src/commands/admin/reset.ts +26 -0
- package/src/commands/admin/rights.ts +68 -0
- package/src/commands/admin/search.ts +31 -0
- package/src/commands/admin/sendMessages.ts +26 -0
- package/src/commands/admin/support.ts +48 -0
- package/src/commands/admin/universe.ts +49 -0
- package/src/commands/admin/universeSettings.ts +32 -0
- package/src/commands/game/achievements.ts +18 -0
- package/src/commands/game/alliance.ts +248 -0
- package/src/commands/game/allianceAdmin.ts +236 -0
- package/src/commands/game/arsenal.ts +12 -0
- package/src/commands/game/banList.ts +20 -0
- package/src/commands/game/battleHall.ts +21 -0
- package/src/commands/game/battleReport.ts +20 -0
- package/src/commands/game/battleSimulator.ts +41 -0
- package/src/commands/game/board.ts +12 -0
- package/src/commands/game/bonusSummary.ts +12 -0
- package/src/commands/game/buddyList.ts +76 -0
- package/src/commands/game/buildings.ts +81 -0
- package/src/commands/game/chat.ts +12 -0
- package/src/commands/game/containers.ts +33 -0
- package/src/commands/game/control.ts +16 -0
- package/src/commands/game/createMoon.ts +28 -0
- package/src/commands/game/dailyBonus.ts +18 -0
- package/src/commands/game/delivery.ts +34 -0
- package/src/commands/game/endpoints.ts +61 -0
- package/src/commands/game/findDebris.ts +16 -0
- package/src/commands/game/fleetAjax.ts +24 -0
- package/src/commands/game/fleetDealer.ts +36 -0
- package/src/commands/game/fleetMissile.ts +25 -0
- package/src/commands/game/fleetStep1.ts +74 -0
- package/src/commands/game/fleetStep2.ts +27 -0
- package/src/commands/game/fleetStep3.ts +28 -0
- package/src/commands/game/fleetTable.ts +96 -0
- package/src/commands/game/galaxy.ts +26 -0
- package/src/commands/game/growth.ts +313 -0
- package/src/commands/game/information.ts +56 -0
- package/src/commands/game/logout.ts +12 -0
- package/src/commands/game/market.ts +67 -0
- package/src/commands/game/messages.ts +129 -0
- package/src/commands/game/notes.ts +65 -0
- package/src/commands/game/overview.ts +49 -0
- package/src/commands/game/phalanx.ts +23 -0
- package/src/commands/game/planet.ts +78 -0
- package/src/commands/game/playerCard.ts +20 -0
- package/src/commands/game/questions.ts +23 -0
- package/src/commands/game/records.ts +16 -0
- package/src/commands/game/reduceFleet.ts +41 -0
- package/src/commands/game/reduceResources.ts +35 -0
- package/src/commands/game/research.ts +80 -0
- package/src/commands/game/resources.ts +49 -0
- package/src/commands/game/scan.ts +12 -0
- package/src/commands/game/search.ts +44 -0
- package/src/commands/game/settings.ts +121 -0
- package/src/commands/game/shipyard.ts +61 -0
- package/src/commands/game/shops.ts +89 -0
- package/src/commands/game/statistics.ts +22 -0
- package/src/commands/game/store.ts +12 -0
- package/src/commands/game/techtree.ts +16 -0
- package/src/commands/game/ticket.ts +44 -0
- package/src/commands/game/trader.ts +51 -0
- package/src/commands/game/workflows/fleet.ts +12 -0
- package/src/commands/game/workflows/snapshot.ts +84 -0
- package/src/commands/game/workflows/social.ts +37 -0
- package/src/commands/http/get.ts +13 -0
- package/src/commands/http/post.ts +44 -0
- package/src/commands/public/banList.ts +21 -0
- package/src/commands/public/battleHall.ts +20 -0
- package/src/commands/public/battleReport.ts +20 -0
- package/src/commands/public/board.ts +20 -0
- package/src/commands/public/disclaimer.ts +20 -0
- package/src/commands/public/externalAuth.ts +17 -0
- package/src/commands/public/index.ts +22 -0
- package/src/commands/public/login.ts +20 -0
- package/src/commands/public/lostPassword.ts +57 -0
- package/src/commands/public/news.ts +20 -0
- package/src/commands/public/register.ts +46 -0
- package/src/commands/public/rules.ts +20 -0
- package/src/commands/public/screens.ts +20 -0
- package/src/commands/public/verify.ts +38 -0
- package/src/commands/rules/new-star.ts +221 -0
- package/src/commands/rules/production.ts +51 -0
- package/src/completion/BifrostCompletion.psm1 +47 -0
- package/src/completion.ts +445 -0
- package/src/connection.ts +106 -0
- package/src/destination.ts +64 -0
- package/src/game.ts +978 -0
- package/src/help.ts +203 -0
- package/src/i18n.ts +45 -0
- package/src/index.ts +2 -0
- package/src/input/admin/accountEditor.ts +156 -0
- package/src/input/admin/ban.ts +23 -0
- package/src/input/admin/create.ts +36 -0
- package/src/input/admin/cronjob.ts +22 -0
- package/src/input/admin/fields.ts +432 -0
- package/src/input/admin/login.ts +9 -0
- package/src/input/admin/messageList.ts +21 -0
- package/src/input/admin/news.ts +29 -0
- package/src/input/admin/quickEditor.ts +115 -0
- package/src/input/admin/records.ts +68 -0
- package/src/input/admin/reset.ts +29 -0
- package/src/input/admin/search.ts +23 -0
- package/src/input/admin/sendMessages.ts +21 -0
- package/src/input/admin/universeSettings.ts +46 -0
- package/src/input/files.ts +65 -0
- package/src/input/game/allianceAdmin.ts +55 -0
- package/src/input/game/battleSimulator.ts +25 -0
- package/src/input/game/fleetStep1.ts +14 -0
- package/src/input/game/settings.ts +46 -0
- package/src/input/game/ticket.ts +16 -0
- package/src/input/parse.ts +173 -0
- package/src/input/paths.ts +392 -0
- package/src/input/protocol/context.ts +10 -0
- package/src/input/protocol/missions.ts +6 -0
- package/src/input/protocol/routes.ts +15 -0
- package/src/input/protocol/settings.ts +126 -0
- package/src/input/protocol/values.ts +13 -0
- package/src/input/public/externalAuth.ts +26 -0
- package/src/input/public/register.ts +9 -0
- package/src/input/rules/new-star.ts +21 -0
- package/src/input/rules/production.ts +14 -0
- package/src/input/shared.ts +51 -0
- package/src/input/spec.ts +155 -0
- package/src/input/values.ts +114 -0
- package/src/input/workflows/fleet.ts +22 -0
- package/src/input/workflows/snapshot.ts +74 -0
- package/src/locales/en-US/commands.ts +377 -0
- package/src/locales/en-US/diagnostics.ts +89 -0
- package/src/locales/en-US.ts +61 -0
- package/src/locales/zh-CN/commands.ts +307 -0
- package/src/locales/zh-CN/diagnostics.ts +81 -0
- package/src/locales/zh-CN.ts +57 -0
- package/src/options.ts +48 -0
- package/src/output.ts +201 -0
- package/src/pointer.ts +46 -0
- package/src/presentation.ts +96 -0
- package/src/public.ts +99 -0
- package/src/registry.ts +67 -0
- package/src/requests.ts +13 -0
- package/src/result.ts +27 -0
- package/src/rules.ts +77 -0
- package/src/runner.ts +214 -0
- package/src/selection.ts +44 -0
- package/src/terminal.ts +27 -0
- package/src/types.ts +110 -0
- package/src/version.ts +11 -0
package/src/runner.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import type { Fetch, Session } from '@senators/bifrost'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
businessInput,
|
|
5
|
+
diagnosticOptions,
|
|
6
|
+
inputDocument,
|
|
7
|
+
parse,
|
|
8
|
+
stringOption,
|
|
9
|
+
} from './arguments.ts'
|
|
10
|
+
import {
|
|
11
|
+
COMPLETION_SHELLS,
|
|
12
|
+
completionCandidates,
|
|
13
|
+
completionScript,
|
|
14
|
+
isCompletionShell,
|
|
15
|
+
} from './completion.ts'
|
|
16
|
+
import { connect, sessionInfo } from './connection.ts'
|
|
17
|
+
import { prepareOutput } from './destination.ts'
|
|
18
|
+
import type { OutputDestination } from './destination.ts'
|
|
19
|
+
import { completionHelp, help } from './help.ts'
|
|
20
|
+
import { messages, withLocale } from './i18n.ts'
|
|
21
|
+
import type { Locale } from './i18n.ts'
|
|
22
|
+
import { createInputSource, parseJson } from './input/files.ts'
|
|
23
|
+
import { checkInput } from './input/parse.ts'
|
|
24
|
+
import { arrayInput, stringInput } from './input/spec.ts'
|
|
25
|
+
import { partialSnapshot, render, renderSerialized, serialize } from './output.ts'
|
|
26
|
+
import { PLAIN, renderHelp, resolvePresentation } from './presentation.ts'
|
|
27
|
+
import type { HelpPart, Presentation } from './presentation.ts'
|
|
28
|
+
import { invoke } from './registry.ts'
|
|
29
|
+
import { OutputError, UsageError } from './result.ts'
|
|
30
|
+
import { parseSelection, selectOutput } from './selection.ts'
|
|
31
|
+
import type { CommandResult, Json } from './types.ts'
|
|
32
|
+
|
|
33
|
+
export type Runtime = {
|
|
34
|
+
stdin: () => string | Promise<string>
|
|
35
|
+
stdout: (output: string) => void | Promise<void>
|
|
36
|
+
stderr: (output: string) => void | Promise<void>
|
|
37
|
+
stdoutPresentation?: Presentation
|
|
38
|
+
stderrPresentation?: Presentation
|
|
39
|
+
locale?: Locale
|
|
40
|
+
fetch?: Fetch
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Run one stateless command; callers explicitly carry cookies between invocations.
|
|
45
|
+
*
|
|
46
|
+
* 执行一条无状态命令,调用方显式传递跨调用 Cookie。
|
|
47
|
+
*/
|
|
48
|
+
export function run(args: readonly string[], runtime: Runtime): Promise<number> {
|
|
49
|
+
const options = diagnosticOptions(args)
|
|
50
|
+
const locale = options.locale === 'auto' ? (runtime.locale ?? 'en-US') : options.locale
|
|
51
|
+
return withLocale(locale, () => runInvocation(args, runtime, options))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function runInvocation(
|
|
55
|
+
args: readonly string[],
|
|
56
|
+
runtime: Runtime,
|
|
57
|
+
options: ReturnType<typeof diagnosticOptions>,
|
|
58
|
+
): Promise<number> {
|
|
59
|
+
let { format, color, links } = options
|
|
60
|
+
let session: Session | undefined
|
|
61
|
+
let destination: OutputDestination | undefined
|
|
62
|
+
let output: Json | undefined
|
|
63
|
+
let code = 0
|
|
64
|
+
try {
|
|
65
|
+
if (args[0] === '__complete') {
|
|
66
|
+
let words: readonly string[]
|
|
67
|
+
const [, mode, payload, ...extra] = args
|
|
68
|
+
if (mode === '--') words = args.slice(2)
|
|
69
|
+
else if (mode === '--encoded' && payload !== undefined && extra.length === 0) {
|
|
70
|
+
const decoded = parseJson(Buffer.from(payload, 'base64').toString('utf8'), 'completion')
|
|
71
|
+
checkInput<readonly string[]>(arrayInput(stringInput), decoded, 'completion')
|
|
72
|
+
words = decoded
|
|
73
|
+
} else throw new UsageError(messages().diagnostics.completionDelimiter)
|
|
74
|
+
const candidates = await completionCandidates(words)
|
|
75
|
+
await runtime.stdout(candidates.length === 0 ? '' : candidates.join('\n') + '\n')
|
|
76
|
+
return 0
|
|
77
|
+
}
|
|
78
|
+
const invocation = parse(args)
|
|
79
|
+
format = invocation.format
|
|
80
|
+
color = invocation.color
|
|
81
|
+
links = invocation.links
|
|
82
|
+
const entry = invocation.command
|
|
83
|
+
let text: string | undefined
|
|
84
|
+
let document: readonly HelpPart[] | undefined
|
|
85
|
+
if (
|
|
86
|
+
invocation.words[0] === 'completion' &&
|
|
87
|
+
(invocation.values.version !== true || invocation.values.help === true)
|
|
88
|
+
) {
|
|
89
|
+
if (invocation.words.length > 2)
|
|
90
|
+
throw new UsageError(messages().diagnostics.completionShellCount)
|
|
91
|
+
const shell = invocation.words[1]
|
|
92
|
+
if (invocation.values.help === true && shell !== undefined && !isCompletionShell(shell))
|
|
93
|
+
throw new UsageError(messages().diagnostics.shellChoice(COMPLETION_SHELLS))
|
|
94
|
+
if (shell === undefined || invocation.values.help === true) document = completionHelp()
|
|
95
|
+
else text = completionScript(shell, invocation.values.enhance === true)
|
|
96
|
+
} else if (
|
|
97
|
+
invocation.values.help === true ||
|
|
98
|
+
(entry === undefined && invocation.values.version !== true)
|
|
99
|
+
)
|
|
100
|
+
/**
|
|
101
|
+
* Words that name no command are a help path: `help` renders a command group's children and
|
|
102
|
+
* rejects anything else as unknown, so one authority decides what a word sequence means.
|
|
103
|
+
*
|
|
104
|
+
* 未对应命令的词序列按帮助路径处理:`help` 会渲染命令分组的子命令,
|
|
105
|
+
* 其余一律判为未知命令,从而由同一处裁决词序列的含义。
|
|
106
|
+
*/
|
|
107
|
+
document = help(invocation.words, await entry?.load())
|
|
108
|
+
const source = createInputSource(runtime.stdin)
|
|
109
|
+
const select = stringOption(invocation.values, 'select')
|
|
110
|
+
if ((text !== undefined || document !== undefined) && select !== undefined)
|
|
111
|
+
throw new UsageError(messages().diagnostics.selectStructuredOnly)
|
|
112
|
+
const selection = await parseSelection(select, source)
|
|
113
|
+
const outputFile = stringOption(invocation.values, 'output')
|
|
114
|
+
const presentation =
|
|
115
|
+
format === 'json' || (outputFile !== undefined && outputFile !== '-')
|
|
116
|
+
? PLAIN
|
|
117
|
+
: resolvePresentation(color, links, runtime.stdoutPresentation)
|
|
118
|
+
destination = await prepareOutput(outputFile, runtime.stdout)
|
|
119
|
+
if (document !== undefined) {
|
|
120
|
+
output = renderHelp(document)
|
|
121
|
+
text = renderHelp(document, presentation)
|
|
122
|
+
} else if (text === undefined) {
|
|
123
|
+
let value: unknown
|
|
124
|
+
/**
|
|
125
|
+
* Version output needs no command, so a request for it and the absence of a command are the
|
|
126
|
+
* same branch here; every other word sequence produced a help document or an error above.
|
|
127
|
+
*
|
|
128
|
+
* 版本输出不需要命令,因此「请求版本」与「没有可执行的命令」在这里是同一分支;
|
|
129
|
+
* 其余词序列已在上方生成帮助文档或报错。
|
|
130
|
+
*/
|
|
131
|
+
if (invocation.values.version === true || entry === undefined) {
|
|
132
|
+
const { cliVersion, sdkVersion } = await import('./version.ts')
|
|
133
|
+
value = { cliVersion, sdkVersion }
|
|
134
|
+
} else {
|
|
135
|
+
const command = await entry.load()
|
|
136
|
+
const baseInput = await inputDocument(invocation.values, source)
|
|
137
|
+
let input = await businessInput(command, invocation.values, baseInput, source)
|
|
138
|
+
let result: CommandResult
|
|
139
|
+
if (command.session) {
|
|
140
|
+
const connection = await connect(invocation, source, runtime.fetch)
|
|
141
|
+
session = connection.session
|
|
142
|
+
if (command.method === 'publicLogin' || command.method === 'adminLogin') {
|
|
143
|
+
input = { ...input }
|
|
144
|
+
if (input.password === undefined) input.password = connection.input.password
|
|
145
|
+
if (command.method === 'publicLogin' && input.username === undefined)
|
|
146
|
+
input.username = connection.input.username
|
|
147
|
+
}
|
|
148
|
+
result = await invoke(command, session, input)
|
|
149
|
+
} else result = command.execute(input)
|
|
150
|
+
code = partialSnapshot(result) ? 1 : 0
|
|
151
|
+
value = { result, session: sessionInfo(session) }
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const full = serialize(value)
|
|
155
|
+
const selected = selectOutput(full, selection)
|
|
156
|
+
output = selected
|
|
157
|
+
text = renderSerialized(selected, format, presentation)
|
|
158
|
+
} catch (error) {
|
|
159
|
+
throw new OutputError(messages().diagnostics.outputSelectFormat, error)
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
output = text
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
await destination.write(text)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
throw new OutputError(messages().diagnostics.outputWrite, error)
|
|
168
|
+
}
|
|
169
|
+
return code
|
|
170
|
+
} catch (error) {
|
|
171
|
+
/**
|
|
172
|
+
* Cleanup failure only adds context to the diagnostic; the exit code still reports the
|
|
173
|
+
* failure that ended the invocation.
|
|
174
|
+
*
|
|
175
|
+
* 清理失败只为诊断补充上下文;退出码仍报告导致本次调用结束的那个失败。
|
|
176
|
+
*/
|
|
177
|
+
let failure = error
|
|
178
|
+
try {
|
|
179
|
+
await destination?.close()
|
|
180
|
+
} catch (cleanup) {
|
|
181
|
+
const combined = new AggregateError(
|
|
182
|
+
[error, cleanup],
|
|
183
|
+
messages().diagnostics.operationAndCleanup,
|
|
184
|
+
)
|
|
185
|
+
failure = error instanceof OutputError ? new OutputError(error.message, combined) : combined
|
|
186
|
+
}
|
|
187
|
+
await runtime.stderr(
|
|
188
|
+
render(
|
|
189
|
+
{
|
|
190
|
+
error: failure,
|
|
191
|
+
session: sessionInfo(session),
|
|
192
|
+
...(output === undefined ? {} : { output }),
|
|
193
|
+
},
|
|
194
|
+
format,
|
|
195
|
+
{ ...resolvePresentation(color, links, runtime.stderrPresentation), error: true },
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
return error instanceof UsageError ? 2 : 1
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Stdin is consumed only by explicit - or @- input sources.
|
|
204
|
+
*
|
|
205
|
+
* 仅显式的 - 或 @- 输入来源读取标准输入。
|
|
206
|
+
*/
|
|
207
|
+
export async function standardInput(
|
|
208
|
+
input: AsyncIterable<string | Buffer> = process.stdin,
|
|
209
|
+
): Promise<string> {
|
|
210
|
+
const chunks: Buffer[] = []
|
|
211
|
+
for await (const chunk of input)
|
|
212
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)
|
|
213
|
+
return Buffer.concat(chunks).toString('utf8')
|
|
214
|
+
}
|
package/src/selection.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { messages } from './i18n.ts'
|
|
2
|
+
import type { InputSource } from './input/files.ts'
|
|
3
|
+
import { readArgument } from './input/files.ts'
|
|
4
|
+
import { isObject } from './input/values.ts'
|
|
5
|
+
import { parsePointer, selectPointer } from './pointer.ts'
|
|
6
|
+
import { UsageError } from './result.ts'
|
|
7
|
+
import type { Json } from './types.ts'
|
|
8
|
+
|
|
9
|
+
export type Selection = readonly string[] | Readonly<Record<string, readonly string[]>>
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One pointer keeps its selected value; an alias map explicitly shapes an output object.
|
|
13
|
+
*
|
|
14
|
+
* 单指针保留所选值;别名映射明确指定输出对象的结构。
|
|
15
|
+
*/
|
|
16
|
+
export async function parseSelection(
|
|
17
|
+
source: string | undefined,
|
|
18
|
+
read: InputSource,
|
|
19
|
+
): Promise<Selection | undefined> {
|
|
20
|
+
if (source === undefined) return undefined
|
|
21
|
+
if (source === '' || source.startsWith('/')) return parsePointer(source)
|
|
22
|
+
const mapping = await readArgument(source, 'select', read)
|
|
23
|
+
if (typeof mapping === 'string') return parsePointer(mapping)
|
|
24
|
+
if (!isObject(mapping)) throw new UsageError(messages().diagnostics.selectionShape)
|
|
25
|
+
return Object.fromEntries(
|
|
26
|
+
Object.entries(mapping).map(([alias, pointer]) => {
|
|
27
|
+
if (typeof pointer !== 'string')
|
|
28
|
+
throw new UsageError(messages().diagnostics.selectionAlias(alias))
|
|
29
|
+
return [alias, parsePointer(pointer)]
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isPointer(selection: Selection): selection is readonly string[] {
|
|
35
|
+
return Array.isArray(selection)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function selectOutput(value: Json, selection: Selection | undefined): Json {
|
|
39
|
+
if (selection === undefined) return value
|
|
40
|
+
if (isPointer(selection)) return selectPointer(value, selection)
|
|
41
|
+
return Object.fromEntries(
|
|
42
|
+
Object.entries(selection).map(([alias, parts]) => [alias, selectPointer(value, parts)]),
|
|
43
|
+
)
|
|
44
|
+
}
|
package/src/terminal.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Presentation } from './presentation.ts'
|
|
2
|
+
|
|
3
|
+
type Terminal = {
|
|
4
|
+
isTTY?: boolean
|
|
5
|
+
hasColors: () => boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Automatic presentation uses each stream's capabilities without querying terminal input.
|
|
10
|
+
*
|
|
11
|
+
* 自动呈现按各输出流的能力启用,不读取终端输入来探测支持情况。
|
|
12
|
+
*/
|
|
13
|
+
export function terminalPresentation(
|
|
14
|
+
stream: Terminal,
|
|
15
|
+
environment: Readonly<Record<string, string | undefined>>,
|
|
16
|
+
): Presentation {
|
|
17
|
+
const interactive = stream.isTTY === true && environment.TERM !== 'dumb'
|
|
18
|
+
return {
|
|
19
|
+
color: interactive && stream.hasColors(),
|
|
20
|
+
links:
|
|
21
|
+
interactive &&
|
|
22
|
+
!environment.TMUX &&
|
|
23
|
+
!environment.STY &&
|
|
24
|
+
(Boolean(environment.WT_SESSION) ||
|
|
25
|
+
['iTerm.app', 'WezTerm', 'vscode', 'mintty'].includes(environment.TERM_PROGRAM ?? '')),
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LoginCredentials,
|
|
3
|
+
Observed,
|
|
4
|
+
PlanetReference,
|
|
5
|
+
Session,
|
|
6
|
+
SnapshotRequest,
|
|
7
|
+
} from '@senators/bifrost'
|
|
8
|
+
import type * as sdk from '@senators/bifrost'
|
|
9
|
+
|
|
10
|
+
import type { InputNode } from './input/spec.ts'
|
|
11
|
+
import type { commands as englishCommands } from './locales/en-US/commands.ts'
|
|
12
|
+
|
|
13
|
+
export type Primitive = string | number | boolean | null
|
|
14
|
+
export type Json = Primitive | Json[] | { [key: string]: Json }
|
|
15
|
+
export type Format = 'text' | 'json'
|
|
16
|
+
export const FORMATS: readonly Format[] = ['text', 'json']
|
|
17
|
+
export type Fields = Record<string, unknown>
|
|
18
|
+
export type SnapshotDescriptor = { command: string; input?: Fields }
|
|
19
|
+
export type ExtensionFactory = (
|
|
20
|
+
descriptor: SnapshotDescriptor,
|
|
21
|
+
planet?: PlanetReference,
|
|
22
|
+
) => Promise<SnapshotRequest['read']>
|
|
23
|
+
type API = typeof sdk
|
|
24
|
+
/**
|
|
25
|
+
* Registered method names must resolve to an SDK function.
|
|
26
|
+
*
|
|
27
|
+
* 注册的方法名必须对应 SDK 函数。
|
|
28
|
+
*/
|
|
29
|
+
export type SDKMethod = {
|
|
30
|
+
[K in keyof API]: API[K] extends (...args: never[]) => unknown ? K : never
|
|
31
|
+
}[keyof API]
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A registered method: an SDK function that also has an entry in the English command catalogue.
|
|
35
|
+
*
|
|
36
|
+
* 已注册的方法:既是 SDK 函数,又在英文命令目录中有条目。
|
|
37
|
+
*/
|
|
38
|
+
export type CommandMethod = SDKMethod & keyof typeof englishCommands
|
|
39
|
+
export type CommandResult = Awaited<ReturnType<API[CommandMethod]>>
|
|
40
|
+
export type ObservedResult = Extract<CommandResult, Observed<{ kind: string }>>
|
|
41
|
+
export type PreparedRead = (session: Session) => Promise<ObservedResult>
|
|
42
|
+
type CommandInfo = {
|
|
43
|
+
name: string
|
|
44
|
+
method: CommandMethod
|
|
45
|
+
input: InputNode
|
|
46
|
+
}
|
|
47
|
+
export type NetworkCommand = CommandInfo &
|
|
48
|
+
(
|
|
49
|
+
| {
|
|
50
|
+
session: true
|
|
51
|
+
extension: true
|
|
52
|
+
prepare: (input: unknown) => PreparedRead
|
|
53
|
+
execute: (session: Session, input: unknown) => Promise<ObservedResult>
|
|
54
|
+
/**
|
|
55
|
+
* Bind an extension to its snapshot planet using the command's explicit input location.
|
|
56
|
+
*
|
|
57
|
+
* 根据命令明确声明的输入位置,将扩展绑定至快照星球。
|
|
58
|
+
*/
|
|
59
|
+
planet?: 'planetId' | 'origin'
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
session: true
|
|
63
|
+
extension: false
|
|
64
|
+
planet?: never
|
|
65
|
+
execute: (session: Session, input: unknown) => CommandResult | Promise<CommandResult>
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
export type OfflineCommand = CommandInfo & {
|
|
69
|
+
session: false
|
|
70
|
+
extension: false
|
|
71
|
+
planet?: never
|
|
72
|
+
execute: (input: unknown) => CommandResult
|
|
73
|
+
}
|
|
74
|
+
export type SnapshotCommand = CommandInfo & {
|
|
75
|
+
session: true
|
|
76
|
+
extension: false
|
|
77
|
+
planet?: never
|
|
78
|
+
execute: (
|
|
79
|
+
session: Session,
|
|
80
|
+
input: unknown,
|
|
81
|
+
extension: ExtensionFactory,
|
|
82
|
+
) => Promise<Extract<CommandResult, { kind: 'planetSnapshot' | 'accountSnapshot' }>>
|
|
83
|
+
}
|
|
84
|
+
export type Command = NetworkCommand | OfflineCommand | SnapshotCommand
|
|
85
|
+
export type SessionInput = {
|
|
86
|
+
baseUrl: string
|
|
87
|
+
universe: number
|
|
88
|
+
sessionToken?: string
|
|
89
|
+
forwardedIp?: string
|
|
90
|
+
} & ((LoginCredentials & { autoLogin: true }) | (Partial<LoginCredentials> & { autoLogin?: false }))
|
|
91
|
+
export type SessionInfo = { baseUrl: string; universe: number; sessionToken: string }
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* CLI input and output error codes; SDK failures retain their own codes.
|
|
95
|
+
*
|
|
96
|
+
* CLI 输入与输出错误码;SDK 失败保留自身错误码。
|
|
97
|
+
*/
|
|
98
|
+
export const ErrorCode = {
|
|
99
|
+
UsageError: 'usage',
|
|
100
|
+
OutputError: 'output',
|
|
101
|
+
} as const
|
|
102
|
+
|
|
103
|
+
export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Arguments that carry a JSON document, plus the two reference kinds that can supply one.
|
|
107
|
+
*
|
|
108
|
+
* 携带 JSON 文档的参数,以及可提供文档的两种引用来源。
|
|
109
|
+
*/
|
|
110
|
+
export type JsonSource = 'input' | 'select' | 'session' | 'completion' | 'stdin' | 'file'
|
package/src/version.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { findPackageJSON } from 'node:module'
|
|
3
|
+
|
|
4
|
+
const sdkPackage = findPackageJSON(import.meta.resolve('@senators/bifrost'))
|
|
5
|
+
const cli: { version: string } = JSON.parse(
|
|
6
|
+
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
|
|
7
|
+
)
|
|
8
|
+
const sdk: { version: string } = JSON.parse(readFileSync(sdkPackage!, 'utf8'))
|
|
9
|
+
|
|
10
|
+
export const cliVersion: string = cli.version
|
|
11
|
+
export const sdkVersion: string = sdk.version
|