@alwaysmeticulous/cli 2.306.0 → 2.307.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/dist/command-utils/common-options.js +4 -1
- package/dist/command-utils/common-options.js.map +1 -1
- package/dist/command-utils/detect-upload-mode.js +4 -1
- package/dist/command-utils/detect-upload-mode.js.map +1 -1
- package/dist/command-utils/detect-upload-mode.spec.js +4 -1
- package/dist/command-utils/detect-upload-mode.spec.js.map +1 -1
- package/dist/command-utils/download-session.utils.js +4 -1
- package/dist/command-utils/download-session.utils.js.map +1 -1
- package/dist/command-utils/json-args.js +4 -1
- package/dist/command-utils/json-args.js.map +1 -1
- package/dist/command-utils/json-args.spec.js +4 -1
- package/dist/command-utils/json-args.spec.js.map +1 -1
- package/dist/command-utils/parse-container-env.js +4 -1
- package/dist/command-utils/parse-container-env.js.map +1 -1
- package/dist/command-utils/parse-rewrites.js +4 -1
- package/dist/command-utils/parse-rewrites.js.map +1 -1
- package/dist/command-utils/print-json.js +4 -1
- package/dist/command-utils/print-json.js.map +1 -1
- package/dist/command-utils/sentry.utils.js +4 -1
- package/dist/command-utils/sentry.utils.js.map +1 -1
- package/dist/commands/agent/build-git-options.js +4 -1
- package/dist/commands/agent/build-git-options.js.map +1 -1
- package/dist/commands/agent/build-git-options.spec.js +4 -1
- package/dist/commands/agent/build-git-options.spec.js.map +1 -1
- package/dist/commands/agent/index.js +10 -7
- package/dist/commands/agent/index.js.map +1 -1
- package/dist/commands/agent/js-coverage-diff.command.js +4 -1
- package/dist/commands/agent/js-coverage-diff.command.js.map +1 -1
- package/dist/commands/agent/js-coverage.command.d.ts +5 -0
- package/dist/commands/agent/js-coverage.command.d.ts.map +1 -1
- package/dist/commands/agent/js-coverage.command.js +122 -23
- package/dist/commands/agent/js-coverage.command.js.map +1 -1
- package/dist/commands/agent/js-coverage.command.spec.js +50 -1
- package/dist/commands/agent/js-coverage.command.spec.js.map +1 -1
- package/dist/commands/agent/screenshot-dom-diff.command.d.ts.map +1 -1
- package/dist/commands/agent/screenshot-dom-diff.command.js +5 -2
- package/dist/commands/agent/screenshot-dom-diff.command.js.map +1 -1
- package/dist/commands/agent/screenshot-image-files.command.d.ts.map +1 -1
- package/dist/commands/agent/screenshot-image-files.command.js +5 -2
- package/dist/commands/agent/screenshot-image-files.command.js.map +1 -1
- package/dist/commands/agent/screenshot-image.command.d.ts.map +1 -1
- package/dist/commands/agent/screenshot-image.command.js +5 -2
- package/dist/commands/agent/screenshot-image.command.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.command.d.ts +1 -1
- package/dist/commands/agent/test-run-diffs.command.d.ts.map +1 -1
- package/dist/commands/agent/test-run-diffs.command.js +18 -25
- package/dist/commands/agent/test-run-diffs.command.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.command.spec.js +4 -2
- package/dist/commands/agent/test-run-diffs.command.spec.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.d.ts +14 -26
- package/dist/commands/agent/test-run-diffs.utils.d.ts.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.js +25 -34
- package/dist/commands/agent/test-run-diffs.utils.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.spec.js +17 -57
- package/dist/commands/agent/test-run-diffs.utils.spec.js.map +1 -1
- package/dist/commands/agent/test-run-for-commit.command.d.ts +1 -0
- package/dist/commands/agent/test-run-for-commit.command.d.ts.map +1 -1
- package/dist/commands/agent/test-run-for-commit.command.js +13 -11
- package/dist/commands/agent/test-run-for-commit.command.js.map +1 -1
- package/dist/commands/agent/timeline.command.js +4 -1
- package/dist/commands/agent/timeline.command.js.map +1 -1
- package/dist/commands/agent/timeline.command.spec.js +4 -1
- package/dist/commands/agent/timeline.command.spec.js.map +1 -1
- package/dist/commands/agent/trigger-test-run.command.d.ts +1 -0
- package/dist/commands/agent/trigger-test-run.command.d.ts.map +1 -1
- package/dist/commands/agent/trigger-test-run.command.js +10 -5
- package/dist/commands/agent/trigger-test-run.command.js.map +1 -1
- package/dist/commands/agent/trigger-test-run.command.spec.js +4 -1
- package/dist/commands/agent/trigger-test-run.command.spec.js.map +1 -1
- package/dist/commands/agent/upload-build.command.js +5 -2
- package/dist/commands/agent/upload-build.command.js.map +1 -1
- package/dist/commands/all-commands.js +4 -1
- package/dist/commands/all-commands.js.map +1 -1
- package/dist/commands/auth/__tests__/get-project.command.spec.d.ts +2 -0
- package/dist/commands/auth/__tests__/get-project.command.spec.d.ts.map +1 -0
- package/dist/commands/auth/__tests__/get-project.command.spec.js +72 -0
- package/dist/commands/auth/__tests__/get-project.command.spec.js.map +1 -0
- package/dist/commands/auth/__tests__/list-projects.command.spec.js +4 -1
- package/dist/commands/auth/__tests__/list-projects.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/login.command.spec.js +15 -28
- package/dist/commands/auth/__tests__/login.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/logout.command.spec.js +5 -5
- package/dist/commands/auth/__tests__/logout.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/set-project.command.spec.d.ts +2 -0
- package/dist/commands/auth/__tests__/set-project.command.spec.d.ts.map +1 -0
- package/dist/commands/auth/__tests__/set-project.command.spec.js +60 -0
- package/dist/commands/auth/__tests__/set-project.command.spec.js.map +1 -0
- package/dist/commands/auth/__tests__/whoami.command.spec.js +18 -7
- package/dist/commands/auth/__tests__/whoami.command.spec.js.map +1 -1
- package/dist/commands/auth/get-project.command.d.ts +10 -0
- package/dist/commands/auth/get-project.command.d.ts.map +1 -0
- package/dist/commands/auth/get-project.command.js +49 -0
- package/dist/commands/auth/get-project.command.js.map +1 -0
- package/dist/commands/auth/index.js +6 -3
- package/dist/commands/auth/index.js.map +1 -1
- package/dist/commands/auth/list-projects.command.js +4 -1
- package/dist/commands/auth/list-projects.command.js.map +1 -1
- package/dist/commands/auth/login.command.d.ts.map +1 -1
- package/dist/commands/auth/login.command.js +11 -23
- package/dist/commands/auth/login.command.js.map +1 -1
- package/dist/commands/auth/logout.command.d.ts.map +1 -1
- package/dist/commands/auth/logout.command.js +8 -3
- package/dist/commands/auth/logout.command.js.map +1 -1
- package/dist/commands/auth/set-project.command.js +4 -1
- package/dist/commands/auth/set-project.command.js.map +1 -1
- package/dist/commands/auth/whoami.command.d.ts.map +1 -1
- package/dist/commands/auth/whoami.command.js +12 -21
- package/dist/commands/auth/whoami.command.js.map +1 -1
- package/dist/commands/ci/__tests__/session-filter.utils.spec.d.ts +2 -0
- package/dist/commands/ci/__tests__/session-filter.utils.spec.d.ts.map +1 -0
- package/dist/commands/ci/__tests__/session-filter.utils.spec.js +66 -0
- package/dist/commands/ci/__tests__/session-filter.utils.spec.js.map +1 -0
- package/dist/commands/ci/deprecated-trigger-options.js +4 -1
- package/dist/commands/ci/deprecated-trigger-options.js.map +1 -1
- package/dist/commands/ci/index.js +4 -1
- package/dist/commands/ci/index.js.map +1 -1
- package/dist/commands/ci/prepare.command.js +4 -1
- package/dist/commands/ci/prepare.command.js.map +1 -1
- package/dist/commands/ci/resolve-git-options.js +4 -1
- package/dist/commands/ci/resolve-git-options.js.map +1 -1
- package/dist/commands/ci/run-local.command.js +4 -1
- package/dist/commands/ci/run-local.command.js.map +1 -1
- package/dist/commands/ci/run-with-uploaded-asset-chunks.command.d.ts +1 -0
- package/dist/commands/ci/run-with-uploaded-asset-chunks.command.d.ts.map +1 -1
- package/dist/commands/ci/run-with-uploaded-asset-chunks.command.js +31 -3
- package/dist/commands/ci/run-with-uploaded-asset-chunks.command.js.map +1 -1
- package/dist/commands/ci/run.command.js +4 -1
- package/dist/commands/ci/run.command.js.map +1 -1
- package/dist/commands/ci/session-filter.utils.d.ts +25 -0
- package/dist/commands/ci/session-filter.utils.d.ts.map +1 -0
- package/dist/commands/ci/session-filter.utils.js +80 -0
- package/dist/commands/ci/session-filter.utils.js.map +1 -0
- package/dist/commands/ci/start-tunnel.command.js +4 -1
- package/dist/commands/ci/start-tunnel.command.js.map +1 -1
- package/dist/commands/ci/trigger-test-run.core.js +5 -2
- package/dist/commands/ci/trigger-test-run.core.js.map +1 -1
- package/dist/commands/ci/trigger-test-run.types.js +4 -1
- package/dist/commands/ci/trigger-test-run.types.js.map +1 -1
- package/dist/commands/ci/upload-asset-chunk.command.js +5 -2
- package/dist/commands/ci/upload-asset-chunk.command.js.map +1 -1
- package/dist/commands/ci/upload-assets.command.js +4 -1
- package/dist/commands/ci/upload-assets.command.js.map +1 -1
- package/dist/commands/ci/upload-container.command.js +4 -1
- package/dist/commands/ci/upload-container.command.js.map +1 -1
- package/dist/commands/debug/clean-workspaces.js +4 -1
- package/dist/commands/debug/clean-workspaces.js.map +1 -1
- package/dist/commands/debug/index.d.ts.map +1 -1
- package/dist/commands/debug/index.js +8 -8
- package/dist/commands/debug/index.js.map +1 -1
- package/dist/commands/debug/present-workspace.js +4 -1
- package/dist/commands/debug/present-workspace.js.map +1 -1
- package/dist/commands/debug/project-worktree.js +4 -1
- package/dist/commands/debug/project-worktree.js.map +1 -1
- package/dist/commands/deprecated-aliases.js +4 -1
- package/dist/commands/deprecated-aliases.js.map +1 -1
- package/dist/commands/download/index.js +4 -1
- package/dist/commands/download/index.js.map +1 -1
- package/dist/commands/download/replay.command.js +4 -1
- package/dist/commands/download/replay.command.js.map +1 -1
- package/dist/commands/download/session.command.js +4 -1
- package/dist/commands/download/session.command.js.map +1 -1
- package/dist/commands/download/test-run.command.js +4 -1
- package/dist/commands/download/test-run.command.js.map +1 -1
- package/dist/commands/local/get-edited-files.utils.js +4 -1
- package/dist/commands/local/get-edited-files.utils.js.map +1 -1
- package/dist/commands/local/get-edited-files.utils.spec.js +4 -1
- package/dist/commands/local/get-edited-files.utils.spec.js.map +1 -1
- package/dist/commands/local/index.js +4 -1
- package/dist/commands/local/index.js.map +1 -1
- package/dist/commands/local/relevant-sessions.command.js +5 -2
- package/dist/commands/local/relevant-sessions.command.js.map +1 -1
- package/dist/commands/project/index.js +4 -1
- package/dist/commands/project/index.js.map +1 -1
- package/dist/commands/project/show.command.js +5 -2
- package/dist/commands/project/show.command.js.map +1 -1
- package/dist/commands/project/upload-source.command.js +4 -1
- package/dist/commands/project/upload-source.command.js.map +1 -1
- package/dist/commands/record/__tests__/login.command.spec.js +7 -2
- package/dist/commands/record/__tests__/login.command.spec.js.map +1 -1
- package/dist/commands/record/__tests__/session.command.spec.js +7 -2
- package/dist/commands/record/__tests__/session.command.spec.js.map +1 -1
- package/dist/commands/record/index.js +4 -1
- package/dist/commands/record/index.js.map +1 -1
- package/dist/commands/record/login.command.js +5 -2
- package/dist/commands/record/login.command.js.map +1 -1
- package/dist/commands/record/session.command.js +5 -2
- package/dist/commands/record/session.command.js.map +1 -1
- package/dist/commands/replay-debugger.ui.js +4 -1
- package/dist/commands/replay-debugger.ui.js.map +1 -1
- package/dist/commands/replay.command.js +4 -1
- package/dist/commands/replay.command.js.map +1 -1
- package/dist/commands/schema.command.js +4 -1
- package/dist/commands/schema.command.js.map +1 -1
- package/dist/commands/schema.command.spec.js +4 -1
- package/dist/commands/schema.command.spec.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -1
- package/dist/main.js.map +1 -1
- package/dist/utils/__tests__/handle-auth-failure.spec.js +4 -1
- package/dist/utils/__tests__/handle-auth-failure.spec.js.map +1 -1
- package/dist/utils/__tests__/resolve-project-identifier.spec.js +38 -31
- package/dist/utils/__tests__/resolve-project-identifier.spec.js.map +1 -1
- package/dist/utils/__tests__/resolve-test-run-from-commit.spec.js +4 -1
- package/dist/utils/__tests__/resolve-test-run-from-commit.spec.js.map +1 -1
- package/dist/utils/__tests__/select-project.spec.js +137 -46
- package/dist/utils/__tests__/select-project.spec.js.map +1 -1
- package/dist/utils/cli-user-error.js +4 -1
- package/dist/utils/cli-user-error.js.map +1 -1
- package/dist/utils/constants.js +4 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/environment.utils.js +4 -1
- package/dist/utils/environment.utils.js.map +1 -1
- package/dist/utils/format-coverage-ranges.js +4 -1
- package/dist/utils/format-coverage-ranges.js.map +1 -1
- package/dist/utils/handle-auth-failure.d.ts +1 -0
- package/dist/utils/handle-auth-failure.d.ts.map +1 -1
- package/dist/utils/handle-auth-failure.js +7 -3
- package/dist/utils/handle-auth-failure.js.map +1 -1
- package/dist/utils/out-of-date-client-error.js +4 -1
- package/dist/utils/out-of-date-client-error.js.map +1 -1
- package/dist/utils/resolve-project-identifier.d.ts +12 -10
- package/dist/utils/resolve-project-identifier.d.ts.map +1 -1
- package/dist/utils/resolve-project-identifier.js +31 -17
- package/dist/utils/resolve-project-identifier.js.map +1 -1
- package/dist/utils/resolve-test-run-from-commit.d.ts +6 -2
- package/dist/utils/resolve-test-run-from-commit.d.ts.map +1 -1
- package/dist/utils/resolve-test-run-from-commit.js +12 -8
- package/dist/utils/resolve-test-run-from-commit.js.map +1 -1
- package/dist/utils/select-project.d.ts +37 -13
- package/dist/utils/select-project.d.ts.map +1 -1
- package/dist/utils/select-project.js +113 -40
- package/dist/utils/select-project.js.map +1 -1
- package/package.json +10 -10
- package/dist/commands/auth/unset-project.command.d.ts +0 -3
- package/dist/commands/auth/unset-project.command.d.ts.map +0 -1
- package/dist/commands/auth/unset-project.command.js +0 -24
- package/dist/commands/auth/unset-project.command.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-auth-failure.d.ts","sourceRoot":"","sources":["../../src/utils/handle-auth-failure.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KA0BlD,CAAC"}
|
|
1
|
+
{"version":3,"file":"handle-auth-failure.d.ts","sourceRoot":"","sources":["../../src/utils/handle-auth-failure.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KA0BlD,CAAC;AAEF,eAAO,MAAM,oBAAoB,SAAU,OAAO,KAAG,MAAM,GAAG,IAc7D,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="af5c9326-089d-5aeb-a695-cc7891267cdd")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleAuthFailure = void 0;
|
|
5
|
+
exports.extractServerMessage = exports.handleAuthFailure = void 0;
|
|
4
6
|
const client_1 = require("@alwaysmeticulous/client");
|
|
5
7
|
const cli_user_error_1 = require("./cli-user-error");
|
|
6
8
|
/**
|
|
@@ -34,7 +36,7 @@ const handleAuthFailure = (error) => {
|
|
|
34
36
|
throw new cli_user_error_1.CliUserError("Your stored OAuth token has expired and could not be refreshed. " +
|
|
35
37
|
"Re-run the command to start a fresh login.");
|
|
36
38
|
}
|
|
37
|
-
const serverMessage = extractServerMessage(error.response?.data);
|
|
39
|
+
const serverMessage = (0, exports.extractServerMessage)(error.response?.data);
|
|
38
40
|
const detail = serverMessage ? `: ${serverMessage}` : ".";
|
|
39
41
|
throw new cli_user_error_1.CliUserError(`Authentication failed (HTTP ${status})${detail}\n` +
|
|
40
42
|
"If the token is stale, run `meticulous auth logout` and re-run the command.");
|
|
@@ -55,4 +57,6 @@ const extractServerMessage = (data) => {
|
|
|
55
57
|
}
|
|
56
58
|
return null;
|
|
57
59
|
};
|
|
58
|
-
|
|
60
|
+
exports.extractServerMessage = extractServerMessage;
|
|
61
|
+
//# sourceMappingURL=handle-auth-failure.js.map
|
|
62
|
+
//# debugId=af5c9326-089d-5aeb-a695-cc7891267cdd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-auth-failure.js","
|
|
1
|
+
{"version":3,"file":"handle-auth-failure.js","sources":["../../src/utils/handle-auth-failure.ts"],"sourceR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ACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAI,IAA8B,CAAC,OAAO,CAAC;QACxD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","debugId":"af5c9326-089d-5aeb-a695-cc7891267cdd"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0aca0fb3-0d1b-5eb2-9571-239dbe63bea6")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.OutOfDateCLIError = exports.isOutOfDateClientError = void 0;
|
|
4
6
|
const isOutOfDateClientError = (error) => {
|
|
@@ -12,4 +14,5 @@ class OutOfDateCLIError extends Error {
|
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
exports.OutOfDateCLIError = OutOfDateCLIError;
|
|
15
|
-
//# sourceMappingURL=out-of-date-client-error.js.map
|
|
17
|
+
//# sourceMappingURL=out-of-date-client-error.js.map
|
|
18
|
+
//# debugId=0aca0fb3-0d1b-5eb2-9571-239dbe63bea6
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"out-of-date-client-error.js","
|
|
1
|
+
{"version":3,"file":"out-of-date-client-error.js","sources":["../../src/utils/out-of-date-client-error.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAEO,MAAM,sBAAsB,GAAG,CACpC,KAAc,EACiB,EAAE;IACjC,OAAQ,KAAe,CAAC,IAAI,KAAK,iBAAiB,CAAC;AACrD,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC;AAEF,MAAa,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CACH,2IAA2I,CAC5I,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAPD,8CAOC","debugId":"0aca0fb3-0d1b-5eb2-9571-239dbe63bea6"}
|
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
* resolved API token.
|
|
4
4
|
*
|
|
5
5
|
* - OAuth tokens are user-scoped (not project-scoped), so they require a
|
|
6
|
-
*
|
|
6
|
+
* default project — set via `meticulous auth set-project` or the web app's
|
|
7
|
+
* user settings, resolved from the backend (not a local file: it needs to
|
|
8
|
+
* be consistent across machines and visible to the hosted MCP server).
|
|
7
9
|
* - Project-scoped API tokens already pin the project, so no extra
|
|
8
10
|
* identifier is needed.
|
|
9
11
|
*
|
|
10
|
-
* Throws `CliUserError` when an OAuth caller has no project
|
|
12
|
+
* Throws `CliUserError` when an OAuth caller has no default project. The
|
|
11
13
|
* top-level `wrapHandler` catches it and exits non-zero with the message.
|
|
12
14
|
*/
|
|
13
|
-
export declare const resolveProjectIdentifier: (apiToken: string) => {
|
|
15
|
+
export declare const resolveProjectIdentifier: (apiToken: string) => Promise<{
|
|
14
16
|
projectId?: string;
|
|
15
|
-
}
|
|
17
|
+
}>;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Resolves the single project a project-scoped API token is bound to, via the
|
|
20
|
+
* `token-info` endpoint, as an `"organization/name"` slug. Best-effort: any
|
|
21
|
+
* failure (network, older backend without the endpoint, etc.) resolves to
|
|
22
|
+
* `null` rather than throwing — used for informational display (`whoami`,
|
|
23
|
+
* `get-project`), where a missing project name shouldn't fail the command.
|
|
22
24
|
*/
|
|
23
|
-
export declare const
|
|
25
|
+
export declare const resolvePinnedProjectSlug: (apiToken: string) => Promise<string | null>;
|
|
24
26
|
//# sourceMappingURL=resolve-project-identifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-project-identifier.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-project-identifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-project-identifier.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-project-identifier.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,aACzB,MAAM,KACf,OAAO,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAiBhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,aACzB,MAAM,KACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAQvB,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0129f18e-5e5d-5b0a-89b3-e66803d56a18")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
5
|
+
exports.resolvePinnedProjectSlug = exports.resolveProjectIdentifier = void 0;
|
|
6
|
+
const common_1 = require("@alwaysmeticulous/common");
|
|
4
7
|
const client_1 = require("@alwaysmeticulous/client");
|
|
5
8
|
const cli_user_error_1 = require("./cli-user-error");
|
|
6
9
|
/**
|
|
@@ -8,37 +11,48 @@ const cli_user_error_1 = require("./cli-user-error");
|
|
|
8
11
|
* resolved API token.
|
|
9
12
|
*
|
|
10
13
|
* - OAuth tokens are user-scoped (not project-scoped), so they require a
|
|
11
|
-
*
|
|
14
|
+
* default project — set via `meticulous auth set-project` or the web app's
|
|
15
|
+
* user settings, resolved from the backend (not a local file: it needs to
|
|
16
|
+
* be consistent across machines and visible to the hosted MCP server).
|
|
12
17
|
* - Project-scoped API tokens already pin the project, so no extra
|
|
13
18
|
* identifier is needed.
|
|
14
19
|
*
|
|
15
|
-
* Throws `CliUserError` when an OAuth caller has no project
|
|
20
|
+
* Throws `CliUserError` when an OAuth caller has no default project. The
|
|
16
21
|
* top-level `wrapHandler` catches it and exits non-zero with the message.
|
|
17
22
|
*/
|
|
18
|
-
const resolveProjectIdentifier = (apiToken) => {
|
|
23
|
+
const resolveProjectIdentifier = async (apiToken) => {
|
|
19
24
|
if (!(0, client_1.isOAuthJwt)(apiToken)) {
|
|
20
25
|
return {};
|
|
21
26
|
}
|
|
22
|
-
const
|
|
27
|
+
const logger = (0, common_1.initLogger)();
|
|
28
|
+
// The legacy `selected-project.json` migration runs in the shared OAuth
|
|
29
|
+
// token-init path (`resolveApiTokenWithOAuth`), so by the time we resolve the
|
|
30
|
+
// default here it has already been migrated if it was present.
|
|
31
|
+
const projectId = await (0, client_1.resolveDefaultProjectId)(apiToken, logger);
|
|
23
32
|
if (!projectId) {
|
|
24
|
-
throw new cli_user_error_1.CliUserError("No project
|
|
33
|
+
throw new cli_user_error_1.CliUserError("No default project set. Run `meticulous auth set-project` to choose " +
|
|
25
34
|
"one before running OAuth-authenticated commands.");
|
|
26
35
|
}
|
|
27
36
|
return { projectId };
|
|
28
37
|
};
|
|
29
38
|
exports.resolveProjectIdentifier = resolveProjectIdentifier;
|
|
30
39
|
/**
|
|
31
|
-
*
|
|
32
|
-
* `
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
40
|
+
* Resolves the single project a project-scoped API token is bound to, via the
|
|
41
|
+
* `token-info` endpoint, as an `"organization/name"` slug. Best-effort: any
|
|
42
|
+
* failure (network, older backend without the endpoint, etc.) resolves to
|
|
43
|
+
* `null` rather than throwing — used for informational display (`whoami`,
|
|
44
|
+
* `get-project`), where a missing project name shouldn't fail the command.
|
|
36
45
|
*/
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const resolvePinnedProjectSlug = async (apiToken) => {
|
|
47
|
+
try {
|
|
48
|
+
const client = (0, client_1.createClient)({ apiToken });
|
|
49
|
+
const project = await (0, client_1.getProject)(client);
|
|
50
|
+
return project ? `${project.organization.name}/${project.name}` : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
40
54
|
}
|
|
41
|
-
return (0, client_1.getStoredProjectId)() ?? undefined;
|
|
42
55
|
};
|
|
43
|
-
exports.
|
|
44
|
-
//# sourceMappingURL=resolve-project-identifier.js.map
|
|
56
|
+
exports.resolvePinnedProjectSlug = resolvePinnedProjectSlug;
|
|
57
|
+
//# sourceMappingURL=resolve-project-identifier.js.map
|
|
58
|
+
//# debugId=0129f18e-5e5d-5b0a-89b3-e66803d56a18
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-project-identifier.js","
|
|
1
|
+
{"version":3,"file":"resolve-project-identifier.js","sources":["../../src/utils/resolve-project-identifier.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAAsD;AACtD,qDAKkC;AAClC,qDAAgD;AAEhD;;;;;;;;;;;;;GAaG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAC3C,QAAgB,EACiB,EAAE;IACnC,IAAI,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,wEAAwE;IACxE,8EAA8E;IAC9E,+DAA+D;IAC/D,MAAM,SAAS,GAAG,MAAM,IAAA,gCAAuB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,6BAAY,CACpB,sEAAsE;YACpE,kDAAkD,CACrD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC,CAAC;AAnBW,QAAA,wBAAwB,4BAmBnC;AAEF;;;;;;GAMG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAC3C,QAAgB,EACQ,EAAE;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC;QACzC,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","debugId":"0129f18e-5e5d-5b0a-89b3-e66803d56a18"}
|
|
@@ -42,16 +42,20 @@ export declare const assertTestRunComplete: (testRunId: string, status: TestRunS
|
|
|
42
42
|
* explicit `commitSha`, or the local checkout's HEAD when omitted), throwing a
|
|
43
43
|
* `CliUserError` when the commit can't be determined or no run matches it.
|
|
44
44
|
*
|
|
45
|
+
* `project` is a one-off override (resolved flexibly server-side); when
|
|
46
|
+
* omitted, project-scoped tokens use their own project and OAuth tokens fall
|
|
47
|
+
* back to the caller's stored default (`meticulous auth set-project`).
|
|
48
|
+
*
|
|
45
49
|
* Logs the resolved commit (see {@link logResolvedCommitSha}) and the test run
|
|
46
50
|
* id (under `--verbose`).
|
|
47
51
|
*/
|
|
48
|
-
export declare const resolveTestRunForCommitOrThrow: (client: MeticulousClient,
|
|
52
|
+
export declare const resolveTestRunForCommitOrThrow: (client: MeticulousClient, commitSha: string | undefined, project?: string) => Promise<ResolvedTestRun>;
|
|
49
53
|
/**
|
|
50
54
|
* Best-effort variant for auto-retry paths: returns `null` (rather than
|
|
51
55
|
* throwing) when the commit can't be determined, no project is selected, or no
|
|
52
56
|
* run matches, so the caller can fall back to its original behaviour.
|
|
53
57
|
*/
|
|
54
|
-
export declare const tryResolveTestRunForCommit: (client: MeticulousClient,
|
|
58
|
+
export declare const tryResolveTestRunForCommit: (client: MeticulousClient, commitSha: string | undefined, project?: string) => Promise<ResolvedTestRun | null>;
|
|
55
59
|
/**
|
|
56
60
|
* Polls a (possibly in-progress) test run until it reaches a terminal status,
|
|
57
61
|
* logging a single "Waiting for test run X to complete..." line when it starts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-test-run-from-commit.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-test-run-from-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-test-run-from-commit.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-test-run-from-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAoBjE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,cACpB,MAAM,GAAG,SAAS,eAChB,MAAM,KAClB,OAAO,CAAC,IAAI,CAQd,CAAC;AAUF,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,WAAY,aAAa,KAAG,OACd,CAAC;AAS/C,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,WAAY,aAAa,KAAG,OACf,CAAC;AAK5C,2EAA2E;AAC3E,eAAO,MAAM,eAAe,WAAY,aAAa,KAAG,OACf,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,WAAY,aAAa,KAAG,OACnC,CAAC;AAEvB;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,cACrB,MAAM,UACT,aAAa,mBACO;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,KAClD,IAgBF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B,WACjC,gBAAgB,aACb,MAAM,GAAG,SAAS,YACnB,MAAM,KACf,OAAO,CAAC,eAAe,CAiBzB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,WAC7B,gBAAgB,aACb,MAAM,GAAG,SAAS,YACnB,MAAM,KACf,OAAO,CAAC,eAAe,GAAG,IAAI,CAmBhC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,WACzB,gBAAgB,aACb,MAAM,uBACU;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,KACtD,OAAO,CAAC,aAAa,CAsBvB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WACxB,gBAAgB,aACb,MAAM,UACT,aAAa,iCAIlB;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,KACjD,OAAO,CAAC,aAAa,GAAG,IAAI,CAM9B,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f829bfa3-8b9d-5d08-93a4-5d558c507380")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.ensureTestRunFinished = exports.awaitTestRunCompletion = exports.tryResolveTestRunForCommit = exports.resolveTestRunForCommitOrThrow = exports.assertTestRunComplete = exports.isTestRunPartial = exports.isTestRunFailed = exports.isTestRunComplete = exports.isTestRunInProgress = exports.logResolvedCommitSha = void 0;
|
|
4
6
|
const client_1 = require("@alwaysmeticulous/client");
|
|
5
7
|
const common_1 = require("@alwaysmeticulous/common");
|
|
6
8
|
const cli_user_error_1 = require("./cli-user-error");
|
|
7
|
-
const resolve_project_identifier_1 = require("./resolve-project-identifier");
|
|
8
9
|
const POLL_INTERVAL_MS = 10_000;
|
|
9
10
|
/** Give up waiting for a run after this long, rather than polling forever. */
|
|
10
11
|
const POLL_TIMEOUT_MS = 10 * 60_000;
|
|
@@ -84,18 +85,21 @@ exports.assertTestRunComplete = assertTestRunComplete;
|
|
|
84
85
|
* explicit `commitSha`, or the local checkout's HEAD when omitted), throwing a
|
|
85
86
|
* `CliUserError` when the commit can't be determined or no run matches it.
|
|
86
87
|
*
|
|
88
|
+
* `project` is a one-off override (resolved flexibly server-side); when
|
|
89
|
+
* omitted, project-scoped tokens use their own project and OAuth tokens fall
|
|
90
|
+
* back to the caller's stored default (`meticulous auth set-project`).
|
|
91
|
+
*
|
|
87
92
|
* Logs the resolved commit (see {@link logResolvedCommitSha}) and the test run
|
|
88
93
|
* id (under `--verbose`).
|
|
89
94
|
*/
|
|
90
|
-
const resolveTestRunForCommitOrThrow = async (client,
|
|
95
|
+
const resolveTestRunForCommitOrThrow = async (client, commitSha, project) => {
|
|
91
96
|
const sha = await (0, common_1.getCommitSha)(commitSha);
|
|
92
97
|
if (!sha) {
|
|
93
98
|
throw new cli_user_error_1.CliUserError("Could not determine a commit SHA. Pass --commitSha or --testRunId, or run inside a git repository.");
|
|
94
99
|
}
|
|
95
100
|
await (0, exports.logResolvedCommitSha)(commitSha, sha);
|
|
96
|
-
const { projectId } = (0, resolve_project_identifier_1.resolveProjectIdentifier)(apiToken);
|
|
97
101
|
const { testRunId, status } = await (0, client_1.getTestRunForCommit)(client, sha, {
|
|
98
|
-
|
|
102
|
+
project,
|
|
99
103
|
});
|
|
100
104
|
if (testRunId == null || status == null) {
|
|
101
105
|
throw new cli_user_error_1.CliUserError(`No test run found for commit ${sha}.`);
|
|
@@ -109,15 +113,14 @@ exports.resolveTestRunForCommitOrThrow = resolveTestRunForCommitOrThrow;
|
|
|
109
113
|
* throwing) when the commit can't be determined, no project is selected, or no
|
|
110
114
|
* run matches, so the caller can fall back to its original behaviour.
|
|
111
115
|
*/
|
|
112
|
-
const tryResolveTestRunForCommit = async (client,
|
|
116
|
+
const tryResolveTestRunForCommit = async (client, commitSha, project) => {
|
|
113
117
|
try {
|
|
114
118
|
const sha = await (0, common_1.getCommitSha)(commitSha);
|
|
115
119
|
if (!sha) {
|
|
116
120
|
return null;
|
|
117
121
|
}
|
|
118
|
-
const { projectId } = (0, resolve_project_identifier_1.resolveProjectIdentifier)(apiToken);
|
|
119
122
|
const { testRunId, status } = await (0, client_1.getTestRunForCommit)(client, sha, {
|
|
120
|
-
|
|
123
|
+
project,
|
|
121
124
|
});
|
|
122
125
|
return testRunId != null && status != null ? { testRunId, status } : null;
|
|
123
126
|
}
|
|
@@ -175,4 +178,5 @@ const ensureTestRunFinished = async (client, testRunId, status, { dontWait, thro
|
|
|
175
178
|
return (0, exports.awaitTestRunCompletion)(client, testRunId, { throwOnFailure });
|
|
176
179
|
};
|
|
177
180
|
exports.ensureTestRunFinished = ensureTestRunFinished;
|
|
178
|
-
//# sourceMappingURL=resolve-test-run-from-commit.js.map
|
|
181
|
+
//# sourceMappingURL=resolve-test-run-from-commit.js.map
|
|
182
|
+
//# debugId=f829bfa3-8b9d-5d08-93a4-5d558c507380
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-test-run-from-commit.js","
|
|
1
|
+
{"version":3,"file":"resolve-test-run-from-commit.js","sources":["../../src/utils/resolve-test-run-from-commit.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAEA,qDAIkC;AAClC,qDAMkC;AAClC,qDAAgD;AAEhD,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,8EAA8E;AAC9E,MAAM,eAAe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BAA6B,MAAM,IAAI,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAA,8BAAsB,EAAC,MAAM,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC;AAdW,QAAA,qBAAqB,yBAchC","debugId":"f829bfa3-8b9d-5d08-93a4-5d558c507380"}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
|
-
import type { MeticulousClient, OAuthProject } from "@alwaysmeticulous/client";
|
|
1
|
+
import type { MeticulousClient, OAuthDefaultProjectResponse, OAuthProject } from "@alwaysmeticulous/client";
|
|
2
2
|
/**
|
|
3
3
|
* Fetches the projects accessible to the OAuth caller, surfacing auth failures
|
|
4
4
|
* via `handleAuthFailure`. Shared by the project selection and listing flows.
|
|
5
|
+
*
|
|
6
|
+
* Results are sorted alphabetically by `organization/project` slug
|
|
7
|
+
* (case-insensitive) so the interactive picker, listing output, and error
|
|
8
|
+
* messages present projects in a predictable order regardless of what the API
|
|
9
|
+
* returns.
|
|
5
10
|
*/
|
|
6
11
|
export declare const fetchAccessibleProjects: (client: MeticulousClient) => Promise<OAuthProject[]>;
|
|
12
|
+
/** `"organization/name"` slug, falling back to the bare id if unnamed. */
|
|
13
|
+
export declare const formatProjectSlug: (project: Pick<OAuthDefaultProjectResponse, "projectId" | "name" | "organization">) => string;
|
|
7
14
|
/**
|
|
8
|
-
* Picks a project
|
|
9
|
-
*
|
|
15
|
+
* Picks a project and persists it as the caller's default (via the backend —
|
|
16
|
+
* see `setOAuthDefaultProject`, consistent across machines and visible to the
|
|
17
|
+
* MCP server). Shared by `auth login` and `auth set-project`.
|
|
10
18
|
*
|
|
11
|
-
* - When `project`
|
|
12
|
-
*
|
|
13
|
-
*
|
|
19
|
+
* - When `project` is given, it's resolved by the backend, which accepts any of
|
|
20
|
+
* a bare id, an `organization/name` slug, or a unique bare name (see
|
|
21
|
+
* `ProjectService.resolveForUserByIdentifier`). We deliberately do NOT match
|
|
22
|
+
* client-side — the CLI would only understand the slug form and diverge from
|
|
23
|
+
* the backend (and from the `--project` override on agent commands).
|
|
14
24
|
* - Otherwise auto-selects the only project, or prompts interactively when
|
|
15
25
|
* there are several — unless `allowInteractivePrompt` is `false` (e.g. a
|
|
16
|
-
* headless login), in which case it
|
|
17
|
-
*
|
|
18
|
-
* on a prompt that no terminal can answer.
|
|
26
|
+
* headless login), in which case it throws with guidance rather than
|
|
27
|
+
* blocking on a prompt that no terminal can answer.
|
|
19
28
|
*
|
|
20
|
-
* Throws `CliUserError` when the
|
|
21
|
-
* project
|
|
29
|
+
* Throws `CliUserError` when the identifier can't be resolved, the caller has
|
|
30
|
+
* no accessible projects, or a project can't be resolved without a prompt.
|
|
22
31
|
*/
|
|
23
|
-
export declare const selectAndStoreProject: ({ client, project, allowInteractivePrompt,
|
|
32
|
+
export declare const selectAndStoreProject: ({ client, project, allowInteractivePrompt, }: {
|
|
24
33
|
client: MeticulousClient;
|
|
25
34
|
project?: string | undefined;
|
|
26
35
|
allowInteractivePrompt?: boolean;
|
|
27
|
-
fallbackToProject?: string | undefined;
|
|
28
36
|
}) => Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Project selection for `auth login`. Behaves like `selectAndStoreProject`
|
|
39
|
+
* (persist an explicit `--project`, auto-select+persist a sole project, prompt
|
|
40
|
+
* among several) with one addition: if the user already has a stored default,
|
|
41
|
+
* respect it rather than re-prompting or failing — so a returning user (in
|
|
42
|
+
* particular a headless `--non-interactive` login) succeeds without re-picking.
|
|
43
|
+
*
|
|
44
|
+
* There's no "cleared default" to preserve here: clearing isn't user-reachable
|
|
45
|
+
* (no `unset-project` command, no web "no default" option), so always selecting
|
|
46
|
+
* a sole project can't silently undo an intentional clear.
|
|
47
|
+
*/
|
|
48
|
+
export declare const selectProjectOnLogin: ({ client, project, interactive, }: {
|
|
49
|
+
client: MeticulousClient;
|
|
50
|
+
project?: string | undefined;
|
|
51
|
+
interactive: boolean;
|
|
52
|
+
}) => Promise<void>;
|
|
29
53
|
//# sourceMappingURL=select-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-project.d.ts","sourceRoot":"","sources":["../../src/utils/select-project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-project.d.ts","sourceRoot":"","sources":["../../src/utils/select-project.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,YAAY,EACb,MAAM,0BAA0B,CAAC;AAMlC;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,WAC1B,gBAAgB,KACvB,OAAO,CAAC,YAAY,EAAE,CAQxB,CAAC;AAgBF,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,YACnB,IAAI,CACX,2BAA2B,EAC3B,WAAW,GAAG,MAAM,GAAG,cAAc,CACtC,KACA,MAG4B,CAAC;AAEhC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,iDAI/B;IACD,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,KAAG,OAAO,CAAC,MAAM,CA6CjB,CAAC;AAwBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,sCAI9B;IACD,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;CACtB,KAAG,OAAO,CAAC,IAAI,CA4Bf,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3dd5fa0-bef9-583c-8433-9978a18d5a5d")}catch(e){}}();
|
|
3
|
+
|
|
2
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
6
|
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.selectAndStoreProject = exports.fetchAccessibleProjects = void 0;
|
|
8
|
+
exports.selectProjectOnLogin = exports.selectAndStoreProject = exports.formatProjectSlug = exports.fetchAccessibleProjects = void 0;
|
|
7
9
|
const client_1 = require("@alwaysmeticulous/client");
|
|
8
10
|
const common_1 = require("@alwaysmeticulous/common");
|
|
9
11
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
@@ -12,10 +14,16 @@ const handle_auth_failure_1 = require("./handle-auth-failure");
|
|
|
12
14
|
/**
|
|
13
15
|
* Fetches the projects accessible to the OAuth caller, surfacing auth failures
|
|
14
16
|
* via `handleAuthFailure`. Shared by the project selection and listing flows.
|
|
17
|
+
*
|
|
18
|
+
* Results are sorted alphabetically by `organization/project` slug
|
|
19
|
+
* (case-insensitive) so the interactive picker, listing output, and error
|
|
20
|
+
* messages present projects in a predictable order regardless of what the API
|
|
21
|
+
* returns.
|
|
15
22
|
*/
|
|
16
23
|
const fetchAccessibleProjects = async (client) => {
|
|
17
24
|
try {
|
|
18
|
-
|
|
25
|
+
const projects = await (0, client_1.getOAuthProjects)(client);
|
|
26
|
+
return [...projects].sort(compareProjectsBySlug);
|
|
19
27
|
}
|
|
20
28
|
catch (error) {
|
|
21
29
|
(0, handle_auth_failure_1.handleAuthFailure)(error);
|
|
@@ -23,70 +31,134 @@ const fetchAccessibleProjects = async (client) => {
|
|
|
23
31
|
}
|
|
24
32
|
};
|
|
25
33
|
exports.fetchAccessibleProjects = fetchAccessibleProjects;
|
|
34
|
+
const compareProjectsBySlug = (a, b) => {
|
|
35
|
+
const orgComparison = a.organization.name.localeCompare(b.organization.name, undefined, {
|
|
36
|
+
sensitivity: "base",
|
|
37
|
+
});
|
|
38
|
+
if (orgComparison !== 0) {
|
|
39
|
+
return orgComparison;
|
|
40
|
+
}
|
|
41
|
+
return a.name.localeCompare(b.name, undefined, { sensitivity: "base" });
|
|
42
|
+
};
|
|
43
|
+
/** `"organization/name"` slug, falling back to the bare id if unnamed. */
|
|
44
|
+
const formatProjectSlug = (project) => project.organization && project.name
|
|
45
|
+
? `${project.organization.name}/${project.name}`
|
|
46
|
+
: (project.projectId ?? "");
|
|
47
|
+
exports.formatProjectSlug = formatProjectSlug;
|
|
26
48
|
/**
|
|
27
|
-
* Picks a project
|
|
28
|
-
*
|
|
49
|
+
* Picks a project and persists it as the caller's default (via the backend —
|
|
50
|
+
* see `setOAuthDefaultProject`, consistent across machines and visible to the
|
|
51
|
+
* MCP server). Shared by `auth login` and `auth set-project`.
|
|
29
52
|
*
|
|
30
|
-
* - When `project`
|
|
31
|
-
*
|
|
32
|
-
*
|
|
53
|
+
* - When `project` is given, it's resolved by the backend, which accepts any of
|
|
54
|
+
* a bare id, an `organization/name` slug, or a unique bare name (see
|
|
55
|
+
* `ProjectService.resolveForUserByIdentifier`). We deliberately do NOT match
|
|
56
|
+
* client-side — the CLI would only understand the slug form and diverge from
|
|
57
|
+
* the backend (and from the `--project` override on agent commands).
|
|
33
58
|
* - Otherwise auto-selects the only project, or prompts interactively when
|
|
34
59
|
* there are several — unless `allowInteractivePrompt` is `false` (e.g. a
|
|
35
|
-
* headless login), in which case it
|
|
36
|
-
*
|
|
37
|
-
* on a prompt that no terminal can answer.
|
|
60
|
+
* headless login), in which case it throws with guidance rather than
|
|
61
|
+
* blocking on a prompt that no terminal can answer.
|
|
38
62
|
*
|
|
39
|
-
* Throws `CliUserError` when the
|
|
40
|
-
* project
|
|
63
|
+
* Throws `CliUserError` when the identifier can't be resolved, the caller has
|
|
64
|
+
* no accessible projects, or a project can't be resolved without a prompt.
|
|
41
65
|
*/
|
|
42
|
-
const selectAndStoreProject = async ({ client, project, allowInteractivePrompt = true,
|
|
66
|
+
const selectAndStoreProject = async ({ client, project, allowInteractivePrompt = true, }) => {
|
|
67
|
+
if (project) {
|
|
68
|
+
// Tolerate accidental surrounding whitespace (e.g. from copy-paste). The
|
|
69
|
+
// backend resolves the identifier flexibly and returns the resolved
|
|
70
|
+
// project, so there's no client-side lookup here.
|
|
71
|
+
const trimmedProject = project.trim();
|
|
72
|
+
let stored;
|
|
73
|
+
try {
|
|
74
|
+
stored = await (0, client_1.setOAuthDefaultProject)(client, trimmedProject);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
(0, handle_auth_failure_1.handleAuthFailure)(error);
|
|
78
|
+
throw await toProjectResolutionError(client, trimmedProject, error);
|
|
79
|
+
}
|
|
80
|
+
const projectSlug = (0, exports.formatProjectSlug)(stored);
|
|
81
|
+
(0, common_1.logNotice)(`Selected project: ${projectSlug}`);
|
|
82
|
+
return projectSlug;
|
|
83
|
+
}
|
|
43
84
|
const projects = await (0, exports.fetchAccessibleProjects)(client);
|
|
44
85
|
if (projects.length === 0) {
|
|
45
86
|
throw new cli_user_error_1.CliUserError("No projects are accessible to your account. Ask an organization " +
|
|
46
87
|
"admin to add you to a project.");
|
|
47
88
|
}
|
|
48
89
|
let selected;
|
|
49
|
-
if (
|
|
50
|
-
// Tolerate accidental surrounding whitespace (e.g. from copy-paste), but
|
|
51
|
-
// keep the match case-sensitive: organization/project names are
|
|
52
|
-
// case-sensitive, so two projects could differ only by case and a
|
|
53
|
-
// case-insensitive match would be ambiguous.
|
|
54
|
-
const trimmedProject = project.trim();
|
|
55
|
-
const match = projects.find((p) => `${p.organization.name}/${p.name}` === trimmedProject);
|
|
56
|
-
if (!match) {
|
|
57
|
-
throw new cli_user_error_1.CliUserError(`Project '${trimmedProject}' not found. Available projects:\n${formatProjectList(projects)}`);
|
|
58
|
-
}
|
|
59
|
-
selected = match;
|
|
60
|
-
}
|
|
61
|
-
else if (projects.length === 1) {
|
|
90
|
+
if (projects.length === 1) {
|
|
62
91
|
selected = projects[0];
|
|
63
92
|
}
|
|
64
93
|
else if (allowInteractivePrompt) {
|
|
65
94
|
selected = await promptForProject(projects);
|
|
66
95
|
}
|
|
67
96
|
else {
|
|
68
|
-
// No interactive terminal to answer the picker. Keep the previously
|
|
69
|
-
// selected project if it's still accessible; otherwise fail with guidance
|
|
70
|
-
// on how to choose one, so callers (and scripts) know no project is set.
|
|
71
|
-
const fallback = fallbackToProject
|
|
72
|
-
? projects.find((p) => `${p.organization.name}/${p.name}` === fallbackToProject)
|
|
73
|
-
: undefined;
|
|
74
|
-
if (fallback) {
|
|
75
|
-
const fallbackSlug = `${fallback.organization.name}/${fallback.name}`;
|
|
76
|
-
(0, client_1.setStoredProject)({ project: fallbackSlug, projectId: fallback.id });
|
|
77
|
-
(0, common_1.logNotice)(`Kept previously selected project: ${fallbackSlug}`);
|
|
78
|
-
return fallbackSlug;
|
|
79
|
-
}
|
|
80
97
|
throw new cli_user_error_1.CliUserError("Multiple projects are accessible but none was selected (no interactive " +
|
|
81
98
|
"terminal). Pass `--project` or run `meticulous auth set-project` to " +
|
|
82
99
|
"choose one.", 1, "warn");
|
|
83
100
|
}
|
|
84
101
|
const projectSlug = `${selected.organization.name}/${selected.name}`;
|
|
85
|
-
(0, client_1.
|
|
102
|
+
await (0, client_1.setOAuthDefaultProject)(client, selected.id);
|
|
86
103
|
(0, common_1.logNotice)(`Selected project: ${projectSlug}`);
|
|
87
104
|
return projectSlug;
|
|
88
105
|
};
|
|
89
106
|
exports.selectAndStoreProject = selectAndStoreProject;
|
|
107
|
+
/**
|
|
108
|
+
* Turns a failed explicit-project resolution into a helpful `CliUserError`: the
|
|
109
|
+
* backend's own message (not found / not accessible / ambiguous name) plus the
|
|
110
|
+
* list of accessible projects to pick from.
|
|
111
|
+
*/
|
|
112
|
+
const toProjectResolutionError = async (client, identifier, error) => {
|
|
113
|
+
const serverMessage = (0, client_1.isFetchError)(error)
|
|
114
|
+
? (0, handle_auth_failure_1.extractServerMessage)(error.response?.data)
|
|
115
|
+
: null;
|
|
116
|
+
const projects = await (0, exports.fetchAccessibleProjects)(client).catch(() => []);
|
|
117
|
+
const list = projects.length
|
|
118
|
+
? `\n\nAvailable projects:\n${formatProjectList(projects)}`
|
|
119
|
+
: "";
|
|
120
|
+
const detail = serverMessage ?? `Project '${identifier}' not found or not accessible.`;
|
|
121
|
+
return new cli_user_error_1.CliUserError(`${detail}${list}`);
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Project selection for `auth login`. Behaves like `selectAndStoreProject`
|
|
125
|
+
* (persist an explicit `--project`, auto-select+persist a sole project, prompt
|
|
126
|
+
* among several) with one addition: if the user already has a stored default,
|
|
127
|
+
* respect it rather than re-prompting or failing — so a returning user (in
|
|
128
|
+
* particular a headless `--non-interactive` login) succeeds without re-picking.
|
|
129
|
+
*
|
|
130
|
+
* There's no "cleared default" to preserve here: clearing isn't user-reachable
|
|
131
|
+
* (no `unset-project` command, no web "no default" option), so always selecting
|
|
132
|
+
* a sole project can't silently undo an intentional clear.
|
|
133
|
+
*/
|
|
134
|
+
const selectProjectOnLogin = async ({ client, project, interactive, }) => {
|
|
135
|
+
// An explicit `--project` always wins.
|
|
136
|
+
if (project) {
|
|
137
|
+
await (0, exports.selectAndStoreProject)({
|
|
138
|
+
client,
|
|
139
|
+
project,
|
|
140
|
+
allowInteractivePrompt: interactive,
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// With several accessible projects, respect an already-stored default (the
|
|
145
|
+
// backend only auto-picks when there's exactly one project, so a non-null
|
|
146
|
+
// result here is necessarily the stored preference). This is what lets a
|
|
147
|
+
// returning `--non-interactive` login succeed instead of failing for lack of
|
|
148
|
+
// a picker.
|
|
149
|
+
const projects = await (0, exports.fetchAccessibleProjects)(client);
|
|
150
|
+
if (projects.length > 1) {
|
|
151
|
+
const existing = await (0, client_1.getOAuthDefaultProject)(client);
|
|
152
|
+
if (existing.projectId) {
|
|
153
|
+
(0, common_1.logNotice)(`Using your default project: ${(0, exports.formatProjectSlug)(existing)}.`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Otherwise select-and-persist: a sole project is auto-selected, several
|
|
158
|
+
// prompt interactively (or, headless, error with guidance).
|
|
159
|
+
await (0, exports.selectAndStoreProject)({ client, allowInteractivePrompt: interactive });
|
|
160
|
+
};
|
|
161
|
+
exports.selectProjectOnLogin = selectProjectOnLogin;
|
|
90
162
|
const promptForProject = async (projects) => {
|
|
91
163
|
const { projectId } = await inquirer_1.default.prompt([
|
|
92
164
|
{
|
|
@@ -106,4 +178,5 @@ const promptForProject = async (projects) => {
|
|
|
106
178
|
return selected;
|
|
107
179
|
};
|
|
108
180
|
const formatProjectList = (projects) => projects.map((p) => ` - ${p.organization.name}/${p.name}`).join("\n");
|
|
109
|
-
//# sourceMappingURL=select-project.js.map
|
|
181
|
+
//# sourceMappingURL=select-project.js.map
|
|
182
|
+
//# debugId=e3dd5fa0-bef9-583c-8433-9978a18d5a5d
|