create-cogitator-app 0.5.2 → 0.6.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.
package/dist/lib.d.ts CHANGED
@@ -538,6 +538,7 @@ interface CompatIssue {
538
538
  */
539
539
  declare function compatibilityIssues(spec: ProjectSpec): CompatIssue[];
540
540
  declare class IncompatibleSpecError extends Error {
541
+ readonly code = "INCOMPATIBLE_SPEC";
541
542
  readonly issues: CompatIssue[];
542
543
  constructor(issues: CompatIssue[]);
543
544
  }
@@ -695,6 +696,20 @@ declare function runScript(pm: PackageManager, script: string, args?: string): s
695
696
  /** The command that runs a binary of an installed package. */
696
697
  declare function execCommand(pm: PackageManager, bin: string): string;
697
698
  declare function installCommand(pm: PackageManager): string;
699
+ /**
700
+ * The code a failed install names its cause with, read from the package
701
+ * manager's output: pnpm's `ERR_PNPM_*`, npm's `code E*`, Yarn's last `YN*`
702
+ * code other than the informational `YN0000` and the generic `YN0001`, a code
703
+ * for the messages of Bun and Yarn 1, which have none (`NO_MATCHING_VERSION`,
704
+ * `HTTP_404`, `ELIFECYCLE`, Bun's network errors as Node codes), or a Node
705
+ * network or file system code in the output. Else the exit code, as `EXIT_1`.
706
+ *
707
+ * The output is not trusted, since install scripts print into it, so every
708
+ * code comes from a closed set: a pnpm or npm code that is not a known one
709
+ * becomes `ERR_PNPM_OTHER` or `NPM_OTHER`, and nothing else of the output is
710
+ * ever returned.
711
+ */
712
+ declare function installErrorCode(output: string, exitCode: number): string;
698
713
 
699
714
  /** The version of create-cogitator-app itself, inlined at build time. */
700
715
  declare function scaffolderVersion(): string;
@@ -788,9 +803,40 @@ interface TelemetryPayload {
788
803
  /** `darwin`, `linux` or `win32`. */
789
804
  os: string;
790
805
  outcome: 'success' | 'failure';
806
+ /** Where a failure stopped, `none` on success. */
807
+ failedStep: FailedStep | 'none';
808
+ /**
809
+ * Why it stopped, as a code such as `ERR_PNPM_NO_MATCHING_VERSION`,
810
+ * `ENOTFOUND` or `HTTP_404` (see `telemetryErrorCode`), `none` on success.
811
+ */
812
+ errorCode: string;
813
+ }
814
+ /**
815
+ * Where a scaffold failed: `create` while making the project (its options,
816
+ * the directory, writing or downloading files), `install` while installing
817
+ * its dependencies.
818
+ */
819
+ type FailedStep = 'create' | 'install';
820
+ /** A failed scaffold: the step it stopped at and the error it stopped with. */
821
+ interface ScaffoldFailure {
822
+ step: FailedStep;
823
+ error: unknown;
791
824
  }
792
825
  declare const PAYLOAD_FIELDS: ReadonlyArray<keyof TelemetryPayload>;
793
- declare function payloadFor(spec: Pick<ProjectSpec, 'preset' | 'provider' | 'memory' | 'features' | 'packageManager'> | undefined, outcome: TelemetryPayload['outcome'], kind?: 'generated' | 'example' | 'template'): TelemetryPayload;
826
+ /**
827
+ * A code for why `error` happened that is safe to send: the `code` of the
828
+ * error or of one of its causes (Node's `ENOTFOUND`, a package manager's
829
+ * `ERR_PNPM_NO_MATCHING_VERSION`, the scaffolder's own `HTTP_404` or
830
+ * `DIRECTORY_NOT_EMPTY`), else the kind of error (`TYPE_ERROR`), else
831
+ * `UNKNOWN`. Never the message, which can hold paths and names.
832
+ */
833
+ declare function telemetryErrorCode(error: unknown): string;
834
+ /** The failure of a scaffold whose install step failed, `undefined` when it did not. */
835
+ declare function installFailure(result: {
836
+ install: StepResult;
837
+ }): ScaffoldFailure | undefined;
838
+ /** The event of a scaffold of `spec`: failed with `failure`, successful without one. */
839
+ declare function payloadFor(spec: Pick<ProjectSpec, 'preset' | 'provider' | 'memory' | 'features' | 'packageManager'> | undefined, failure?: ScaffoldFailure, kind?: 'generated' | 'example' | 'template'): TelemetryPayload;
794
840
  /** Why no event is sent, or `undefined` when one is. */
795
841
  declare function telemetryDisabledReason(options: {
796
842
  flag?: boolean;
@@ -806,7 +852,9 @@ declare function telemetryDisabledReason(options: {
806
852
  declare function firstRunNotice(env?: NodeJS.ProcessEnv): string | undefined;
807
853
  /**
808
854
  * Sends the event to Umami. It never throws and never takes longer than its
809
- * timeout: a slow or failing network changes nothing for the scaffolder.
855
+ * timeout: a slow or failing network changes nothing for the scaffolder. A
856
+ * payload that is not exactly an event (another field, a value with a path or
857
+ * a space in it) sends nothing.
810
858
  */
811
859
  declare function sendTelemetry(payload: TelemetryPayload, options?: {
812
860
  fetch?: typeof fetch;
@@ -815,6 +863,16 @@ declare function sendTelemetry(payload: TelemetryPayload, options?: {
815
863
  timeoutMs?: number;
816
864
  }): Promise<boolean>;
817
865
 
866
+ /**
867
+ * A failure with a short, stable `code` that names its cause, such as
868
+ * `HTTP_404` or `DIRECTORY_NOT_EMPTY`. The code holds no path, name or anything
869
+ * a user typed, which is what lets telemetry report it.
870
+ */
871
+ declare class CodedError extends Error {
872
+ readonly code: string;
873
+ constructor(code: string, message: string, options?: ErrorOptions);
874
+ }
875
+
818
876
  interface Io {
819
877
  stdout: (text: string) => void;
820
878
  stderr: (text: string) => void;
@@ -836,4 +894,4 @@ declare function run(argv: readonly string[], io?: Io, deps?: RunDeps): Promise<
836
894
  /** The candidate closest to `input`, when it is close enough to be a typo of it. */
837
895
  declare function closest(input: string, candidates: readonly string[]): string | undefined;
838
896
 
839
- export { APP_CHOICES, APP_KINDS, type AddChanges, type AddConflict, AddConflictError, type AddNote, type AddOptions, type AddPlan, type AddResult, type AppKind, CHANNELS, CHANNEL_CHOICES, CODING_AGENTS, CODING_AGENT_CHOICES, type ChannelKind, type Choice, type CodingAgent, type CompatIssue, DEFAULT_OLLAMA_URL, DEFAULT_PRESET, DEPLOY_CHOICES, DEPLOY_TARGETS, type DeployTarget, type DownloadResult, type ExampleEntry, type ExamplePlan, type ExamplePlanOptions, FEATURES, FEATURE_CHOICES, type FeatureId, type FileChange, IMAGES, IncompatibleSpecError, type KeyCheck, type LLMProvider, LOCK_PATH, MANIFEST_KEY, MEMORIES, MEMORY_CHOICES, type MemoryKind, type ModelChoice, type ModelChoices, type ModelSource, NotAScaffoldedProjectError, OLLAMA_SUGGESTED_MODELS, type OllamaModel, PACKAGE_MANAGERS, PAYLOAD_FIELDS, PRESETS, PROVIDERS, PROVIDER_INFO, type PackageManager, type PlanOptions, type PreparedTemplate, type Preset, type ProjectPlan, type ProjectSpec, type ProjectSpecInput, ProjectSpecSchema, type ProviderInfo, type RemoteTemplate, SERVERS, SERVER_CHOICES, type ScaffoldLock, type ScaffoldLogger, type ScaffoldManifest, type ScaffoldOptions, type ScaffoldResult, type ServerFramework, type StarterOptions, type StarterResult, type StepResult, TELEMETRY_DOCS, TELEMETRY_HOST, type TelemetryPayload, VECTOR_STORES, VECTOR_STORE_CHOICES, VERSIONS, type VectorStore, addToProject, assertCompatible, bareModel, changesDependencies, checkApiKey, closest, cloudModelChoices, cogitatorVersion, compatibilityIssues, createFromExample, createFromTemplate, defaultModel, describeKeyCheck, describeModel, describeTemplate, detectPackageManager, detectPackageManagerSpec, downloadTemplate, exampleFileUrl, exampleRef, examples, execCommand, fetchExampleFiles, findExample, findPreset, firstRunNotice, formatProject, hasOllamaModel, hashContent, installCommand, knownCogitatorVersions, listOllamaModels, modelChoices, ollamaModelChoices, parseExampleArgument, parseSpec, payloadFor, planAdd, planExample, planProject, prepareTemplate, presetIds, providerEnvKey, providerInfo, pullOllamaModel, qualifiedModel, readLock, resolveExample, resolveOllamaUrl, run, runScript, scaffold, scaffolderVersion, sendTelemetry, silentLogger, telemetryDisabledReason, telemetryWebsiteId, templateArchive, unifiedDiff, updateLock, validateProjectName, writeFiles, writeLock };
897
+ export { APP_CHOICES, APP_KINDS, type AddChanges, type AddConflict, AddConflictError, type AddNote, type AddOptions, type AddPlan, type AddResult, type AppKind, CHANNELS, CHANNEL_CHOICES, CODING_AGENTS, CODING_AGENT_CHOICES, type ChannelKind, type Choice, CodedError, type CodingAgent, type CompatIssue, DEFAULT_OLLAMA_URL, DEFAULT_PRESET, DEPLOY_CHOICES, DEPLOY_TARGETS, type DeployTarget, type DownloadResult, type ExampleEntry, type ExamplePlan, type ExamplePlanOptions, FEATURES, FEATURE_CHOICES, type FailedStep, type FeatureId, type FileChange, IMAGES, IncompatibleSpecError, type KeyCheck, type LLMProvider, LOCK_PATH, MANIFEST_KEY, MEMORIES, MEMORY_CHOICES, type MemoryKind, type ModelChoice, type ModelChoices, type ModelSource, NotAScaffoldedProjectError, OLLAMA_SUGGESTED_MODELS, type OllamaModel, PACKAGE_MANAGERS, PAYLOAD_FIELDS, PRESETS, PROVIDERS, PROVIDER_INFO, type PackageManager, type PlanOptions, type PreparedTemplate, type Preset, type ProjectPlan, type ProjectSpec, type ProjectSpecInput, ProjectSpecSchema, type ProviderInfo, type RemoteTemplate, SERVERS, SERVER_CHOICES, type ScaffoldFailure, type ScaffoldLock, type ScaffoldLogger, type ScaffoldManifest, type ScaffoldOptions, type ScaffoldResult, type ServerFramework, type StarterOptions, type StarterResult, type StepResult, TELEMETRY_DOCS, TELEMETRY_HOST, type TelemetryPayload, VECTOR_STORES, VECTOR_STORE_CHOICES, VERSIONS, type VectorStore, addToProject, assertCompatible, bareModel, changesDependencies, checkApiKey, closest, cloudModelChoices, cogitatorVersion, compatibilityIssues, createFromExample, createFromTemplate, defaultModel, describeKeyCheck, describeModel, describeTemplate, detectPackageManager, detectPackageManagerSpec, downloadTemplate, exampleFileUrl, exampleRef, examples, execCommand, fetchExampleFiles, findExample, findPreset, firstRunNotice, formatProject, hasOllamaModel, hashContent, installCommand, installErrorCode, installFailure, knownCogitatorVersions, listOllamaModels, modelChoices, ollamaModelChoices, parseExampleArgument, parseSpec, payloadFor, planAdd, planExample, planProject, prepareTemplate, presetIds, providerEnvKey, providerInfo, pullOllamaModel, qualifiedModel, readLock, resolveExample, resolveOllamaUrl, run, runScript, scaffold, scaffolderVersion, sendTelemetry, silentLogger, telemetryDisabledReason, telemetryErrorCode, telemetryWebsiteId, templateArchive, unifiedDiff, updateLock, validateProjectName, writeFiles, writeLock };