sim 2.2.33-preview.316.1 → 2.2.33-preview.318.1

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.
@@ -0,0 +1,7 @@
1
+ /** What an apply's `provenance` carries about git, each field only when read. */
2
+ export interface GitProvenance {
3
+ gitSha?: string;
4
+ repo?: string;
5
+ }
6
+ /** The git commit and remote of `dir`, as far as they can be read. */
7
+ export declare function gitProvenance(dir: string): Promise<GitProvenance>;
@@ -3,6 +3,6 @@ import type { OutputFormat } from '../../config/index';
3
3
  * Prints a protocol command's result: the record itself in a machine format, else one line per
4
4
  * field, with `display` replacing the text of the fields it names (a list a person reads as a
5
5
  * sentence rather than as JSON). An override is built from server text (resource keys, ids), so it
6
- * is sanitized like every other field.
6
+ * is sanitized like every other field. A {@link COMMAND_FIELDS} field is never clamped.
7
7
  */
8
8
  export declare function printProtocolResult(format: OutputFormat, result: Record<string, unknown>, display?: Readonly<Record<string, string>>): void;
@@ -53,6 +53,12 @@ export declare const SOURCE_DOWNLOADS_DIR = ".sim/downloads";
53
53
  export declare const SOURCE_STAGING_PREFIX = ".sim-staging-";
54
54
  /** Refuses a server answer naming a file the printer never writes, before anything is written. */
55
55
  export declare function assertPrintedSourcePaths(files: Record<string, string>): void;
56
+ /**
57
+ * Refuses, before a write is sent, a code file the server would store but the CLI could never
58
+ * write back: one rule ({@link isCodeFilePath}) for both, so an apply is never stored and then
59
+ * reported as failed.
60
+ */
61
+ export declare function assertSendableCodeFiles(files: Record<string, string>): void;
56
62
  /** Files read or written at once on a local disk; a catalog's declarations run to hundreds of small files. */
57
63
  export declare const FILE_CONCURRENCY = 32;
58
64
  /**
@@ -89,6 +95,14 @@ export declare function absoluteDirOption(command: Command): Command;
89
95
  * takes the profile's (`null` when none is selected).
90
96
  */
91
97
  export declare function directoryWorkspace(dir: string, readFrom: string | null, profile: Pick<ResolvedProfile, 'workspaceId' | 'sources'>, next: (readFrom: string, named: string) => string): string | null;
98
+ /** Which source command family a directory belongs to: one workflow's, or a whole workspace's. */
99
+ export type SourceDirKind = 'workflow' | 'workspace';
100
+ /**
101
+ * Refuses a `kind` command on a directory of the other kind, whatever `--force` says: a workflow
102
+ * get into a workspace directory (or the reverse) would replace its base, so staleness could no
103
+ * longer be detected and its unapplied edits would sit in a directory neither command reads.
104
+ */
105
+ export declare function assertSourceDirKind(dir: string, kind: SourceDirKind): Promise<void>;
92
106
  /** The workspace {@link SOURCE_STARTER_FILE} names, or `null` when the directory holds no starter. */
93
107
  export declare function readStarterWorkspace(dir: string): Promise<string | null>;
94
108
  /**
@@ -146,7 +160,10 @@ export declare function sameFileStat(a: FileStat, b: FileStat): boolean;
146
160
  export interface StatDigest extends FileStat {
147
161
  sha256: string;
148
162
  }
149
- /** `.sim/written.json` as one command reads it, once. */
163
+ /**
164
+ * What the CLI last wrote, as one command reads it, once: the digests from `.sim/written.json`
165
+ * and the stats from `.sim/cache/stats.json` that still match them.
166
+ */
150
167
  export interface Written {
151
168
  digests: Record<string, string>;
152
169
  stats: Record<string, FileStat>;
@@ -159,8 +176,11 @@ export declare function digest(text: string): string;
159
176
  * it was taken with.
160
177
  */
161
178
  export declare function writtenRecord(files: Record<string, string>, kept?: Record<string, string>, stats?: ReadonlyMap<string, StatDigest>): Written;
162
- /** The text of `.sim/written.json` for `written`. */
163
- export declare function writtenFile(written: Written): string;
179
+ /**
180
+ * The files that record `written`: `.sim/written.json` (committed) and, when a blob stat is
181
+ * recorded, the machine-local `.sim/cache/stats.json` with the cache folder's own `.gitignore`.
182
+ */
183
+ export declare function writtenFiles(written: Written): Array<readonly [string, string]>;
164
184
  /** What the CLI recorded for its last write, empty when it recorded nothing. */
165
185
  export declare function readWritten(dir: string): Promise<Written>;
166
186
  /** The blob digests `written` holds with their stats, to carry into the next record. */
@@ -215,7 +235,8 @@ interface PrintedSourceAnswer {
215
235
  /**
216
236
  * Writes a server answer into the source directory in one staged update: its files, lock and base,
217
237
  * plus `extra`, pruning the function files the previous lock named and the new one no longer does.
218
- * Returns how many files it wrote.
238
+ * Returns how many files it wrote. A get refuses an unsafe path first
239
+ * ({@link assertPrintedSourcePaths}); after a stored write one is skipped ({@link writableFiles}).
219
240
  */
220
241
  export declare function writeBack(dir: string, answer: PrintedSourceAnswer, previousLock: unknown, extra?: SourceDirChange): Promise<number>;
221
242
  /**
@@ -6,8 +6,15 @@
6
6
  */
7
7
  import type { FileChange, SourceStatus } from '@sim/workspace-code/status';
8
8
  import type { OutputFormat } from '../../config/index';
9
+ import { type Diagnostic } from './source-ui';
9
10
  /** Whether the server was asked: `checked`, `unreachable` (degraded to local), or `offline`. */
10
11
  export type ServerCheck = 'checked' | 'unreachable' | 'offline';
12
+ /**
13
+ * The dry run's findings a status's plan shows: its errors and warnings, less those `listed`
14
+ * says the status reports as a change of its own (a stale base is drift or a conflict), and the
15
+ * info `I_FINDINGS_TRUNCATED` that says the list is incomplete (counted as neither).
16
+ */
17
+ export declare function planFindings(diagnostics: readonly Diagnostic[], listed: (code: Diagnostic['code']) => boolean): Diagnostic[];
11
18
  /** The next command a status recommends, and why. */
12
19
  export interface NextStep {
13
20
  command: string;
@@ -48,10 +55,12 @@ export declare function unreachableReason(error: unknown): string | null;
48
55
  */
49
56
  export declare function loginCommand(error: unknown, authProfile: string): string | null;
50
57
  /**
51
- * Prints a status: the machine shape for `json` and `yaml`, else one screen naming each local
52
- * change, each drifted and conflicting resource, the dry run's summary line and the next command.
58
+ * Prints a status: the machine shape for `json` and `yaml`, with the plan's `findings` (from
59
+ * {@link planFindings}) under `diagnostics`, else the findings on stderr as an apply prints them
60
+ * and one screen naming each local change, each drifted and conflicting resource, the dry run's
61
+ * summary line and the next command.
53
62
  */
54
- export declare function printStatusReport<Plan>(format: OutputFormat, heading: string, report: StatusReport<Plan>, planLine: (plan: Plan) => string): void;
63
+ export declare function printStatusReport<Plan>(format: OutputFormat, heading: string, report: StatusReport<Plan>, planLine: (plan: Plan) => string, findings: readonly Diagnostic[]): void;
55
64
  /** One file's difference, as `diff --output json` prints it. */
56
65
  export interface FileDiff {
57
66
  path: string;
@@ -142,4 +151,10 @@ interface NextStepInput {
142
151
  * checked or the changes have errors, else apply. `null` when there is nothing to do.
143
152
  */
144
153
  export declare function nextStep(status: SourceStatus, input: NextStepInput): NextStep | null;
154
+ /**
155
+ * A status's plan: the plan read, or, from a server that predates it (its route answers `404`),
156
+ * the apply dry run it replaced, which spends the source-write budget. A `404` the dry run also
157
+ * answers is the resource's own, and is thrown.
158
+ */
159
+ export declare function readPlan<T>(plan: () => Promise<T>, dryRun: () => Promise<T>): Promise<T>;
145
160
  export {};
@@ -55,13 +55,27 @@ export interface WorkspaceTypes {
55
55
  * `404` from a server that predates the route) only the declared resources are typed, or `null`
56
56
  * without any: the source still writes and type-checks, with every other key a plain string.
57
57
  */
58
- export declare function loadWorkspaceTypes(client: OperationClient<'getSourceResources'>, workspaceId: string, local?: LocalDeclarations): Promise<WorkspaceTypes | null>;
58
+ export declare function loadWorkspaceTypes(client: OperationClient<'getSourceResources'>, workspaceId: string, local?: LocalDeclarations, options?: {
59
+ optional?: boolean;
60
+ }): Promise<WorkspaceTypes | null>;
59
61
  /**
60
62
  * Regenerates `workspace.d.ts` from the stored manifest the last get kept beside it and what the
61
63
  * directory declares now (`local`), so `tsc` types a key added since without a request. A
62
64
  * directory with no kept manifest (written by an older CLI) is left as it is.
63
65
  */
64
66
  export declare function refreshWorkspaceTypes(dir: string, local: LocalDeclarations): Promise<void>;
67
+ /**
68
+ * Re-reads the workspace's resources into a workflow directory's `workspace.d.ts` and the manifest
69
+ * kept beside it, so `tsc` types a resource created since the last get (a child workflow, a table,
70
+ * a credential) instead of refusing its key, and stops accepting one deleted since. The commands
71
+ * that already talk to the server (apply, create, status) call it; an offline
72
+ * check cannot. Only a directory holding types the CLI wrote is touched (a workflow folder of a
73
+ * workspace directory types its workflows at the root, which the workspace commands refresh), only
74
+ * a file whose text changes is rewritten, and a failure to list the resources (a rate limit, a
75
+ * dropped connection) leaves the files as they are: the types are a convenience, never the write,
76
+ * so a rate-limited listing is not resent. A dry run, which writes no files, does not call it.
77
+ */
78
+ export declare function refreshWorkflowWorkspaceTypes(client: OperationClient<'getSourceResources'>, dir: string, workspaceId: string): Promise<void>;
65
79
  /**
66
80
  * Refuses a catalog for another SDK major than the bundled `core.d.ts`: its builders would be
67
81
  * written beside declarations that cannot type them.
@@ -1,4 +1,4 @@
1
- import { type BlockCatalog, type StoredEdgeRef } from '@sim/workflow-code';
1
+ import { type BlockCatalog, type CanonicalBlock, type StoredEdgeRef } from '@sim/workflow-code';
2
2
  import type { OperationClient } from '../../runtime/called-operations';
3
3
  /** A printed source as a get, apply or create answers it. */
4
4
  interface PrintedAnswer {
@@ -6,11 +6,13 @@ interface PrintedAnswer {
6
6
  lock: unknown;
7
7
  base: unknown;
8
8
  }
9
+ /** A digest of one compiled block, to tell a block an edit changed from one it left alone. */
10
+ export declare function blockDigest(block: CanonicalBlock): string;
9
11
  /**
10
- * The `.sim/stored-edges.json` write for a printed source: its edges, compiled against `catalog`
11
- * (the one it was printed with), tagged with its base fingerprint. `null` when the answer has no
12
- * fingerprint or entry, or nothing to compile it with; the record left on disk then names an
13
- * older fingerprint, which a check ignores.
12
+ * The `.sim/stored-edges.json` write for a printed source: its edges and a digest of each block
13
+ * ({@link blockDigest}, by key), compiled against `catalog` (the one it was printed with), tagged
14
+ * with its base fingerprint. `null` when the answer has no fingerprint or entry, or nothing to
15
+ * compile it with; the record left on disk then names an older fingerprint, which a check ignores.
14
16
  */
15
17
  export declare function storedEdgesWrite(answer: PrintedAnswer, catalog: BlockCatalog | null, folder?: string): readonly [string, string] | null;
16
18
  /** The stored-edges records of a workspace answer, and the folders left without one. */
@@ -39,6 +41,12 @@ export declare function unrecordedFoldersWarning(unrecorded: readonly string[]):
39
41
  * record, one an older CLI or another base wrote, or a malformed one.
40
42
  */
41
43
  export declare function readStoredEdges(dir: string): Promise<StoredEdgeRef[] | undefined>;
44
+ /**
45
+ * The digest of each block of the printed source the record of the base `dir` holds now was
46
+ * written from, by key (see {@link storedEdgesWrite}); `undefined` when there is no such record or
47
+ * it records no blocks (an older CLI wrote it).
48
+ */
49
+ export declare function readStoredBlockDigests(dir: string): Promise<ReadonlyMap<string, string> | undefined>;
42
50
  /** The stored-edges records of the workflow folders whose base a write removes (`paths`). */
43
51
  export declare function removedWorkflowRecords(paths: Iterable<string>): string[];
44
52
  export {};
@@ -1,4 +1,9 @@
1
1
  import { Command } from 'commander';
2
+ /**
3
+ * Indexes `command` for `tasks` too, so `sim cli search` finds it from how an agent or a person
4
+ * phrases the job, not only from its name. Returns the command, to chain.
5
+ */
6
+ export declare function searchTasks(command: Command, tasks: readonly string[]): Command;
2
7
  export interface SearchResult {
3
8
  command: string;
4
9
  summary: string;
@@ -318,6 +318,11 @@ export interface CommandSpec {
318
318
  * the point is that the caller can tell whether they meant it.
319
319
  */
320
320
  confirm?: string;
321
+ /**
322
+ * Accept `-y/--yes` without a `confirm` gate, as a no-op: a write callers run beside confirmed
323
+ * ones (a deploy after `workflows source apply --yes`) takes the flag they pass there.
324
+ */
325
+ acceptsYes?: true;
321
326
  /**
322
327
  * Discover table columns from inside this nested field as well as from the
323
328
  * row's own scalars.