@savvy-web/silk-effects 0.6.0 → 1.0.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.
Files changed (155) hide show
  1. package/README.md +48 -17
  2. package/_virtual/_rolldown/runtime.js +18 -0
  3. package/changesets/api/categories.js +247 -0
  4. package/changesets/api/changelog.js +134 -0
  5. package/changesets/api/dependency-table.js +163 -0
  6. package/changesets/api/linter.js +168 -0
  7. package/changesets/api/transformer.js +140 -0
  8. package/changesets/categories/index.js +299 -0
  9. package/changesets/categories/types.js +66 -0
  10. package/changesets/changelog/formatting.js +119 -0
  11. package/changesets/changelog/getDependencyReleaseLine.js +114 -0
  12. package/changesets/changelog/getReleaseLine.js +122 -0
  13. package/changesets/changelog/index.js +99 -0
  14. package/changesets/constants.js +43 -0
  15. package/changesets/errors.js +305 -0
  16. package/changesets/index.js +146 -0
  17. package/changesets/markdownlint/index.js +29 -0
  18. package/changesets/markdownlint/rules/content-structure.js +98 -0
  19. package/changesets/markdownlint/rules/dependency-table-format.js +170 -0
  20. package/changesets/markdownlint/rules/heading-hierarchy.js +61 -0
  21. package/changesets/markdownlint/rules/required-sections.js +54 -0
  22. package/changesets/markdownlint/rules/uncategorized-content.js +54 -0
  23. package/changesets/markdownlint/rules/utils.js +30 -0
  24. package/changesets/remark/plugins/aggregate-dependency-tables.js +47 -0
  25. package/changesets/remark/plugins/contributor-footnotes.js +123 -0
  26. package/changesets/remark/plugins/deduplicate-items.js +30 -0
  27. package/changesets/remark/plugins/issue-link-refs.js +58 -0
  28. package/changesets/remark/plugins/merge-sections.js +43 -0
  29. package/changesets/remark/plugins/normalize-format.js +47 -0
  30. package/changesets/remark/plugins/reorder-sections.js +34 -0
  31. package/changesets/remark/presets.js +119 -0
  32. package/changesets/remark/rules/content-structure.js +22 -0
  33. package/changesets/remark/rules/dependency-table-format.js +40 -0
  34. package/changesets/remark/rules/heading-hierarchy.js +19 -0
  35. package/changesets/remark/rules/required-sections.js +17 -0
  36. package/changesets/remark/rules/uncategorized-content.js +31 -0
  37. package/changesets/schemas/changeset.js +146 -0
  38. package/changesets/schemas/dependency-table.js +189 -0
  39. package/changesets/schemas/git.js +69 -0
  40. package/changesets/schemas/github.js +175 -0
  41. package/changesets/schemas/options.js +182 -0
  42. package/changesets/schemas/package-scope.js +128 -0
  43. package/changesets/schemas/primitives.js +72 -0
  44. package/changesets/schemas/version-files.js +151 -0
  45. package/changesets/services/branch-analyzer.js +278 -0
  46. package/changesets/services/changelog.js +50 -0
  47. package/changesets/services/config-inspector.js +390 -0
  48. package/changesets/services/github.js +178 -0
  49. package/changesets/services/markdown.js +106 -0
  50. package/changesets/services/workspace-snapshot.js +182 -0
  51. package/changesets/utils/commit-parser.js +80 -0
  52. package/changesets/utils/dep-diff.js +77 -0
  53. package/changesets/utils/dependency-table.js +347 -0
  54. package/changesets/utils/issue-refs.js +101 -0
  55. package/changesets/utils/jsonpath.js +175 -0
  56. package/changesets/utils/logger.js +50 -0
  57. package/changesets/utils/markdown-link.js +57 -0
  58. package/changesets/utils/publishability.js +39 -0
  59. package/changesets/utils/remark-pipeline.js +79 -0
  60. package/changesets/utils/section-parser.js +94 -0
  61. package/changesets/utils/strip-frontmatter.js +46 -0
  62. package/changesets/utils/version-blocks.js +108 -0
  63. package/changesets/utils/version-files.js +336 -0
  64. package/changesets/utils/worktree-snapshot.js +142 -0
  65. package/changesets/vendor/github-info.js +55 -0
  66. package/commitlint/config/factory.js +69 -0
  67. package/commitlint/config/plugins.js +227 -0
  68. package/commitlint/config/rules.js +155 -0
  69. package/commitlint/config/schema.js +46 -0
  70. package/commitlint/detection/dco.js +53 -0
  71. package/commitlint/detection/scopes.js +45 -0
  72. package/commitlint/formatter/format.js +85 -0
  73. package/commitlint/formatter/messages.js +79 -0
  74. package/commitlint/hook/diagnostics/branch.js +36 -0
  75. package/commitlint/hook/diagnostics/cache.js +37 -0
  76. package/commitlint/hook/diagnostics/commitlint-config.js +36 -0
  77. package/commitlint/hook/diagnostics/open-issues.js +56 -0
  78. package/commitlint/hook/diagnostics/package-manager.js +51 -0
  79. package/commitlint/hook/diagnostics/signing.js +107 -0
  80. package/commitlint/hook/envelope.js +46 -0
  81. package/commitlint/hook/output.js +45 -0
  82. package/commitlint/hook/parse-bash-command.js +105 -0
  83. package/commitlint/hook/rules/closes-trailer.js +31 -0
  84. package/commitlint/hook/rules/forbidden-content.js +32 -0
  85. package/commitlint/hook/rules/plan-leakage.js +36 -0
  86. package/commitlint/hook/rules/signing-flag-conflict.js +25 -0
  87. package/commitlint/hook/rules/soft-wrap.js +37 -0
  88. package/commitlint/hook/rules/types.js +14 -0
  89. package/commitlint/hook/rules/verbosity.js +31 -0
  90. package/commitlint/hook/silence-logger.js +39 -0
  91. package/commitlint/index.js +146 -0
  92. package/commitlint/prompt/config.js +91 -0
  93. package/commitlint/prompt/emojis.js +74 -0
  94. package/commitlint/prompt/prompter.js +135 -0
  95. package/commitlint/static.js +73 -0
  96. package/errors/BiomeSyncError.js +21 -0
  97. package/errors/ChangesetConfigError.js +20 -0
  98. package/errors/ConfigNotFoundError.js +21 -0
  99. package/errors/SectionParseError.js +16 -0
  100. package/errors/SectionValidationError.js +16 -0
  101. package/errors/SectionWriteError.js +16 -0
  102. package/errors/TagFormatError.js +20 -0
  103. package/errors/ToolNotFoundError.js +11 -0
  104. package/errors/ToolResolutionError.js +11 -0
  105. package/errors/ToolVersionMismatchError.js +11 -0
  106. package/errors/VersioningDetectionError.js +20 -0
  107. package/errors/WorkspaceAnalysisError.js +21 -0
  108. package/index.d.ts +9743 -8380
  109. package/index.js +36 -6657
  110. package/lint/Handler.js +39 -0
  111. package/lint/cli/sections.js +65 -0
  112. package/lint/cli/templates/markdownlint.gen.js +183 -0
  113. package/lint/config/Preset.js +152 -0
  114. package/lint/config/createConfig.js +89 -0
  115. package/lint/handlers/Biome.js +179 -0
  116. package/lint/handlers/Markdown.js +139 -0
  117. package/lint/handlers/PackageJson.js +130 -0
  118. package/lint/handlers/PnpmWorkspace.js +141 -0
  119. package/lint/handlers/ShellScripts.js +58 -0
  120. package/lint/handlers/TypeScript.js +134 -0
  121. package/lint/handlers/Yaml.js +167 -0
  122. package/lint/index.js +52 -0
  123. package/lint/utils/Command.js +285 -0
  124. package/lint/utils/Filter.js +100 -0
  125. package/lint/utils/Workspace.js +86 -0
  126. package/package.json +52 -63
  127. package/schemas/CommentStyle.js +16 -0
  128. package/schemas/ResolvedTool.js +63 -0
  129. package/schemas/SavvySections.js +113 -0
  130. package/schemas/SectionBlock.js +70 -0
  131. package/schemas/SectionDefinition.js +121 -0
  132. package/schemas/SectionResults.js +12 -0
  133. package/schemas/TagStrategySchemas.js +18 -0
  134. package/schemas/ToolDefinition.js +39 -0
  135. package/schemas/ToolResults.js +14 -0
  136. package/schemas/VersioningSchemas.js +95 -0
  137. package/schemas/WorkspaceAnalysisSchemas.js +190 -0
  138. package/services/BiomeSchemaSync.js +133 -0
  139. package/services/ChangesetConfig.js +78 -0
  140. package/services/ChangesetConfigReader.js +106 -0
  141. package/services/ConfigDiscovery.js +71 -0
  142. package/services/ManagedSection.js +288 -0
  143. package/services/SilkPublishability.js +193 -0
  144. package/services/SilkWorkspaceAnalyzer.js +213 -0
  145. package/services/TagStrategy.js +54 -0
  146. package/services/ToolDiscovery.js +229 -0
  147. package/services/VersioningStrategy.js +67 -0
  148. package/tsdoc-metadata.json +11 -11
  149. package/turbo/digest.js +127 -0
  150. package/turbo/errors.js +48 -0
  151. package/turbo/index.js +32 -0
  152. package/turbo/schemas/DryRun.js +57 -0
  153. package/turbo/schemas/results.js +61 -0
  154. package/turbo/services/TurboInspector.js +100 -0
  155. package/utils/ToolCommand.js +40 -0
@@ -0,0 +1,305 @@
1
+ import { Data } from "effect";
2
+
3
+ //#region src/changesets/errors.ts
4
+ /**
5
+ * Tagged errors for \@savvy-web/changesets.
6
+ *
7
+ * @remarks
8
+ * All errors in this module extend Effect's `Data.TaggedError`, enabling
9
+ * type-safe error handling via `Effect.catchTag`. Each error class carries
10
+ * structured metadata (not just a string message) so that callers can
11
+ * programmatically inspect failure details.
12
+ *
13
+ * The `*Base` exports are anonymous base classes generated by
14
+ * `Data.TaggedError()`. They are exported solely for api-extractor
15
+ * compatibility and should not be used directly.
16
+ *
17
+ * @see {@link https://effect.website/docs/data-types/data#taggerror | Effect TaggedError documentation}
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ /**
22
+ * Base class for {@link ChangesetValidationError}.
23
+ *
24
+ * @privateRemarks
25
+ * This export is required for api-extractor documentation generation.
26
+ * Effect's Data.TaggedError creates an anonymous base class that must be
27
+ * explicitly exported to avoid "forgotten export" warnings. Do not delete.
28
+ *
29
+ * @internal
30
+ */
31
+ const ChangesetValidationErrorBase = Data.TaggedError("ChangesetValidationError");
32
+ /**
33
+ * Changeset file validation failure.
34
+ *
35
+ * @remarks
36
+ * Raised when a changeset markdown file fails structural validation
37
+ * (e.g., missing summary, invalid heading, malformed dependency table).
38
+ * Carries an array of structured issues, each with a JSON-path pointing
39
+ * to the problematic field and a human-readable message.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { Effect } from "effect";
44
+ * import { ChangesetValidationError } from "@savvy-web/changesets";
45
+ *
46
+ * declare const program: Effect.Effect<void, ChangesetValidationError>;
47
+ *
48
+ * const handled = program.pipe(
49
+ * Effect.catchTag("ChangesetValidationError", (err) => {
50
+ * for (const issue of err.issues) {
51
+ * console.error(`${issue.path}: ${issue.message}`);
52
+ * }
53
+ * return Effect.void;
54
+ * }),
55
+ * );
56
+ * ```
57
+ *
58
+ * @see {@link ChangesetSchema} for the schema that drives validation
59
+ *
60
+ * @public
61
+ */
62
+ var ChangesetValidationError = class extends ChangesetValidationErrorBase {
63
+ get message() {
64
+ return `${this.file ? `${this.file}: ` : ""}Changeset validation failed:\n${this.issues.map((i) => ` - ${i.path}: ${i.message}`).join("\n")}`;
65
+ }
66
+ };
67
+ /**
68
+ * Base class for {@link GitHubApiError}.
69
+ *
70
+ * @privateRemarks
71
+ * This export is required for api-extractor documentation generation.
72
+ * Effect's Data.TaggedError creates an anonymous base class that must be
73
+ * explicitly exported to avoid "forgotten export" warnings. Do not delete.
74
+ *
75
+ * @internal
76
+ */
77
+ const GitHubApiErrorBase = Data.TaggedError("GitHubApiError");
78
+ /**
79
+ * GitHub API request failure.
80
+ *
81
+ * @remarks
82
+ * Raised when a call to the GitHub API (via `\@changesets/get-github-info`)
83
+ * fails due to network issues, authentication errors, rate limiting, or
84
+ * server errors. Use the {@link GitHubApiError.isRetryable | isRetryable}
85
+ * property to determine whether a retry strategy should be applied.
86
+ * Rate-limited responses (403/429) and server errors (5xx) are considered
87
+ * retryable.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { Effect, Schedule } from "effect";
92
+ * import { GitHubApiError } from "@savvy-web/changesets";
93
+ *
94
+ * declare const program: Effect.Effect<void, GitHubApiError>;
95
+ *
96
+ * const withRetry = program.pipe(
97
+ * Effect.catchTag("GitHubApiError", (err) => {
98
+ * if (err.isRetryable) {
99
+ * return Effect.retry(program, Schedule.exponential("1 second"));
100
+ * }
101
+ * return Effect.fail(err);
102
+ * }),
103
+ * );
104
+ * ```
105
+ *
106
+ * @see {@link GitHubService} for the Effect service that may produce this error
107
+ *
108
+ * @public
109
+ */
110
+ var GitHubApiError = class extends GitHubApiErrorBase {
111
+ get message() {
112
+ const status = this.statusCode ? ` (${this.statusCode})` : "";
113
+ return `GitHub API error during ${this.operation}${status}: ${this.reason}`;
114
+ }
115
+ /** Whether this error is a rate-limit response (403 or 429). */
116
+ get isRateLimited() {
117
+ return this.statusCode === 403 || this.statusCode === 429;
118
+ }
119
+ /** Whether this error is eligible for retry (server errors or rate limits). */
120
+ get isRetryable() {
121
+ return this.statusCode !== void 0 && (this.statusCode >= 500 || this.isRateLimited);
122
+ }
123
+ };
124
+ /**
125
+ * Base class for {@link MarkdownParseError}.
126
+ *
127
+ * @privateRemarks
128
+ * This export is required for api-extractor documentation generation.
129
+ * Effect's Data.TaggedError creates an anonymous base class that must be
130
+ * explicitly exported to avoid "forgotten export" warnings. Do not delete.
131
+ *
132
+ * @internal
133
+ */
134
+ const MarkdownParseErrorBase = Data.TaggedError("MarkdownParseError");
135
+ /**
136
+ * Markdown parsing failure.
137
+ *
138
+ * @remarks
139
+ * Raised when a markdown file cannot be parsed into an AST by the unified/remark
140
+ * pipeline. Carries optional source file location information (line, column)
141
+ * for diagnostic display.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * import { Effect } from "effect";
146
+ * import { MarkdownParseError } from "@savvy-web/changesets";
147
+ *
148
+ * declare const program: Effect.Effect<string, MarkdownParseError>;
149
+ *
150
+ * const handled = program.pipe(
151
+ * Effect.catchTag("MarkdownParseError", (err) => {
152
+ * console.error(err.message);
153
+ * return Effect.succeed("");
154
+ * }),
155
+ * );
156
+ * ```
157
+ *
158
+ * @see {@link MarkdownService} for the Effect service that may produce this error
159
+ *
160
+ * @public
161
+ */
162
+ var MarkdownParseError = class extends MarkdownParseErrorBase {
163
+ get message() {
164
+ const loc = this.line ? `:${this.line}${this.column ? `:${this.column}` : ""}` : "";
165
+ return `${this.source ? `${this.source}${loc}: ` : ""}Markdown parse error: ${this.reason}`;
166
+ }
167
+ };
168
+ /**
169
+ * Base class for {@link ConfigurationError}.
170
+ *
171
+ * @privateRemarks
172
+ * This export is required for api-extractor documentation generation.
173
+ * Effect's Data.TaggedError creates an anonymous base class that must be
174
+ * explicitly exported to avoid "forgotten export" warnings. Do not delete.
175
+ *
176
+ * @internal
177
+ */
178
+ const ConfigurationErrorBase = Data.TaggedError("ConfigurationError");
179
+ /**
180
+ * Invalid or missing configuration.
181
+ *
182
+ * @remarks
183
+ * Raised when the changeset configuration (typically from `.changeset/config.json`)
184
+ * is missing required fields, has invalid values, or cannot be parsed. The `field`
185
+ * property identifies which configuration field is problematic, and `reason`
186
+ * provides an actionable message.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * import { Effect } from "effect";
191
+ * import { ConfigurationError, validateChangesetOptions } from "@savvy-web/changesets";
192
+ *
193
+ * const program = validateChangesetOptions({ repo: "invalid" }).pipe(
194
+ * Effect.catchTag("ConfigurationError", (err) => {
195
+ * console.error(`Field "${err.field}": ${err.reason}`);
196
+ * return Effect.fail(err);
197
+ * }),
198
+ * );
199
+ * ```
200
+ *
201
+ * @see {@link ChangesetOptionsSchema} for the expected configuration shape
202
+ * @see {@link validateChangesetOptions} for the validation function that produces this error
203
+ *
204
+ * @public
205
+ */
206
+ var ConfigurationError = class extends ConfigurationErrorBase {
207
+ get message() {
208
+ return `Configuration error (${this.field}): ${this.reason}`;
209
+ }
210
+ };
211
+ /**
212
+ * Base class for {@link VersionFileError}.
213
+ *
214
+ * @privateRemarks
215
+ * This export is required for api-extractor documentation generation.
216
+ * Effect's Data.TaggedError creates an anonymous base class that must be
217
+ * explicitly exported to avoid "forgotten export" warnings. Do not delete.
218
+ *
219
+ * @internal
220
+ */
221
+ const VersionFileErrorBase = Data.TaggedError("VersionFileError");
222
+ /**
223
+ * Version file update failure.
224
+ *
225
+ * @remarks
226
+ * Raised when a JSON file targeted by the `versionFiles` configuration option
227
+ * cannot be read, parsed, or updated at the specified JSONPath. Common causes
228
+ * include missing files, invalid JSON, or JSONPath expressions that do not
229
+ * match any field in the target file.
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * import { Effect } from "effect";
234
+ * import { VersionFileError } from "@savvy-web/changesets";
235
+ *
236
+ * declare const program: Effect.Effect<void, VersionFileError>;
237
+ *
238
+ * const handled = program.pipe(
239
+ * Effect.catchTag("VersionFileError", (err) => {
240
+ * console.error(`Failed to update ${err.filePath}: ${err.reason}`);
241
+ * if (err.jsonPath) {
242
+ * console.error(` at JSONPath: ${err.jsonPath}`);
243
+ * }
244
+ * return Effect.void;
245
+ * }),
246
+ * );
247
+ * ```
248
+ *
249
+ * @see {@link VersionFilesSchema} for the configuration that drives version file updates
250
+ * @see {@link JsonPathSchema} for JSONPath expression validation
251
+ *
252
+ * @public
253
+ */
254
+ var VersionFileError = class extends VersionFileErrorBase {
255
+ get message() {
256
+ const path = this.jsonPath ? ` at ${this.jsonPath}` : "";
257
+ return `Version file error (${this.filePath}${path}): ${this.reason}`;
258
+ }
259
+ };
260
+ /**
261
+ * Base class for {@link GitError}.
262
+ *
263
+ * @privateRemarks
264
+ * Effect's `Data.TaggedError` creates an anonymous base class that
265
+ * api-extractor cannot follow without an explicit export.
266
+ *
267
+ * @internal
268
+ */
269
+ const GitErrorBase = Data.TaggedError("GitError");
270
+ /**
271
+ * Git command failure.
272
+ *
273
+ * @remarks
274
+ * Raised by services that shell out to `git` — `BranchAnalyzer` is the
275
+ * canonical consumer. Captures the failing command, the working directory
276
+ * it was invoked in, and the underlying reason (often the captured stderr
277
+ * from the child process) so callers can produce actionable diagnostics.
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * import { Effect } from "effect";
282
+ * import { GitError } from "@savvy-web/changesets";
283
+ *
284
+ * declare const program: Effect.Effect<void, GitError>;
285
+ *
286
+ * const handled = program.pipe(
287
+ * Effect.catchTag("GitError", (err) =>
288
+ * Effect.logError(`git failed in ${err.cwd}: ${err.command}\n${err.reason}`)
289
+ * ),
290
+ * );
291
+ * ```
292
+ *
293
+ * @see {@link BranchAnalyzer} which produces these errors when computing
294
+ * merge bases or running `git diff`
295
+ *
296
+ * @public
297
+ */
298
+ var GitError = class extends GitErrorBase {
299
+ get message() {
300
+ return `git command failed in ${this.cwd}: ${this.command}\n${this.reason}`;
301
+ }
302
+ };
303
+
304
+ //#endregion
305
+ export { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, VersionFileError, VersionFileErrorBase };
@@ -0,0 +1,146 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { Categories } from "./api/categories.js";
3
+ import { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, VersionFileError, VersionFileErrorBase } from "./errors.js";
4
+ import { JsonPathSchema, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, VersionFileConfigSchema, VersionFilesSchema } from "./schemas/version-files.js";
5
+ import { GlobSchema, PackageScopeSchema, PackagesRecordSchema } from "./schemas/package-scope.js";
6
+ import { ChangesetOptionsSchema, RepoSchema } from "./schemas/options.js";
7
+ import { GitHubLive, GitHubService, GitHubServiceBase, makeGitHubTest } from "./services/github.js";
8
+ import { MarkdownLive, MarkdownService, MarkdownServiceBase } from "./services/markdown.js";
9
+ import { NonEmptyString, PositiveInteger } from "./schemas/primitives.js";
10
+ import { DependencyActionSchema, DependencyTableRowSchema, DependencyTableSchema, DependencyTableTypeSchema, VersionOrEmptySchema } from "./schemas/dependency-table.js";
11
+ import { serializeDependencyTableToMarkdown } from "./utils/dependency-table.js";
12
+ import { GitHubInfoSchema, IssueNumberSchema, UrlOrMarkdownLinkSchema, UsernameSchema } from "./schemas/github.js";
13
+ import changelogFunctions from "./changelog/index.js";
14
+ import { Changelog } from "./api/changelog.js";
15
+ import { DependencyTable } from "./api/dependency-table.js";
16
+ import { ContentStructureRule } from "./remark/rules/content-structure.js";
17
+ import { HeadingHierarchyRule } from "./remark/rules/heading-hierarchy.js";
18
+ import { RequiredSectionsRule } from "./remark/rules/required-sections.js";
19
+ import { UncategorizedContentRule } from "./remark/rules/uncategorized-content.js";
20
+ import { ChangesetLinter } from "./api/linter.js";
21
+ import { ContributorFootnotesPlugin } from "./remark/plugins/contributor-footnotes.js";
22
+ import { DeduplicateItemsPlugin } from "./remark/plugins/deduplicate-items.js";
23
+ import { IssueLinkRefsPlugin } from "./remark/plugins/issue-link-refs.js";
24
+ import { MergeSectionsPlugin } from "./remark/plugins/merge-sections.js";
25
+ import { NormalizeFormatPlugin } from "./remark/plugins/normalize-format.js";
26
+ import { ReorderSectionsPlugin } from "./remark/plugins/reorder-sections.js";
27
+ import { ChangelogTransformer } from "./api/transformer.js";
28
+ import { ConfigInspector, ConfigInspectorBase, ConfigInspectorLive, makeConfigInspectorTest } from "./services/config-inspector.js";
29
+ import { BranchAnalyzer, BranchAnalyzerBase, BranchAnalyzerLive, makeBranchAnalyzerTest } from "./services/branch-analyzer.js";
30
+ import { ChangelogService, ChangelogServiceBase } from "./services/changelog.js";
31
+ import { WorkspaceSnapshotReader, WorkspaceSnapshotReaderBase, WorkspaceSnapshotReaderLive } from "./services/workspace-snapshot.js";
32
+ import { SectionCategorySchema } from "./categories/types.js";
33
+ import { CommitHashSchema, VersionTypeSchema } from "./schemas/git.js";
34
+ import { ChangesetSchema, ChangesetSummarySchema, DependencyTypeSchema, DependencyUpdateSchema } from "./schemas/changeset.js";
35
+ import { computeWorkspaceDependencyDiffs } from "./utils/dep-diff.js";
36
+ import { listPublishablePackageNames } from "./utils/publishability.js";
37
+ import { VersionFiles } from "./utils/version-files.js";
38
+ import { gitMergeBase, snapshotFromWorktree } from "./utils/worktree-snapshot.js";
39
+ import { ContentStructureRule as ContentStructureRule$1 } from "./markdownlint/rules/content-structure.js";
40
+ import { DependencyTableFormatRule } from "./markdownlint/rules/dependency-table-format.js";
41
+ import { HeadingHierarchyRule as HeadingHierarchyRule$1 } from "./markdownlint/rules/heading-hierarchy.js";
42
+ import { RequiredSectionsRule as RequiredSectionsRule$1 } from "./markdownlint/rules/required-sections.js";
43
+ import { UncategorizedContentRule as UncategorizedContentRule$1 } from "./markdownlint/rules/uncategorized-content.js";
44
+ import SilkChangesetsRules from "./markdownlint/index.js";
45
+ import { AggregateDependencyTablesPlugin } from "./remark/plugins/aggregate-dependency-tables.js";
46
+ import { DependencyTableFormatRule as DependencyTableFormatRule$1 } from "./remark/rules/dependency-table-format.js";
47
+ import { SilkChangesetPreset, SilkChangesetTransformPreset } from "./remark/presets.js";
48
+
49
+ //#region src/changesets/index.ts
50
+ var changesets_exports = /* @__PURE__ */ __exportAll({
51
+ AggregateDependencyTablesPlugin: () => AggregateDependencyTablesPlugin,
52
+ BranchAnalyzer: () => BranchAnalyzer,
53
+ BranchAnalyzerBase: () => BranchAnalyzerBase,
54
+ BranchAnalyzerLive: () => BranchAnalyzerLive,
55
+ Categories: () => Categories,
56
+ Changelog: () => Changelog,
57
+ ChangelogService: () => ChangelogService,
58
+ ChangelogServiceBase: () => ChangelogServiceBase,
59
+ ChangelogTransformer: () => ChangelogTransformer,
60
+ ChangesetLinter: () => ChangesetLinter,
61
+ ChangesetOptionsSchema: () => ChangesetOptionsSchema,
62
+ ChangesetSchema: () => ChangesetSchema,
63
+ ChangesetSummarySchema: () => ChangesetSummarySchema,
64
+ ChangesetValidationError: () => ChangesetValidationError,
65
+ ChangesetValidationErrorBase: () => ChangesetValidationErrorBase,
66
+ CommitHashSchema: () => CommitHashSchema,
67
+ ConfigInspector: () => ConfigInspector,
68
+ ConfigInspectorBase: () => ConfigInspectorBase,
69
+ ConfigInspectorLive: () => ConfigInspectorLive,
70
+ ConfigurationError: () => ConfigurationError,
71
+ ConfigurationErrorBase: () => ConfigurationErrorBase,
72
+ ContentStructureRule: () => ContentStructureRule,
73
+ ContributorFootnotesPlugin: () => ContributorFootnotesPlugin,
74
+ DeduplicateItemsPlugin: () => DeduplicateItemsPlugin,
75
+ DependencyActionSchema: () => DependencyActionSchema,
76
+ DependencyTable: () => DependencyTable,
77
+ DependencyTableFormatRule: () => DependencyTableFormatRule$1,
78
+ DependencyTableRowSchema: () => DependencyTableRowSchema,
79
+ DependencyTableSchema: () => DependencyTableSchema,
80
+ DependencyTableTypeSchema: () => DependencyTableTypeSchema,
81
+ DependencyTypeSchema: () => DependencyTypeSchema,
82
+ DependencyUpdateSchema: () => DependencyUpdateSchema,
83
+ GitError: () => GitError,
84
+ GitErrorBase: () => GitErrorBase,
85
+ GitHubApiError: () => GitHubApiError,
86
+ GitHubApiErrorBase: () => GitHubApiErrorBase,
87
+ GitHubInfoSchema: () => GitHubInfoSchema,
88
+ GitHubLive: () => GitHubLive,
89
+ GitHubService: () => GitHubService,
90
+ GitHubServiceBase: () => GitHubServiceBase,
91
+ GlobSchema: () => GlobSchema,
92
+ HeadingHierarchyRule: () => HeadingHierarchyRule,
93
+ IssueLinkRefsPlugin: () => IssueLinkRefsPlugin,
94
+ IssueNumberSchema: () => IssueNumberSchema,
95
+ JsonPathSchema: () => JsonPathSchema,
96
+ LegacyVersionFileConfigSchema: () => LegacyVersionFileConfigSchema,
97
+ LegacyVersionFilesSchema: () => LegacyVersionFilesSchema,
98
+ MarkdownLive: () => MarkdownLive,
99
+ MarkdownParseError: () => MarkdownParseError,
100
+ MarkdownParseErrorBase: () => MarkdownParseErrorBase,
101
+ MarkdownService: () => MarkdownService,
102
+ MarkdownServiceBase: () => MarkdownServiceBase,
103
+ MarkdownlintContentStructureRule: () => ContentStructureRule$1,
104
+ MarkdownlintDependencyTableFormatRule: () => DependencyTableFormatRule,
105
+ MarkdownlintHeadingHierarchyRule: () => HeadingHierarchyRule$1,
106
+ MarkdownlintRequiredSectionsRule: () => RequiredSectionsRule$1,
107
+ MarkdownlintUncategorizedContentRule: () => UncategorizedContentRule$1,
108
+ MergeSectionsPlugin: () => MergeSectionsPlugin,
109
+ NonEmptyString: () => NonEmptyString,
110
+ NormalizeFormatPlugin: () => NormalizeFormatPlugin,
111
+ PackageScopeSchema: () => PackageScopeSchema,
112
+ PackagesRecordSchema: () => PackagesRecordSchema,
113
+ PositiveInteger: () => PositiveInteger,
114
+ ReorderSectionsPlugin: () => ReorderSectionsPlugin,
115
+ RepoSchema: () => RepoSchema,
116
+ RequiredSectionsRule: () => RequiredSectionsRule,
117
+ SectionCategorySchema: () => SectionCategorySchema,
118
+ SilkChangesetPreset: () => SilkChangesetPreset,
119
+ SilkChangesetTransformPreset: () => SilkChangesetTransformPreset,
120
+ SilkChangesetsRules: () => SilkChangesetsRules,
121
+ UncategorizedContentRule: () => UncategorizedContentRule,
122
+ UrlOrMarkdownLinkSchema: () => UrlOrMarkdownLinkSchema,
123
+ UsernameSchema: () => UsernameSchema,
124
+ VersionFileConfigSchema: () => VersionFileConfigSchema,
125
+ VersionFileError: () => VersionFileError,
126
+ VersionFileErrorBase: () => VersionFileErrorBase,
127
+ VersionFiles: () => VersionFiles,
128
+ VersionFilesSchema: () => VersionFilesSchema,
129
+ VersionOrEmptySchema: () => VersionOrEmptySchema,
130
+ VersionTypeSchema: () => VersionTypeSchema,
131
+ WorkspaceSnapshotReader: () => WorkspaceSnapshotReader,
132
+ WorkspaceSnapshotReaderBase: () => WorkspaceSnapshotReaderBase,
133
+ WorkspaceSnapshotReaderLive: () => WorkspaceSnapshotReaderLive,
134
+ changelogFunctions: () => changelogFunctions,
135
+ computeWorkspaceDependencyDiffs: () => computeWorkspaceDependencyDiffs,
136
+ gitMergeBase: () => gitMergeBase,
137
+ listPublishablePackageNames: () => listPublishablePackageNames,
138
+ makeBranchAnalyzerTest: () => makeBranchAnalyzerTest,
139
+ makeConfigInspectorTest: () => makeConfigInspectorTest,
140
+ makeGitHubTest: () => makeGitHubTest,
141
+ serializeDependencyTableToMarkdown: () => serializeDependencyTableToMarkdown,
142
+ snapshotFromWorktree: () => snapshotFromWorktree
143
+ });
144
+
145
+ //#endregion
146
+ export { changesets_exports };
@@ -0,0 +1,29 @@
1
+ import { ContentStructureRule } from "./rules/content-structure.js";
2
+ import { DependencyTableFormatRule } from "./rules/dependency-table-format.js";
3
+ import { HeadingHierarchyRule } from "./rules/heading-hierarchy.js";
4
+ import { RequiredSectionsRule } from "./rules/required-sections.js";
5
+ import { UncategorizedContentRule } from "./rules/uncategorized-content.js";
6
+
7
+ //#region src/changesets/markdownlint/index.ts
8
+ /**
9
+ * All changeset rules as an array for markdownlint-cli2 `customRules` config.
10
+ *
11
+ * @example
12
+ * ```json
13
+ * {
14
+ * "customRules": ["@savvy-web/changesets/markdownlint"]
15
+ * }
16
+ * ```
17
+ *
18
+ * @public
19
+ */
20
+ const SilkChangesetsRules = [
21
+ HeadingHierarchyRule,
22
+ RequiredSectionsRule,
23
+ ContentStructureRule,
24
+ UncategorizedContentRule,
25
+ DependencyTableFormatRule
26
+ ];
27
+
28
+ //#endregion
29
+ export { SilkChangesetsRules as default };
@@ -0,0 +1,98 @@
1
+ import { RULE_DOCS } from "../../constants.js";
2
+ import { getHeadingLevel } from "./utils.js";
3
+
4
+ //#region src/changesets/markdownlint/rules/content-structure.ts
5
+ /**
6
+ * Check whether any non-blank tokens exist between two indices in the token stream.
7
+ *
8
+ * @param tokens - The full micromark token array
9
+ * @param currentIdx - Start index (exclusive)
10
+ * @param nextIdx - End index (exclusive)
11
+ * @returns `true` when at least one non-lineEnding token exists in the range
12
+ *
13
+ * @internal
14
+ */
15
+ function hasContentBetween(tokens, currentIdx, nextIdx) {
16
+ for (let i = currentIdx + 1; i < nextIdx; i++) {
17
+ const token = tokens[i];
18
+ if (token.type !== "lineEnding" && token.type !== "lineEndingBlank") return true;
19
+ }
20
+ return false;
21
+ }
22
+ /**
23
+ * markdownlint rule: `changeset-content-structure` (CSH003).
24
+ *
25
+ * Validates content quality inside changeset markdown files by inspecting
26
+ * micromark tokens for three categories of structural problems:
27
+ *
28
+ * 1. **Empty sections** -- an `atxHeading` (h2) followed immediately by another
29
+ * h2 or the end of the token stream with no intervening content tokens.
30
+ * 2. **Code blocks without a language identifier** -- a `codeFenced` token whose
31
+ * opening fence child lacks a `codeFencedFenceInfo` token.
32
+ * 3. **Empty list items** -- a `listItemPrefix` token with no subsequent
33
+ * `content` token before the next prefix or end of list.
34
+ *
35
+ * @remarks
36
+ * This rule mirrors the remark-lint rule `remarkLintContentStructure` but uses
37
+ * markdownlint's micromark token API so it can run inside markdownlint-cli2 and
38
+ * the VS Code markdownlint extension.
39
+ *
40
+ * @example
41
+ * ```json
42
+ * {
43
+ * "changeset-content-structure": true
44
+ * }
45
+ * ```
46
+ *
47
+ * @see {@link https://github.com/savvy-web/changesets/blob/main/docs/rules/CSH003.md | CSH003 rule documentation}
48
+ * @see `src/remark/rules/content-structure.ts` for the corresponding remark-lint rule
49
+ *
50
+ * @public
51
+ */
52
+ const ContentStructureRule = {
53
+ names: ["changeset-content-structure", "CSH003"],
54
+ description: "Sections must have content, code blocks need languages, list items need text",
55
+ tags: ["changeset"],
56
+ parser: "micromark",
57
+ function: function CSH003(params, onError) {
58
+ const tokens = params.parsers.micromark.tokens;
59
+ const h2Indices = [];
60
+ for (let i = 0; i < tokens.length; i++) if (tokens[i].type === "atxHeading" && getHeadingLevel(tokens[i]) === 2) h2Indices.push(i);
61
+ for (let i = 0; i < h2Indices.length; i++) {
62
+ const currentIdx = h2Indices[i];
63
+ if (!hasContentBetween(tokens, currentIdx, i + 1 < h2Indices.length ? h2Indices[i + 1] : tokens.length)) onError({
64
+ lineNumber: tokens[currentIdx].startLine,
65
+ detail: `Empty section: heading has no content before the next section or end of file. Add a list of changes (e.g., "- Added feature X") under this heading, or remove the empty heading. See: ${RULE_DOCS.CSH003}`
66
+ });
67
+ }
68
+ for (const token of tokens) {
69
+ if (token.type !== "codeFenced") continue;
70
+ if (!(token.children.find((c) => c.type === "codeFencedFence")?.children.some((c) => c.type === "codeFencedFenceInfo") ?? false)) onError({
71
+ lineNumber: token.startLine,
72
+ detail: `Code block is missing a language identifier. Add a language after the opening fence (e.g., \`\`\`ts, \`\`\`json, \`\`\`bash). See: ${RULE_DOCS.CSH003}`
73
+ });
74
+ }
75
+ for (const token of tokens) {
76
+ if (token.type !== "listOrdered" && token.type !== "listUnordered") continue;
77
+ const children = token.children;
78
+ for (let i = 0; i < children.length; i++) {
79
+ if (children[i].type !== "listItemPrefix") continue;
80
+ let hasContent = false;
81
+ for (let j = i + 1; j < children.length; j++) {
82
+ if (children[j].type === "listItemPrefix") break;
83
+ if (children[j].type === "content") {
84
+ hasContent = true;
85
+ break;
86
+ }
87
+ }
88
+ if (!hasContent) onError({
89
+ lineNumber: children[i].startLine,
90
+ detail: `Empty list item. Each list item must contain descriptive text (e.g., "- Fixed login timeout issue"). See: ${RULE_DOCS.CSH003}`
91
+ });
92
+ }
93
+ }
94
+ }
95
+ };
96
+
97
+ //#endregion
98
+ export { ContentStructureRule };