@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,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>;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The agent skills pack: short SKILL.md files generated on the platform side
3
+ * from the docs topics (somewhere.cloud scripts/skills/generate.mjs) and
4
+ * shipped inside this release as skills-pack.generated.ts, so `somewhere init`
5
+ * works offline and the pack is pinned to the CLI version.
6
+ *
7
+ * Layout in a project:
8
+ * .agents/skills/<name>/SKILL.md the files
9
+ * .claude/skills/<name> a link to ../../.agents/skills/<name>
10
+ * skills-lock.json pack version, CLI version, file hashes
11
+ */
12
+ export interface SkillsPackFile {
13
+ path: string;
14
+ sha256: string;
15
+ content: string;
16
+ }
17
+ export interface SkillsPack {
18
+ schema: number;
19
+ name: string;
20
+ version: string;
21
+ sha256: string;
22
+ files: SkillsPackFile[];
23
+ }
24
+ export interface SkillsLock {
25
+ pack: string;
26
+ version: string;
27
+ sha256: string;
28
+ cli: string;
29
+ source: 'bundled' | 'docs-host';
30
+ files: Record<string, string>;
31
+ }
32
+ export declare const SKILLS_DIR = ".agents/skills";
33
+ export declare const CLAUDE_SKILLS_DIR = ".claude/skills";
34
+ export declare const SKILLS_LOCK = "skills-lock.json";
35
+ /** Recompute every file hash and the pack digest; throw on any mismatch. */
36
+ export declare function verifyPack(pack: SkillsPack): SkillsPack;
37
+ export declare function skillNames(pack: SkillsPack): string[];
38
+ export declare function readLock(dir: string): SkillsLock | null;
39
+ export interface InstallResult {
40
+ version: string;
41
+ written: string[];
42
+ removed: string[];
43
+ claude: 'link' | 'copy';
44
+ }
45
+ /**
46
+ * Write the pack and its lock. Only skills this pack (or the previous lock)
47
+ * owns are touched. Local edits, same-name project skills, and symlinked
48
+ * write paths are refused before any file is changed.
49
+ */
50
+ export declare function installSkills(dir: string, pack: SkillsPack, opts: {
51
+ cli: string;
52
+ source: SkillsLock['source'];
53
+ }): InstallResult;
54
+ export type SkillsState = 'current' | 'stale' | 'modified' | 'missing' | 'unknown';
55
+ export interface SkillsStatus {
56
+ state: SkillsState;
57
+ installed: string | null;
58
+ bundled: string;
59
+ latest: string | null;
60
+ cli: string;
61
+ lock_cli: string | null;
62
+ missing: string[];
63
+ modified: string[];
64
+ message: string;
65
+ }
66
+ /**
67
+ * modified = a skill file was edited or deleted after install;
68
+ * missing = no skills-lock.json;
69
+ * current / stale = the lock matches (or not) the pack the docs host serves
70
+ * now, or — when the host cannot be reached — this CLI's bundled pack;
71
+ * unknown = offline, and the installed pack came from the docs host, so
72
+ * this CLI cannot tell whether it is still the latest.
73
+ */
74
+ export declare function skillsStatus(dir: string, bundled: SkillsPack, cli: string, latest: SkillsPack | null): SkillsStatus;
75
+ export declare const DOCS_BASE = "https://somewhere.cloud";
76
+ /**
77
+ * The pack the docs host serves now, hash-verified. null when the host is
78
+ * unreachable or has no pack (offline, or a host that predates the route);
79
+ * a pack that fails verification THROWS — it is never installed.
80
+ */
81
+ export declare function fetchLatestPack(timeoutMs?: number): Promise<SkillsPack | null>;
@@ -0,0 +1,2 @@
1
+ import type { SkillsPack } from './skills-pack.js';
2
+ export declare const BUNDLED_SKILLS_PACK: SkillsPack;
@@ -0,0 +1,42 @@
1
+ import { type GenericLintResult } from './generic-lint.js';
2
+ import { type ContractVerdict } from './platform-contract.js';
3
+ export interface LintFinding {
4
+ rule: string;
5
+ severity: 'warning';
6
+ file: string;
7
+ line: number;
8
+ message: string;
9
+ fix: string;
10
+ docs: string;
11
+ }
12
+ export interface SourceLintSnapshot {
13
+ version: string;
14
+ findings: LintFinding[];
15
+ source_sha256: string;
16
+ schema_sha256: string | null;
17
+ coverage: {
18
+ schema: 'checked' | 'absent';
19
+ /** Present from source lint v2: the request-to-ownership trace on server writes. */
20
+ request_ownership?: 'checked' | 'partial' | 'skipped' | 'not-applicable';
21
+ authorization: 'not-assessed';
22
+ };
23
+ }
24
+ export interface LocalLintResult extends SourceLintSnapshot {
25
+ ok: boolean;
26
+ duration_ms: number;
27
+ checked_files: number;
28
+ skipped: Array<{
29
+ path: string;
30
+ reason: string;
31
+ }>;
32
+ generic: GenericLintResult;
33
+ /** This CLI's consumer contract against the platform's last announced one (tsk_0f3d05b9). */
34
+ contract: ContractVerdict;
35
+ }
36
+ /** Same collector as deploy, same rule source as the platform. No installs,
37
+ * network, generated-file writes or automatic fixes. Optional generic rules
38
+ * run the project's installed linter in a child process. */
39
+ export declare function lintProject(directory: string, options?: {
40
+ generic?: boolean;
41
+ apiBase?: string;
42
+ }): Promise<LocalLintResult>;
@@ -0,0 +1,14 @@
1
+ type SpinnerColor = 'cyan' | 'green' | 'red' | 'yellow' | string;
2
+ interface OraOptions {
3
+ text?: string;
4
+ color?: SpinnerColor;
5
+ }
6
+ export interface Ora {
7
+ text: string;
8
+ start(text?: string): Ora;
9
+ stop(): Ora;
10
+ succeed(text?: string): Ora;
11
+ fail(text?: string): Ora;
12
+ }
13
+ export default function ora(input?: string | OraOptions): Ora;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The first `npx @somewhere-cloud/cli …` on a cold cache can sit silent for a
3
+ * minute. That silence is npm's, not ours: npm downloads and installs the
4
+ * package BEFORE it runs the entrypoint, so no JavaScript we ship can print
5
+ * during it — there is nothing running yet to print.
6
+ *
7
+ * What the CLI can do is speak the instant it is handed control, which marks the
8
+ * boundary between "npm was still fetching" and "the CLI is working" and tells a
9
+ * waiting human the version they actually got.
10
+ *
11
+ * Rules, so this can never break a caller:
12
+ * - stderr only. stdout stays byte-identical for pipes, `--json`, and agents.
13
+ * - interactive only (stdout is a TTY). Redirected or captured output, CI logs
14
+ * and agent invocations see nothing new.
15
+ * - never on the npx/npm pass-through commands, whose output belongs to the
16
+ * tool being wrapped.
17
+ */
18
+ export interface StartupNoticeContext {
19
+ isTTY: boolean;
20
+ jsonOutput: boolean;
21
+ passThrough: boolean;
22
+ }
23
+ export declare function startupNotice(version: string, ctx: StartupNoticeContext): string | null;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * How many files, said the same way everywhere.
3
+ *
4
+ * One project used to get three different answers out of one CLI: `somewhere
5
+ * deploy` said "2 static file(s) + 1 function(s)", `somewhere preview` said
6
+ * "Synced 3 files" with the function invisible inside the number, and
7
+ * `somewhere promote` said "3 files + functions" with the count of functions
8
+ * replaced by the word. A developer reading all three cannot tell whether the
9
+ * app grew, whether the function shipped, or which number to trust — which is
10
+ * exactly what happened in the parity run that produced this module.
11
+ *
12
+ * The shape, everywhere: `3 static files + 1 function`. Two nouns, two
13
+ * numbers, no parenthesised plurals.
14
+ *
15
+ * The counting rule, everywhere: static = the pages, scripts, styles and
16
+ * assets that make up the site; functions = the api/ handlers, counted
17
+ * separately because they are the half a boolean used to hide. It is the same
18
+ * split the project itself reports, so the CLI's number and the project's
19
+ * number are the same number.
20
+ *
21
+ * Pure and dependency-free so both directions can be fixtured without a
22
+ * network.
23
+ */
24
+ export interface PublishSurfaceCounts {
25
+ /** Pages, scripts, styles, assets. `null` when it genuinely is not known. */
26
+ staticFiles: number | null;
27
+ /**
28
+ * api/ handlers. `null` means "not known"; `'some'` means the only thing
29
+ * available was a yes/no — say functions are there without inventing a count.
30
+ */
31
+ functions: number | 'some' | null;
32
+ }
33
+ /**
34
+ * The one phrase. Renders as many of the two halves as are actually known:
35
+ *
36
+ * { staticFiles: 3, functions: 1 } → `3 static files + 1 function`
37
+ * { staticFiles: 3, functions: 0 } → `3 static files`
38
+ * { staticFiles: 1, functions: 2 } → `1 static file + 2 functions`
39
+ * { staticFiles: 3, functions: 'some' } → `3 static files + functions`
40
+ * { staticFiles: null, functions: 1 } → `1 function`
41
+ * { staticFiles: null, functions: null} → `Files`
42
+ *
43
+ * A zero function count prints nothing rather than "+ 0 functions": a static
44
+ * site saying it has no backend on every line is noise, and the absence is
45
+ * already the answer.
46
+ */
47
+ export declare function formatPublishSurface(counts: PublishSurfaceCounts): string;
48
+ /**
49
+ * Count a collected publish surface the way the project does.
50
+ *
51
+ * Binary assets are static files — an image is as much part of the site as the
52
+ * page that shows it, and splitting them out is an implementation detail of how
53
+ * the CLI reads them off disk, not something a developer asked about.
54
+ */
55
+ export declare function countPublishSurface(collected: {
56
+ files: Record<string, unknown>;
57
+ binaryFiles?: Record<string, unknown>;
58
+ functions?: Record<string, unknown>;
59
+ }): PublishSurfaceCounts;
60
+ /**
61
+ * Functions are the files that become routes. A file or folder whose name
62
+ * starts with `_` (`api/_lib.ts`, `api/_lib/db.ts`) is an import-only helper
63
+ * the platform never publishes, so it is uploaded but not counted.
64
+ */
65
+ export declare function countFunctionRoutes(functions: Record<string, unknown>): number;
66
+ /**
67
+ * A count the platform sent, when it sent one. Anything that is not a finite
68
+ * number is not a count — `null` (unknown) is honest and renders as an absence,
69
+ * where `0` would be a claim.
70
+ */
71
+ export declare function countFromResponse(value: unknown): number | null;
72
+ /** The exact paths one deploy sends, as the platform will store them (tsk_23f34679). */
73
+ export interface UploadInventory {
74
+ /** Every static file in the request body (text and binary), sorted. */
75
+ static_files: string[];
76
+ /** Every function route in the request body, sorted; `_` helpers are bundled into them, not listed. */
77
+ functions: string[];
78
+ }
79
+ /**
80
+ * The one source for "what did this deploy upload": the same selection the
81
+ * request body carries, so the headline count, the terminal list and the JSON
82
+ * `uploaded` field can never disagree. A partial deploy lists only the half it
83
+ * sends: `--scope functions` sends no static files, `--scope static` no functions.
84
+ */
85
+ export declare function uploadInventory(files: Record<string, unknown>, binaryFiles: Record<string, unknown>, functions: Record<string, unknown>, scope?: 'functions' | 'static'): UploadInventory;
86
+ /** Terminal list of an inventory: paths inline when short, a pointer to the JSON list when long. */
87
+ export declare const INLINE_UPLOAD_LIST_MAX = 20;
88
+ export declare function formatUploadInventory(inventory: UploadInventory): string;
@@ -0,0 +1,53 @@
1
+ /** No-login deploy path (tsk_35674c33): mint a short-lived, unauthenticated
2
+ * developer credential gated by client-side proof-of-work instead of a
3
+ * signup. This is the whole "auth" for logged-out `somewhere deploy` — see
4
+ * src/commands/deploy.ts for how the minted credential is cached/reused and
5
+ * wired into the normal deploy flow. */
6
+ import { ApiClient } from './client.js';
7
+ /** GET /v1/auth/pow/challenge response payload (unauthenticated). */
8
+ export interface PowChallenge {
9
+ nonce: string;
10
+ difficulty: number;
11
+ algorithm: string;
12
+ /** The exact string the client hashes: `${nonce}:${suffix}`. Sent by the
13
+ * server so the client never has to guess the hash-input format. */
14
+ input: string;
15
+ expires_at: string;
16
+ ttl_seconds: number;
17
+ }
18
+ /** POST /v1/auth/temp-create response payload (unauthenticated — the solved
19
+ * PoW is the auth). `key`/`access_token` are the same bearer credential;
20
+ * the server contract names both, see mintTempAccount(). */
21
+ export interface TempAccount {
22
+ key: string;
23
+ key_prefix?: string;
24
+ key_id?: string;
25
+ scopes: string[];
26
+ expires_at: string;
27
+ ttl_seconds: number;
28
+ claim_token: string;
29
+ claim_url: string;
30
+ }
31
+ /** Count LEADING ZERO BITS (not hex chars — the server's difficulty unit is
32
+ * bits) in a digest. Walks bytes most-significant-first and stops counting
33
+ * at the first 1 bit, whether that's mid-byte or in a later byte. */
34
+ export declare function leadingZeroBits(buf: Uint8Array): number;
35
+ /** Sync brute-force PoW solve: try counter suffixes `0`, `1`, `2`, … (base36)
36
+ * until sha256(`${nonce}:${suffix}`) has at least `difficulty` leading zero
37
+ * bits. This is the entire cost the server imposes in place of a signup, so
38
+ * it must stay cheap for a real client (sub-second at difficulty ~20) — a
39
+ * synchronous loop is fine at that scale; no worker threads needed. */
40
+ export declare function solvePow(nonce: string, difficulty: number): {
41
+ suffix: string;
42
+ hash: string;
43
+ };
44
+ /** Mint a temporary, no-login developer credential: GET the PoW challenge,
45
+ * solve it locally, POST the solution for a bearer key.
46
+ *
47
+ * Both routes are public: the request carries no credential, never runs the
48
+ * stored login's refresh, and is never resent. Failures are the platform's
49
+ * typed errors (pfb_011a9fd3f5f3): CliApiError with the documented `code`
50
+ * (RATE_LIMITED, INVALID_POW, TEMP_DEPLOYS_DISABLED, ...), HTTP status,
51
+ * retry / retry_after_ms and request/trace ids, and INVALID_RESPONSE with
52
+ * the status for a body that is not JSON. */
53
+ export declare function mintTempAccount(client?: Pick<ApiClient, 'call'>): Promise<TempAccount>;
@@ -0,0 +1,10 @@
1
+ export declare function terminalSafe(value: unknown): string;
2
+ /**
3
+ * A stored multi-line value (a crash stack) rendered under its record (tsk_da2dba3d). Each line is escaped as
4
+ * above AND starts with one fixed continuation marker, so no line of untrusted text can begin at the margin
5
+ * or pass as a record of its own (a stack line written to look like ` [info] ...` stays visibly inside
6
+ * the stack). The marker is the ONLY prefix a continuation line ever gets; the text cannot choose another.
7
+ * Lines past `maxLines` are counted, not silently dropped; --json keeps the whole value.
8
+ */
9
+ export declare const CONTINUATION_MARKER = " stack | ";
10
+ export declare function terminalContinuation(value: unknown, maxLines?: number): string[];
@@ -0,0 +1,16 @@
1
+ import type { TestInfo } from '@playwright/test';
2
+ export declare function rememberSecrets(...values: string[]): void;
3
+ export declare function scrub(value: string): string;
4
+ export interface RequestEvidence {
5
+ method: string;
6
+ path: string;
7
+ status: number;
8
+ code: string;
9
+ }
10
+ export interface Diagnostics {
11
+ request?: RequestEvidence;
12
+ screenshot?: string;
13
+ timings: Record<string, number>;
14
+ }
15
+ export declare function diagnostics(info: TestInfo): Diagnostics;
16
+ export declare function timed<T>(info: TestInfo, name: string, work: () => Promise<T>): Promise<T>;
@@ -0,0 +1,29 @@
1
+ const secrets = new Set();
2
+ export function rememberSecrets(...values) { for (const value of values)
3
+ if (value)
4
+ secrets.add(value); }
5
+ export function scrub(value) {
6
+ for (const secret of secrets)
7
+ value = value.split(secret).join('[redacted]');
8
+ return value.replace(/\u001b\[[0-9;]*m/g, '').replace(/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|smt_[A-Za-z0-9_-]+/g, '[redacted]');
9
+ }
10
+ const reports = new WeakMap();
11
+ export function diagnostics(info) {
12
+ let report = reports.get(info);
13
+ if (!report) {
14
+ report = { timings: {} };
15
+ reports.set(info, report);
16
+ }
17
+ return report;
18
+ }
19
+ export async function timed(info, name, work) {
20
+ const start = performance.now();
21
+ try {
22
+ return await work();
23
+ }
24
+ finally {
25
+ const report = diagnostics(info);
26
+ report.timings[name] = (report.timings[name] ?? 0) + performance.now() - start;
27
+ }
28
+ }
29
+ //# sourceMappingURL=test-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-diagnostics.js","sourceRoot":"","sources":["../../src/lib/test-diagnostics.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;AAClC,MAAM,UAAU,eAAe,CAAC,GAAG,MAAgB,IAAU,KAAK,MAAM,KAAK,IAAI,MAAM;IAAE,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7E,OAAO,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,uEAAuE,EAAE,YAAY,CAAC,CAAC;AAC/I,CAAC;AAGD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAyB,CAAC;AACrD,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QAAC,MAAM,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAAC,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAI,IAAc,EAAE,IAAY,EAAE,IAAsB;IACjF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,CAAC;QAAC,OAAO,MAAM,IAAI,EAAE,CAAC;IAAC,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAAC,CAAC;AAC5J,CAAC"}