create-thally-docs 0.8.1 → 0.10.0

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,65 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/stable-scaffold-release.json
4
+ var stable_scaffold_release_default = {
5
+ schemaVersion: 1,
6
+ id: "2026-08-05.04438581.baf29307",
7
+ source: {
8
+ repository: "thallylabs/starter",
9
+ commitSha: "04438581a402d02e9f4308ff047c4c4a48d8169f",
10
+ treeSha: "c962a01b3b8b24ffdb65671c2f7805a47175ba42",
11
+ archiveUrl: "https://codeload.github.com/thallylabs/starter/tar.gz/04438581a402d02e9f4308ff047c4c4a48d8169f",
12
+ manifestPath: "starter-release.json",
13
+ manifestSha256: "e019c6416c6c6872114cdf9d9b5eec6579873f46f826748cf39254fd16628392"
14
+ },
15
+ runtime: {
16
+ repository: "thallylabs/thally",
17
+ commitSha: "baf2930771baf449238bd6c68101ceb3af33ee96",
18
+ treeSha: "56f8217b4da6740015e4775d2ce0aeb60bc167a0",
19
+ contentSource: "assets",
20
+ identityContractVersion: 1
21
+ },
22
+ starterVersion: 2
23
+ };
24
+
25
+ // src/previous-scaffold-releases.json
26
+ var previous_scaffold_releases_default = [
27
+ {
28
+ schemaVersion: 1,
29
+ id: "2026-08-05.d5fef916.f3817263",
30
+ source: {
31
+ repository: "thallylabs/starter",
32
+ commitSha: "d5fef9167ea81f12a861deec5515a78a0f756781",
33
+ treeSha: "31c1e49342ce9f4122dc0cd60fe714868ca03150",
34
+ archiveUrl: "https://codeload.github.com/thallylabs/starter/tar.gz/d5fef9167ea81f12a861deec5515a78a0f756781",
35
+ manifestPath: "starter-release.json",
36
+ manifestSha256: "06cccd3496c368ef95a11b3afc15add610f261b8106e8371720b084adbf7fa5a"
37
+ },
38
+ runtime: {
39
+ repository: "thallylabs/thally",
40
+ commitSha: "f38172638cd2cc944ac9ecda19c096ce4d9b4599",
41
+ treeSha: "d33ad60ad0acabee1cf950880c8bd908e83a002a",
42
+ contentSource: "assets",
43
+ identityContractVersion: 1
44
+ },
45
+ starterVersion: 1
46
+ }
47
+ ];
48
+
49
+ // src/release.ts
50
+ var STABLE_SCAFFOLD_RELEASE = stable_scaffold_release_default;
51
+ var SUPPORTED_SCAFFOLD_RELEASES = [
52
+ STABLE_SCAFFOLD_RELEASE,
53
+ ...previous_scaffold_releases_default
54
+ ];
55
+ function isStableScaffoldRelease(value) {
56
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
57
+ const candidate = value;
58
+ return candidate.schemaVersion === STABLE_SCAFFOLD_RELEASE.schemaVersion && candidate.id === STABLE_SCAFFOLD_RELEASE.id && candidate.starterVersion === STABLE_SCAFFOLD_RELEASE.starterVersion && candidate.source?.repository === STABLE_SCAFFOLD_RELEASE.source.repository && candidate.source?.commitSha === STABLE_SCAFFOLD_RELEASE.source.commitSha && candidate.source?.treeSha === STABLE_SCAFFOLD_RELEASE.source.treeSha && candidate.source?.archiveUrl === STABLE_SCAFFOLD_RELEASE.source.archiveUrl && candidate.source?.manifestPath === STABLE_SCAFFOLD_RELEASE.source.manifestPath && candidate.source?.manifestSha256 === STABLE_SCAFFOLD_RELEASE.source.manifestSha256 && candidate.runtime?.repository === STABLE_SCAFFOLD_RELEASE.runtime.repository && candidate.runtime?.commitSha === STABLE_SCAFFOLD_RELEASE.runtime.commitSha && candidate.runtime?.treeSha === STABLE_SCAFFOLD_RELEASE.runtime.treeSha && candidate.runtime?.contentSource === STABLE_SCAFFOLD_RELEASE.runtime.contentSource && candidate.runtime?.identityContractVersion === STABLE_SCAFFOLD_RELEASE.runtime.identityContractVersion;
59
+ }
60
+
61
+ export {
62
+ STABLE_SCAFFOLD_RELEASE,
63
+ SUPPORTED_SCAFFOLD_RELEASES,
64
+ isStableScaffoldRelease
65
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Documented owner-field personalization for the immutable starter tree.
3
+ *
4
+ * Runtime source, authored pages, navigation structure, dependencies, CI, and
5
+ * repository policy all belong to `thallylabs/starter`. This module may change
6
+ * only the small set of fields an owner answers during creation.
7
+ */
8
+ interface StarterLocale {
9
+ code: string;
10
+ label: string;
11
+ }
12
+ interface StarterPersonalizationOptions {
13
+ projectName: string;
14
+ packageName: string;
15
+ description: string;
16
+ brandPreset: string;
17
+ repoUrl: string;
18
+ enableAiChat: boolean;
19
+ i18nLocales?: Array<StarterLocale>;
20
+ }
21
+ /**
22
+ * Personalize only the owner-controlled settings in `docs.json`.
23
+ *
24
+ * Authored tabs, groups, pages, theme choices, and every unrelated key remain
25
+ * byte-for-byte equivalent after JSON normalization.
26
+ */
27
+ declare function updateStarterDocsConfig(targetDir: string, enableAiChat: boolean, repoUrl: string, i18nLocales?: Array<StarterLocale>): void;
28
+ /** Personalize the documented identity and repository fields in `site.ts`. */
29
+ declare function updateSiteConfig(targetDir: string, projectName: string, description: string, brandPreset: string, repoUrl: string): void;
30
+ /** Rename only the root package identity; dependency pins belong to starter. */
31
+ declare function updatePackageIdentity(targetDir: string, packageName: string): void;
32
+ /** Update the provider-portable Worker name without recreating its config. */
33
+ declare function updateCloudflareRuntimeName(targetDir: string, packageName: string): void;
34
+ /** Copy the canonical environment guide to the ignored local filename. */
35
+ declare function updateEnvExample(targetDir: string): void;
36
+ /** Apply the complete, intentionally narrow owner-personalization contract. */
37
+ declare function personalizeStarter(targetDir: string, options: StarterPersonalizationOptions): void;
38
+
39
+ export { type StarterLocale, type StarterPersonalizationOptions, personalizeStarter, updateCloudflareRuntimeName, updateEnvExample, updatePackageIdentity, updateSiteConfig, updateStarterDocsConfig };
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ personalizeStarter,
4
+ updateCloudflareRuntimeName,
5
+ updateEnvExample,
6
+ updatePackageIdentity,
7
+ updateSiteConfig,
8
+ updateStarterDocsConfig
9
+ } from "./chunk-ORUAMPNF.js";
10
+ export {
11
+ personalizeStarter,
12
+ updateCloudflareRuntimeName,
13
+ updateEnvExample,
14
+ updatePackageIdentity,
15
+ updateSiteConfig,
16
+ updateStarterDocsConfig
17
+ };
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  migrateDocs
4
- } from "./chunk-SDZZYPSN.js";
4
+ } from "./chunk-GAFCLXU4.js";
5
5
  import {
6
6
  logo,
7
7
  readDocsJson,
@@ -9,7 +9,11 @@ import {
9
9
  slugify,
10
10
  success,
11
11
  writeDocsJson
12
- } from "./chunk-RS6U2GSX.js";
12
+ } from "./chunk-GTGHYJXS.js";
13
+ import "./chunk-ORUAMPNF.js";
14
+ import "./chunk-ENQIF6MA.js";
15
+ import "./chunk-KXJT2MG5.js";
16
+ import "./chunk-WMHBVXWW.js";
13
17
 
14
18
  // src/index.ts
15
19
  import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
@@ -149,13 +153,13 @@ async function gatherAnswers(dirArg, useDefaults, installPreference) {
149
153
  let i18nLocales;
150
154
  if (!useDefaults) {
151
155
  const enableI18n = await input({
152
- message: " Enable multi-language support? (y/N):",
156
+ message: " Add another documentation language? (y/N):",
153
157
  default: "N"
154
158
  });
155
159
  if (enableI18n.toLowerCase() === "y") {
156
160
  const localesInput = await input({
157
- message: " Which locales? (comma-separated codes, e.g. es,fr,de):",
158
- default: "es"
161
+ message: " Which additional locales? (comma-separated codes, e.g. fr,de,ja):",
162
+ default: "fr"
159
163
  });
160
164
  const LOCALE_LABELS = {
161
165
  en: "English",
@@ -0,0 +1,35 @@
1
+ import { MigrationPlatform, MigrationFetcher, MigrationBundle, MigrationWarning } from '@thallylabs/migrate';
2
+
3
+ /**
4
+ * CLI materializer for the shared Thally migration engine. Discovery completes
5
+ * before scaffolding or writing, and every generated path is proven to remain
6
+ * inside the selected project directory.
7
+ */
8
+
9
+ interface MigrateOptions {
10
+ sourceUrl: string;
11
+ projectDir: string;
12
+ into: boolean;
13
+ /** Retained for CLI compatibility; Markdown/MDX imports do not require a key. */
14
+ apiKey?: string;
15
+ branch?: string;
16
+ docsDir?: string;
17
+ projectName?: string;
18
+ yes: boolean;
19
+ maxPages?: number;
20
+ /** Explicit source platform selected by an interactive or automated caller. */
21
+ platform?: MigrationPlatform;
22
+ /** Optional host fetch boundary; used by Thally Cloud adapters and tests. */
23
+ fetcher?: MigrationFetcher;
24
+ }
25
+ interface MigrateResult {
26
+ pagesWritten: number;
27
+ assetsWritten: number;
28
+ projectDir: string;
29
+ platform: MigrationBundle['platform'];
30
+ warnings: Array<MigrationWarning>;
31
+ }
32
+ /** Import a GitHub docs repository or public docs URL into a Thally project. */
33
+ declare function migrateDocs(options: MigrateOptions): Promise<MigrateResult>;
34
+
35
+ export { type MigrateOptions, type MigrateResult, migrateDocs };
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  migrateDocs
4
- } from "../chunk-SDZZYPSN.js";
5
- import "../chunk-RS6U2GSX.js";
4
+ } from "../chunk-GAFCLXU4.js";
5
+ import "../chunk-GTGHYJXS.js";
6
+ import "../chunk-ORUAMPNF.js";
7
+ import "../chunk-ENQIF6MA.js";
8
+ import "../chunk-KXJT2MG5.js";
9
+ import "../chunk-WMHBVXWW.js";
6
10
  export {
7
11
  migrateDocs
8
12
  };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Immutable source and runtime identity for every newly scaffolded Thally site.
3
+ *
4
+ * A release is promoted only after the source snapshot and its compiled runtime
5
+ * have passed the scaffold, build, and identity-safety gates. Consumers must
6
+ * use the whole record: independently resolving "latest template" and "latest
7
+ * runtime" recreates the drift this contract exists to prevent.
8
+ */
9
+ interface ScaffoldSourceRelease {
10
+ repository: string;
11
+ commitSha: string;
12
+ treeSha: string;
13
+ archiveUrl: string;
14
+ manifestPath: 'starter-release.json';
15
+ manifestSha256: string;
16
+ }
17
+ interface ScaffoldOwnershipContract {
18
+ frameworkSyncEligible: readonly string[];
19
+ userOwnedNeverOverwrite: readonly string[];
20
+ manualReview: readonly string[];
21
+ }
22
+ interface StarterReleaseManifest {
23
+ schemaVersion: 1;
24
+ starterVersion: number;
25
+ repository: string;
26
+ defaultBranch: string;
27
+ runtime: Pick<ScaffoldRuntimeRelease, 'repository' | 'commitSha' | 'treeSha'>;
28
+ packages: Record<string, string>;
29
+ ownership: ScaffoldOwnershipContract;
30
+ }
31
+ interface ScaffoldRuntimeRelease {
32
+ repository: string;
33
+ commitSha: string;
34
+ treeSha: string;
35
+ contentSource: 'assets';
36
+ identityContractVersion: number;
37
+ }
38
+ interface ScaffoldRelease {
39
+ schemaVersion: 1;
40
+ id: string;
41
+ source: ScaffoldSourceRelease;
42
+ runtime: ScaffoldRuntimeRelease;
43
+ starterVersion: number;
44
+ }
45
+ /**
46
+ * Current stable scaffold release.
47
+ *
48
+ * The source commit is the complete, standalone `thallylabs/starter` tree and
49
+ * the runtime commit is the matching engine change. `create-thally-docs`, the
50
+ * CLI, MCP, and Thally Cloud all import this exact record rather than following
51
+ * a moving branch independently. Promotion replaces the placeholders in the
52
+ * adjacent JSON record, which is also consumed by Cloud build parity checks.
53
+ */
54
+ declare const STABLE_SCAFFOLD_RELEASE: ScaffoldRelease;
55
+ /**
56
+ * Immutable releases this toolchain can use as a three-way update base.
57
+ *
58
+ * Promotion prepends the new stable record but retains earlier records. That
59
+ * lets a project created directly from GitHub carry only the exact manifest
60
+ * bytes and still resolve its original starter without mutable branch state.
61
+ */
62
+ declare const SUPPORTED_SCAFFOLD_RELEASES: readonly ScaffoldRelease[];
63
+ /** True only when an unknown record is the currently supported release. */
64
+ declare function isStableScaffoldRelease(value: unknown): value is ScaffoldRelease;
65
+
66
+ export { STABLE_SCAFFOLD_RELEASE, SUPPORTED_SCAFFOLD_RELEASES, type ScaffoldOwnershipContract, type ScaffoldRelease, type ScaffoldRuntimeRelease, type ScaffoldSourceRelease, type StarterReleaseManifest, isStableScaffoldRelease };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ STABLE_SCAFFOLD_RELEASE,
4
+ SUPPORTED_SCAFFOLD_RELEASES,
5
+ isStableScaffoldRelease
6
+ } from "./chunk-WMHBVXWW.js";
7
+ export {
8
+ STABLE_SCAFFOLD_RELEASE,
9
+ SUPPORTED_SCAFFOLD_RELEASES,
10
+ isStableScaffoldRelease
11
+ };
@@ -0,0 +1,53 @@
1
+ export { STABLE_SCAFFOLD_RELEASE } from './release.js';
2
+
3
+ /**
4
+ * Immutable starter archive download and extraction.
5
+ *
6
+ * The dedicated starter repository is already a customer-ready project. Every
7
+ * safe filesystem entry is extracted; there is no exclusion list or second
8
+ * manifest that can silently produce a different scaffold.
9
+ */
10
+
11
+ /** Repository whose complete tree becomes every newly scaffolded site. */
12
+ declare const STARTER_REPOSITORY: string;
13
+ /** Exact starter commit consumed by every creation surface. */
14
+ declare const STARTER_COMMIT_SHA: string;
15
+ /** GitHub codeload's single top-level directory for the pinned archive. */
16
+ declare const STARTER_ARCHIVE_ROOT: string;
17
+ interface StarterArchiveEntryMetadata {
18
+ type: string;
19
+ size: number;
20
+ }
21
+ /**
22
+ * Validate one codeload entry before `strip: 1` can write it to disk.
23
+ *
24
+ * Git cannot store devices or FIFOs, and starter sites do not need links. A
25
+ * release containing one is rejected rather than partially extracted because
26
+ * the entire repository tree is the immutable contract.
27
+ */
28
+ declare function validateStarterArchiveEntry(archivePath: string, entry: StarterArchiveEntryMetadata, archiveRoot?: string): void;
29
+
30
+ interface ScaffoldOptions {
31
+ projectDir: string;
32
+ projectName: string;
33
+ description: string;
34
+ brandPreset: string;
35
+ repoUrl: string;
36
+ doInstall: boolean;
37
+ enableAiChat?: boolean;
38
+ i18nLocales?: Array<{
39
+ code: string;
40
+ label: string;
41
+ }>;
42
+ /** Repos to pre-register for Thally Track (opt-in). Empty/undefined = Track off. */
43
+ trackRepos?: Array<{
44
+ owner: string;
45
+ repo: string;
46
+ }>;
47
+ }
48
+ interface ScaffoldResult {
49
+ projectDir: string;
50
+ }
51
+ declare function scaffold(options: ScaffoldOptions): Promise<ScaffoldResult>;
52
+
53
+ export { STARTER_ARCHIVE_ROOT, STARTER_COMMIT_SHA, STARTER_REPOSITORY, type ScaffoldOptions, type ScaffoldResult, scaffold, validateStarterArchiveEntry };
package/dist/scaffold.js CHANGED
@@ -1,7 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scaffold
4
- } from "./chunk-RS6U2GSX.js";
4
+ } from "./chunk-GTGHYJXS.js";
5
+ import "./chunk-ORUAMPNF.js";
6
+ import {
7
+ STARTER_ARCHIVE_ROOT,
8
+ STARTER_COMMIT_SHA,
9
+ STARTER_REPOSITORY,
10
+ validateStarterArchiveEntry
11
+ } from "./chunk-ENQIF6MA.js";
12
+ import "./chunk-KXJT2MG5.js";
13
+ import {
14
+ STABLE_SCAFFOLD_RELEASE
15
+ } from "./chunk-WMHBVXWW.js";
5
16
  export {
6
- scaffold
17
+ STABLE_SCAFFOLD_RELEASE,
18
+ STARTER_ARCHIVE_ROOT,
19
+ STARTER_COMMIT_SHA,
20
+ STARTER_REPOSITORY,
21
+ scaffold,
22
+ validateStarterArchiveEntry
7
23
  };
@@ -0,0 +1,68 @@
1
+ import { ScaffoldOwnershipContract, ScaffoldRelease, StarterReleaseManifest } from './release.js';
2
+
3
+ /**
4
+ * Ownership-aware, three-way planning for future starter runtime updates.
5
+ *
6
+ * The ownership contract comes from the pinned starter archive's
7
+ * `starter-release.json`. Automatic updates touch only framework-eligible files
8
+ * that still match the recorded old starter; owner and manual-review paths are
9
+ * never included in an apply plan.
10
+ */
11
+
12
+ type StarterPathOwnership = 'protected' | 'manual' | 'syncable' | 'unmanaged';
13
+ interface StarterRuntimeSyncPlan {
14
+ copyPaths: string[];
15
+ deletePaths: string[];
16
+ conflictPaths: string[];
17
+ manualReviewPaths: string[];
18
+ preservedPaths: string[];
19
+ unchangedPaths: string[];
20
+ targetPreconditions: Record<string, StarterTargetPrecondition>;
21
+ }
22
+ interface StarterTargetPrecondition {
23
+ kind: 'missing' | 'file';
24
+ sha256?: string;
25
+ }
26
+ interface StarterApplyProvenance {
27
+ sourcePath: string;
28
+ targetPath: string;
29
+ expectedSha256: string;
30
+ }
31
+ interface ApplyStarterRuntimeSyncOptions {
32
+ /** Explicit acknowledgement that the caller reviewed this exact plan. */
33
+ confirmed: boolean;
34
+ /** Optional immutable provenance file, atomically replaced after mutations. */
35
+ provenance?: StarterApplyProvenance;
36
+ /** Integration hook; an exception aborts and rolls back the transaction. */
37
+ onMutationApplied?: (path: string, index: number) => void;
38
+ }
39
+ /** Parse and validate the ownership section in `starter-release.json`. */
40
+ declare function parseStarterOwnershipContract(value: unknown): ScaffoldOwnershipContract;
41
+ /**
42
+ * Combine the previous and next release policies without weakening ownership.
43
+ *
44
+ * A later starter may broaden framework ownership, but it cannot retroactively
45
+ * make a path safe to overwrite when either release marked that path as owner
46
+ * controlled or manual-review. Classification precedence enforces that union.
47
+ */
48
+ declare function mergeStarterOwnershipContracts(previous: ScaffoldOwnershipContract, next: ScaffoldOwnershipContract): ScaffoldOwnershipContract;
49
+ /** Stable SHA-256 of the exact manifest bytes promoted with a release. */
50
+ declare function starterManifestSha256(source: string): string;
51
+ /**
52
+ * Parse the archive-owned release manifest and bind it to its promoted source,
53
+ * runtime identity, and SHA-256. Branch names never participate in updates.
54
+ */
55
+ declare function parseStarterReleaseManifest(source: string, release?: ScaffoldRelease): StarterReleaseManifest;
56
+ /** Read and validate the canonical ownership manifest from an extracted archive. */
57
+ declare function readStarterReleaseManifest(starterDir: string, release?: ScaffoldRelease): StarterReleaseManifest;
58
+ /** Protected > manual-review > syncable > unmanaged. */
59
+ declare function classifyStarterPath(path: string, contract: ScaffoldOwnershipContract): StarterPathOwnership;
60
+ /**
61
+ * Build a safe three-way update plan from the recorded old starter, the new
62
+ * starter, and the customer's current tree.
63
+ */
64
+ declare function planStarterRuntimeSync(oldStarterDir: string, newStarterDir: string, targetDir: string, ownership: ScaffoldOwnershipContract): StarterRuntimeSyncPlan;
65
+ /** Apply an explicitly confirmed, conflict-free three-way plan. */
66
+ declare function applyStarterRuntimeSyncPlan(newStarterDir: string, targetDir: string, plan: StarterRuntimeSyncPlan, ownership: ScaffoldOwnershipContract, options: ApplyStarterRuntimeSyncOptions): void;
67
+
68
+ export { type ApplyStarterRuntimeSyncOptions, type StarterApplyProvenance, type StarterPathOwnership, type StarterRuntimeSyncPlan, type StarterTargetPrecondition, applyStarterRuntimeSyncPlan, classifyStarterPath, mergeStarterOwnershipContracts, parseStarterOwnershipContract, parseStarterReleaseManifest, planStarterRuntimeSync, readStarterReleaseManifest, starterManifestSha256 };
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ applyStarterRuntimeSyncPlan,
4
+ classifyStarterPath,
5
+ mergeStarterOwnershipContracts,
6
+ parseStarterOwnershipContract,
7
+ parseStarterReleaseManifest,
8
+ planStarterRuntimeSync,
9
+ readStarterReleaseManifest,
10
+ starterManifestSha256
11
+ } from "./chunk-KXJT2MG5.js";
12
+ import "./chunk-WMHBVXWW.js";
13
+ export {
14
+ applyStarterRuntimeSyncPlan,
15
+ classifyStarterPath,
16
+ mergeStarterOwnershipContracts,
17
+ parseStarterOwnershipContract,
18
+ parseStarterReleaseManifest,
19
+ planStarterRuntimeSync,
20
+ readStarterReleaseManifest,
21
+ starterManifestSha256
22
+ };
@@ -0,0 +1,43 @@
1
+ import { ScaffoldRelease } from './release.js';
2
+ import { StarterRuntimeSyncPlan } from './starter-sync.js';
3
+
4
+ /**
5
+ * User-reachable orchestration for immutable starter release updates.
6
+ *
7
+ * Projects carry the exact bytes of `starter-release.json`. The manifest hash
8
+ * resolves the old release from the toolchain's retained immutable catalog;
9
+ * neither the old nor new side follows a branch. Updates are dry-run by
10
+ * default and advance provenance only after a confirmed, conflict-free apply.
11
+ */
12
+
13
+ interface StarterUpdateDownload {
14
+ (targetDir: string, release: ScaffoldRelease): Promise<void>;
15
+ }
16
+ interface UpdateStarterProjectOptions {
17
+ targetDir: string;
18
+ /** Applying is opt-in. Omitted/false always produces a dry-run plan. */
19
+ apply?: boolean;
20
+ /** Separate acknowledgement for programmatic callers. */
21
+ confirmed?: boolean;
22
+ targetRelease?: ScaffoldRelease;
23
+ releases?: readonly ScaffoldRelease[];
24
+ download?: StarterUpdateDownload;
25
+ }
26
+ interface StarterUpdateResult {
27
+ previousRelease: ScaffoldRelease;
28
+ targetRelease: ScaffoldRelease;
29
+ plan: StarterRuntimeSyncPlan;
30
+ isUpToDate: boolean;
31
+ applied: boolean;
32
+ }
33
+ /** Resolve exact downstream provenance without consulting a moving branch. */
34
+ declare function resolveStarterReleaseFromManifest(source: string, releases?: readonly ScaffoldRelease[]): ScaffoldRelease;
35
+ /**
36
+ * Plan or explicitly apply an immutable three-way starter update.
37
+ *
38
+ * Direct GitHub-template copies need no generated state beyond the canonical
39
+ * manifest: its pinned hash selects the old archive from the retained catalog.
40
+ */
41
+ declare function updateStarterProject(options: UpdateStarterProjectOptions): Promise<StarterUpdateResult>;
42
+
43
+ export { type StarterUpdateDownload, type StarterUpdateResult, type UpdateStarterProjectOptions, resolveStarterReleaseFromManifest, updateStarterProject };
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ downloadStarter
4
+ } from "./chunk-ENQIF6MA.js";
5
+ import {
6
+ applyStarterRuntimeSyncPlan,
7
+ mergeStarterOwnershipContracts,
8
+ parseStarterReleaseManifest,
9
+ planStarterRuntimeSync,
10
+ readStarterReleaseManifest,
11
+ starterManifestSha256
12
+ } from "./chunk-KXJT2MG5.js";
13
+ import {
14
+ STABLE_SCAFFOLD_RELEASE,
15
+ SUPPORTED_SCAFFOLD_RELEASES
16
+ } from "./chunk-WMHBVXWW.js";
17
+
18
+ // src/starter-update.ts
19
+ import {
20
+ existsSync,
21
+ mkdirSync,
22
+ mkdtempSync,
23
+ readFileSync,
24
+ rmSync
25
+ } from "fs";
26
+ import { tmpdir } from "os";
27
+ import { join } from "path";
28
+ var EMPTY_PLAN = {
29
+ copyPaths: [],
30
+ deletePaths: [],
31
+ conflictPaths: [],
32
+ manualReviewPaths: [],
33
+ preservedPaths: [],
34
+ unchangedPaths: [],
35
+ targetPreconditions: {}
36
+ };
37
+ function readDownstreamManifest(targetDir, manifestPath) {
38
+ const path = join(targetDir, manifestPath);
39
+ if (!existsSync(path)) {
40
+ throw new Error(
41
+ `This project has no ${manifestPath}; update it from a versioned Thally starter first.`
42
+ );
43
+ }
44
+ return readFileSync(path, "utf8");
45
+ }
46
+ function resolveStarterReleaseFromManifest(source, releases = SUPPORTED_SCAFFOLD_RELEASES) {
47
+ const hash = starterManifestSha256(source);
48
+ const matching = releases.filter(
49
+ (release) => release.source.manifestSha256 === hash
50
+ );
51
+ if (matching.length !== 1) {
52
+ throw new Error(
53
+ "The project starter manifest is edited, unknown, or ambiguously registered; refusing to update."
54
+ );
55
+ }
56
+ parseStarterReleaseManifest(source, matching[0]);
57
+ return matching[0];
58
+ }
59
+ function assertForwardRelease(previous, target) {
60
+ if (previous.source.repository !== target.source.repository || previous.source.manifestPath !== target.source.manifestPath) {
61
+ throw new Error("Starter updates cannot cross repository or manifest contracts.");
62
+ }
63
+ if (previous.source.commitSha !== target.source.commitSha && previous.starterVersion >= target.starterVersion) {
64
+ throw new Error("The installed CLI does not contain a newer starter release.");
65
+ }
66
+ }
67
+ async function updateStarterProject(options) {
68
+ const targetRelease = options.targetRelease ?? STABLE_SCAFFOLD_RELEASE;
69
+ const releases = options.releases ?? SUPPORTED_SCAFFOLD_RELEASES;
70
+ const manifestPath = targetRelease.source.manifestPath;
71
+ const downstreamManifest = readDownstreamManifest(options.targetDir, manifestPath);
72
+ const previousRelease = resolveStarterReleaseFromManifest(
73
+ downstreamManifest,
74
+ releases
75
+ );
76
+ assertForwardRelease(previousRelease, targetRelease);
77
+ if (previousRelease.source.commitSha === targetRelease.source.commitSha) {
78
+ return {
79
+ previousRelease,
80
+ targetRelease,
81
+ plan: EMPTY_PLAN,
82
+ isUpToDate: true,
83
+ applied: false
84
+ };
85
+ }
86
+ if (options.apply && !options.confirmed) {
87
+ throw new Error("Pass explicit confirmation before applying a starter update.");
88
+ }
89
+ const workspace = mkdtempSync(join(tmpdir(), "thally-starter-update-"));
90
+ const oldStarterDir = join(workspace, "old");
91
+ const newStarterDir = join(workspace, "new");
92
+ mkdirSync(oldStarterDir);
93
+ mkdirSync(newStarterDir);
94
+ const download = options.download ?? (async (targetDir, release) => {
95
+ await downloadStarter(targetDir, void 0, release, { announce: false });
96
+ });
97
+ try {
98
+ await download(oldStarterDir, previousRelease);
99
+ await download(newStarterDir, targetRelease);
100
+ const oldManifest = readStarterReleaseManifest(oldStarterDir, previousRelease);
101
+ const newManifest = readStarterReleaseManifest(newStarterDir, targetRelease);
102
+ const ownership = mergeStarterOwnershipContracts(
103
+ oldManifest.ownership,
104
+ newManifest.ownership
105
+ );
106
+ const plan = planStarterRuntimeSync(
107
+ oldStarterDir,
108
+ newStarterDir,
109
+ options.targetDir,
110
+ ownership
111
+ );
112
+ if (!options.apply) {
113
+ return {
114
+ previousRelease,
115
+ targetRelease,
116
+ plan,
117
+ isUpToDate: false,
118
+ applied: false
119
+ };
120
+ }
121
+ if (plan.conflictPaths.length > 0) {
122
+ throw new Error("Resolve starter synchronization conflicts before applying.");
123
+ }
124
+ if (readDownstreamManifest(options.targetDir, manifestPath) !== downstreamManifest) {
125
+ throw new Error("The project starter manifest changed during update planning.");
126
+ }
127
+ applyStarterRuntimeSyncPlan(
128
+ newStarterDir,
129
+ options.targetDir,
130
+ plan,
131
+ ownership,
132
+ {
133
+ confirmed: true,
134
+ provenance: {
135
+ sourcePath: join(newStarterDir, manifestPath),
136
+ targetPath: join(options.targetDir, manifestPath),
137
+ expectedSha256: previousRelease.source.manifestSha256
138
+ }
139
+ }
140
+ );
141
+ return {
142
+ previousRelease,
143
+ targetRelease,
144
+ plan,
145
+ isUpToDate: false,
146
+ applied: true
147
+ };
148
+ } finally {
149
+ rmSync(workspace, { recursive: true, force: true });
150
+ }
151
+ }
152
+ export {
153
+ resolveStarterReleaseFromManifest,
154
+ updateStarterProject
155
+ };