@credibledata/cred-cli 0.0.103 → 0.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -1
- package/dist/agent-contract.spec.js +548 -0
- package/dist/agent-contract.spec.js.map +1 -0
- package/dist/browser.js +72 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.spec.js +125 -0
- package/dist/browser.spec.js.map +1 -0
- package/dist/client/api.js +4137 -1159
- package/dist/client/api.js.map +1 -1
- package/dist/client-codeassist/api.js +476 -0
- package/dist/client-codeassist/api.js.map +1 -0
- package/dist/client-codeassist/base.js +69 -0
- package/dist/client-codeassist/base.js.map +1 -0
- package/dist/client-codeassist/common.js +162 -0
- package/dist/client-codeassist/common.js.map +1 -0
- package/dist/client-codeassist/configuration.js +44 -0
- package/dist/client-codeassist/configuration.js.map +1 -0
- package/dist/client-codeassist/index.js +32 -0
- package/dist/client-codeassist/index.js.map +1 -0
- package/dist/clientconfiguration.js +17 -289
- package/dist/clientconfiguration.js.map +1 -1
- package/dist/clientconfiguration.spec.js +35 -96
- package/dist/clientconfiguration.spec.js.map +1 -1
- package/dist/commands/add.js +103 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.spec.js +113 -0
- package/dist/commands/add.spec.js.map +1 -0
- package/dist/commands/connection/createconnections.js +104 -7
- package/dist/commands/connection/createconnections.js.map +1 -1
- package/dist/commands/connection/createconnections.spec.js +35 -1
- package/dist/commands/connection/createconnections.spec.js.map +1 -1
- package/dist/commands/connection/deleteconnection.js +4 -2
- package/dist/commands/connection/deleteconnection.js.map +1 -1
- package/dist/commands/connection/deleteconnection.spec.js +6 -1
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
- package/dist/commands/connection/listconnections.js +2 -0
- package/dist/commands/connection/listconnections.js.map +1 -1
- package/dist/commands/connection/updateconnection.js +365 -0
- package/dist/commands/connection/updateconnection.js.map +1 -0
- package/dist/commands/connection/updateconnection.spec.js +625 -0
- package/dist/commands/connection/updateconnection.spec.js.map +1 -0
- package/dist/commands/database/createdatabase.js +52 -0
- package/dist/commands/database/createdatabase.js.map +1 -0
- package/dist/commands/database/database.spec.js +267 -0
- package/dist/commands/database/database.spec.js.map +1 -0
- package/dist/commands/database/deletedatabase.js +91 -0
- package/dist/commands/database/deletedatabase.js.map +1 -0
- package/dist/commands/database/getdatabase.js +97 -0
- package/dist/commands/database/getdatabase.js.map +1 -0
- package/dist/commands/database/listdatabases.js +36 -0
- package/dist/commands/database/listdatabases.js.map +1 -0
- package/dist/commands/database/shared.js +125 -0
- package/dist/commands/database/shared.js.map +1 -0
- package/dist/commands/database/shared.spec.js +109 -0
- package/dist/commands/database/shared.spec.js.map +1 -0
- package/dist/commands/database/updatedatabase.js +39 -0
- package/dist/commands/database/updatedatabase.js.map +1 -0
- package/dist/commands/environment/createenvironment.js +59 -28
- package/dist/commands/environment/createenvironment.js.map +1 -1
- package/dist/commands/environment/createenvironment.spec.js +29 -0
- package/dist/commands/environment/createenvironment.spec.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.js +3 -2
- package/dist/commands/environment/deleteenvironment.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.spec.js +5 -1
- package/dist/commands/environment/deleteenvironment.spec.js.map +1 -1
- package/dist/commands/environment/getenvironment.js +1 -0
- package/dist/commands/environment/getenvironment.js.map +1 -1
- package/dist/commands/environment/listenvironments.js +40 -8
- package/dist/commands/environment/listenvironments.js.map +1 -1
- package/dist/commands/environment/listenvironments.spec.js +41 -2
- package/dist/commands/environment/listenvironments.spec.js.map +1 -1
- package/dist/commands/environment/setenvironment.js +145 -6
- package/dist/commands/environment/setenvironment.js.map +1 -1
- package/dist/commands/environment/setenvironment.spec.js +256 -8
- package/dist/commands/environment/setenvironment.spec.js.map +1 -1
- package/dist/commands/environment/updateenvironment.js +12 -8
- package/dist/commands/environment/updateenvironment.js.map +1 -1
- package/dist/commands/environment/updateenvironment.spec.js +36 -2
- package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
- package/dist/commands/get.js +64 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/group/addmember.js +3 -1
- package/dist/commands/group/addmember.js.map +1 -1
- package/dist/commands/group/addmember.spec.js +7 -2
- package/dist/commands/group/addmember.spec.js.map +1 -1
- package/dist/commands/group/creategroup.js +2 -0
- package/dist/commands/group/creategroup.js.map +1 -1
- package/dist/commands/group/deletegroup.js +3 -1
- package/dist/commands/group/deletegroup.js.map +1 -1
- package/dist/commands/group/deletegroup.spec.js +7 -1
- package/dist/commands/group/deletegroup.spec.js.map +1 -1
- package/dist/commands/group/getgroup.js +2 -0
- package/dist/commands/group/getgroup.js.map +1 -1
- package/dist/commands/group/listgroups.js +2 -0
- package/dist/commands/group/listgroups.js.map +1 -1
- package/dist/commands/group/removemember.js +3 -1
- package/dist/commands/group/removemember.js.map +1 -1
- package/dist/commands/group/removemember.spec.js +7 -2
- package/dist/commands/group/removemember.spec.js.map +1 -1
- package/dist/commands/groupaccesstoken/deleteToken.js +2 -1
- package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
- package/dist/commands/groupaccesstoken/groupContainer.js +2 -0
- package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
- package/dist/commands/list.js +24 -4
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/materialization/cancelrun.js +3 -1
- package/dist/commands/materialization/cancelrun.js.map +1 -1
- package/dist/commands/materialization/getindex.js +2 -0
- package/dist/commands/materialization/getindex.js.map +1 -1
- package/dist/commands/materialization/getmaterialization.js +2 -0
- package/dist/commands/materialization/getmaterialization.js.map +1 -1
- package/dist/commands/materialization/getpreaggregate.js +2 -0
- package/dist/commands/materialization/getpreaggregate.js.map +1 -1
- package/dist/commands/materialization/getrun.js +2 -0
- package/dist/commands/materialization/getrun.js.map +1 -1
- package/dist/commands/materialization/listindexes.js +2 -0
- package/dist/commands/materialization/listindexes.js.map +1 -1
- package/dist/commands/materialization/listmaterializations.js +2 -0
- package/dist/commands/materialization/listmaterializations.js.map +1 -1
- package/dist/commands/materialization/listpreaggregates.js +2 -0
- package/dist/commands/materialization/listpreaggregates.js.map +1 -1
- package/dist/commands/materialization/listruns.js +3 -1
- package/dist/commands/materialization/listruns.js.map +1 -1
- package/dist/commands/materialization/rerun.js +3 -1
- package/dist/commands/materialization/rerun.js.map +1 -1
- package/dist/commands/misc/inquirerHost.js +87 -0
- package/dist/commands/misc/inquirerHost.js.map +1 -0
- package/dist/commands/misc/inquirerHost.spec.js +91 -0
- package/dist/commands/misc/inquirerHost.spec.js.map +1 -0
- package/dist/commands/misc/login.js +348 -58
- package/dist/commands/misc/login.js.map +1 -1
- package/dist/commands/misc/login.spec.js +525 -7
- package/dist/commands/misc/login.spec.js.map +1 -1
- package/dist/commands/misc/logout.js +26 -3
- package/dist/commands/misc/logout.js.map +1 -1
- package/dist/commands/misc/logout.spec.js +52 -12
- package/dist/commands/misc/logout.spec.js.map +1 -1
- package/dist/commands/misc/resolveLoginTarget.spec.js +90 -0
- package/dist/commands/misc/resolveLoginTarget.spec.js.map +1 -0
- package/dist/commands/misc/scope.spec.js +108 -0
- package/dist/commands/misc/scope.spec.js.map +1 -0
- package/dist/commands/misc/set-access-token.js +1 -1
- package/dist/commands/misc/set-access-token.js.map +1 -1
- package/dist/commands/misc/set-access-token.spec.js +13 -2
- package/dist/commands/misc/set-access-token.spec.js.map +1 -1
- package/dist/commands/misc/setup.js +819 -0
- package/dist/commands/misc/setup.js.map +1 -0
- package/dist/commands/misc/setup.spec.js +783 -0
- package/dist/commands/misc/setup.spec.js.map +1 -0
- package/dist/commands/misc/status.js +168 -0
- package/dist/commands/misc/status.js.map +1 -0
- package/dist/commands/misc/status.spec.js +301 -0
- package/dist/commands/misc/status.spec.js.map +1 -0
- package/dist/commands/misc/token.js +57 -0
- package/dist/commands/misc/token.js.map +1 -0
- package/dist/commands/misc/token.spec.js +92 -0
- package/dist/commands/misc/token.spec.js.map +1 -0
- package/dist/commands/package/deletepackage.js +4 -2
- package/dist/commands/package/deletepackage.js.map +1 -1
- package/dist/commands/package/deletepackage.spec.js +7 -1
- package/dist/commands/package/deletepackage.spec.js.map +1 -1
- package/dist/commands/package/getpackage.js +142 -0
- package/dist/commands/package/getpackage.js.map +1 -0
- package/dist/commands/package/getpackage.spec.js +246 -0
- package/dist/commands/package/getpackage.spec.js.map +1 -0
- package/dist/commands/package/listpackages.js +2 -0
- package/dist/commands/package/listpackages.js.map +1 -1
- package/dist/commands/package/publish.archive.spec.js +570 -0
- package/dist/commands/package/publish.archive.spec.js.map +1 -0
- package/dist/commands/package/publish.js +780 -49
- package/dist/commands/package/publish.js.map +1 -1
- package/dist/commands/package/publish.spec.js +451 -8
- package/dist/commands/package/publish.spec.js.map +1 -1
- package/dist/commands/package/updatepackage.js +22 -19
- package/dist/commands/package/updatepackage.js.map +1 -1
- package/dist/commands/package/updatepackage.spec.js +36 -1
- package/dist/commands/package/updatepackage.spec.js.map +1 -1
- package/dist/commands/permission/createpermission.js +3 -1
- package/dist/commands/permission/createpermission.js.map +1 -1
- package/dist/commands/permission/deletepermission.js +6 -3
- package/dist/commands/permission/deletepermission.js.map +1 -1
- package/dist/commands/permission/getpermission.js +2 -0
- package/dist/commands/permission/getpermission.js.map +1 -1
- package/dist/commands/permission/listpermissions.js +2 -0
- package/dist/commands/permission/listpermissions.js.map +1 -1
- package/dist/commands/rm.js +21 -0
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/set.js +40 -6
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/set.spec.js +123 -0
- package/dist/commands/set.spec.js.map +1 -0
- package/dist/commands/table/addtable.js +155 -0
- package/dist/commands/table/addtable.js.map +1 -0
- package/dist/commands/table/deletetable.js +45 -0
- package/dist/commands/table/deletetable.js.map +1 -0
- package/dist/commands/table/gettable.js +32 -0
- package/dist/commands/table/gettable.js.map +1 -0
- package/dist/commands/table/listtables.js +36 -0
- package/dist/commands/table/listtables.js.map +1 -0
- package/dist/commands/table/table.spec.js +304 -0
- package/dist/commands/table/table.spec.js.map +1 -0
- package/dist/commands/table/tablefile.js +195 -0
- package/dist/commands/table/tablefile.js.map +1 -0
- package/dist/commands/table/tablefile.spec.js +158 -0
- package/dist/commands/table/tablefile.spec.js.map +1 -0
- package/dist/commands/update.js +21 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.js +4 -2
- package/dist/commands/version/archive-unarchive-version.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.spec.js +6 -1
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
- package/dist/commands/version/listversions.js +2 -0
- package/dist/commands/version/listversions.js.map +1 -1
- package/dist/common/UserGroupId.js +9 -4
- package/dist/common/UserGroupId.js.map +1 -1
- package/dist/common/UserGroupId.spec.js +5 -0
- package/dist/common/UserGroupId.spec.js.map +1 -1
- package/dist/constants.js +37 -143
- package/dist/constants.js.map +1 -1
- package/dist/index.js +487 -90
- package/dist/index.js.map +1 -1
- package/dist/logger.js +42 -9
- package/dist/logger.js.map +1 -1
- package/dist/session.js +56 -0
- package/dist/session.js.map +1 -0
- package/dist/session.spec.js +103 -0
- package/dist/session.spec.js.map +1 -0
- package/dist/setup-core/briefing.js +176 -0
- package/dist/setup-core/briefing.js.map +1 -0
- package/dist/setup-core/credstore.js +415 -0
- package/dist/setup-core/credstore.js.map +1 -0
- package/dist/setup-core/credstore.spec.js +238 -0
- package/dist/setup-core/credstore.spec.js.map +1 -0
- package/dist/setup-core/environments.js +267 -0
- package/dist/setup-core/environments.js.map +1 -0
- package/dist/setup-core/flow.e2e.js +165 -0
- package/dist/setup-core/flow.e2e.js.map +1 -0
- package/dist/setup-core/flow.js +765 -0
- package/dist/setup-core/flow.js.map +1 -0
- package/dist/setup-core/flow.spec.js +1348 -0
- package/dist/setup-core/flow.spec.js.map +1 -0
- package/dist/setup-core/folderconfig.js +283 -0
- package/dist/setup-core/folderconfig.js.map +1 -0
- package/dist/setup-core/git.js +97 -0
- package/dist/setup-core/git.js.map +1 -0
- package/dist/setup-core/host.js +77 -0
- package/dist/setup-core/host.js.map +1 -0
- package/dist/setup-core/importconnections.js +470 -0
- package/dist/setup-core/importconnections.js.map +1 -0
- package/dist/setup-core/importconnections.spec.js +594 -0
- package/dist/setup-core/importconnections.spec.js.map +1 -0
- package/dist/setup-core/liveness.js +94 -0
- package/dist/setup-core/liveness.js.map +1 -0
- package/dist/setup-core/liveness.spec.js +59 -0
- package/dist/setup-core/liveness.spec.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.js +26 -0
- package/dist/setup-core/localpublisherconfig.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.spec.js +29 -0
- package/dist/setup-core/localpublisherconfig.spec.js.map +1 -0
- package/dist/setup-core/mcpconfig.js +198 -0
- package/dist/setup-core/mcpconfig.js.map +1 -0
- package/dist/setup-core/mcpconfig.spec.js +205 -0
- package/dist/setup-core/mcpconfig.spec.js.map +1 -0
- package/dist/setup-core/packagemanifest.js +55 -0
- package/dist/setup-core/packagemanifest.js.map +1 -0
- package/dist/setup-core/ports.js +182 -0
- package/dist/setup-core/ports.js.map +1 -0
- package/dist/setup-core/ports.spec.js +173 -0
- package/dist/setup-core/ports.spec.js.map +1 -0
- package/dist/setup-core/publisherconfig.js +268 -0
- package/dist/setup-core/publisherconfig.js.map +1 -0
- package/dist/setup-core/publisherconfig.oracle.js +166 -0
- package/dist/setup-core/publisherconfig.oracle.js.map +1 -0
- package/dist/setup-core/publisherconfig.spec.js +277 -0
- package/dist/setup-core/publisherconfig.spec.js.map +1 -0
- package/dist/setup-core/publisherversion.js +26 -0
- package/dist/setup-core/publisherversion.js.map +1 -0
- package/dist/setup-core/readiness.spec.js +161 -0
- package/dist/setup-core/readiness.spec.js.map +1 -0
- package/dist/setup-core/readylines.js +169 -0
- package/dist/setup-core/readylines.js.map +1 -0
- package/dist/setup-core/readylines.spec.js +70 -0
- package/dist/setup-core/readylines.spec.js.map +1 -0
- package/dist/setup-core/refresh.js +348 -0
- package/dist/setup-core/refresh.js.map +1 -0
- package/dist/setup-core/refresh.spec.js +501 -0
- package/dist/setup-core/refresh.spec.js.map +1 -0
- package/dist/setup-core/skills.js +279 -0
- package/dist/setup-core/skills.js.map +1 -0
- package/dist/setup-core/skills.spec.js +334 -0
- package/dist/setup-core/skills.spec.js.map +1 -0
- package/dist/setup-core/supervisor.js +879 -0
- package/dist/setup-core/supervisor.js.map +1 -0
- package/dist/setup-core/supervisor.spec.js +833 -0
- package/dist/setup-core/supervisor.spec.js.map +1 -0
- package/dist/setup-core/writefile.js +61 -0
- package/dist/setup-core/writefile.js.map +1 -0
- package/dist/setup-core/writefile.spec.js +68 -0
- package/dist/setup-core/writefile.spec.js.map +1 -0
- package/dist/utils.js +409 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.spec.js +373 -2
- package/dist/utils.spec.js.map +1 -1
- package/dist/versioncheck-refresh.js +18 -0
- package/dist/versioncheck-refresh.js.map +1 -0
- package/dist/versioncheck.js +324 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/versioncheck.spec.js +587 -0
- package/dist/versioncheck.spec.js.map +1 -0
- package/node_modules/@credibledata/cli-auth/dist/index.d.ts +86 -0
- package/node_modules/@credibledata/cli-auth/dist/index.js +102 -0
- package/node_modules/@credibledata/cli-auth/package.json +19 -0
- package/package.json +18 -6
- package/.github/workflows/build.yml +0 -23
- package/.mocharc.json +0 -10
- package/.prettierignore +0 -2
- package/.prettierrc +0 -4
- package/README-DEV.md +0 -40
- package/coverage/coverage-summary.json +0 -40
- package/coverage/tmp/coverage-2152-1789496974457-0.json +0 -1
- package/coverage/tmp/coverage-2153-1789496954404-0.json +0 -1
- package/docker/Dockerfile.ci +0 -18
- package/docker-compose.yml +0 -18
- package/eslint.config.mjs +0 -45
- package/generate-client.sh +0 -27
- package/mocha.setup.ts +0 -4
- package/openapitools.json +0 -10
- package/src/client/.openapi-generator/FILES +0 -9
- package/src/client/.openapi-generator/VERSION +0 -1
- package/src/client/.openapi-generator-ignore +0 -23
- package/src/client/api.ts +0 -15999
- package/src/client/base.ts +0 -86
- package/src/client/common.ts +0 -150
- package/src/client/configuration.ts +0 -110
- package/src/client/git_push.sh +0 -57
- package/src/client/index.ts +0 -18
- package/src/clientconfiguration.spec.ts +0 -615
- package/src/clientconfiguration.ts +0 -364
- package/src/commands/add.ts +0 -191
- package/src/commands/connection/createconnections.spec.ts +0 -413
- package/src/commands/connection/createconnections.ts +0 -109
- package/src/commands/connection/deleteconnection.spec.ts +0 -189
- package/src/commands/connection/deleteconnection.ts +0 -57
- package/src/commands/connection/listconnections.spec.ts +0 -132
- package/src/commands/connection/listconnections.ts +0 -58
- package/src/commands/environment/createenvironment.spec.ts +0 -249
- package/src/commands/environment/createenvironment.ts +0 -73
- package/src/commands/environment/deleteenvironment.spec.ts +0 -152
- package/src/commands/environment/deleteenvironment.ts +0 -48
- package/src/commands/environment/getenvironment.spec.ts +0 -110
- package/src/commands/environment/getenvironment.ts +0 -43
- package/src/commands/environment/listenvironments.spec.ts +0 -123
- package/src/commands/environment/listenvironments.ts +0 -67
- package/src/commands/environment/setenvironment.spec.ts +0 -63
- package/src/commands/environment/setenvironment.ts +0 -14
- package/src/commands/environment/updateenvironment.spec.ts +0 -386
- package/src/commands/environment/updateenvironment.ts +0 -168
- package/src/commands/get.ts +0 -153
- package/src/commands/group/addmember.spec.ts +0 -257
- package/src/commands/group/addmember.ts +0 -85
- package/src/commands/group/creategroup.spec.ts +0 -146
- package/src/commands/group/creategroup.ts +0 -54
- package/src/commands/group/deletegroup.spec.ts +0 -120
- package/src/commands/group/deletegroup.ts +0 -45
- package/src/commands/group/getgroup.spec.ts +0 -129
- package/src/commands/group/getgroup.ts +0 -47
- package/src/commands/group/listgroups.spec.ts +0 -137
- package/src/commands/group/listgroups.ts +0 -45
- package/src/commands/group/removemember.spec.ts +0 -224
- package/src/commands/group/removemember.ts +0 -75
- package/src/commands/groupaccesstoken/createToken.spec.ts +0 -211
- package/src/commands/groupaccesstoken/createToken.ts +0 -72
- package/src/commands/groupaccesstoken/deleteToken.spec.ts +0 -147
- package/src/commands/groupaccesstoken/deleteToken.ts +0 -29
- package/src/commands/groupaccesstoken/groupContainer.ts +0 -83
- package/src/commands/groupaccesstoken/listTokens.spec.ts +0 -147
- package/src/commands/groupaccesstoken/listTokens.ts +0 -29
- package/src/commands/legacy.ts +0 -5
- package/src/commands/list.ts +0 -326
- package/src/commands/materialization/cancelrun.ts +0 -70
- package/src/commands/materialization/getindex.ts +0 -55
- package/src/commands/materialization/getmaterialization.ts +0 -57
- package/src/commands/materialization/getpreaggregate.ts +0 -58
- package/src/commands/materialization/getrun.ts +0 -55
- package/src/commands/materialization/listindexes.ts +0 -69
- package/src/commands/materialization/listmaterializations.ts +0 -53
- package/src/commands/materialization/listpreaggregates.ts +0 -74
- package/src/commands/materialization/listruns.ts +0 -77
- package/src/commands/materialization/rerun.ts +0 -123
- package/src/commands/misc/login.spec.ts +0 -371
- package/src/commands/misc/login.ts +0 -343
- package/src/commands/misc/logout.spec.ts +0 -32
- package/src/commands/misc/logout.ts +0 -9
- package/src/commands/misc/loopbackOAuth.ts +0 -127
- package/src/commands/misc/set-access-token.spec.ts +0 -95
- package/src/commands/misc/set-access-token.ts +0 -32
- package/src/commands/package/deletepackage.spec.ts +0 -164
- package/src/commands/package/deletepackage.ts +0 -58
- package/src/commands/package/listpackages.spec.ts +0 -163
- package/src/commands/package/listpackages.ts +0 -74
- package/src/commands/package/publish.spec.ts +0 -642
- package/src/commands/package/publish.ts +0 -236
- package/src/commands/package/updatepackage.spec.ts +0 -319
- package/src/commands/package/updatepackage.ts +0 -95
- package/src/commands/permission/createpermission.spec.ts +0 -507
- package/src/commands/permission/createpermission.ts +0 -181
- package/src/commands/permission/deletepermission.ts +0 -117
- package/src/commands/permission/getpermission.ts +0 -115
- package/src/commands/permission/listpermissions.ts +0 -101
- package/src/commands/permission/scope.ts +0 -180
- package/src/commands/rm.ts +0 -146
- package/src/commands/set.ts +0 -25
- package/src/commands/update.ts +0 -107
- package/src/commands/version/archive-unarchive-version.spec.ts +0 -456
- package/src/commands/version/archive-unarchive-version.ts +0 -108
- package/src/commands/version/listversions.spec.ts +0 -138
- package/src/commands/version/listversions.ts +0 -45
- package/src/common/UserGroupId.spec.ts +0 -115
- package/src/common/UserGroupId.ts +0 -137
- package/src/constants.spec.ts +0 -111
- package/src/constants.ts +0 -228
- package/src/index.ts +0 -378
- package/src/logger.spec.ts +0 -158
- package/src/logger.ts +0 -90
- package/src/polyfills/file.polyfill.ts +0 -6
- package/src/utils.spec.ts +0 -135
- package/src/utils.ts +0 -115
- package/src/validator.spec.ts +0 -51
- package/src/validator.ts +0 -44
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PORT_FLAG = exports.PACKAGE_FLAG = void 0;
|
|
16
|
+
exports.isOwnSessionRunning = isOwnSessionRunning;
|
|
17
|
+
exports.writtenBeforeBoot = writtenBeforeBoot;
|
|
18
|
+
exports.refuseUnanswerable = refuseUnanswerable;
|
|
19
|
+
exports.refuseBesideOtherPublisher = refuseBesideOtherPublisher;
|
|
20
|
+
exports.wireDirectory = wireDirectory;
|
|
21
|
+
exports.startSession = startSession;
|
|
22
|
+
exports.runSetup = runSetup;
|
|
23
|
+
exports.joinNames = joinNames;
|
|
24
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const os_1 = __importDefault(require("os"));
|
|
27
|
+
const path_1 = __importDefault(require("path"));
|
|
28
|
+
const folderconfig_1 = require("./folderconfig");
|
|
29
|
+
const git_1 = require("./git");
|
|
30
|
+
const localpublisherconfig_1 = require("./localpublisherconfig");
|
|
31
|
+
const importconnections_1 = require("./importconnections");
|
|
32
|
+
const host_1 = require("./host");
|
|
33
|
+
const briefing_1 = require("./briefing");
|
|
34
|
+
const mcpconfig_1 = require("./mcpconfig");
|
|
35
|
+
const liveness_1 = require("./liveness");
|
|
36
|
+
const ports_1 = require("./ports");
|
|
37
|
+
const packagemanifest_1 = require("./packagemanifest");
|
|
38
|
+
const publisherconfig_1 = require("./publisherconfig");
|
|
39
|
+
const skills_1 = require("./skills");
|
|
40
|
+
const supervisor_1 = require("./supervisor");
|
|
41
|
+
/**
|
|
42
|
+
* Where the server keeps `publisher_data/`, one location per modeling directory.
|
|
43
|
+
*
|
|
44
|
+
* It must be OUTSIDE the modeling directory, and that is a constraint rather
|
|
45
|
+
* than a preference: the server mounts a package by copying it into
|
|
46
|
+
* `publisher_data/`, so a server root inside the package makes the destination a
|
|
47
|
+
* subdirectory of the source and the mount dies with `ERR_FS_CP_EINVAL: cannot
|
|
48
|
+
* copy <dir> to a subdirectory of self`. The environment is then skipped, while
|
|
49
|
+
* both ports still bind.
|
|
50
|
+
*
|
|
51
|
+
* Under the home directory rather than a temp dir, and keyed by a hash of the
|
|
52
|
+
* absolute path so two modeling directories never collide. The server's
|
|
53
|
+
* database in it is rebuilt from the config at every boot (the supervisor
|
|
54
|
+
* passes `--init`), so nothing in it has to outlive a session. Keeping runtime state out of the user's
|
|
55
|
+
* git working tree is a real benefit of this, but not the reason for it.
|
|
56
|
+
*/
|
|
57
|
+
function sessionServerRoot(directory) {
|
|
58
|
+
const key = crypto_1.default
|
|
59
|
+
.createHash("sha256")
|
|
60
|
+
.update(path_1.default.resolve(directory))
|
|
61
|
+
.digest("hex")
|
|
62
|
+
.slice(0, 16);
|
|
63
|
+
return path_1.default.join(os_1.default.homedir(), ".credible", "sessions", key);
|
|
64
|
+
}
|
|
65
|
+
function ensureServerRoot(directory) {
|
|
66
|
+
const serverRoot = sessionServerRoot(directory);
|
|
67
|
+
// 0700: this directory holds `publisher.config.json`, which carries a live
|
|
68
|
+
// warehouse access token while a session runs. The file itself is written
|
|
69
|
+
// 0600, and the mode here means no other account can even list the path.
|
|
70
|
+
// Set explicitly as well: `mkdirSync` leaves an existing directory's mode
|
|
71
|
+
// as it found it.
|
|
72
|
+
fs_1.default.mkdirSync(serverRoot, { recursive: true, mode: 0o700 });
|
|
73
|
+
if (process.platform !== "win32")
|
|
74
|
+
fs_1.default.chmodSync(serverRoot, 0o700);
|
|
75
|
+
return serverRoot;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Where the config the server reads lives — and why it is not in the user's
|
|
79
|
+
* directory.
|
|
80
|
+
*
|
|
81
|
+
* The file has to carry a live warehouse access token: the server takes one in
|
|
82
|
+
* the connection entry and has no refresh hook, so the supervisor rewrites the
|
|
83
|
+
* file with a current token at every spawn and every renewal. That makes it a
|
|
84
|
+
* credential, and a credential must not sit in a git working tree, where
|
|
85
|
+
* `git add -A` in another tab commits it and any other account on the machine
|
|
86
|
+
* can read it.
|
|
87
|
+
*
|
|
88
|
+
* Nothing forces it to live next to the model code: the server is launched with
|
|
89
|
+
* an absolute `--config`, and the package `location` inside the config is
|
|
90
|
+
* absolute too (see {@link buildPublisherConfig}), so no path in the file
|
|
91
|
+
* resolves relative to it. So it goes in the session directory beside
|
|
92
|
+
* `publisher_data/`, which is already private, already per-directory, and
|
|
93
|
+
* already outside the repo.
|
|
94
|
+
*/
|
|
95
|
+
function sessionConfigPath(directory) {
|
|
96
|
+
return path_1.default.join(sessionServerRoot(directory), "publisher.config.json");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Is this directory's own session running — not merely something answering on
|
|
100
|
+
* its pinned port?
|
|
101
|
+
*
|
|
102
|
+
* All three must hold: the session's stamped config and pid file exist (the
|
|
103
|
+
* supervisor removes both when the server exits), the pid is alive, and the
|
|
104
|
+
* port answers. The files alone were not enough: a `kill -9`, a reboot or a
|
|
105
|
+
* closed terminal leaves them behind, and two directories wired one after the
|
|
106
|
+
* other both pin 4000/4040, so the other directory's publisher answered and
|
|
107
|
+
* this one was reported as running.
|
|
108
|
+
*/
|
|
109
|
+
function isOwnSessionRunning(directory, uiPort) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (!fs_1.default.existsSync(sessionConfigPath(directory)))
|
|
112
|
+
return false;
|
|
113
|
+
const pidFile = path_1.default.join(sessionServerRoot(directory), supervisor_1.SESSION_PID_FILE);
|
|
114
|
+
// Written before the last boot means the process it names is gone, and
|
|
115
|
+
// after a reboot its pid can belong to something else that is alive.
|
|
116
|
+
if (writtenBeforeBoot(pidFile))
|
|
117
|
+
return false;
|
|
118
|
+
const pid = Number.parseInt(readOrEmpty(pidFile), 10);
|
|
119
|
+
if (!Number.isInteger(pid) || pid <= 0 || !isAlive(pid))
|
|
120
|
+
return false;
|
|
121
|
+
return (0, liveness_1.isPublisherServing)(uiPort);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** True when `file` is older than this machine's last boot. */
|
|
125
|
+
function writtenBeforeBoot(file, now = Date.now()) {
|
|
126
|
+
try {
|
|
127
|
+
return fs_1.default.statSync(file).mtimeMs < now - os_1.default.uptime() * 1000;
|
|
128
|
+
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function readOrEmpty(file) {
|
|
134
|
+
try {
|
|
135
|
+
return fs_1.default.readFileSync(file, "utf-8");
|
|
136
|
+
}
|
|
137
|
+
catch (_a) {
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Signal 0 checks for a process without touching it. EPERM means it exists. */
|
|
142
|
+
function isAlive(pid) {
|
|
143
|
+
try {
|
|
144
|
+
process.kill(pid, 0);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return error.code === "EPERM";
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The question `--skills` answers, naming the first few skills found. */
|
|
152
|
+
function skillsQuestion(foreign) {
|
|
153
|
+
const shown = foreign.slice(0, 4).join(", ") + (foreign.length > 4 ? ", …" : "");
|
|
154
|
+
return `Found ${foreign.length} skill${foreign.length === 1 ? "" : "s"} already in ${skills_1.SKILLS_DIR}/ that cred did not install (${shown}). What should happen to them?`;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Refuse, before anything is written, the questions `cred init` could not ask.
|
|
158
|
+
*
|
|
159
|
+
* Without a terminal a question exits 2. Asked in order, the connections and
|
|
160
|
+
* skills questions came after the environment was created and selected, so an
|
|
161
|
+
* agent that stopped at the exit 2 left an empty environment behind and
|
|
162
|
+
* `~/.cred` pointing at it. Checked up front, exit 2 means nothing happened,
|
|
163
|
+
* which is what a caller re-running with the flag assumes. A misspelled
|
|
164
|
+
* `--connections` name is refused here for the same reason.
|
|
165
|
+
*/
|
|
166
|
+
function refuseUnanswerable(directory, options, interactive) {
|
|
167
|
+
var _a;
|
|
168
|
+
// The package picker, and a `--package` that names nothing listed. Asked
|
|
169
|
+
// after login and the environment, so an agent that stopped at it left
|
|
170
|
+
// `~/.cred` written and maybe an environment created.
|
|
171
|
+
const remembered = (0, folderconfig_1.findFolderConfig)(directory);
|
|
172
|
+
const decided = decidePackageDir(directory, {
|
|
173
|
+
flag: options.package,
|
|
174
|
+
pinned: (remembered === null || remembered === void 0 ? void 0 : remembered.root) === path_1.default.resolve(directory)
|
|
175
|
+
? remembered.config.package
|
|
176
|
+
: undefined,
|
|
177
|
+
});
|
|
178
|
+
if (!interactive && "listed" in decided) {
|
|
179
|
+
throw new host_1.NeedsInputError(PACKAGE_QUESTION, {
|
|
180
|
+
flag: `${exports.PACKAGE_FLAG} <dir>`,
|
|
181
|
+
options: decided.names,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const local = (0, importconnections_1.findLocalPublisherConfig)(directory);
|
|
185
|
+
// Named connections with no readable file to find them in is the silent
|
|
186
|
+
// skip `checkSelection` exists to prevent, one step earlier.
|
|
187
|
+
if (!local && Array.isArray(options.connections)) {
|
|
188
|
+
throw new host_1.SetupError((0, importconnections_1.localPublisherConfigProblem)(directory), `run this in the directory that has the connections, or drop ${importconnections_1.CONNECTIONS_FLAG}.`);
|
|
189
|
+
}
|
|
190
|
+
if (local && options.connections !== "none") {
|
|
191
|
+
(0, importconnections_1.checkSelection)(local, options.connections);
|
|
192
|
+
if (!interactive &&
|
|
193
|
+
options.connections === undefined &&
|
|
194
|
+
local.candidates.length > 0) {
|
|
195
|
+
throw new host_1.NeedsInputError(importconnections_1.CONNECTIONS_QUESTION, {
|
|
196
|
+
flag: importconnections_1.CONNECTIONS_FLAG,
|
|
197
|
+
options: local.candidates.map((c) => c.name),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (!interactive && !options.skills) {
|
|
202
|
+
const pinned = (_a = (0, folderconfig_1.findFolderConfig)(directory)) === null || _a === void 0 ? void 0 : _a.config;
|
|
203
|
+
const foreign = (pinned === null || pinned === void 0 ? void 0 : pinned.skills) || (pinned === null || pinned === void 0 ? void 0 : pinned.skillsPolicy) === "none"
|
|
204
|
+
? []
|
|
205
|
+
: (0, skills_1.foreignSkills)(directory);
|
|
206
|
+
if (foreign.length) {
|
|
207
|
+
throw new host_1.NeedsInputError(skillsQuestion(foreign), {
|
|
208
|
+
flag: skills_1.SKILLS_FLAG,
|
|
209
|
+
options: ["replace", "keep", "none"],
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Steps 1–4 and 7: everything that leaves files on disk, without starting
|
|
216
|
+
* anything.
|
|
217
|
+
*
|
|
218
|
+
* Split from the spawn so `--no-start` is a real mode rather than an early
|
|
219
|
+
* return, and so `cred dev` can re-derive the same wiring on a later day and
|
|
220
|
+
* pick up connection changes made in Credible since.
|
|
221
|
+
*/
|
|
222
|
+
const OTHER_PUBLISHER_MESSAGE = `Another Publisher, not one this directory's cred session started, is running on ports ${ports_1.DEFAULT_UI_PORT}/${ports_1.DEFAULT_MCP_PORT}.`;
|
|
223
|
+
function otherPublisherError(free) {
|
|
224
|
+
return new host_1.SetupError(OTHER_PUBLISHER_MESSAGE, `stop it and run this again to serve this directory on ${ports_1.DEFAULT_UI_PORT}/${ports_1.DEFAULT_MCP_PORT}, or leave it running and ${portFix(free)}`);
|
|
225
|
+
}
|
|
226
|
+
/** The flag that moves this directory to a free pair, with the pair to pass. */
|
|
227
|
+
function portFix(free) {
|
|
228
|
+
return free
|
|
229
|
+
? `re-run with ${exports.PORT_FLAG} ${free.uiPort} (free now; MCP takes ${free.mcpPort}). cred remembers it and points .mcp.json there.`
|
|
230
|
+
: `re-run with ${exports.PORT_FLAG} <port>, a port that is free along with the one 40 above it. cred remembers it and points .mcp.json there.`;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Whether someone else's publisher holds the default pair this directory would
|
|
234
|
+
* use: in the "I already run a publisher" journey, the user's own, started from
|
|
235
|
+
* this same directory. Moving to a derived pair rewrote `.mcp.json` away from
|
|
236
|
+
* the one server the agent could reach. Not this directory's own session; the
|
|
237
|
+
* caller checks that first.
|
|
238
|
+
*/
|
|
239
|
+
function otherPublisherOnDefaults(directory, pinnedPorts) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
// Only the journey this exists for: a directory with its own
|
|
242
|
+
// publisher.config.json, whose own server is the likely holder. Anywhere
|
|
243
|
+
// else the holder is usually another directory's `cred dev`, and the
|
|
244
|
+
// derived pair in ports.ts is the right answer, not a refusal.
|
|
245
|
+
if (!fs_1.default.existsSync(path_1.default.join(directory, "publisher.config.json"))) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const onDefaults = !pinnedPorts ||
|
|
249
|
+
(pinnedPorts.uiPort === ports_1.DEFAULT_UI_PORT &&
|
|
250
|
+
pinnedPorts.mcpPort === ports_1.DEFAULT_MCP_PORT);
|
|
251
|
+
return onDefaults && (yield (0, liveness_1.isPublisherServing)(ports_1.DEFAULT_UI_PORT));
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Refuse to start beside someone else's publisher, before login and the
|
|
256
|
+
* environment lookup. Checked only inside `wireDirectory`, the refusal came
|
|
257
|
+
* after both, 25 seconds and more on a slow deployment.
|
|
258
|
+
*/
|
|
259
|
+
function refuseBesideOtherPublisher(directory, port) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
const found = (0, folderconfig_1.findFolderConfig)(directory);
|
|
262
|
+
const pinned = (found === null || found === void 0 ? void 0 : found.root) === directory ? found.config : undefined;
|
|
263
|
+
const ownSessionRunning = Boolean((pinned === null || pinned === void 0 ? void 0 : pinned.ports) &&
|
|
264
|
+
(yield isOwnSessionRunning(directory, pinned.ports.uiPort)));
|
|
265
|
+
if (port !== undefined) {
|
|
266
|
+
// The same check `wireDirectory` repeats when it takes the pair; made
|
|
267
|
+
// here too so a busy pair is refused before login and any import.
|
|
268
|
+
yield chosenPair(directory, port, {
|
|
269
|
+
ownSessionRunning,
|
|
270
|
+
pinned: pinned === null || pinned === void 0 ? void 0 : pinned.ports,
|
|
271
|
+
});
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (ownSessionRunning)
|
|
275
|
+
return;
|
|
276
|
+
if (yield otherPublisherOnDefaults(directory, pinned === null || pinned === void 0 ? void 0 : pinned.ports)) {
|
|
277
|
+
throw otherPublisherError(yield (0, ports_1.suggestFreePair)(directory));
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function wireDirectory(context, options) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
var _a, _b, _c, _d;
|
|
284
|
+
const { organization, credibleEnvironment } = options;
|
|
285
|
+
if (!organization) {
|
|
286
|
+
throw new host_1.SetupError("No organization is selected.", "run `cred login` and pick one, or pass --organization.");
|
|
287
|
+
}
|
|
288
|
+
if (!credibleEnvironment) {
|
|
289
|
+
throw new host_1.SetupError("No Credible environment is selected.", "run `cred set environment` and pick one, or pass --environment.");
|
|
290
|
+
}
|
|
291
|
+
// Setup adopts a directory; it never fetches code. Someone who keeps their
|
|
292
|
+
// models in a repo clones it with git and runs setup inside the result, which
|
|
293
|
+
// is what `git clone` is for — wrapping it in a prompt added a step, a second
|
|
294
|
+
// way to get the destination wrong, and no capability. Cloning the
|
|
295
|
+
// environment's MANAGED repo is a different proposition (Credible knows the
|
|
296
|
+
// URL and authenticates it) and is still to come; see
|
|
297
|
+
// `git-synced-modeling.md` gate 1.
|
|
298
|
+
//
|
|
299
|
+
// Resolved once, here, because this value is an identity rather than just a
|
|
300
|
+
// path: it is sha256'd for the session directory, hashed for the derived
|
|
301
|
+
// port pair, and compared against `findFolderConfig`'s always-absolute
|
|
302
|
+
// `root` to find the ports this directory used last. A relative
|
|
303
|
+
// `--directory` reached all three as a different string, so `cred init -d
|
|
304
|
+
// sub` re-derived its ports every run and rewrote `.mcp.json` with a URL the
|
|
305
|
+
// agent's saved config no longer matched. Everything downstream can then
|
|
306
|
+
// treat it as absolute.
|
|
307
|
+
const directory = path_1.default.resolve((_a = options.directory) !== null && _a !== void 0 ? _a : context.cwd);
|
|
308
|
+
const remembered = (0, folderconfig_1.findFolderConfig)(directory);
|
|
309
|
+
const pinned = (remembered === null || remembered === void 0 ? void 0 : remembered.root) === directory ? remembered.config : undefined;
|
|
310
|
+
// A second session for the same directory would find the pinned ports busy
|
|
311
|
+
// — held by the first — fall through to another pair, rewrite `.mcp.json`
|
|
312
|
+
// to it and start a second server, leaving the first serving on the URL any
|
|
313
|
+
// open agent still has.
|
|
314
|
+
const ownSessionRunning = Boolean((pinned === null || pinned === void 0 ? void 0 : pinned.ports) &&
|
|
315
|
+
(yield isOwnSessionRunning(directory, pinned.ports.uiPort)));
|
|
316
|
+
if (options.start && ownSessionRunning) {
|
|
317
|
+
throw new host_1.SetupError(`A local Publisher for this directory is already running at http://localhost:${pinned.ports.uiPort}.`, "use that one (`cred status --json` reports it), or stop it — Ctrl-C in its terminal — and run this again.");
|
|
318
|
+
}
|
|
319
|
+
// Someone else's publisher on the default pair — in the "I already run a
|
|
320
|
+
// publisher" journey, the user's own, started from this same directory.
|
|
321
|
+
// Moving to a derived pair rewrote `.mcp.json` away from the one server the
|
|
322
|
+
// agent could reach, to a port nothing served until `cred dev`. Staying on
|
|
323
|
+
// the default pair keeps that URL; the old server has to stop first.
|
|
324
|
+
const otherPublisher = options.port === undefined &&
|
|
325
|
+
!ownSessionRunning &&
|
|
326
|
+
(yield otherPublisherOnDefaults(directory, pinned === null || pinned === void 0 ? void 0 : pinned.ports));
|
|
327
|
+
if (otherPublisher && options.start) {
|
|
328
|
+
throw otherPublisherError(yield (0, ports_1.suggestFreePair)(directory));
|
|
329
|
+
}
|
|
330
|
+
if (otherPublisher) {
|
|
331
|
+
context.host.log("warn", `${OTHER_PUBLISHER_MESSAGE} This directory stays on them: stop that one before \`cred dev\`, which serves here through Credible. Or keep it running and move this directory: ${portFix(yield (0, ports_1.suggestFreePair)(directory))}`);
|
|
332
|
+
}
|
|
333
|
+
const packageDir = yield resolvePackageDir(directory, context.host, {
|
|
334
|
+
flag: options.package,
|
|
335
|
+
pinned: pinned === null || pinned === void 0 ? void 0 : pinned.package,
|
|
336
|
+
});
|
|
337
|
+
// Before listing: a connection adopted now should appear in the config this
|
|
338
|
+
// run writes, rather than needing a second `cred dev` to show up.
|
|
339
|
+
if (context.createConnection && !options.skipConnectionImport) {
|
|
340
|
+
const local = (0, importconnections_1.findLocalPublisherConfig)(directory);
|
|
341
|
+
if (local) {
|
|
342
|
+
yield (0, importconnections_1.importLocalConnections)(local, context.host, credibleEnvironment, context.createConnection, {
|
|
343
|
+
selection: options.connections,
|
|
344
|
+
existingNames: () => __awaiter(this, void 0, void 0, function* () {
|
|
345
|
+
return (yield context.listConnections(organization, credibleEnvironment))
|
|
346
|
+
.map((c) => c.name)
|
|
347
|
+
.filter((name) => Boolean(name));
|
|
348
|
+
}),
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const connections = yield context.listConnections(organization, credibleEnvironment);
|
|
353
|
+
// Otherwise this looks like success: the server starts, serves the package,
|
|
354
|
+
// and every query fails. The only sign was the server's own "Loaded 0
|
|
355
|
+
// connections" line.
|
|
356
|
+
if (connections.length === 0) {
|
|
357
|
+
context.host.log("warn", `The Credible environment '${credibleEnvironment}' has no connections, so the local Publisher will have nothing to query. To fix it, ${briefing_1.NO_CONNECTIONS_NEXT_STEP}.`);
|
|
358
|
+
}
|
|
359
|
+
// A directory of `.malloy` files is not yet a package; without a manifest the
|
|
360
|
+
// server loads the environment and then fails the package.
|
|
361
|
+
const manifest = (0, packagemanifest_1.ensurePackageManifest)(packageDir, (0, publisherconfig_1.packageNameFromDirectory)(path_1.default.basename(packageDir)));
|
|
362
|
+
if (manifest.action === "created") {
|
|
363
|
+
context.host.log("info", `Wrote ${packagemanifest_1.PACKAGE_MANIFEST_FILE} so ${packageDir === directory ? "this directory" : path_1.default.relative(directory, packageDir)} loads as the package '${manifest.name}'.`);
|
|
364
|
+
}
|
|
365
|
+
else if (manifest.missingVersion) {
|
|
366
|
+
// The scaffolder writes `{ "name": … }` only. The publisher serves it
|
|
367
|
+
// fine; `cred publish` will not send it. Said here, once, where the
|
|
368
|
+
// user is looking, rather than at publish time.
|
|
369
|
+
context.host.log("warn", `${path_1.default.relative(directory, manifest.filePath) || packagemanifest_1.PACKAGE_MANIFEST_FILE} has no "version". The local publisher does not need one; \`cred publish\` does — add "version": "0.0.1" before publishing.`);
|
|
370
|
+
}
|
|
371
|
+
const retrieval = (0, publisherconfig_1.readLocalRetrieval)(directory);
|
|
372
|
+
if (retrieval && "problem" in retrieval) {
|
|
373
|
+
context.host.log("warn", retrieval.problem);
|
|
374
|
+
}
|
|
375
|
+
else if (retrieval) {
|
|
376
|
+
context.host.log("info", "Using the retrieval settings in this directory's publisher.config.json.");
|
|
377
|
+
}
|
|
378
|
+
const config = (0, publisherconfig_1.buildPublisherConfig)({
|
|
379
|
+
deployment: context.deployment,
|
|
380
|
+
organization,
|
|
381
|
+
credibleEnvironment,
|
|
382
|
+
connections,
|
|
383
|
+
// Already absolute (see `directory` above); the server rejects "." and a
|
|
384
|
+
// bare name, and skips the environment without failing the boot when it
|
|
385
|
+
// does.
|
|
386
|
+
packageLocation: packageDir,
|
|
387
|
+
packageName: manifest.name,
|
|
388
|
+
environmentName: (0, publisherconfig_1.localEnvironmentName)(credibleEnvironment),
|
|
389
|
+
retrieval: retrieval && "settings" in retrieval ? retrieval.settings : undefined,
|
|
390
|
+
});
|
|
391
|
+
// Reuse this directory's remembered ports so an agent's saved `.mcp.json` URL
|
|
392
|
+
// keeps resolving across sessions. While this directory's own session holds
|
|
393
|
+
// them (`--no-start` beside a running `cred dev`) they are busy because they
|
|
394
|
+
// are in use, so they are kept rather than probed: probing found them busy
|
|
395
|
+
// and moved `.mcp.json` to a pair nothing was listening on.
|
|
396
|
+
const ports = options.port !== undefined
|
|
397
|
+
? yield chosenPair(directory, options.port, {
|
|
398
|
+
ownSessionRunning,
|
|
399
|
+
pinned: pinned === null || pinned === void 0 ? void 0 : pinned.ports,
|
|
400
|
+
})
|
|
401
|
+
: ownSessionRunning && (pinned === null || pinned === void 0 ? void 0 : pinned.ports)
|
|
402
|
+
? Object.assign(Object.assign({}, pinned.ports), { derived: false }) : otherPublisher
|
|
403
|
+
? {
|
|
404
|
+
uiPort: ports_1.DEFAULT_UI_PORT,
|
|
405
|
+
mcpPort: ports_1.DEFAULT_MCP_PORT,
|
|
406
|
+
derived: false,
|
|
407
|
+
}
|
|
408
|
+
: yield (0, ports_1.allocatePortPair)(directory, {
|
|
409
|
+
preferred: pinned === null || pinned === void 0 ? void 0 : pinned.ports,
|
|
410
|
+
});
|
|
411
|
+
const { installed: skills, declined: skillsDeclined } = yield syncSkills(context, directory, remembered === null || remembered === void 0 ? void 0 : remembered.config.skills, (_b = options.skills) !== null && _b !== void 0 ? _b : remembered === null || remembered === void 0 ? void 0 : remembered.config.skillsPolicy);
|
|
412
|
+
const configPath = sessionConfigPath(directory);
|
|
413
|
+
const mcp = (0, mcpconfig_1.writeMcpConfig)({
|
|
414
|
+
directory,
|
|
415
|
+
mcpPort: ports.mcpPort,
|
|
416
|
+
deployment: context.deployment,
|
|
417
|
+
organization,
|
|
418
|
+
});
|
|
419
|
+
if (mcp.preserved.length) {
|
|
420
|
+
context.host.log("info", `Kept your other MCP servers in .mcp.json: ${mcp.preserved.join(", ")}.`);
|
|
421
|
+
}
|
|
422
|
+
if (mcp.retired.length) {
|
|
423
|
+
// A server vanishing from `.mcp.json` looks like something went wrong
|
|
424
|
+
// unless we say it was ours to remove.
|
|
425
|
+
context.host.log("info", `Removed ${mcp.retired.join(", ")} from .mcp.json — setup no longer registers it; the local publisher's own search_database_schema covers it.`);
|
|
426
|
+
}
|
|
427
|
+
if (mcp.displaced) {
|
|
428
|
+
// Said as a warning, not an aside: nothing in the previous file survived
|
|
429
|
+
// the rewrite, and the user may not consider it broken — an agent reading
|
|
430
|
+
// `.mcp.json` tolerates things `JSON.parse` refuses.
|
|
431
|
+
context.host.log("warn", `Could not read your existing .mcp.json, so its contents were replaced. The original is at ${mcp.displaced} — copy any servers you had back across.`);
|
|
432
|
+
}
|
|
433
|
+
if (mcp.changed) {
|
|
434
|
+
// An agent reads `.mcp.json` when its session starts, so one already open
|
|
435
|
+
// in this directory — including the one that just ran `cred init` — has
|
|
436
|
+
// no `malloy` tools until it restarts. Said only when the file actually
|
|
437
|
+
// changed: ports are stable per directory, so a later `cred dev` normally
|
|
438
|
+
// rewrites nothing and this line would be noise.
|
|
439
|
+
context.host.log("info", `Wrote .mcp.json. An agent already running in this directory will not see the new MCP servers until it restarts — for Claude Code, exit and start \`claude\` here again; it asks once to trust the project's servers.`);
|
|
440
|
+
}
|
|
441
|
+
(0, briefing_1.writeBriefing)(directory, {
|
|
442
|
+
organization,
|
|
443
|
+
credibleEnvironment,
|
|
444
|
+
localEnvironment: config.environments[0].name,
|
|
445
|
+
connectionNames: config.environments[0].connections.map((c) => c.name),
|
|
446
|
+
publisherUrl: `http://localhost:${ports.uiPort}`,
|
|
447
|
+
// Observed, not asked. The briefing tells an agent whether `git push`
|
|
448
|
+
// means anything here, and only the directory itself knows.
|
|
449
|
+
gitRemote: (0, git_1.detectGitRemote)(directory),
|
|
450
|
+
skillsInstalled: skills !== undefined,
|
|
451
|
+
// Importable connections, or ones held back only by an unset variable:
|
|
452
|
+
// the file can still hold a literal password next to a `${HOST}`, and
|
|
453
|
+
// counting candidates alone made the briefing change with the shell.
|
|
454
|
+
localConfigHasConnections: (() => {
|
|
455
|
+
const local = (0, importconnections_1.findLocalPublisherConfig)(directory);
|
|
456
|
+
return Boolean(local &&
|
|
457
|
+
(local.candidates.length > 0 ||
|
|
458
|
+
local.skipped.some((entry) => entry.fix)));
|
|
459
|
+
})(),
|
|
460
|
+
packagePath: packageDir === directory
|
|
461
|
+
? undefined
|
|
462
|
+
: path_1.default.relative(directory, packageDir),
|
|
463
|
+
host: "cli",
|
|
464
|
+
});
|
|
465
|
+
// The pin records the deployment always, production included. Leaving it
|
|
466
|
+
// out for production meant the directory followed the global deployment,
|
|
467
|
+
// so once `~/.cred` moved to staging (`ms2ad set-env`, or a login to
|
|
468
|
+
// another cluster), a production directory's publish and `cred dev` ran
|
|
469
|
+
// with staging's credentials against the production organization it
|
|
470
|
+
// remembers.
|
|
471
|
+
(0, folderconfig_1.writeFolderConfig)(directory, Object.assign(Object.assign({ organization, environment: credibleEnvironment, ports: { uiPort: ports.uiPort, mcpPort: ports.mcpPort },
|
|
472
|
+
// `undefined`, not an omitted key: `writeFolderConfig` merges over the
|
|
473
|
+
// file's raw contents, so an omitted key keeps whatever the file had, and
|
|
474
|
+
// a directory that stopped serving a subpackage would keep pointing at it.
|
|
475
|
+
// `JSON.stringify` drops an `undefined` value, so this clears it.
|
|
476
|
+
package: packageDir === directory
|
|
477
|
+
? undefined
|
|
478
|
+
: path_1.default.relative(directory, packageDir), deployment: context.deployment }, (skills ? { skills } : {})), {
|
|
479
|
+
// A decision rather than a record of files, so it is written every run:
|
|
480
|
+
// `replace` or `keep` clears an earlier `none`.
|
|
481
|
+
skillsPolicy: skillsDeclined ? "none" : undefined }));
|
|
482
|
+
// The pin is this developer's choice of environment, not a property of the
|
|
483
|
+
// models, so a teammate must not inherit it by cloning.
|
|
484
|
+
if ((0, folderconfig_1.ensureConfigIgnored)(directory) === "added") {
|
|
485
|
+
context.host.log("info", `Added ${folderconfig_1.FOLDER_CONFIG_DIR}/ to .gitignore — it records the environment you chose, which is yours rather than the repository's.`);
|
|
486
|
+
}
|
|
487
|
+
if (skills) {
|
|
488
|
+
// Installer-managed files, regenerated by every setup and pinned in a
|
|
489
|
+
// gitignored file: derived, like node_modules, not the repository's.
|
|
490
|
+
(0, folderconfig_1.ensureIgnored)(directory, (0, skills_1.skillsGitignoreEntries)(skills), "modeling skills installed by cred init; re-run it to refresh them");
|
|
491
|
+
}
|
|
492
|
+
// Said when the pair is new to this directory, not on every session that
|
|
493
|
+
// reuses the one it remembered.
|
|
494
|
+
const portsMoved = ((_c = pinned === null || pinned === void 0 ? void 0 : pinned.ports) === null || _c === void 0 ? void 0 : _c.uiPort) !== ports.uiPort ||
|
|
495
|
+
((_d = pinned === null || pinned === void 0 ? void 0 : pinned.ports) === null || _d === void 0 ? void 0 : _d.mcpPort) !== ports.mcpPort;
|
|
496
|
+
if (options.port !== undefined && portsMoved) {
|
|
497
|
+
context.host.log("info", `This directory now uses ports ${ports.uiPort}/${ports.mcpPort}, and will keep doing so.`);
|
|
498
|
+
}
|
|
499
|
+
else if (ports.derived && portsMoved) {
|
|
500
|
+
context.host.log("info", `Ports ${ports_1.DEFAULT_UI_PORT}/${ports_1.DEFAULT_MCP_PORT} were busy, so this directory uses ${ports.uiPort}/${ports.mcpPort} and will keep doing so.`);
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
directory,
|
|
504
|
+
packageDir,
|
|
505
|
+
organization,
|
|
506
|
+
credibleEnvironment,
|
|
507
|
+
config,
|
|
508
|
+
configPath,
|
|
509
|
+
serverRoot: ensureServerRoot(directory),
|
|
510
|
+
uiPort: ports.uiPort,
|
|
511
|
+
mcpPort: ports.mcpPort,
|
|
512
|
+
};
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Which directory is the package.
|
|
517
|
+
*
|
|
518
|
+
* Usually the workspace itself. But `create-malloy-package` lays a project out
|
|
519
|
+
* as a Publisher *server* directory — `publisher.config.json`, `.mcp.json`,
|
|
520
|
+
* skills at the top, the package in a subdirectory it names — and a user who
|
|
521
|
+
* runs setup at the top is standing in the workspace, not the package. Treating
|
|
522
|
+
* the top as the package wrote a second manifest there and served the wrong
|
|
523
|
+
* directory. So: a workspace with a manifest of its own is the package; one
|
|
524
|
+
* without, whose `publisher.config.json` names local packages, serves one of
|
|
525
|
+
* those — `--package`, else the pin's earlier choice, else the only one, else a
|
|
526
|
+
* picker. The workspace files stay at the top whichever it is.
|
|
527
|
+
*/
|
|
528
|
+
function resolvePackageDir(directory, host, choice) {
|
|
529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
530
|
+
const decided = decidePackageDir(directory, choice);
|
|
531
|
+
if ("directory" in decided) {
|
|
532
|
+
if (decided.note)
|
|
533
|
+
host.log("info", decided.note);
|
|
534
|
+
return decided.directory;
|
|
535
|
+
}
|
|
536
|
+
return host.select(PACKAGE_QUESTION, decided.listed.map((dir, i) => ({ name: decided.names[i], value: dir })), { flag: `${exports.PACKAGE_FLAG} <dir>`, options: decided.names });
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
const PACKAGE_QUESTION = "This directory's publisher.config.json lists several packages. Which one should the local publisher serve?";
|
|
540
|
+
/**
|
|
541
|
+
* The package directory, when it can be decided without asking; otherwise the
|
|
542
|
+
* choices to ask about. Pure, so {@link refuseUnanswerable} can tell up front
|
|
543
|
+
* that the question would come, and refuse a bad `--package` before anything
|
|
544
|
+
* is written.
|
|
545
|
+
*/
|
|
546
|
+
function decidePackageDir(directory, choice) {
|
|
547
|
+
if (fs_1.default.existsSync(path_1.default.join(directory, packagemanifest_1.PACKAGE_MANIFEST_FILE))) {
|
|
548
|
+
if (choice.flag) {
|
|
549
|
+
throw new host_1.SetupError(`${exports.PACKAGE_FLAG} was given, but this directory is itself a package (it has a ${packagemanifest_1.PACKAGE_MANIFEST_FILE}).`, `drop ${exports.PACKAGE_FLAG}.`);
|
|
550
|
+
}
|
|
551
|
+
return { directory };
|
|
552
|
+
}
|
|
553
|
+
const listed = listedPackageDirs(directory);
|
|
554
|
+
const names = listed.map((dir) => path_1.default.relative(directory, dir));
|
|
555
|
+
if (choice.flag) {
|
|
556
|
+
const wanted = path_1.default.resolve(directory, choice.flag);
|
|
557
|
+
if (!listed.includes(wanted)) {
|
|
558
|
+
throw new host_1.SetupError(`${exports.PACKAGE_FLAG} ${choice.flag} is not a package this directory's publisher.config.json lists.`, names.length
|
|
559
|
+
? `pass one of: ${names.join(", ")}.`
|
|
560
|
+
: `drop ${exports.PACKAGE_FLAG}; this directory lists no local packages.`);
|
|
561
|
+
}
|
|
562
|
+
return { directory: wanted };
|
|
563
|
+
}
|
|
564
|
+
if (listed.length === 0)
|
|
565
|
+
return { directory };
|
|
566
|
+
if (choice.pinned) {
|
|
567
|
+
const pinned = path_1.default.resolve(directory, choice.pinned);
|
|
568
|
+
if (listed.includes(pinned))
|
|
569
|
+
return { directory: pinned };
|
|
570
|
+
}
|
|
571
|
+
if (listed.length === 1) {
|
|
572
|
+
return {
|
|
573
|
+
directory: listed[0],
|
|
574
|
+
note: `This is a Publisher server directory; serving the package it lists at ${names[0]}/.`,
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
return { listed, names };
|
|
578
|
+
}
|
|
579
|
+
/** The flag that answers {@link resolvePackageDir}'s question. */
|
|
580
|
+
exports.PACKAGE_FLAG = "--package";
|
|
581
|
+
exports.PORT_FLAG = "--port";
|
|
582
|
+
/**
|
|
583
|
+
* The pair `--port` names, refused when something else holds it.
|
|
584
|
+
*
|
|
585
|
+
* Unlike the remembered pair, which quietly gives way to another when busy, a
|
|
586
|
+
* chosen pair is used as given or not at all: moving off it would point
|
|
587
|
+
* `.mcp.json` somewhere the user did not ask for. This directory's own running
|
|
588
|
+
* session holding it is not a conflict (`--no-start` beside `cred dev`). That
|
|
589
|
+
* session running on a different pair is: moving the pin and `.mcp.json` away
|
|
590
|
+
* from the live server leaves the agent's URL pointing at nothing, and the
|
|
591
|
+
* next ownership check would miss the running server.
|
|
592
|
+
*/
|
|
593
|
+
function chosenPair(directory, uiPort, own) {
|
|
594
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
595
|
+
const pair = (0, ports_1.pairForUiPort)(uiPort);
|
|
596
|
+
const derived = pair.uiPort !== ports_1.DEFAULT_UI_PORT || pair.mcpPort !== ports_1.DEFAULT_MCP_PORT;
|
|
597
|
+
if (own.ownSessionRunning && own.pinned) {
|
|
598
|
+
if (own.pinned.uiPort === pair.uiPort &&
|
|
599
|
+
own.pinned.mcpPort === pair.mcpPort) {
|
|
600
|
+
return Object.assign(Object.assign({}, pair), { derived });
|
|
601
|
+
}
|
|
602
|
+
throw new host_1.SetupError(`This directory's local Publisher is running on ${own.pinned.uiPort}/${own.pinned.mcpPort}, so ${exports.PORT_FLAG} ${uiPort} cannot move it.`, `stop that session (Ctrl-C in its terminal), then run this again with ${exports.PORT_FLAG} ${uiPort}.`);
|
|
603
|
+
}
|
|
604
|
+
if (yield (0, ports_1.pairIsFree)(pair)) {
|
|
605
|
+
return Object.assign(Object.assign({}, pair), { derived });
|
|
606
|
+
}
|
|
607
|
+
throw new host_1.SetupError(`Ports ${pair.uiPort}/${pair.mcpPort}, from ${exports.PORT_FLAG} ${uiPort}, are in use.`, portFix(yield (0, ports_1.suggestFreePair)(directory)));
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
/** Local package directories a `publisher.config.json` names, that exist. */
|
|
611
|
+
function listedPackageDirs(directory) {
|
|
612
|
+
const parsed = (0, localpublisherconfig_1.readLocalPublisherConfig)(directory);
|
|
613
|
+
const found = [];
|
|
614
|
+
const environments = parsed === null || parsed === void 0 ? void 0 : parsed.environments;
|
|
615
|
+
if (!Array.isArray(environments))
|
|
616
|
+
return found;
|
|
617
|
+
for (const environment of environments) {
|
|
618
|
+
const packages = environment === null || environment === void 0 ? void 0 : environment.packages;
|
|
619
|
+
if (!Array.isArray(packages))
|
|
620
|
+
continue;
|
|
621
|
+
for (const entry of packages) {
|
|
622
|
+
const location = entry === null || entry === void 0 ? void 0 : entry.location;
|
|
623
|
+
// Only local paths: a GCS/S3/GitHub URI is not a directory to serve.
|
|
624
|
+
if (typeof location !== "string" ||
|
|
625
|
+
/^[a-z][a-z0-9+.-]*:\/\//i.test(location)) {
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
const resolved = path_1.default.resolve(directory, location);
|
|
629
|
+
if (resolved !== directory && fs_1.default.existsSync(resolved)) {
|
|
630
|
+
found.push(resolved);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return [...new Set(found)];
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Step 4b: install or refresh the skills, when this front door can fetch them.
|
|
638
|
+
*
|
|
639
|
+
* Returns the state to pin, or `undefined` when nothing was synced. A failure
|
|
640
|
+
* here is reported and does not fail setup: the directory still works with the
|
|
641
|
+
* MCP servers alone, and the next `cred dev` tries again — whereas failing would
|
|
642
|
+
* take a working publisher down over a docs download.
|
|
643
|
+
*
|
|
644
|
+
* Skills already present that we did not install — `create-malloy-package`'s
|
|
645
|
+
* set, most often — are the one question here, asked once: on a first install
|
|
646
|
+
* that finds some, and not on later runs, where "not ours" also describes the
|
|
647
|
+
* user's own skills. `replace` is the recommendation because the served
|
|
648
|
+
* `malloy-*` skills are the same ones the scaffolder installs, at a pinned
|
|
649
|
+
* version, plus Credible's — and because it moves them into
|
|
650
|
+
* `.credible/replaced-skills/` rather than deleting them, since on a first
|
|
651
|
+
* install they may be the user's own. `keep` installs beside them, except a
|
|
652
|
+
* skill with the same name as one of ours: two cannot share a directory, and
|
|
653
|
+
* writing ours over it would record its files as ours and delete them on the
|
|
654
|
+
* next update. So a same-named one is moved aside as `replace` would, and said
|
|
655
|
+
* so. `none` leaves the directory alone.
|
|
656
|
+
*
|
|
657
|
+
* `declined` is whether the user has turned the skills down, by flag, by the
|
|
658
|
+
* picker, or earlier (the pin's `skillsPolicy`, passed in as `policy`). The
|
|
659
|
+
* flow records it in the pin so no later run asks again or installs them.
|
|
660
|
+
*/
|
|
661
|
+
function syncSkills(context, directory, previous, policy) {
|
|
662
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
663
|
+
if (policy === "none")
|
|
664
|
+
return { installed: previous, declined: true };
|
|
665
|
+
if (!context.fetchSkills)
|
|
666
|
+
return { declined: false };
|
|
667
|
+
const foreign = previous ? [] : (0, skills_1.foreignSkills)(directory);
|
|
668
|
+
let decided = policy !== null && policy !== void 0 ? policy : "keep";
|
|
669
|
+
if (foreign.length && !policy) {
|
|
670
|
+
decided = yield context.host.select(skillsQuestion(foreign), [
|
|
671
|
+
{
|
|
672
|
+
// Short enough for an 80-column terminal: inquirer wraps a long
|
|
673
|
+
// row, and the half that fell off was the half that mattered.
|
|
674
|
+
name: "Replace them with Credible's set — moved aside, not deleted (recommended)",
|
|
675
|
+
value: "replace",
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
name: "Keep them, and install Credible's beside them",
|
|
679
|
+
value: "keep",
|
|
680
|
+
},
|
|
681
|
+
{ name: "Do not install skills", value: "none" },
|
|
682
|
+
], { flag: skills_1.SKILLS_FLAG, options: ["replace", "keep", "none"] });
|
|
683
|
+
if (decided === "none")
|
|
684
|
+
return { declined: true };
|
|
685
|
+
}
|
|
686
|
+
let response;
|
|
687
|
+
try {
|
|
688
|
+
response = yield context.fetchSkills(skills_1.SKILLS_MANIFEST);
|
|
689
|
+
}
|
|
690
|
+
catch (error) {
|
|
691
|
+
context.host.log("warn", `Could not fetch the modeling skills (${error instanceof Error ? error.message : String(error)}). Continuing without them; the next \`cred dev\` will try again.`);
|
|
692
|
+
return { declined: false };
|
|
693
|
+
}
|
|
694
|
+
if (!response)
|
|
695
|
+
return { declined: false };
|
|
696
|
+
if (decided === "replace" && foreign.length) {
|
|
697
|
+
const movedTo = (0, skills_1.moveForeignSkills)(directory, foreign);
|
|
698
|
+
context.host.log("info", `Moved ${foreign.length} skill${foreign.length === 1 ? "" : "s"} that cred did not install to ${movedTo}/, as asked. Delete that directory once you are sure nothing in it is yours.`);
|
|
699
|
+
}
|
|
700
|
+
else if (decided === "keep" && foreign.length) {
|
|
701
|
+
// Every skill writeSkillFiles writes: the auto-discovered ones and the
|
|
702
|
+
// supporting ones they reference.
|
|
703
|
+
const ours = new Set([...response.auto_discovered, ...response.supporting].map((skill) => skill.name));
|
|
704
|
+
const colliding = foreign.filter((name) => ours.has(name));
|
|
705
|
+
if (colliding.length) {
|
|
706
|
+
const movedTo = (0, skills_1.moveForeignSkills)(directory, colliding);
|
|
707
|
+
context.host.log("warn", `Kept your existing skills. ${joinNames(colliding)} had the same name${colliding.length === 1 ? "" : "s"} as Credible's, so ${colliding.length === 1 ? "yours was" : "yours were"} moved to ${movedTo}/.`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
installed: (0, skills_1.installSkills)(directory, response, context.host, previous)
|
|
712
|
+
.state,
|
|
713
|
+
declined: false,
|
|
714
|
+
};
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
/** Step 5 and 6: start the server, and open it once it is genuinely serving. */
|
|
718
|
+
function startSession(context, wired, options) {
|
|
719
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
720
|
+
return (0, supervisor_1.startPublisher)({
|
|
721
|
+
directory: wired.directory,
|
|
722
|
+
serverRoot: wired.serverRoot,
|
|
723
|
+
configPath: wired.configPath,
|
|
724
|
+
config: wired.config,
|
|
725
|
+
uiPort: wired.uiPort,
|
|
726
|
+
mcpPort: wired.mcpPort,
|
|
727
|
+
watchEnvironment: wired.config.environments[0].name,
|
|
728
|
+
publisherVersion: context.publisherVersion,
|
|
729
|
+
host: context.host,
|
|
730
|
+
credStore: context.credStore,
|
|
731
|
+
openBrowser: options.open,
|
|
732
|
+
showAllOutput: context.showAllPublisherOutput,
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* The whole flow: wire, then run.
|
|
738
|
+
*
|
|
739
|
+
* Setup deliberately ends in a running server rather than a printed
|
|
740
|
+
* instruction. Every step before that is invisible plumbing the user cannot
|
|
741
|
+
* check, and the Publisher UI is the first artifact that proves the whole chain
|
|
742
|
+
* — auth, connections, proxy, compile — is actually live. A setup that ends with
|
|
743
|
+
* "now run `cred dev`" ends on an unverified claim.
|
|
744
|
+
*/
|
|
745
|
+
function runSetup(context, options) {
|
|
746
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
747
|
+
const wired = yield wireDirectory(context, options);
|
|
748
|
+
if (!options.start) {
|
|
749
|
+
context.host.log("info",
|
|
750
|
+
// The last line an agent sees, so it repeats the restart: the agent
|
|
751
|
+
// that ran this has no `malloy` tools until it starts again.
|
|
752
|
+
`Wired ${wired.directory}. Next: restart any agent session in that directory so it loads .mcp.json, then run \`cred dev\` there to start the publisher.`);
|
|
753
|
+
return { wired };
|
|
754
|
+
}
|
|
755
|
+
const running = yield startSession(context, wired, { open: options.open });
|
|
756
|
+
return { wired, running };
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
/** "a", "a and b", "a, b and c". */
|
|
760
|
+
function joinNames(names) {
|
|
761
|
+
return names.length <= 2
|
|
762
|
+
? names.join(" and ")
|
|
763
|
+
: `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
764
|
+
}
|
|
765
|
+
//# sourceMappingURL=flow.js.map
|