@somewhere-cloud/cli 0.38.48 → 0.38.51

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 (142) 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 +74 -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-features.d.ts +50 -0
  81. package/dist/lib/init-green-template.d.ts +2 -0
  82. package/dist/lib/init-install.d.ts +14 -0
  83. package/dist/lib/init-scaffold.d.ts +44 -0
  84. package/dist/lib/init-template.d.ts +2 -0
  85. package/dist/lib/init-test-template.d.ts +2 -0
  86. package/dist/lib/init-ui-kit.d.ts +8 -0
  87. package/dist/lib/last-run.d.ts +38 -0
  88. package/dist/lib/link-hint.d.ts +5 -0
  89. package/dist/lib/next-actions.d.ts +48 -0
  90. package/dist/lib/notify/index.d.ts +18 -0
  91. package/dist/lib/notify/providers/update.d.ts +45 -0
  92. package/dist/lib/notify/types.d.ts +25 -0
  93. package/dist/lib/open.d.ts +1 -0
  94. package/dist/lib/output.d.ts +61 -0
  95. package/dist/lib/platform-command.d.ts +6 -0
  96. package/dist/lib/platform-contract.d.ts +26 -0
  97. package/dist/lib/platform-tools.d.ts +77 -0
  98. package/dist/lib/playwright-fixtures.d.ts +19 -0
  99. package/dist/lib/playwright-fixtures.js +140 -0
  100. package/dist/lib/playwright-fixtures.js.map +1 -0
  101. package/dist/lib/post-live-render.d.ts +48 -0
  102. package/dist/lib/project-notices.d.ts +18 -0
  103. package/dist/lib/project-pin.d.ts +57 -0
  104. package/dist/lib/project-ref.d.ts +32 -0
  105. package/dist/lib/project-urls.d.ts +18 -0
  106. package/dist/lib/promote-handoff.d.ts +65 -0
  107. package/dist/lib/promote-outcome.d.ts +98 -0
  108. package/dist/lib/publish-surface.d.ts +8 -0
  109. package/dist/lib/repro-packet.d.ts +35 -0
  110. package/dist/lib/scaffold.d.ts +46 -0
  111. package/dist/lib/skills-pack.d.ts +81 -0
  112. package/dist/lib/skills-pack.generated.d.ts +2 -0
  113. package/dist/lib/source-lint.d.ts +42 -0
  114. package/dist/lib/spinner.d.ts +14 -0
  115. package/dist/lib/startup-notice.d.ts +23 -0
  116. package/dist/lib/surface-counts.d.ts +88 -0
  117. package/dist/lib/temp-auth.d.ts +53 -0
  118. package/dist/lib/terminal-text.d.ts +10 -0
  119. package/dist/lib/test-identities.d.ts +122 -0
  120. package/dist/lib/test-identities.js +1 -1
  121. package/dist/lib/test-identities.js.map +1 -1
  122. package/dist/lib/test-reporter.d.ts +13 -0
  123. package/dist/lib/test-reporter.js +28 -0
  124. package/dist/lib/test-reporter.js.map +1 -0
  125. package/dist/lib/typecheck-version.d.ts +1 -0
  126. package/dist/lib/typecheck.d.ts +136 -0
  127. package/dist/lib/update-security.d.ts +25 -0
  128. package/dist/lib/vendor/deploy-paths.d.ts +21 -0
  129. package/dist/lib/vendor/repro-guidance.d.ts +111 -0
  130. package/dist/lib/verify-keep.d.ts +92 -0
  131. package/dist/lib/verify-progress.d.ts +2 -0
  132. package/dist/lib/verify-report.d.ts +4 -0
  133. package/dist/lib/version.d.ts +1 -0
  134. package/dist/testing.d.ts +37 -0
  135. package/dist/testing.js +2 -0
  136. package/dist/testing.js.map +1 -1
  137. package/dist/types.d.ts +104 -0
  138. package/npm-shrinkwrap.json +48 -2
  139. package/package.json +14 -3
  140. package/runtime/PLATFORM-SOURCE.json +1 -1
  141. package/runtime/SOURCE-LINT-VENDOR.json +1 -1
  142. package/src/testing.ts +4 -1
@@ -0,0 +1,140 @@
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
+ let loaded;
7
+ const digests = new WeakMap();
8
+ function runner() {
9
+ if (loaded)
10
+ return loaded;
11
+ const require = createRequire(join(process.cwd(), 'package.json'));
12
+ let pw;
13
+ try {
14
+ pw = require('@playwright/test');
15
+ }
16
+ catch {
17
+ throw new Error('Install project test dependencies: npm install -D @playwright/test @somewhere-cloud/cli');
18
+ }
19
+ const test = pw.test.extend({
20
+ newUser: async ({ browser }, use) => {
21
+ const projectId = loadProjectConfig()?.project_id;
22
+ if (!projectId)
23
+ throw new Error('Run somewhere test from a linked project folder.');
24
+ const client = new ApiClient(getToken());
25
+ const urls = await client.call('GET', `/projects/${encodeURIComponent(projectId)}/urls`);
26
+ const { origin, host } = productionOrigin(urls.prod_fallback);
27
+ const map = await client.call('GET', '/db/access-map', undefined, { project_id: projectId });
28
+ const owned = [];
29
+ const contexts = [];
30
+ const partialIds = [];
31
+ try {
32
+ await use(async () => {
33
+ let created;
34
+ try {
35
+ created = await createTestIdentities(client, projectId, 'user', 1, 'pw');
36
+ }
37
+ catch (error) {
38
+ partialIds.push(...(error.createdIds ?? []));
39
+ owned.push(...(error.issued ?? []));
40
+ throw error;
41
+ }
42
+ owned.push(...created.issued);
43
+ const issued = created.issued[0];
44
+ const context = await browser.newContext({ baseURL: origin, extraHTTPHeaders: { Origin: origin }, storageState: buildStorageState(origin, host, issued, expiryOf(issued, created.receivedAt)) });
45
+ contexts.push(context);
46
+ constrain(context.request, origin);
47
+ digests.set(context.request, map.browser_data.contract_digest);
48
+ const page = await context.newPage();
49
+ return { id: issued.user.id, email: issued.user.email, page, request: context.request };
50
+ });
51
+ }
52
+ finally {
53
+ const failures = [];
54
+ for (const context of contexts)
55
+ try {
56
+ await context.close();
57
+ }
58
+ catch {
59
+ failures.push('Browser context cleanup failed');
60
+ }
61
+ const ids = [...new Set([...owned.map(identity => identity.user.id), ...partialIds])];
62
+ if (ids.length) {
63
+ try {
64
+ await client.call('DELETE', '/auth/test-users', { project_id: projectId, ids });
65
+ const remaining = await client.call('GET', '/auth/test-users', undefined, { project_id: projectId });
66
+ if (remaining.identities.some(identity => ids.includes(identity.id)))
67
+ failures.push('Test user cleanup unconfirmed');
68
+ }
69
+ catch {
70
+ failures.push('Test user cleanup unconfirmed; app rows remain');
71
+ }
72
+ }
73
+ if (failures.length)
74
+ throw new Error(failures.join('; '));
75
+ }
76
+ },
77
+ anonymous: async ({ browser }, use) => {
78
+ const projectId = loadProjectConfig()?.project_id;
79
+ if (!projectId)
80
+ throw new Error('Run from a linked project folder.');
81
+ const client = new ApiClient(getToken());
82
+ const urls = await client.call('GET', `/projects/${encodeURIComponent(projectId)}/urls`);
83
+ const { origin } = productionOrigin(urls.prod_fallback);
84
+ const map = await client.call('GET', '/db/access-map', undefined, { project_id: projectId });
85
+ const context = await browser.newContext({ baseURL: origin, extraHTTPHeaders: { Origin: origin } });
86
+ constrain(context.request, origin);
87
+ digests.set(context.request, map.browser_data.contract_digest);
88
+ try {
89
+ await use(context.request);
90
+ }
91
+ finally {
92
+ await context.close();
93
+ }
94
+ },
95
+ });
96
+ loaded = { test, expect: pw.expect };
97
+ return loaded;
98
+ }
99
+ // Patch the shared-cookie client, preserving its identity and cookie rotation.
100
+ function constrain(client, origin) {
101
+ for (const method of ['fetch', 'get', 'post', 'put', 'patch', 'delete', 'head']) {
102
+ const original = client[method].bind(client);
103
+ Object.defineProperty(client, method, { value: (path, options = {}) => {
104
+ const url = new URL(path, origin);
105
+ if (url.origin !== origin)
106
+ throw new Error('Fixture requests must stay on the app origin');
107
+ const headers = new Headers(options.headers);
108
+ if (headers.has('Authorization'))
109
+ throw new Error('Fixture clients do not accept Authorization headers');
110
+ headers.set('Origin', origin);
111
+ return original(url.href, { ...options, headers: Object.fromEntries(headers), maxRedirects: 0 });
112
+ } });
113
+ }
114
+ }
115
+ export const test = new Proxy((() => { }), {
116
+ apply: (_target, receiver, args) => Reflect.apply(runner().test, receiver, args),
117
+ get: (_target, key) => Reflect.get(runner().test, key),
118
+ });
119
+ export const expect = new Proxy((() => { }), {
120
+ apply: (_target, receiver, args) => Reflect.apply(runner().expect, receiver, args),
121
+ get: (_target, key) => Reflect.get(runner().expect, key),
122
+ });
123
+ export async function expectRefused(response, status, code) {
124
+ const actual = response.status();
125
+ if ([400, 409].includes(actual) || [400, 409].includes(status))
126
+ throw new Error(`HTTP ${actual}: malformed request or contract mismatch proves no access refusal`);
127
+ const body = await response.json();
128
+ if (actual !== status || body.error !== code)
129
+ throw new Error(`Expected HTTP ${status} ${code}; received HTTP ${actual} ${typeof body.error === 'string' && /^[A-Z_]+$/.test(body.error) ? body.error : 'unknown error code'}`);
130
+ }
131
+ export function data(client, table, request) {
132
+ if (!digests.has(client))
133
+ throw new Error('Use a newUser or anonymous fixture client');
134
+ return client.post('/__sw/data', { data: { ...request, table, contract: digests.get(client) ?? '' } });
135
+ }
136
+ export async function ready(page, state = 'ready') {
137
+ const locator = typeof state === 'string' ? page.locator(state === 'ready' ? '[data-app-state="signed-in"], [data-app-state="signed-out"]' : `[data-app-state="${state}"]`) : state;
138
+ await locator.waitFor({ state: 'visible' });
139
+ }
140
+ //# 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,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAMhI,IAAI,MAA0F,CAAC;AAC/F,MAAM,OAAO,GAAG,IAAI,OAAO,EAAoC,CAAC;AAEhE,SAAS,MAAM;IACb,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;IACnE,IAAI,EAAqC,CAAC;IAC1C,IAAI,CAAC;QAAC,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAsC,CAAC;IAAC,CAAC;IAC9E,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAC;IAAC,CAAC;IACrH,MAAM,IAAI,GAAG,EAAE,CA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,EAAE,EAAE,CAAC,CAAC;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[];
@@ -0,0 +1,98 @@
1
+ /**
2
+ * What a promote actually did — as opposed to what the response said.
3
+ *
4
+ * A promote is the one irreversible step in the preview loop, so it is the one
5
+ * command that must never report an outcome it does not know (tsk_33023348: a
6
+ * promote that had SHIPPED printed "Promote failed / Unknown error", and the
7
+ * obvious retry then said "Production was not changed" about production that
8
+ * had already changed).
9
+ *
10
+ * The rule this module encodes: a failure the CLI could not READ is not a
11
+ * failure it can REPORT. The platform stamps every response with correlation
12
+ * ids and, on a refusal it authored, an error code. When neither is present —
13
+ * a dropped connection, a timeout, a 5xx, a body of a shape we do not know —
14
+ * the only honest source of truth is the project's production pointer
15
+ * (`active_release_id`), read again after the fact.
16
+ *
17
+ * Everything here is pure so both directions can be fixtured without a network.
18
+ */
19
+ /**
20
+ * Did the platform read this request and decide, or did we never learn the
21
+ * answer?
22
+ *
23
+ * A 4xx carrying the platform's own error code is a decision: the request
24
+ * reached the route, the route refused it, and production is whatever the
25
+ * refusal says. Anything else — no HTTP response at all (statusCode 0), a 5xx,
26
+ * or a body this CLI could not classify — leaves the outcome genuinely unknown,
27
+ * because the flip may have landed before the connection died.
28
+ */
29
+ export declare function isUnreadablePromoteResponse(err: unknown): boolean;
30
+ /**
31
+ * The production pointer as the CLI managed to read it. `known: false` is NOT
32
+ * "no release" — it is "the read itself failed", and the two must never
33
+ * collapse, because "no release" would otherwise look like evidence.
34
+ */
35
+ export type ActivePointer = {
36
+ known: true;
37
+ releaseId: string | null;
38
+ version: number | null;
39
+ } | {
40
+ known: false;
41
+ };
42
+ export type PromoteVerdict =
43
+ /** The pointer moved: production is serving something new. The promote landed. */
44
+ {
45
+ kind: 'applied';
46
+ activeReleaseId: string;
47
+ }
48
+ /** The pointer is where it was: production was genuinely not changed. */
49
+ | {
50
+ kind: 'not_applied';
51
+ activeReleaseId: string | null;
52
+ }
53
+ /** We could not read the pointer on one side or the other. Say so; claim nothing. */
54
+ | {
55
+ kind: 'unknown';
56
+ };
57
+ /**
58
+ * Decide what happened from the production pointer before and after.
59
+ *
60
+ * `before` is read immediately before the promote is sent, so the comparison is
61
+ * against the exact release the developer was live on when they ran the command
62
+ * — not against the candidate, which is a draft artifact and never becomes the
63
+ * active release id (promote rebuilds the candidate through the ordinary
64
+ * release path, so a landed promote produces a THIRD id, distinct from both).
65
+ * That is precisely why "did production change?" is the only usable question.
66
+ */
67
+ export declare function promoteVerdictFromPointer(args: {
68
+ before: ActivePointer;
69
+ after: ActivePointer;
70
+ }): PromoteVerdict;
71
+ /**
72
+ * The customer-facing lines for a promote whose response we could not read.
73
+ *
74
+ * Rule 8: no release ids in the sentence a person reads — the id is evidence,
75
+ * printed as a separate reference line by the caller, not part of the claim.
76
+ */
77
+ export declare function describeUnreadablePromote(verdict: PromoteVerdict): {
78
+ /** True when production really is carrying the promoted app. */
79
+ succeeded: boolean;
80
+ headline: string;
81
+ detail: string;
82
+ };
83
+ /**
84
+ * A refusal the platform authored is reported as the platform wrote it — except
85
+ * that the CLI has one thing the route does not: it can read the production
86
+ * pointer after the fact. When a refusal asserts production is untouched and
87
+ * the pointer says otherwise, the pointer wins and the CLI says so.
88
+ *
89
+ * This is the second half of tsk_33023348: promoting twice is the obvious
90
+ * response to a false "failed", and the second attempt used to answer with a
91
+ * confident falsehood.
92
+ */
93
+ export declare function refusalContradictsProduction(args: {
94
+ message: string;
95
+ /** The release the CLI recorded as live when the promote was last attempted. */
96
+ expectedUnchanged: string | null;
97
+ after: ActivePointer;
98
+ }): boolean;
@@ -0,0 +1,8 @@
1
+ export declare function isReferenceCorpusPath(relPath: string): boolean;
2
+ /** True when `name` is app surface at the project root on shape alone. */
3
+ export declare function isAppSurfaceRootFile(name: string): boolean;
4
+ /**
5
+ * The customer-facing reason a root file was held back. Rule 8: say what was
6
+ * excluded and how to publish it on purpose — no internals, no ticket ids.
7
+ */
8
+ export declare function excludedRootFileReason(name: string): string;
@@ -0,0 +1,35 @@
1
+ import { type ReproRecord } from './vendor/repro-guidance.js';
2
+ export * from './vendor/repro-guidance.js';
3
+ /** Map a CliApiError/PlatformToolError (or anything else) into the shared builder. `cause` is never read for text. */
4
+ export declare function buildRecord(cause: unknown, context: {
5
+ cliVersion: string;
6
+ command?: string;
7
+ projectId?: string;
8
+ startedAt?: number;
9
+ now?: number;
10
+ }): ReproRecord;
11
+ /** The CLOSED set of codes the function runtime itself answers or reports for a failure (tsk_fca1267b):
12
+ * its own crash codes, the scope rejection and DB_EXPOSED_SERVER_ERROR_CODES. An app's own err.code is
13
+ * owner text (it may hold anything, a key included, and still match the CODE shape), so it is never
14
+ * copied into a packet: any code outside this set becomes APP_ERROR_CODE. */
15
+ export declare const RUNTIME_FAILURE_CODES: ReadonlySet<string>;
16
+ export declare const APP_ERROR_CODE = "APP_ERROR_CODE";
17
+ /** The packet code for a crash row: the server-recorded response_code, else the row's code, and only
18
+ * when it is in RUNTIME_FAILURE_CODES; otherwise APP_ERROR_CODE. */
19
+ export declare function runtimeFailureCode(data: Record<string, unknown>): string;
20
+ /** A function failure the caller hit over HTTP (e.g. 500 FUNCTION_ERROR with its trace_id), rebuilt from the
21
+ * owner's own log rows for that trace. Reads ONLY data.response_code/data.code (mapped through
22
+ * RUNTIME_FAILURE_CODES), data.status, data.request_id, data.method and data.path (templated by the shared
23
+ * builder); the message, stack and every other field are never read.
24
+ * Rows come newest first; the newest reported failure wins. Null when no row reports one. */
25
+ export declare function buildCrashRecord(rows: unknown, context: {
26
+ cliVersion: string;
27
+ traceId: string;
28
+ projectId?: string;
29
+ }): ReproRecord | null;
30
+ export declare function writeLastError(record: ReproRecord): void;
31
+ /** Re-validate on read: every field goes back through the shared builder's validators, so a
32
+ * hand-edited file cannot smuggle a field into the packet. `commands` is the registered command
33
+ * tree's paths; a command outside it is dropped. Only the stored time, outcome and duration are
34
+ * kept from the file, each checked here. */
35
+ export declare function readLastError(commands?: ReadonlySet<string>): ReproRecord | null;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Local-typecheck scaffolding for a pulled project tree.
3
+ *
4
+ * `somewhere pull` brings down raw source but no tsconfig.json / package.json,
5
+ * so a local `tsc --noEmit` has nothing to run against — a dropped import
6
+ * (TS2304 "X is not defined") sails through and only 500s in production. This
7
+ * writes the two files a typecheck needs, lenient enough that untyped esm.sh
8
+ * deps don't drown the real "undefined symbol" signal:
9
+ * - skipLibCheck — don't typecheck dep .d.ts (and most deps ship none)
10
+ * - noImplicitAny: false — untyped imports become `any`, not errors
11
+ * - moduleResolution bundler + jsx react-jsx — match the deploy compiler
12
+ *
13
+ * Both files are written ONLY when absent. A project that ships its own
14
+ * tsconfig.json / package.json keeps it untouched.
15
+ */
16
+ export declare const SCAFFOLD_TSCONFIG_FILENAME = "tsconfig.json";
17
+ export declare const SCAFFOLD_PACKAGE_FILENAME = "package.json";
18
+ export declare const SCAFFOLD_GITIGNORE_FILENAME = ".gitignore";
19
+ /**
20
+ * The starters' .gitignore (tsk_8a68dfa2 item 8). Deploys skip dotfiles, so a
21
+ * pulled app never brings one down, and `somewhere typecheck`/`dev` then leave
22
+ * the generated schema declarations (thousands of lines under src/) untracked
23
+ * in git. Same text as the `somewhere init` starters; a test pins the two
24
+ * together.
25
+ */
26
+ export declare function buildScaffoldGitignore(): string;
27
+ /**
28
+ * The lenient tsconfig that catches undefined symbols (TS2304) without
29
+ * flagging every untyped dependency import. Returned as a pretty JSON string.
30
+ */
31
+ export declare function buildScaffoldTsconfig(): string;
32
+ /**
33
+ * A minimal package.json carrying whatever deps we could recover. `deps` comes
34
+ * from a pulled package.json if the project shipped one; otherwise empty (the
35
+ * lenient tsconfig treats unresolved imports as `any`, so a typecheck still
36
+ * runs and still catches local undefined-symbol bugs).
37
+ */
38
+ export declare function buildScaffoldPackageJson(projectName: string, deps: Record<string, string>): string;
39
+ /** npm package names: lowercase, no spaces, safe charset. */
40
+ export declare function sanitizePackageName(name: string): string;
41
+ /**
42
+ * Pull a `dependencies` map out of a pulled package.json's raw text, if one
43
+ * was in the project source. Returns {} on anything unparseable — the
44
+ * scaffold stays lenient by design, so a missing/garbled deps map is fine.
45
+ */
46
+ export declare function extractDeps(packageJsonText: string | undefined): Record<string, string>;