@somewhere-cloud/cli 0.38.49 → 0.38.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/commands/advisor.d.ts +9 -0
  2. package/dist/commands/ai.d.ts +2 -0
  3. package/dist/commands/api.d.ts +14 -0
  4. package/dist/commands/auth.d.ts +30 -0
  5. package/dist/commands/browser.d.ts +247 -0
  6. package/dist/commands/call.d.ts +22 -0
  7. package/dist/commands/catalog.d.ts +16 -0
  8. package/dist/commands/check.d.ts +114 -0
  9. package/dist/commands/claim.d.ts +5 -0
  10. package/dist/commands/cron.d.ts +14 -0
  11. package/dist/commands/db-rows.d.ts +2 -0
  12. package/dist/commands/db.d.ts +2 -0
  13. package/dist/commands/deploy.d.ts +235 -0
  14. package/dist/commands/dev.d.ts +171 -0
  15. package/dist/commands/docs.d.ts +85 -0
  16. package/dist/commands/email.d.ts +8 -0
  17. package/dist/commands/env.d.ts +2 -0
  18. package/dist/commands/errors.d.ts +2 -0
  19. package/dist/commands/feedback.d.ts +2 -0
  20. package/dist/commands/fs.d.ts +2 -0
  21. package/dist/commands/git.d.ts +2 -0
  22. package/dist/commands/grep.d.ts +2 -0
  23. package/dist/commands/hooks.d.ts +2 -0
  24. package/dist/commands/init.d.ts +17 -0
  25. package/dist/commands/link.d.ts +8 -0
  26. package/dist/commands/lint.d.ts +2 -0
  27. package/dist/commands/logs.d.ts +2 -0
  28. package/dist/commands/mcp.d.ts +4 -0
  29. package/dist/commands/open.d.ts +2 -0
  30. package/dist/commands/postgres.d.ts +2 -0
  31. package/dist/commands/project.d.ts +8 -0
  32. package/dist/commands/promote.d.ts +28 -0
  33. package/dist/commands/pull.d.ts +2 -0
  34. package/dist/commands/restore.d.ts +5 -0
  35. package/dist/commands/rollback.d.ts +21 -0
  36. package/dist/commands/run.d.ts +2 -0
  37. package/dist/commands/skills.d.ts +2 -0
  38. package/dist/commands/status.d.ts +27 -0
  39. package/dist/commands/support.d.ts +2 -0
  40. package/dist/commands/tasks.d.ts +2 -0
  41. package/dist/commands/test-users.d.ts +4 -0
  42. package/dist/commands/test.d.ts +2 -0
  43. package/dist/commands/test.js +100 -0
  44. package/dist/commands/test.js.map +1 -0
  45. package/dist/commands/typecheck.d.ts +9 -0
  46. package/dist/commands/update.d.ts +25 -0
  47. package/dist/commands/upgrade.d.ts +12 -0
  48. package/dist/commands/usage.d.ts +2 -0
  49. package/dist/commands/verify.d.ts +419 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +2 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/lib/advisor-context.d.ts +20 -0
  54. package/dist/lib/advisor-runs.d.ts +26 -0
  55. package/dist/lib/agent-hooks.d.ts +74 -0
  56. package/dist/lib/allowed-origins.d.ts +11 -0
  57. package/dist/lib/auth.d.ts +12 -0
  58. package/dist/lib/base-files.d.ts +31 -0
  59. package/dist/lib/browser-actions.d.ts +106 -0
  60. package/dist/lib/browser-flow-preflight.d.ts +6 -0
  61. package/dist/lib/browser-refusal.d.ts +17 -0
  62. package/dist/lib/browser-run.d.ts +102 -0
  63. package/dist/lib/build-errors.d.ts +24 -0
  64. package/dist/lib/chrome.d.ts +66 -0
  65. package/dist/lib/claim-handoff.d.ts +11 -0
  66. package/dist/lib/client.d.ts +150 -0
  67. package/dist/lib/config.d.ts +125 -0
  68. package/dist/lib/declared-data.d.ts +50 -0
  69. package/dist/lib/deploy-check.d.ts +56 -0
  70. package/dist/lib/device-login.d.ts +41 -0
  71. package/dist/lib/device.d.ts +2 -0
  72. package/dist/lib/envfile-write.d.ts +17 -0
  73. package/dist/lib/files.d.ts +111 -0
  74. package/dist/lib/frontend-dev.d.ts +28 -0
  75. package/dist/lib/generic-lint.d.ts +9 -0
  76. package/dist/lib/help-summary.d.ts +2 -0
  77. package/dist/lib/http.d.ts +9 -0
  78. package/dist/lib/init-agent-guide.d.ts +13 -0
  79. package/dist/lib/init-feature-template.d.ts +8 -0
  80. package/dist/lib/init-feature-template.js +10 -7
  81. package/dist/lib/init-feature-template.js.map +1 -1
  82. package/dist/lib/init-features.d.ts +50 -0
  83. package/dist/lib/init-green-template.d.ts +2 -0
  84. package/dist/lib/init-install.d.ts +14 -0
  85. package/dist/lib/init-scaffold.d.ts +44 -0
  86. package/dist/lib/init-template.d.ts +2 -0
  87. package/dist/lib/init-test-template.d.ts +2 -0
  88. package/dist/lib/init-test-template.js +44 -21
  89. package/dist/lib/init-test-template.js.map +1 -1
  90. package/dist/lib/init-ui-kit.d.ts +8 -0
  91. package/dist/lib/last-run.d.ts +38 -0
  92. package/dist/lib/link-hint.d.ts +5 -0
  93. package/dist/lib/next-actions.d.ts +48 -0
  94. package/dist/lib/notify/index.d.ts +18 -0
  95. package/dist/lib/notify/providers/update.d.ts +45 -0
  96. package/dist/lib/notify/types.d.ts +25 -0
  97. package/dist/lib/open.d.ts +1 -0
  98. package/dist/lib/output.d.ts +61 -0
  99. package/dist/lib/platform-command.d.ts +6 -0
  100. package/dist/lib/platform-contract.d.ts +26 -0
  101. package/dist/lib/platform-tools.d.ts +77 -0
  102. package/dist/lib/playwright-fixtures.d.ts +20 -0
  103. package/dist/lib/playwright-fixtures.js +171 -0
  104. package/dist/lib/playwright-fixtures.js.map +1 -0
  105. package/dist/lib/post-live-render.d.ts +48 -0
  106. package/dist/lib/project-notices.d.ts +18 -0
  107. package/dist/lib/project-pin.d.ts +57 -0
  108. package/dist/lib/project-ref.d.ts +32 -0
  109. package/dist/lib/project-urls.d.ts +18 -0
  110. package/dist/lib/promote-handoff.d.ts +65 -0
  111. package/dist/lib/promote-outcome.d.ts +98 -0
  112. package/dist/lib/publish-surface.d.ts +8 -0
  113. package/dist/lib/repro-packet.d.ts +35 -0
  114. package/dist/lib/scaffold.d.ts +46 -0
  115. package/dist/lib/skills-pack.d.ts +81 -0
  116. package/dist/lib/skills-pack.generated.d.ts +2 -0
  117. package/dist/lib/source-lint.d.ts +42 -0
  118. package/dist/lib/spinner.d.ts +14 -0
  119. package/dist/lib/startup-notice.d.ts +23 -0
  120. package/dist/lib/surface-counts.d.ts +88 -0
  121. package/dist/lib/temp-auth.d.ts +53 -0
  122. package/dist/lib/terminal-text.d.ts +10 -0
  123. package/dist/lib/test-diagnostics.d.ts +16 -0
  124. package/dist/lib/test-diagnostics.js +29 -0
  125. package/dist/lib/test-diagnostics.js.map +1 -0
  126. package/dist/lib/test-identities.d.ts +122 -0
  127. package/dist/lib/test-identities.js +1 -1
  128. package/dist/lib/test-identities.js.map +1 -1
  129. package/dist/lib/test-reporter.d.ts +12 -0
  130. package/dist/lib/test-reporter.js +30 -0
  131. package/dist/lib/test-reporter.js.map +1 -0
  132. package/dist/lib/typecheck-version.d.ts +1 -0
  133. package/dist/lib/typecheck.d.ts +136 -0
  134. package/dist/lib/update-security.d.ts +25 -0
  135. package/dist/lib/vendor/deploy-paths.d.ts +21 -0
  136. package/dist/lib/vendor/repro-guidance.d.ts +111 -0
  137. package/dist/lib/verify-keep.d.ts +92 -0
  138. package/dist/lib/verify-progress.d.ts +2 -0
  139. package/dist/lib/verify-report.d.ts +4 -0
  140. package/dist/lib/version.d.ts +1 -0
  141. package/dist/testing.d.ts +37 -0
  142. package/dist/testing.js +2 -0
  143. package/dist/testing.js.map +1 -1
  144. package/dist/types.d.ts +104 -0
  145. package/npm-shrinkwrap.json +48 -2
  146. package/package.json +14 -3
  147. package/runtime/PLATFORM-SOURCE.json +1 -1
  148. package/runtime/SOURCE-LINT-VENDOR.json +1 -1
  149. package/src/testing.ts +3 -0
@@ -0,0 +1,61 @@
1
+ type Style = (value: string) => string;
2
+ export declare function setJsonOutputMode(enabled: boolean): void;
3
+ export declare const teal: Style;
4
+ export declare const dim: Style;
5
+ export declare const bold: Style;
6
+ export declare const red: Style;
7
+ export declare const green: Style;
8
+ export declare const yellow: Style;
9
+ export declare const cyan: Style;
10
+ export declare function success(msg: string): void;
11
+ /**
12
+ * The platform's own refusal, exactly as it should reach `--json`.
13
+ *
14
+ * Both error types that carry one (the API's CliApiError and an MCP tool's
15
+ * PlatformToolError) are matched by shape rather than imported: output.ts sits
16
+ * below client.ts in the import graph. Anything else — a bad flag, a missing
17
+ * file — originated in the CLI and has no code of its own.
18
+ */
19
+ export declare function platformErrorEnvelope(cause: unknown): {
20
+ code: string;
21
+ message: string;
22
+ extra: Record<string, unknown>;
23
+ } | null;
24
+ /** index.ts installs the local repro capture here; output.ts stays dependency-free. */
25
+ export declare function setFailureHook(hook: ((cause: unknown) => void) | null): void;
26
+ /** Record a failure that a command reports in its own output (for example verify's summary) without printing. */
27
+ export declare function noteFailure(cause: unknown): void;
28
+ /** Capture may retain response provenance while the printed error stays unchanged. */
29
+ export declare function error(msg: string, cause?: unknown, captureCause?: unknown): void;
30
+ /**
31
+ * The short scalar fields of a typed failure's validated `data` (for example an
32
+ * ordered edit's edit_index, path, expected, actual, conflicts_with) as one line
33
+ * for text output. Only fields the error's own validator kept are present; a
34
+ * line longer than 200 characters is left to --json.
35
+ */
36
+ export declare function platformErrorDetail(cause: unknown): string | null;
37
+ /**
38
+ * The platform's code and request/trace ids for a text-mode failure (tsk_c95a437d): an agent reading
39
+ * text output gets the same handles `--json` carries. Only validated shapes are printed, so a server
40
+ * cannot place arbitrary text here; the message above stays the platform's own.
41
+ */
42
+ export declare function platformErrorIds(cause: unknown): string | null;
43
+ /** Recovery is tied to this response's validated handle, never the shared last-error file. */
44
+ export declare function printSupportPacketRecovery(cause: unknown): void;
45
+ export declare function warn(msg: string): void;
46
+ export declare function info(msg: string): void;
47
+ export declare function printJson(value: unknown): void;
48
+ export declare function printJsonLine(value: unknown): void;
49
+ export declare function printJsonError(errorCode: string, message: string,
50
+ /** Envelope fields worth machine-reading — today the correlation ids. */
51
+ extra?: Record<string, unknown>): void;
52
+ export declare function stripAnsi(value: string): string;
53
+ export declare function heading(msg: string): void;
54
+ export declare function table(headers: string[], rows: string[][], widths?: number[]): void;
55
+ /** Epoch milliseconds for an API timestamp. Zoneless strings are UTC, never the
56
+ * machine's local time (pfb_b69363269589); ISO with Z/offset and epoch numbers
57
+ * keep their own meaning. */
58
+ export declare function parseApiTime(value: string | number): number;
59
+ export declare function timeAgo(dateStr: string | number): string;
60
+ export declare function statusDot(status: string): string;
61
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare function resolveProjectRef(explicit: string | undefined): string;
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
3
+ export declare function unwrapPlatformData(value: unknown): unknown;
4
+ export declare function compactRecord(entries: Array<[string, unknown]>): Record<string, unknown>;
5
+ export declare function parseCommaList(value: string | undefined): string[] | undefined;
6
+ export declare function truncateText(value: unknown, max?: number): string;
@@ -0,0 +1,26 @@
1
+ export declare const CONTRACT_HEADER = "x-sw-consumer-contract";
2
+ export interface ConsumerContract {
3
+ version: number;
4
+ digest: string;
5
+ }
6
+ export interface SeenPlatformContract extends ConsumerContract {
7
+ seen_at: number;
8
+ origin: string;
9
+ }
10
+ export interface ContractVerdict {
11
+ status: 'unknown' | 'current' | 'outdated' | 'ahead' | 'mismatch';
12
+ compatible: boolean | null;
13
+ message: string;
14
+ cli: ConsumerContract | null;
15
+ platform: SeenPlatformContract | null;
16
+ }
17
+ /** The CLI's own contract, from the vendored platform bundle (null: a bundle from before it existed). */
18
+ export declare function cliConsumerContract(): ConsumerContract | null;
19
+ /** Keep the contract a platform response announced. A response without the header changes nothing. */
20
+ export declare function recordPlatformContract(headers: {
21
+ get(name: string): string | null;
22
+ }, url: string, now?: number): SeenPlatformContract | null;
23
+ /** The last contract seen from `apiBase`'s origin, or null. */
24
+ export declare function seenPlatformContract(apiBase: string): SeenPlatformContract | null;
25
+ /** Whether this CLI may judge code for the platform at `apiBase`. */
26
+ export declare function platformContractVerdict(apiBase: string, now?: number): ContractVerdict;
@@ -0,0 +1,77 @@
1
+ import type { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
2
+ import type { CallToolResult, Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ import { type InvalidDetail } from './vendor/repro-guidance.js';
4
+ export interface PlatformToolCallOptions {
5
+ allTools?: boolean;
6
+ signal?: AbortSignal;
7
+ }
8
+ /** The typed fields of an ordered-edit refusal (project_patch / fs_replace `edits`,
9
+ * tsk_81dd50f0): which edit failed and why, the same handles the MCP response carries. */
10
+ export interface EditRefusalDetail {
11
+ edit_index?: number;
12
+ path?: string;
13
+ expected?: number;
14
+ actual?: number;
15
+ conflicts_with?: string;
16
+ }
17
+ export type PlatformToolErrorData = {
18
+ invalid?: InvalidDetail;
19
+ } & EditRefusalDetail;
20
+ /** Keep only well-formed ordered-edit refusal fields; everything else in `data` is dropped. */
21
+ export declare function safeEditDetail(value: unknown): EditRefusalDetail | undefined;
22
+ export declare class PlatformToolError extends Error {
23
+ readonly tool: string;
24
+ /** The platform's own error code, message, fix and request id, when the
25
+ * tool answered with its JSON envelope — `message` above flattens them. */
26
+ readonly code?: string | undefined;
27
+ readonly detail?: string | undefined;
28
+ readonly hint?: string | undefined;
29
+ readonly meta: {
30
+ requestId?: string;
31
+ traceId?: string;
32
+ retry?: boolean;
33
+ retryAfterMs?: number;
34
+ };
35
+ /** The HTTP status the platform reported for this tool failure (its envelope's
36
+ * `http_status`), so a definite refusal is not recorded as an unknown outcome. */
37
+ readonly statusCode?: number | undefined;
38
+ /** Only validated typed fields: the canonical input location and the ordered-edit
39
+ * refusal detail. Arbitrary tool data is never copied. */
40
+ readonly data?: PlatformToolErrorData | undefined;
41
+ constructor(tool: string, message: string,
42
+ /** The platform's own error code, message, fix and request id, when the
43
+ * tool answered with its JSON envelope — `message` above flattens them. */
44
+ code?: string | undefined, detail?: string | undefined, hint?: string | undefined, meta?: {
45
+ requestId?: string;
46
+ traceId?: string;
47
+ retry?: boolean;
48
+ retryAfterMs?: number;
49
+ },
50
+ /** The HTTP status the platform reported for this tool failure (its envelope's
51
+ * `http_status`), so a definite refusal is not recorded as an unknown outcome. */
52
+ statusCode?: number | undefined,
53
+ /** Only validated typed fields: the canonical input location and the ordered-edit
54
+ * refusal detail. Arbitrary tool data is never copied. */
55
+ data?: PlatformToolErrorData | undefined);
56
+ }
57
+ export declare function mcpAccessExpiresSoon(): boolean;
58
+ /** Reuse ApiClient's canonical cli-pair rotation and persistence path. */
59
+ export declare function refreshMcpAccessToken(preemptive: boolean): Promise<string>;
60
+ /** The status code and server message of an upstream MCP HTTP refusal (the SDK flattens them into text). */
61
+ export declare function mcpHttpFailure(err: unknown): {
62
+ status: number;
63
+ code?: string;
64
+ message: string;
65
+ } | null;
66
+ /** The real reason a request failed: the platform's code and message, the HTTP status, or the network cause. */
67
+ export declare function describeMcpFailure(err: unknown, url?: string): string;
68
+ export declare function isMcpAuthRejection(err: unknown): boolean;
69
+ export declare function createPlatformMcpTransport(token: string, options?: PlatformToolCallOptions & {
70
+ userAgent?: string;
71
+ }): Promise<StreamableHTTPClientTransport>;
72
+ export declare function listPlatformTools(options?: PlatformToolCallOptions): Promise<Tool[]>;
73
+ export declare function platformToolErrorFromText(name: string, text: string): PlatformToolError;
74
+ export declare function callPlatformToolRaw(name: string, args: Record<string, unknown>, options?: PlatformToolCallOptions): Promise<CallToolResult>;
75
+ export declare function platformToolResultValue(result: CallToolResult): unknown;
76
+ export declare function callPlatformTool(name: string, args: Record<string, unknown>, options?: PlatformToolCallOptions): Promise<unknown>;
77
+ export declare function callPlatformHelpTool(name: 'advisor' | 'catalog' | 'docs', args: Record<string, unknown>): Promise<string>;
@@ -0,0 +1,20 @@
1
+ import type { APIRequestContext, APIResponse, Locator, Page, TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from '@playwright/test';
2
+ import type { DataRequest } from '../testing.js';
3
+ export interface TestUser {
4
+ id: string;
5
+ email: string;
6
+ page: Page;
7
+ request: APIRequestContext;
8
+ }
9
+ interface Fixtures {
10
+ _evidence: void;
11
+ newUser: () => Promise<TestUser>;
12
+ anonymous: APIRequestContext;
13
+ }
14
+ type RunnerTest = TestType<PlaywrightTestArgs & PlaywrightTestOptions & Fixtures, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
15
+ export declare const test: RunnerTest;
16
+ export declare const expect: typeof import('@playwright/test').expect;
17
+ export declare function expectRefused(response: APIResponse, status: number, code: string): Promise<void>;
18
+ export declare function data(client: APIRequestContext, table: string, request: DataRequest): Promise<APIResponse>;
19
+ export declare function ready(page: Page, state?: 'ready' | 'signed-in' | 'signed-out' | Locator): Promise<void>;
20
+ export {};
@@ -0,0 +1,171 @@
1
+ import { createRequire } from 'node:module';
2
+ import { join } from 'node:path';
3
+ import { ApiClient } from './client.js';
4
+ import { getToken, loadProjectConfig } from './config.js';
5
+ import { buildStorageState, createTestIdentities, expiryOf, productionOrigin } from './test-identities.js';
6
+ import { diagnostics, rememberSecrets, scrub, timed } from './test-diagnostics.js';
7
+ let loaded;
8
+ const digests = new WeakMap();
9
+ function runner() {
10
+ if (loaded)
11
+ return loaded;
12
+ const require = createRequire(join(process.cwd(), 'package.json'));
13
+ let pw;
14
+ try {
15
+ pw = require('@playwright/test');
16
+ }
17
+ catch {
18
+ throw new Error('Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli');
19
+ }
20
+ const test = pw.test.extend({
21
+ _evidence: [async ({}, use, info) => {
22
+ try {
23
+ await use();
24
+ }
25
+ finally {
26
+ const report = diagnostics(info);
27
+ await info.attach('somewhere-diagnostics', { body: Buffer.from(JSON.stringify({ ...report, title: scrub(info.title), errors: info.errors.map(error => scrub(error.message ?? 'Test failed').split('\n').find(line => line.trim()) ?? 'Test failed'), secretAudit: 'issued values scrubbed before reporting' })), contentType: 'application/json' });
28
+ }
29
+ }, { auto: true }],
30
+ newUser: async ({ browser }, use, info) => {
31
+ const projectId = loadProjectConfig()?.project_id;
32
+ if (!projectId)
33
+ throw new Error('Run somewhere test from a linked project folder.');
34
+ const client = new ApiClient(getToken());
35
+ const urls = await timed(info, 'target lookup', () => client.call('GET', `/projects/${encodeURIComponent(projectId)}/urls`));
36
+ const { origin, host } = productionOrigin(urls.prod_fallback);
37
+ const map = await timed(info, 'access map', () => client.call('GET', '/db/access-map', undefined, { project_id: projectId }));
38
+ const owned = [];
39
+ const contexts = [];
40
+ const partialIds = [];
41
+ try {
42
+ await use(async () => {
43
+ let created;
44
+ try {
45
+ created = await timed(info, 'test-user creation', () => createTestIdentities(client, projectId, 'user', 1, 'pw'));
46
+ }
47
+ catch (error) {
48
+ partialIds.push(...(error.createdIds ?? []));
49
+ owned.push(...(error.issued ?? []));
50
+ throw error;
51
+ }
52
+ owned.push(...created.issued);
53
+ const issued = created.issued[0];
54
+ rememberSecrets(issued.access_token, issued.refresh_token);
55
+ const context = await browser.newContext({ baseURL: origin, extraHTTPHeaders: { Origin: origin }, storageState: buildStorageState(origin, host, issued, expiryOf(issued, created.receivedAt)) });
56
+ contexts.push(context);
57
+ constrain(context.request, origin, info);
58
+ digests.set(context.request, map.browser_data.contract_digest);
59
+ const page = await timed(info, 'page creation', () => context.newPage());
60
+ page.on('load', () => { void page.evaluate("performance.getEntriesByType('navigation')[0]?.duration ?? 0").then(ms => { diagnostics(info).timings['page load'] = ms; }).catch(() => { }); });
61
+ return { id: issued.user.id, email: issued.user.email, page, request: context.request };
62
+ });
63
+ }
64
+ finally {
65
+ const failures = [];
66
+ for (const context of contexts)
67
+ try {
68
+ if (info.status !== info.expectedStatus) {
69
+ const page = context.pages()[0];
70
+ if (page && !/auth|login|signup|reset/i.test(new URL(page.url()).pathname)) {
71
+ const path = info.outputPath('failure.png');
72
+ await page.screenshot({ path, mask: [page.locator('input, textarea')] });
73
+ diagnostics(info).screenshot = path;
74
+ }
75
+ }
76
+ await context.close();
77
+ }
78
+ catch {
79
+ failures.push('Browser context cleanup failed');
80
+ }
81
+ const ids = [...new Set([...owned.map(identity => identity.user.id), ...partialIds])];
82
+ if (ids.length) {
83
+ try {
84
+ await timed(info, 'test-user deletion', () => client.call('DELETE', '/auth/test-users', { project_id: projectId, ids }));
85
+ const remaining = await timed(info, 'cleanup confirmation', () => client.call('GET', '/auth/test-users', undefined, { project_id: projectId }));
86
+ if (remaining.identities.some(identity => ids.includes(identity.id)))
87
+ failures.push('Test user cleanup unconfirmed');
88
+ }
89
+ catch {
90
+ failures.push('Test user cleanup unconfirmed; app rows remain');
91
+ }
92
+ }
93
+ if (failures.length)
94
+ throw new Error(failures.join('; '));
95
+ }
96
+ },
97
+ anonymous: async ({ browser }, use, info) => {
98
+ const projectId = loadProjectConfig()?.project_id;
99
+ if (!projectId)
100
+ throw new Error('Run from a linked project folder.');
101
+ const client = new ApiClient(getToken());
102
+ const urls = await timed(info, 'target lookup', () => client.call('GET', `/projects/${encodeURIComponent(projectId)}/urls`));
103
+ const { origin } = productionOrigin(urls.prod_fallback);
104
+ const map = await timed(info, 'access map', () => client.call('GET', '/db/access-map', undefined, { project_id: projectId }));
105
+ const context = await browser.newContext({ baseURL: origin, extraHTTPHeaders: { Origin: origin } });
106
+ constrain(context.request, origin, info);
107
+ digests.set(context.request, map.browser_data.contract_digest);
108
+ try {
109
+ await use(context.request);
110
+ }
111
+ finally {
112
+ await context.close();
113
+ }
114
+ },
115
+ });
116
+ loaded = { test, expect: pw.expect };
117
+ return loaded;
118
+ }
119
+ // Patch the shared-cookie client, preserving its identity and cookie rotation.
120
+ function constrain(client, origin, info) {
121
+ for (const method of ['fetch']) {
122
+ const original = client[method].bind(client);
123
+ Object.defineProperty(client, method, { value: async (path, options = {}) => {
124
+ const url = new URL(path, origin);
125
+ if (url.origin !== origin)
126
+ throw new Error('Fixture requests must stay on the app origin');
127
+ const headers = new Headers(options.headers);
128
+ if (headers.has('Authorization'))
129
+ throw new Error('Fixture clients do not accept Authorization headers');
130
+ headers.set('Origin', origin);
131
+ const response = await timed(info, 'app requests', () => original(url.href, { ...options, headers: Object.fromEntries(headers), maxRedirects: 0 }));
132
+ let code = 'none';
133
+ if (response.status() >= 400) {
134
+ try {
135
+ const body = await response.json();
136
+ if (typeof body.error === 'string' && /^[A-Z_]+$/.test(body.error))
137
+ code = body.error;
138
+ }
139
+ catch { }
140
+ }
141
+ diagnostics(info).request = { method: String(options.method ?? 'GET').toUpperCase(), path: scrub(url.pathname), status: response.status(), code };
142
+ return response;
143
+ } });
144
+ }
145
+ }
146
+ export const test = new Proxy((() => { }), {
147
+ apply: (_target, receiver, args) => Reflect.apply(runner().test, receiver, args),
148
+ get: (_target, key) => Reflect.get(runner().test, key),
149
+ });
150
+ export const expect = new Proxy((() => { }), {
151
+ apply: (_target, receiver, args) => Reflect.apply(runner().expect, receiver, args),
152
+ get: (_target, key) => Reflect.get(runner().expect, key),
153
+ });
154
+ export async function expectRefused(response, status, code) {
155
+ const actual = response.status();
156
+ if ([400, 409].includes(actual) || [400, 409].includes(status))
157
+ throw new Error(`HTTP ${actual}: malformed request or contract mismatch proves no access refusal`);
158
+ const body = await response.json();
159
+ if (actual !== status || body.error !== code)
160
+ throw new Error(`Expected HTTP ${status} ${code}; received HTTP ${actual} ${typeof body.error === 'string' && /^[A-Z_]+$/.test(body.error) ? body.error : 'unknown error code'}`);
161
+ }
162
+ export function data(client, table, request) {
163
+ if (!digests.has(client))
164
+ throw new Error('Use a newUser or anonymous fixture client');
165
+ return client.post('/__sw/data', { data: { ...request, table, contract: digests.get(client) ?? '' } });
166
+ }
167
+ export async function ready(page, state = 'ready') {
168
+ const locator = typeof state === 'string' ? page.locator(state === 'ready' ? '[data-app-state="signed-in"], [data-app-state="signed-out"]' : `[data-app-state="${state}"]`) : state;
169
+ await locator.waitFor({ state: 'visible' });
170
+ }
171
+ //# sourceMappingURL=playwright-fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright-fixtures.js","sourceRoot":"","sources":["../../src/lib/playwright-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,E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C;AACzG,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAU,EAAE,QAAwD,OAAO;IACrG,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,6DAA6D,CAAC,CAAC,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACpL,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Close the loop on a release whose blank-page check runs after the deploy
3
+ * answered (tsk_b9507144).
4
+ *
5
+ * A release that can be undone by moving the live pointer answers before its
6
+ * browser check, with post_live_render: { status: 'pending' }. The check takes
7
+ * 0.7-2.8 s and rolls a blank page back. The CLI waits for it, up to
8
+ * POST_LIVE_RENDER_WAIT_MS, by reading GET /deploy/log?release_id=:
9
+ * - settled and passed: the deploy result gains that blank_page_check;
10
+ * - rendered blank: the platform returns the same DEPLOY_BLANK_PAGE body a
11
+ * gated first deploy answers with, raised here as that same error;
12
+ * - not settled in time: the deploy is live and the line below says the
13
+ * check is still running.
14
+ */
15
+ import { type ApiClient } from './client.js';
16
+ export declare const POST_LIVE_RENDER_WAIT_MS = 5000;
17
+ export declare const POST_LIVE_RENDER_POLL_MS = 400;
18
+ export declare const POST_LIVE_RENDER_STILL_RUNNING = "live; blank-page check still running, see the deploy log";
19
+ export interface PostLiveRenderRecord {
20
+ status: string;
21
+ blank_page_check?: unknown;
22
+ warning?: string;
23
+ message?: string;
24
+ active_release_id?: string | null;
25
+ }
26
+ export type PostLiveRenderWait = {
27
+ kind: 'not_pending';
28
+ } | {
29
+ kind: 'settled';
30
+ post_live_render: PostLiveRenderRecord;
31
+ blank_page_check: unknown;
32
+ } | {
33
+ kind: 'timeout';
34
+ };
35
+ /** Wait for a pending render check. Throws the DEPLOY_BLANK_PAGE CliApiError
36
+ * when the release rendered blank. A read that fails is retried until the
37
+ * deadline; never success by default. */
38
+ export declare function awaitPostLiveRender(client: Pick<ApiClient, 'call'>, projectId: string | undefined, result: {
39
+ release_id?: string;
40
+ post_live_render?: {
41
+ status?: string;
42
+ } | null;
43
+ }, opts?: {
44
+ waitMs?: number;
45
+ pollMs?: number;
46
+ now?: () => number;
47
+ sleep?: (ms: number) => Promise<void>;
48
+ }): Promise<PostLiveRenderWait>;
@@ -0,0 +1,18 @@
1
+ import type { ApiClient } from './client.js';
2
+ export interface ProjectNotice {
3
+ id: string;
4
+ title: string;
5
+ body_md: string;
6
+ severity: 'info' | 'action_required' | 'critical';
7
+ action_hint: string;
8
+ target_runtime_version: number;
9
+ current_runtime_version: number | null;
10
+ created_at: number;
11
+ }
12
+ export interface ShowProjectNoticeOptions {
13
+ now?: number;
14
+ statePath?: string;
15
+ write?: (line: string) => void;
16
+ }
17
+ export declare function formatProjectNotice(notice: ProjectNotice): string;
18
+ export declare function showProjectNotices(client: ApiClient, projectRef: string, options?: ShowProjectNoticeOptions): Promise<ProjectNotice[]>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A project records the CLI version it was built with, the way an npm project
3
+ * records any dependency (tsk_a4641877). Getting a newer CLI is then a
4
+ * deliberate `somewhere upgrade`, not whatever `npx …@latest` fetched today.
5
+ *
6
+ * Where the pin lives, read in this order (the first one found is the pin):
7
+ * package.json devDependencies (or dependencies) "@somewhere-cloud/cli"
8
+ * — what `somewhere init` writes into a new starter
9
+ * .somewhere.json "cli_version" — for a linked folder whose package.json
10
+ * does not declare the CLI (or that has none): written by
11
+ * init --bare/link and by the first deploy, never into a
12
+ * package.json the CLI did not write (a devDependency added
13
+ * behind a lockfile would break the owner's `npm ci`).
14
+ */
15
+ export declare const CLI_PACKAGE_NAME = "@somewhere-cloud/cli";
16
+ export declare const PIN_FILE_KEY = "cli_version";
17
+ export type PinSource = 'package.json' | '.somewhere.json';
18
+ export interface ProjectPin {
19
+ /** Exactly as written: an exact version, or a range someone chose. */
20
+ spec: string;
21
+ source: PinSource;
22
+ }
23
+ /** Every place this folder records a CLI version, in precedence order. */
24
+ export declare function readProjectPins(dir: string): ProjectPin[];
25
+ /** The pin that governs this folder, or null when it records none (or one that
26
+ * is not a version or range, such as a tag or a file: path). */
27
+ export declare function readProjectPin(dir: string): ProjectPin | null;
28
+ export declare function pinSatisfied(pin: ProjectPin, version: string): boolean;
29
+ /** The CLI installed in this folder's node_modules, when it satisfies the pin
30
+ * and is not the one already running: the command is handed to it. */
31
+ export declare function installedPinnedCli(dir: string, pin: ProjectPin, running: string): {
32
+ version: string;
33
+ bin: string;
34
+ } | null;
35
+ /** The one line a folder pinned to another CLI version prints, on stderr. */
36
+ export declare function pinNotice(pin: ProjectPin, running: string, delegatedTo: string | null): string;
37
+ /** Set on a command handed to the project's installed CLI, so it runs as is. */
38
+ export declare const PINNED_CHILD_ENV = "SOMEWHERE_PINNED_CLI";
39
+ export interface PinDecision {
40
+ notice: string | null;
41
+ /** The installed pinned CLI's entrypoint to hand this command to. */
42
+ delegate: string | null;
43
+ }
44
+ export declare function decidePin(dir: string, running: string, argv: string[], env: NodeJS.ProcessEnv): PinDecision;
45
+ /** Write `version` into every place this folder records a pin. */
46
+ export declare function writeProjectPins(dir: string, pins: ProjectPin[], version: string): PinSource[];
47
+ /** Record this CLI in a linked folder that records no version yet: the first
48
+ * deploy pins the project. Only .somewhere.json is written. */
49
+ export declare function recordPinIfMissing(dir: string, version: string): boolean;
50
+ export interface ChangelogEntry {
51
+ version: string;
52
+ body: string;
53
+ }
54
+ /** This CLI's own CHANGELOG.md, shipped in the package. */
55
+ export declare function readBundledChangelog(): string;
56
+ /** The `## x.y.z` sections above `from` up to and including `to`, newest first. */
57
+ export declare function changelogBetween(markdown: string, from: string, to: string): ChangelogEntry[];
@@ -0,0 +1,32 @@
1
+ /**
2
+ * One way to name a project, on every command.
3
+ *
4
+ * The CLI grew two syntaxes: most commands take `--project <ref>`, but `logs`,
5
+ * `errors`, `status`, `open` and `rollback` took only a positional and
6
+ * answered `error: unknown option '--project'`. An agent that learned the flag
7
+ * on `deploy` hit a wall on `logs`, with nothing in the message to suggest the
8
+ * positional exists (parity finding #10).
9
+ *
10
+ * The fix is additive on purpose: the positional keeps working everywhere, so
11
+ * nothing that runs today stops running, and the flag now works everywhere too.
12
+ * Passing both is only an error when they disagree — repeating yourself is
13
+ * harmless; naming two different projects in one command is not, and guessing
14
+ * which one was meant is how the wrong project gets rolled back.
15
+ */
16
+ export type ProjectRefChoice = {
17
+ kind: 'ref';
18
+ ref: string;
19
+ }
20
+ /** Neither form was given — the caller falls back to the linked project. */
21
+ | {
22
+ kind: 'none';
23
+ } | {
24
+ kind: 'conflict';
25
+ positional: string;
26
+ flag: string;
27
+ };
28
+ export declare function chooseProjectRef(positional: string | undefined, flag: string | undefined): ProjectRefChoice;
29
+ export declare function projectRefConflictMessage(conflict: {
30
+ positional: string;
31
+ flag: string;
32
+ }): string;
@@ -0,0 +1,18 @@
1
+ import { ApiClient } from './client.js';
2
+ export interface ProjectServingUrlFields {
3
+ subdomain?: string | null;
4
+ slug?: string | null;
5
+ }
6
+ export declare function getProjectServingUrl(client: ApiClient, projectRef: string): Promise<string | null>;
7
+ /** Frontend hot reload needs an existing deployed backend. The URL endpoint
8
+ * carries canonical release identity or the legacy serving version. A reserved
9
+ * hostname alone is not evidence of a deploy. */
10
+ export declare function getDeployedProjectServingUrl(client: ApiClient, projectRef: string): Promise<string>;
11
+ /** The app URL to hand to SDK clients, exactly as the platform reports it:
12
+ * the attached custom domain, else the platform-issued tenant origin. */
13
+ export declare function getAuthoritativeAppUrl(client: Pick<ApiClient, 'call'>, projectRef: string): Promise<string | null>;
14
+ /** An https origin without credentials, or null. */
15
+ export declare function httpsOrigin(value: unknown): string | null;
16
+ /** Display-only fallback from the globally unique subdomain. A slug is unique
17
+ * only per owner and can be another customer's subdomain, so it is never a host. */
18
+ export declare function fallbackProjectServingUrl(project: ProjectServingUrlFields): string | null;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The promote command the CLI hands back, and the two things it must say after
3
+ * a promote lands.
4
+ *
5
+ * Both come out of the same parity run:
6
+ *
7
+ * - The printed promote command could not be run in the shell that printed it.
8
+ * `somewhere preview` and `somewhere status` printed
9
+ * `somewhere promote <session> <preview>`; `somewhere promote` then refuses
10
+ * that exact command with "Refusing to promote without confirmation in a
11
+ * non-interactive shell" — so the one context where the hosted loop is the
12
+ * only way to see the app (an agent, a script, a piped terminal) is the one
13
+ * context where the CLI's own output does not work.
14
+ *
15
+ * - Promotion moved the app and said nothing about the data. Preview rows stay
16
+ * in the preview database; that isolation is the point, but a developer who
17
+ * is not told rediscovers it by opening an empty production page and
18
+ * repeating the whole acceptance pass.
19
+ *
20
+ * Pure so both directions can be fixtured without a network or a terminal.
21
+ */
22
+ /**
23
+ * The promote command for a given shell.
24
+ *
25
+ * Non-interactive: one line, with `--yes`, because there is nobody to answer a
26
+ * prompt and a command that cannot run is not a handoff.
27
+ *
28
+ * Interactive: the plain command first — a person at a keyboard should get the
29
+ * confirmation, not be handed an unattended promote they did not ask for — and
30
+ * the `--yes` form named after it, so the same output is still useful when it
31
+ * is scrolled back to from a script.
32
+ */
33
+ export declare function promoteCommands(args: {
34
+ previewSessionId: string;
35
+ previewId: string;
36
+ projectRef: string;
37
+ interactive: boolean;
38
+ }): string[];
39
+ /** Quote an opaque project ref so the printed command is safe to paste into a
40
+ * POSIX shell even when the ref is a project name rather than a UUID/slug. */
41
+ export declare function shellArgument(value: string): string;
42
+ /** The single command to print when only one line fits. Always runnable here. */
43
+ export declare function promoteCommandForShell(args: {
44
+ previewSessionId: string;
45
+ previewId: string;
46
+ projectRef: string;
47
+ interactive: boolean;
48
+ }): string;
49
+ /** The label for each printed variant, so two lines are not two mysteries. */
50
+ export declare function promoteCommandLines(args: {
51
+ previewSessionId: string;
52
+ previewId: string;
53
+ projectRef: string;
54
+ interactive: boolean;
55
+ }): string[];
56
+ /**
57
+ * What a developer needs to know about their data the moment production
58
+ * changes.
59
+ *
60
+ * The platform is adding a field that says this in its own words; when it
61
+ * sends one, that wins, so the sentence can be corrected without waiting for a
62
+ * CLI release. Until then the CLI says it from what it already knows, because
63
+ * a line that waits on a deploy is a line nobody reads.
64
+ */
65
+ export declare function promotedDataNotes(platformNote?: unknown): string[];