mdcontext 0.0.1 → 0.2.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.
- package/.changeset/README.md +28 -0
- package/.changeset/config.json +11 -0
- package/.claude/settings.local.json +25 -0
- package/.github/workflows/ci.yml +83 -0
- package/.github/workflows/claude-code-review.yml +44 -0
- package/.github/workflows/claude.yml +85 -0
- package/.github/workflows/release.yml +113 -0
- package/.tldrignore +112 -0
- package/BACKLOG.md +338 -0
- package/CONTRIBUTING.md +186 -0
- package/NOTES/NOTES +44 -0
- package/README.md +434 -11
- package/biome.json +36 -0
- package/cspell.config.yaml +14 -0
- package/dist/chunk-23UPXDNL.js +3044 -0
- package/dist/chunk-2W7MO2DL.js +1366 -0
- package/dist/chunk-3NUAZGMA.js +1689 -0
- package/dist/chunk-7TOWB2XB.js +366 -0
- package/dist/chunk-7XOTOADQ.js +3065 -0
- package/dist/chunk-AH2PDM2K.js +3042 -0
- package/dist/chunk-BNXWSZ63.js +3742 -0
- package/dist/chunk-BTL5DJVU.js +3222 -0
- package/dist/chunk-HDHYG7E4.js +104 -0
- package/dist/chunk-HLR4KZBP.js +3234 -0
- package/dist/chunk-IP3FRFEB.js +1045 -0
- package/dist/chunk-KHU56VDO.js +3042 -0
- package/dist/chunk-KRYIFLQR.js +88 -0
- package/dist/chunk-LBSDNLEM.js +287 -0
- package/dist/chunk-MNTQ7HCP.js +2643 -0
- package/dist/chunk-MUJELQQ6.js +1387 -0
- package/dist/chunk-MXJGMSLV.js +2199 -0
- package/dist/chunk-N6QJGC3Z.js +2636 -0
- package/dist/chunk-OBELGBPM.js +1713 -0
- package/dist/chunk-OT7R5XTA.js +3192 -0
- package/dist/chunk-P7X4RA2T.js +106 -0
- package/dist/chunk-PIDUQNC2.js +3185 -0
- package/dist/chunk-POGCDIH4.js +3187 -0
- package/dist/chunk-PSIEOQGZ.js +3043 -0
- package/dist/chunk-PVRT3IHA.js +3238 -0
- package/dist/chunk-QNN4TT23.js +1430 -0
- package/dist/chunk-RE3R45RJ.js +3042 -0
- package/dist/chunk-S7E6TFX6.js +803 -0
- package/dist/chunk-SG6GLU4U.js +1378 -0
- package/dist/chunk-SJCDV2ST.js +274 -0
- package/dist/chunk-SYE5XLF3.js +104 -0
- package/dist/chunk-T5VLYBZD.js +103 -0
- package/dist/chunk-TOQB7VWU.js +3238 -0
- package/dist/chunk-VFNMZ4ZQ.js +3228 -0
- package/dist/chunk-VVTGZNBT.js +1629 -0
- package/dist/chunk-W7Q4RFEV.js +104 -0
- package/dist/chunk-XTYYVRLO.js +3190 -0
- package/dist/chunk-Y6MDYVJD.js +3063 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +5458 -0
- package/dist/index.d.ts +653 -0
- package/dist/index.js +79 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +472 -0
- package/dist/schema-BAWSG7KY.js +22 -0
- package/dist/schema-E3QUPL26.js +20 -0
- package/dist/schema-EHL7WUT6.js +20 -0
- package/docs/019-USAGE.md +625 -0
- package/docs/020-current-implementation.md +364 -0
- package/docs/021-DOGFOODING-FINDINGS.md +175 -0
- package/docs/BACKLOG.md +80 -0
- package/docs/CONFIG.md +1123 -0
- package/docs/DESIGN.md +439 -0
- package/docs/ERRORS.md +383 -0
- package/docs/PROJECT.md +88 -0
- package/docs/ROADMAP.md +407 -0
- package/docs/summarization.md +320 -0
- package/docs/test-links.md +9 -0
- package/justfile +40 -0
- package/package.json +74 -9
- package/pnpm-workspace.yaml +5 -0
- package/research/INDEX.md +315 -0
- package/research/code-review/README.md +90 -0
- package/research/code-review/cli-error-handling-review.md +979 -0
- package/research/code-review/code-review-validation-report.md +464 -0
- package/research/code-review/main-ts-review.md +1128 -0
- package/research/config-analysis/01-current-implementation.md +470 -0
- package/research/config-analysis/02-strategy-recommendation.md +428 -0
- package/research/config-analysis/03-task-candidates.md +715 -0
- package/research/config-analysis/033-research-configuration-management.md +828 -0
- package/research/config-analysis/034-research-effect-cli-config.md +1504 -0
- package/research/config-analysis/04-consolidated-task-candidates.md +277 -0
- package/research/config-docs/SUMMARY.md +357 -0
- package/research/config-docs/TEST-RESULTS.md +776 -0
- package/research/config-docs/TODO.md +542 -0
- package/research/config-docs/analysis.md +744 -0
- package/research/config-docs/fix-validation.md +502 -0
- package/research/config-docs/help-audit.md +264 -0
- package/research/config-docs/help-system-analysis.md +890 -0
- package/research/dogfood/consolidated-tool-evaluation.md +373 -0
- package/research/dogfood/strategy-a/a-synthesis.md +184 -0
- package/research/dogfood/strategy-a/a1-docs.md +226 -0
- package/research/dogfood/strategy-a/a2-amorphic.md +156 -0
- package/research/dogfood/strategy-a/a3-llm.md +164 -0
- package/research/dogfood/strategy-b/b-synthesis.md +228 -0
- package/research/dogfood/strategy-b/b1-architecture.md +207 -0
- package/research/dogfood/strategy-b/b2-gaps.md +258 -0
- package/research/dogfood/strategy-b/b3-workflows.md +250 -0
- package/research/dogfood/strategy-c/c-synthesis.md +451 -0
- package/research/dogfood/strategy-c/c1-explorer.md +192 -0
- package/research/dogfood/strategy-c/c2-diver-memory.md +145 -0
- package/research/dogfood/strategy-c/c3-diver-control.md +148 -0
- package/research/dogfood/strategy-c/c4-diver-failure.md +151 -0
- package/research/dogfood/strategy-c/c5-diver-execution.md +221 -0
- package/research/dogfood/strategy-c/c6-diver-org.md +221 -0
- package/research/effect-cli-error-handling.md +845 -0
- package/research/effect-errors-as-values.md +943 -0
- package/research/errors-task-analysis/00-consolidated-tasks.md +207 -0
- package/research/errors-task-analysis/cli-commands-analysis.md +909 -0
- package/research/errors-task-analysis/embeddings-analysis.md +709 -0
- package/research/errors-task-analysis/index-search-analysis.md +812 -0
- package/research/frontmatter/COMMENTS-ARE-SKIPPED.md +149 -0
- package/research/frontmatter/LLM-CODE-NAVIGATION.md +276 -0
- package/research/issue-review.md +603 -0
- package/research/llm-summarization/agent-cli-tools-2026.md +1082 -0
- package/research/llm-summarization/alternative-providers-2026.md +1428 -0
- package/research/llm-summarization/anthropic-2026.md +367 -0
- package/research/llm-summarization/claude-cli-integration.md +1706 -0
- package/research/llm-summarization/cli-integration-patterns.md +3155 -0
- package/research/llm-summarization/openai-2026.md +473 -0
- package/research/llm-summarization/openai-compatible-providers-2026.md +1022 -0
- package/research/llm-summarization/opencode-cli-integration.md +1552 -0
- package/research/llm-summarization/prompt-engineering-2026.md +1426 -0
- package/research/llm-summarization/prototype-results.md +56 -0
- package/research/llm-summarization/provider-switching-patterns-2026.md +2153 -0
- package/research/llm-summarization/typescript-llm-libraries-2026.md +2436 -0
- package/research/mdcontext-error-analysis.md +521 -0
- package/research/mdcontext-pudding/00-EXECUTIVE-SUMMARY.md +282 -0
- package/research/mdcontext-pudding/01-index-embed.md +956 -0
- package/research/mdcontext-pudding/02-search-COMMANDS.md +142 -0
- package/research/mdcontext-pudding/02-search-SUMMARY.md +146 -0
- package/research/mdcontext-pudding/02-search.md +970 -0
- package/research/mdcontext-pudding/03-context.md +779 -0
- package/research/mdcontext-pudding/04-navigation-and-analytics.md +803 -0
- package/research/mdcontext-pudding/04-tree.md +704 -0
- package/research/mdcontext-pudding/05-config.md +1038 -0
- package/research/mdcontext-pudding/06-links-summary.txt +87 -0
- package/research/mdcontext-pudding/06-links.md +679 -0
- package/research/mdcontext-pudding/07-stats.md +693 -0
- package/research/mdcontext-pudding/BUG-FIX-PLAN.md +388 -0
- package/research/mdcontext-pudding/P0-BUG-VALIDATION.md +167 -0
- package/research/mdcontext-pudding/README.md +168 -0
- package/research/mdcontext-pudding/TESTING-SUMMARY.md +128 -0
- package/research/npm_publish/011-npm-workflow-research-agent2.md +792 -0
- package/research/npm_publish/012-npm-workflow-research-agent1.md +530 -0
- package/research/npm_publish/013-npm-workflow-research-agent3.md +722 -0
- package/research/npm_publish/014-npm-workflow-synthesis.md +556 -0
- package/research/npm_publish/031-npm-workflow-task-analysis.md +134 -0
- package/research/research-quality-review.md +834 -0
- package/research/semantic-search/002-research-embedding-models.md +490 -0
- package/research/semantic-search/003-research-rag-alternatives.md +523 -0
- package/research/semantic-search/004-research-vector-search.md +841 -0
- package/research/semantic-search/032-research-semantic-search.md +427 -0
- package/research/semantic-search/embedding-text-analysis.md +156 -0
- package/research/semantic-search/multi-word-failure-reproduction.md +171 -0
- package/research/semantic-search/query-processing-analysis.md +207 -0
- package/research/semantic-search/root-cause-and-solution.md +114 -0
- package/research/semantic-search/threshold-validation-report.md +69 -0
- package/research/semantic-search/vector-search-analysis.md +63 -0
- package/research/task-management-2026/00-synthesis-recommendations.md +295 -0
- package/research/task-management-2026/01-ai-workflow-tools.md +416 -0
- package/research/task-management-2026/02-agent-framework-patterns.md +476 -0
- package/research/task-management-2026/03-lightweight-file-based.md +567 -0
- package/research/task-management-2026/04-established-tools-ai-features.md +541 -0
- package/research/task-management-2026/linear/01-core-features-workflow.md +771 -0
- package/research/task-management-2026/linear/02-api-integrations.md +930 -0
- package/research/task-management-2026/linear/03-ai-features.md +368 -0
- package/research/task-management-2026/linear/04-pricing-setup.md +205 -0
- package/research/task-management-2026/linear/05-usage-patterns-best-practices.md +605 -0
- package/research/test-path-issues.md +276 -0
- package/review/ALP-76/1-error-type-design.md +962 -0
- package/review/ALP-76/2-error-handling-patterns.md +906 -0
- package/review/ALP-76/3-error-presentation.md +624 -0
- package/review/ALP-76/4-test-coverage.md +625 -0
- package/review/ALP-76/5-migration-completeness.md +440 -0
- package/review/ALP-76/6-effect-best-practices.md +755 -0
- package/scripts/apply-branch-protection.sh +47 -0
- package/scripts/branch-protection-templates.json +79 -0
- package/scripts/prototype-summarization.ts +346 -0
- package/scripts/rebuild-hnswlib.js +58 -0
- package/scripts/setup-branch-protection.sh +64 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/active-provider.json +7 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.json +541 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/bm25.meta.json +5 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/config.json +8 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/documents.json +60 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/links.json +13 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/.mdcontext/indexes/sections.json +1197 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/configuration-management.md +99 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/distributed-systems.md +92 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/error-handling.md +78 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/failure-automation.md +55 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/job-context.md +69 -0
- package/src/__tests__/fixtures/semantic-search/multi-word-corpus/process-orchestration.md +99 -0
- package/src/cli/argv-preprocessor.test.ts +210 -0
- package/src/cli/argv-preprocessor.ts +202 -0
- package/src/cli/cli.test.ts +627 -0
- package/src/cli/commands/backlinks.ts +54 -0
- package/src/cli/commands/config-cmd.ts +642 -0
- package/src/cli/commands/context.ts +285 -0
- package/src/cli/commands/duplicates.ts +122 -0
- package/src/cli/commands/embeddings.ts +529 -0
- package/src/cli/commands/index-cmd.ts +480 -0
- package/src/cli/commands/index.ts +16 -0
- package/src/cli/commands/links.ts +52 -0
- package/src/cli/commands/search.ts +1281 -0
- package/src/cli/commands/stats.ts +149 -0
- package/src/cli/commands/tree.ts +128 -0
- package/src/cli/config-layer.ts +176 -0
- package/src/cli/error-handler.test.ts +235 -0
- package/src/cli/error-handler.ts +655 -0
- package/src/cli/flag-schemas.ts +341 -0
- package/src/cli/help.ts +588 -0
- package/src/cli/index.ts +9 -0
- package/src/cli/main.ts +435 -0
- package/src/cli/options.ts +41 -0
- package/src/cli/shared-error-handling.ts +199 -0
- package/src/cli/typo-suggester.test.ts +105 -0
- package/src/cli/typo-suggester.ts +130 -0
- package/src/cli/utils.ts +259 -0
- package/src/config/file-provider.test.ts +320 -0
- package/src/config/file-provider.ts +273 -0
- package/src/config/index.ts +72 -0
- package/src/config/integration.test.ts +667 -0
- package/src/config/precedence.test.ts +277 -0
- package/src/config/precedence.ts +451 -0
- package/src/config/schema.test.ts +414 -0
- package/src/config/schema.ts +603 -0
- package/src/config/service.test.ts +320 -0
- package/src/config/service.ts +243 -0
- package/src/config/testing.test.ts +264 -0
- package/src/config/testing.ts +110 -0
- package/src/core/index.ts +1 -0
- package/src/core/types.ts +113 -0
- package/src/duplicates/detector.test.ts +183 -0
- package/src/duplicates/detector.ts +414 -0
- package/src/duplicates/index.ts +18 -0
- package/src/embeddings/embedding-namespace.test.ts +300 -0
- package/src/embeddings/embedding-namespace.ts +947 -0
- package/src/embeddings/heading-boost.test.ts +222 -0
- package/src/embeddings/hnsw-build-options.test.ts +198 -0
- package/src/embeddings/hyde.test.ts +272 -0
- package/src/embeddings/hyde.ts +264 -0
- package/src/embeddings/index.ts +10 -0
- package/src/embeddings/openai-provider.ts +414 -0
- package/src/embeddings/pricing.json +22 -0
- package/src/embeddings/provider-constants.ts +204 -0
- package/src/embeddings/provider-errors.test.ts +967 -0
- package/src/embeddings/provider-errors.ts +565 -0
- package/src/embeddings/provider-factory.test.ts +240 -0
- package/src/embeddings/provider-factory.ts +225 -0
- package/src/embeddings/provider-integration.test.ts +788 -0
- package/src/embeddings/query-preprocessing.test.ts +187 -0
- package/src/embeddings/semantic-search-threshold.test.ts +508 -0
- package/src/embeddings/semantic-search.ts +1270 -0
- package/src/embeddings/types.ts +359 -0
- package/src/embeddings/vector-store.ts +708 -0
- package/src/embeddings/voyage-provider.ts +313 -0
- package/src/errors/errors.test.ts +845 -0
- package/src/errors/index.ts +533 -0
- package/src/index/ignore-patterns.test.ts +354 -0
- package/src/index/ignore-patterns.ts +305 -0
- package/src/index/index.ts +4 -0
- package/src/index/indexer.ts +684 -0
- package/src/index/storage.ts +260 -0
- package/src/index/types.ts +147 -0
- package/src/index/watcher.ts +189 -0
- package/src/index.ts +30 -0
- package/src/integration/search-keyword.test.ts +678 -0
- package/src/mcp/server.ts +612 -0
- package/src/parser/index.ts +1 -0
- package/src/parser/parser.test.ts +291 -0
- package/src/parser/parser.ts +394 -0
- package/src/parser/section-filter.test.ts +277 -0
- package/src/parser/section-filter.ts +392 -0
- package/src/search/__tests__/hybrid-search.test.ts +650 -0
- package/src/search/bm25-store.ts +366 -0
- package/src/search/cross-encoder.test.ts +253 -0
- package/src/search/cross-encoder.ts +406 -0
- package/src/search/fuzzy-search.test.ts +419 -0
- package/src/search/fuzzy-search.ts +273 -0
- package/src/search/hybrid-search.ts +448 -0
- package/src/search/path-matcher.test.ts +276 -0
- package/src/search/path-matcher.ts +33 -0
- package/src/search/query-parser.test.ts +260 -0
- package/src/search/query-parser.ts +319 -0
- package/src/search/searcher.test.ts +280 -0
- package/src/search/searcher.ts +724 -0
- package/src/search/wink-bm25.d.ts +30 -0
- package/src/summarization/cli-providers/claude.ts +202 -0
- package/src/summarization/cli-providers/detection.test.ts +273 -0
- package/src/summarization/cli-providers/detection.ts +118 -0
- package/src/summarization/cli-providers/index.ts +8 -0
- package/src/summarization/cost.test.ts +139 -0
- package/src/summarization/cost.ts +102 -0
- package/src/summarization/error-handler.test.ts +127 -0
- package/src/summarization/error-handler.ts +111 -0
- package/src/summarization/index.ts +102 -0
- package/src/summarization/pipeline.test.ts +498 -0
- package/src/summarization/pipeline.ts +231 -0
- package/src/summarization/prompts.test.ts +269 -0
- package/src/summarization/prompts.ts +133 -0
- package/src/summarization/provider-factory.test.ts +396 -0
- package/src/summarization/provider-factory.ts +178 -0
- package/src/summarization/types.ts +184 -0
- package/src/summarize/budget-bugs.test.ts +620 -0
- package/src/summarize/formatters.ts +419 -0
- package/src/summarize/index.ts +20 -0
- package/src/summarize/summarizer.test.ts +275 -0
- package/src/summarize/summarizer.ts +597 -0
- package/src/summarize/verify-bugs.test.ts +238 -0
- package/src/types/huggingface-transformers.d.ts +66 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/tokens.test.ts +142 -0
- package/src/utils/tokens.ts +186 -0
- package/tests/fixtures/cli/.mdcontext/active-provider.json +7 -0
- package/tests/fixtures/cli/.mdcontext/config.json +8 -0
- package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.bin +0 -0
- package/tests/fixtures/cli/.mdcontext/embeddings/openai_text-embedding-3-small_512/vectors.meta.bin +0 -0
- package/tests/fixtures/cli/.mdcontext/indexes/documents.json +33 -0
- package/tests/fixtures/cli/.mdcontext/indexes/links.json +12 -0
- package/tests/fixtures/cli/.mdcontext/indexes/sections.json +247 -0
- package/tests/fixtures/cli/README.md +9 -0
- package/tests/fixtures/cli/api-reference.md +11 -0
- package/tests/fixtures/cli/getting-started.md +11 -0
- package/tests/integration/embed-index.test.ts +712 -0
- package/tests/integration/search-context.test.ts +469 -0
- package/tests/integration/search-semantic.test.ts +522 -0
- package/tsconfig.json +26 -0
- package/vitest.config.ts +16 -0
- package/vitest.setup.ts +12 -0
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
# Modern npm Publishing Workflows: 2026 Best Practices
|
|
2
|
+
|
|
3
|
+
A comprehensive research document covering developer experience, automated changelogs, testing strategies, quality gates, and the Bun migration question for CLI tools.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
1. [Developer Experience (DX) Best Practices](#1-developer-experience-dx-best-practices)
|
|
10
|
+
2. [Changelog Generation and Versioning](#2-changelog-generation-and-versioning)
|
|
11
|
+
3. [Testing Before Publish](#3-testing-before-publish)
|
|
12
|
+
4. [Package Quality Checks](#4-package-quality-checks)
|
|
13
|
+
5. [Error Handling and Rollback](#5-error-handling-and-rollback)
|
|
14
|
+
6. [Bun Migration Analysis](#6-bun-migration-analysis)
|
|
15
|
+
7. [Recommendations for mdcontext](#7-recommendations-for-mdcontext)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 1. Developer Experience (DX) Best Practices
|
|
20
|
+
|
|
21
|
+
### Trusted Publishing with OIDC (Most Important 2025-2026 Feature)
|
|
22
|
+
|
|
23
|
+
As of July 2025, [npm trusted publishing with OIDC](https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/) is generally available. This is a game-changer for security and developer experience:
|
|
24
|
+
|
|
25
|
+
**Key Benefits:**
|
|
26
|
+
|
|
27
|
+
- **No more token management**: Eliminates storing, rotating, or accidentally exposing npm tokens
|
|
28
|
+
- **Short-lived credentials**: Each publish uses workflow-specific credentials that cannot be exfiltrated
|
|
29
|
+
- **Automatic provenance**: Provenance attestations are published by default (no `--provenance` flag needed)
|
|
30
|
+
- **Industry standard**: Implements OpenSSF trusted publishers specification (joining PyPI, RubyGems)
|
|
31
|
+
|
|
32
|
+
**Requirements:**
|
|
33
|
+
|
|
34
|
+
- npm CLI version 11.5.1 or later
|
|
35
|
+
- GitHub Actions with `id-token: write` permission
|
|
36
|
+
|
|
37
|
+
### Example Workflow with pnpm and OIDC
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
name: Publish Package
|
|
41
|
+
|
|
42
|
+
on:
|
|
43
|
+
release:
|
|
44
|
+
types: [created]
|
|
45
|
+
|
|
46
|
+
permissions:
|
|
47
|
+
contents: read
|
|
48
|
+
id-token: write # Required for OIDC trusted publishing
|
|
49
|
+
|
|
50
|
+
jobs:
|
|
51
|
+
publish:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
|
|
56
|
+
# IMPORTANT: pnpm setup MUST precede Node.js setup for caching
|
|
57
|
+
- uses: pnpm/action-setup@v4
|
|
58
|
+
with:
|
|
59
|
+
version: 10
|
|
60
|
+
|
|
61
|
+
- uses: actions/setup-node@v4
|
|
62
|
+
with:
|
|
63
|
+
node-version: "22"
|
|
64
|
+
cache: "pnpm"
|
|
65
|
+
registry-url: "https://registry.npmjs.org"
|
|
66
|
+
|
|
67
|
+
- run: pnpm install --frozen-lockfile
|
|
68
|
+
- run: pnpm build
|
|
69
|
+
- run: pnpm test
|
|
70
|
+
|
|
71
|
+
# Trusted publishing - no NPM_TOKEN needed!
|
|
72
|
+
- run: pnpm publish --no-git-checks
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Critical Notes:**
|
|
76
|
+
|
|
77
|
+
- The `--no-git-checks` flag bypasses pnpm's detached HEAD check in GitHub Actions
|
|
78
|
+
- pnpm setup must come BEFORE setup-node to enable `cache: 'pnpm'`
|
|
79
|
+
- Use `NODE_AUTH_TOKEN` (not `NPM_TOKEN`) if still using token-based auth
|
|
80
|
+
|
|
81
|
+
### Security Best Practices
|
|
82
|
+
|
|
83
|
+
Based on [Zach Leatherman's security recommendations](https://www.zachleat.com/web/npm-security):
|
|
84
|
+
|
|
85
|
+
1. **Two-Factor Authentication everywhere** - Both GitHub AND npm, for all maintainers
|
|
86
|
+
2. **Immutable Releases** - Enable at organization level on GitHub
|
|
87
|
+
3. **Reduce dependencies** - Every dependency inherits security risk
|
|
88
|
+
4. **pnpm 10.16+ delayed updates** - New setting for safer dependency updates
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 2. Changelog Generation and Versioning
|
|
93
|
+
|
|
94
|
+
### Tool Comparison
|
|
95
|
+
|
|
96
|
+
| Tool | Philosophy | Best For | Weekly Downloads |
|
|
97
|
+
| ------------------------------------------------------------------------------- | ---------------------- | -------------------------------- | ---------------- |
|
|
98
|
+
| [semantic-release](https://github.com/semantic-release/release-notes-generator) | Fully automated | Single packages, full automation | ~2M |
|
|
99
|
+
| [Changesets](https://github.com/changesets/changesets) | Human control | Monorepos, collaborative teams | ~800K |
|
|
100
|
+
| [release-it](https://github.com/release-it/release-it) | Flexible middle-ground | Customizable workflows | ~670K |
|
|
101
|
+
| [np](https://github.com/sindresorhus/np) | Interactive local | Single packages, manual control | ~400K |
|
|
102
|
+
|
|
103
|
+
### Semantic-Release
|
|
104
|
+
|
|
105
|
+
**Pros:**
|
|
106
|
+
|
|
107
|
+
- Zero human intervention once configured
|
|
108
|
+
- Strong Conventional Commits integration
|
|
109
|
+
- Extensive plugin ecosystem
|
|
110
|
+
|
|
111
|
+
**Cons:**
|
|
112
|
+
|
|
113
|
+
- Not built for monorepos (community plugins are outdated)
|
|
114
|
+
- Version coupling with deploys causes cleanup issues on failure
|
|
115
|
+
- Package.json version stays at `0.0.0` until build
|
|
116
|
+
|
|
117
|
+
### Changesets (Recommended for Most Projects)
|
|
118
|
+
|
|
119
|
+
**Workflow:**
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Developer creates changeset describing their change
|
|
123
|
+
pnpm changeset
|
|
124
|
+
|
|
125
|
+
# CI detects changesets and opens version PR
|
|
126
|
+
# After PR merge, packages are published
|
|
127
|
+
pnpm changeset version
|
|
128
|
+
pnpm changeset publish
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Pros:**
|
|
132
|
+
|
|
133
|
+
- Built for monorepos first
|
|
134
|
+
- Human-reviewable changelog entries
|
|
135
|
+
- Decouples versioning from deployment
|
|
136
|
+
- [pnpm integration](https://pnpm.io/next/using-changesets) is excellent
|
|
137
|
+
|
|
138
|
+
**Cons:**
|
|
139
|
+
|
|
140
|
+
- Requires package.json for version tracking (odd for non-JS packages)
|
|
141
|
+
- More manual than semantic-release
|
|
142
|
+
|
|
143
|
+
### GitHub Actions with Changesets
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
name: Release
|
|
147
|
+
|
|
148
|
+
on:
|
|
149
|
+
push:
|
|
150
|
+
branches: [main]
|
|
151
|
+
|
|
152
|
+
permissions:
|
|
153
|
+
contents: write
|
|
154
|
+
pull-requests: write
|
|
155
|
+
id-token: write
|
|
156
|
+
|
|
157
|
+
jobs:
|
|
158
|
+
release:
|
|
159
|
+
runs-on: ubuntu-latest
|
|
160
|
+
steps:
|
|
161
|
+
- uses: actions/checkout@v4
|
|
162
|
+
|
|
163
|
+
- uses: pnpm/action-setup@v4
|
|
164
|
+
with:
|
|
165
|
+
version: 10
|
|
166
|
+
|
|
167
|
+
- uses: actions/setup-node@v4
|
|
168
|
+
with:
|
|
169
|
+
node-version: "22"
|
|
170
|
+
cache: "pnpm"
|
|
171
|
+
registry-url: "https://registry.npmjs.org"
|
|
172
|
+
|
|
173
|
+
- run: pnpm install --frozen-lockfile
|
|
174
|
+
|
|
175
|
+
- name: Create Release Pull Request or Publish
|
|
176
|
+
uses: changesets/action@v1
|
|
177
|
+
with:
|
|
178
|
+
publish: pnpm changeset publish
|
|
179
|
+
env:
|
|
180
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### np (Interactive Local Publishing)
|
|
184
|
+
|
|
185
|
+
Best for maintainers who prefer local control:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Interactive UI for version selection and publishing
|
|
189
|
+
npx np
|
|
190
|
+
|
|
191
|
+
# Skip tests (use with caution)
|
|
192
|
+
npx np --yolo
|
|
193
|
+
|
|
194
|
+
# Preview without executing
|
|
195
|
+
npx np --preview
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Safety checks np performs:**
|
|
199
|
+
|
|
200
|
+
- Publishing from correct branch
|
|
201
|
+
- Clean working directory
|
|
202
|
+
- No unpulled remote changes
|
|
203
|
+
- Pre-release version warnings
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 3. Testing Before Publish
|
|
208
|
+
|
|
209
|
+
### Matrix Testing Strategy
|
|
210
|
+
|
|
211
|
+
Based on [GitHub Actions matrix best practices](https://codefresh.io/learn/github-actions/github-actions-matrix/):
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
name: CI
|
|
215
|
+
|
|
216
|
+
on: [push, pull_request]
|
|
217
|
+
|
|
218
|
+
jobs:
|
|
219
|
+
test:
|
|
220
|
+
strategy:
|
|
221
|
+
fail-fast: false # Continue other tests if one fails
|
|
222
|
+
matrix:
|
|
223
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
224
|
+
node: [18, 20, 22]
|
|
225
|
+
exclude:
|
|
226
|
+
# Skip problematic combinations
|
|
227
|
+
- os: windows-latest
|
|
228
|
+
node: 18
|
|
229
|
+
|
|
230
|
+
runs-on: ${{ matrix.os }}
|
|
231
|
+
|
|
232
|
+
steps:
|
|
233
|
+
- uses: actions/checkout@v4
|
|
234
|
+
|
|
235
|
+
- uses: pnpm/action-setup@v4
|
|
236
|
+
with:
|
|
237
|
+
version: 10
|
|
238
|
+
|
|
239
|
+
- uses: actions/setup-node@v4
|
|
240
|
+
with:
|
|
241
|
+
node-version: ${{ matrix.node }}
|
|
242
|
+
cache: "pnpm"
|
|
243
|
+
|
|
244
|
+
- run: pnpm install --frozen-lockfile
|
|
245
|
+
|
|
246
|
+
- run: pnpm test
|
|
247
|
+
|
|
248
|
+
- run: pnpm build
|
|
249
|
+
|
|
250
|
+
# Test CLI binary actually works
|
|
251
|
+
- name: Test CLI
|
|
252
|
+
run: |
|
|
253
|
+
node dist/cli/main.js --version
|
|
254
|
+
node dist/cli/main.js --help
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Best Practices for Matrix Testing
|
|
258
|
+
|
|
259
|
+
1. **Use `npm ci` / `pnpm install --frozen-lockfile`** for deterministic installs
|
|
260
|
+
2. **Environment-specific caching** based on OS + lockfile hash
|
|
261
|
+
3. **`fail-fast: false`** to see all failures, not just the first
|
|
262
|
+
4. **Test actual binary execution**, not just unit tests
|
|
263
|
+
5. **Skip irrelevant combinations** with `exclude`
|
|
264
|
+
|
|
265
|
+
### Integration Test Recommendations
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
# Separate integration job that runs after unit tests pass
|
|
269
|
+
integration:
|
|
270
|
+
needs: [test]
|
|
271
|
+
runs-on: ubuntu-latest
|
|
272
|
+
steps:
|
|
273
|
+
- uses: actions/checkout@v4
|
|
274
|
+
|
|
275
|
+
# ... setup steps ...
|
|
276
|
+
|
|
277
|
+
- name: Pack and test installation
|
|
278
|
+
run: |
|
|
279
|
+
pnpm pack
|
|
280
|
+
npm install -g ./mdcontext-*.tgz
|
|
281
|
+
mdcontext --help
|
|
282
|
+
mdcontext analyze ./README.md
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 4. Package Quality Checks
|
|
288
|
+
|
|
289
|
+
### Essential Quality Tools
|
|
290
|
+
|
|
291
|
+
#### 1. publint - Package Publishing Lint
|
|
292
|
+
|
|
293
|
+
[publint](https://publint.dev/) catches packaging errors before users do:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Run locally
|
|
297
|
+
npx publint
|
|
298
|
+
|
|
299
|
+
# Or check online at publint.dev
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**What it checks:**
|
|
303
|
+
|
|
304
|
+
- `main`, `module`, `exports` field correctness
|
|
305
|
+
- ESM/CJS interpretation issues
|
|
306
|
+
- Missing entrypoints
|
|
307
|
+
- `default` condition ordering
|
|
308
|
+
- `__esModule` marker issues
|
|
309
|
+
|
|
310
|
+
#### 2. Are The Types Wrong (attw)
|
|
311
|
+
|
|
312
|
+
[@arethetypeswrong/cli](https://github.com/arethetypeswrong/arethetypeswrong.github.io) validates TypeScript types:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Check packed tarball
|
|
316
|
+
npm pack
|
|
317
|
+
npx attw ./package-1.0.0.tgz
|
|
318
|
+
|
|
319
|
+
# Or pack and check in one step
|
|
320
|
+
npx attw --pack .
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Issues detected:**
|
|
324
|
+
|
|
325
|
+
- Resolution failures
|
|
326
|
+
- Missing types
|
|
327
|
+
- CJS/ESM masquerading
|
|
328
|
+
- Incorrect default exports
|
|
329
|
+
- Module syntax mismatches
|
|
330
|
+
|
|
331
|
+
#### 3. Bundlephobia / Package Size Checks
|
|
332
|
+
|
|
333
|
+
[Bundlephobia](https://bundlephobia.com/) shows package impact:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# CLI version
|
|
337
|
+
npx bundle-phobia-cli package-name
|
|
338
|
+
|
|
339
|
+
# Or use bundlewatch for CI
|
|
340
|
+
npm install -D bundlewatch
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Integrated Quality Gate Workflow
|
|
344
|
+
|
|
345
|
+
```yaml
|
|
346
|
+
quality:
|
|
347
|
+
runs-on: ubuntu-latest
|
|
348
|
+
steps:
|
|
349
|
+
- uses: actions/checkout@v4
|
|
350
|
+
|
|
351
|
+
- uses: pnpm/action-setup@v4
|
|
352
|
+
with:
|
|
353
|
+
version: 10
|
|
354
|
+
|
|
355
|
+
- uses: actions/setup-node@v4
|
|
356
|
+
with:
|
|
357
|
+
node-version: "22"
|
|
358
|
+
cache: "pnpm"
|
|
359
|
+
|
|
360
|
+
- run: pnpm install --frozen-lockfile
|
|
361
|
+
- run: pnpm build
|
|
362
|
+
|
|
363
|
+
# Type checking
|
|
364
|
+
- run: pnpm typecheck
|
|
365
|
+
|
|
366
|
+
# Linting
|
|
367
|
+
- run: pnpm lint
|
|
368
|
+
|
|
369
|
+
# Package structure validation
|
|
370
|
+
- name: Validate package
|
|
371
|
+
run: npx publint
|
|
372
|
+
|
|
373
|
+
# TypeScript types validation
|
|
374
|
+
- name: Check types
|
|
375
|
+
run: npx attw --pack .
|
|
376
|
+
|
|
377
|
+
# Size check (optional, for libraries)
|
|
378
|
+
- name: Check bundle size
|
|
379
|
+
run: |
|
|
380
|
+
npx bundlewatch --config bundlewatch.config.js
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### bundlewatch Configuration
|
|
384
|
+
|
|
385
|
+
```javascript
|
|
386
|
+
// bundlewatch.config.js
|
|
387
|
+
module.exports = {
|
|
388
|
+
files: [
|
|
389
|
+
{
|
|
390
|
+
path: "./dist/*.js",
|
|
391
|
+
maxSize: "50kb",
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
ci: {
|
|
395
|
+
trackBranches: ["main"],
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 5. Error Handling and Rollback
|
|
403
|
+
|
|
404
|
+
### Common Failure Scenarios
|
|
405
|
+
|
|
406
|
+
1. **Partial publish in monorepos** - Some packages published, others failed
|
|
407
|
+
2. **Git tags pushed but publish failed** - Inconsistent state
|
|
408
|
+
3. **npm registry errors** - Timeouts, rate limits
|
|
409
|
+
4. **2FA failures** - Token/OIDC issues
|
|
410
|
+
|
|
411
|
+
### Recovery Strategies
|
|
412
|
+
|
|
413
|
+
#### For Lerna/Changesets Monorepos
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# After failed publish with tags already pushed
|
|
417
|
+
npx lerna publish from-package --yes
|
|
418
|
+
|
|
419
|
+
# Or with changesets
|
|
420
|
+
pnpm changeset publish
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
#### Manual Recovery Steps
|
|
424
|
+
|
|
425
|
+
1. **Check what was published**: `npm view package-name versions`
|
|
426
|
+
2. **If nothing published**: Fix issue, retry publish
|
|
427
|
+
3. **If partially published**: Use `from-package` to publish remaining
|
|
428
|
+
4. **If wrong version published**:
|
|
429
|
+
- Within 72 hours: `npm unpublish package@version`
|
|
430
|
+
- After 72 hours: Publish new patch version with fix
|
|
431
|
+
|
|
432
|
+
### Automated Rollback Considerations
|
|
433
|
+
|
|
434
|
+
```yaml
|
|
435
|
+
publish:
|
|
436
|
+
runs-on: ubuntu-latest
|
|
437
|
+
steps:
|
|
438
|
+
- name: Publish
|
|
439
|
+
id: publish
|
|
440
|
+
run: pnpm publish --no-git-checks
|
|
441
|
+
continue-on-error: true
|
|
442
|
+
|
|
443
|
+
- name: Handle failure
|
|
444
|
+
if: steps.publish.outcome == 'failure'
|
|
445
|
+
run: |
|
|
446
|
+
echo "Publish failed!"
|
|
447
|
+
# Log the issue, don't auto-rollback git
|
|
448
|
+
# Manual intervention is safer
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
**Key insight**: npm publishes are generally **not** safely auto-reversible. Instead:
|
|
452
|
+
|
|
453
|
+
- Use `--dry-run` first
|
|
454
|
+
- Keep pre-publish checks comprehensive
|
|
455
|
+
- Document manual recovery steps
|
|
456
|
+
- Consider `npm publish --access public --dry-run` in CI before actual publish
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## 6. Bun Migration Analysis
|
|
461
|
+
|
|
462
|
+
### Current State (2026)
|
|
463
|
+
|
|
464
|
+
Based on extensive research from multiple sources:
|
|
465
|
+
|
|
466
|
+
**Adoption:**
|
|
467
|
+
|
|
468
|
+
- 7+ million monthly downloads
|
|
469
|
+
- Used by Midjourney, Anthropic (for Claude Code CLI)
|
|
470
|
+
- [Anthropic acquired Bun in November 2025](https://dev.to/rayenmabrouk/why-we-ditched-node-for-bun-in-2026-and-why-you-should-too-48kg)
|
|
471
|
+
|
|
472
|
+
**Compatibility:**
|
|
473
|
+
|
|
474
|
+
- 95%+ Node.js API compatibility
|
|
475
|
+
- Native TypeScript execution (no transpilation step)
|
|
476
|
+
- [Full workspace support](https://bun.com/docs/pm/workspaces) with glob patterns
|
|
477
|
+
|
|
478
|
+
**Performance:**
|
|
479
|
+
|
|
480
|
+
- 3-4x faster execution than Node.js in many scenarios
|
|
481
|
+
- HTTP: ~52,000 req/s vs Node's ~13,000 req/s
|
|
482
|
+
- 30-50% infrastructure cost reductions reported
|
|
483
|
+
|
|
484
|
+
### Real-World Migration Experiences
|
|
485
|
+
|
|
486
|
+
#### Successes
|
|
487
|
+
|
|
488
|
+
- **Serverless functions**: 35% execution time reduction, lower AWS costs
|
|
489
|
+
- **CLI tools**: Fast startup times ideal for command-line use
|
|
490
|
+
- **Development servers**: Instant hot reload
|
|
491
|
+
|
|
492
|
+
#### Challenges
|
|
493
|
+
|
|
494
|
+
According to [2026 production assessments](https://dev.to/last9/is-bun-production-ready-in-2026-a-practical-assessment-181h):
|
|
495
|
+
|
|
496
|
+
- **34% of projects** experienced compatibility challenges
|
|
497
|
+
- **19% of monorepo migrations** had import resolution failures
|
|
498
|
+
- **28% struggled with Docker** initially
|
|
499
|
+
- Native module edge cases still exist
|
|
500
|
+
|
|
501
|
+
### Bun vs Node.js for CLI Tools
|
|
502
|
+
|
|
503
|
+
| Aspect | Bun | Node.js |
|
|
504
|
+
| ----------------------- | --------------------------- | ---------------------- |
|
|
505
|
+
| Startup time | ~25ms | ~100-150ms |
|
|
506
|
+
| TypeScript execution | Native | Requires transpilation |
|
|
507
|
+
| Single-file executables | Yes (`bun build --compile`) | Needs pkg/nexe |
|
|
508
|
+
| npm compatibility | 95%+ | 100% |
|
|
509
|
+
| Native addons | Some issues | Full support |
|
|
510
|
+
| Ecosystem maturity | Growing | Mature |
|
|
511
|
+
|
|
512
|
+
### mdcontext Specific Analysis
|
|
513
|
+
|
|
514
|
+
Looking at the mdcontext `package.json`:
|
|
515
|
+
|
|
516
|
+
**Dependencies that may have Bun issues:**
|
|
517
|
+
|
|
518
|
+
- `hnswlib-node` - Native addon, potential compatibility issues
|
|
519
|
+
- `tiktoken` - Native addon for tokenization
|
|
520
|
+
- `@effect/*` - Modern ESM, should work fine
|
|
521
|
+
|
|
522
|
+
**Low-risk dependencies:**
|
|
523
|
+
|
|
524
|
+
- `openai`, `remark-*`, `unified` - Pure JS, should work
|
|
525
|
+
- `gray-matter`, `chokidar` - Widely used, likely compatible
|
|
526
|
+
|
|
527
|
+
### Migration Path if Desired
|
|
528
|
+
|
|
529
|
+
```bash
|
|
530
|
+
# Step 1: Test package manager only
|
|
531
|
+
bun install # Creates bun.lockb
|
|
532
|
+
|
|
533
|
+
# Step 2: Run tests
|
|
534
|
+
bun test # Uses Bun's built-in test runner
|
|
535
|
+
|
|
536
|
+
# Step 3: Run CLI
|
|
537
|
+
bun run src/cli/main.ts # Direct TS execution
|
|
538
|
+
|
|
539
|
+
# Step 4: Build (still use tsup for npm compatibility)
|
|
540
|
+
bun run build
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## 7. Recommendations for mdcontext
|
|
546
|
+
|
|
547
|
+
### Publishing Workflow Recommendation
|
|
548
|
+
|
|
549
|
+
**Recommended approach: Changesets + OIDC Trusted Publishing**
|
|
550
|
+
|
|
551
|
+
```yaml
|
|
552
|
+
# .github/workflows/release.yml
|
|
553
|
+
name: Release
|
|
554
|
+
|
|
555
|
+
on:
|
|
556
|
+
push:
|
|
557
|
+
branches: [main]
|
|
558
|
+
|
|
559
|
+
permissions:
|
|
560
|
+
contents: write
|
|
561
|
+
pull-requests: write
|
|
562
|
+
id-token: write
|
|
563
|
+
|
|
564
|
+
jobs:
|
|
565
|
+
test:
|
|
566
|
+
strategy:
|
|
567
|
+
fail-fast: false
|
|
568
|
+
matrix:
|
|
569
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
570
|
+
node: [18, 20, 22]
|
|
571
|
+
runs-on: ${{ matrix.os }}
|
|
572
|
+
steps:
|
|
573
|
+
- uses: actions/checkout@v4
|
|
574
|
+
- uses: pnpm/action-setup@v4
|
|
575
|
+
with:
|
|
576
|
+
version: 10
|
|
577
|
+
- uses: actions/setup-node@v4
|
|
578
|
+
with:
|
|
579
|
+
node-version: ${{ matrix.node }}
|
|
580
|
+
cache: "pnpm"
|
|
581
|
+
- run: pnpm install --frozen-lockfile
|
|
582
|
+
- run: pnpm test
|
|
583
|
+
- run: pnpm build
|
|
584
|
+
- name: Test CLI
|
|
585
|
+
run: node dist/cli/main.js --help
|
|
586
|
+
|
|
587
|
+
quality:
|
|
588
|
+
runs-on: ubuntu-latest
|
|
589
|
+
steps:
|
|
590
|
+
- uses: actions/checkout@v4
|
|
591
|
+
- uses: pnpm/action-setup@v4
|
|
592
|
+
with:
|
|
593
|
+
version: 10
|
|
594
|
+
- uses: actions/setup-node@v4
|
|
595
|
+
with:
|
|
596
|
+
node-version: "22"
|
|
597
|
+
cache: "pnpm"
|
|
598
|
+
- run: pnpm install --frozen-lockfile
|
|
599
|
+
- run: pnpm build
|
|
600
|
+
- run: pnpm typecheck
|
|
601
|
+
- run: npx publint
|
|
602
|
+
- run: npx attw --pack .
|
|
603
|
+
|
|
604
|
+
release:
|
|
605
|
+
needs: [test, quality]
|
|
606
|
+
runs-on: ubuntu-latest
|
|
607
|
+
steps:
|
|
608
|
+
- uses: actions/checkout@v4
|
|
609
|
+
- uses: pnpm/action-setup@v4
|
|
610
|
+
with:
|
|
611
|
+
version: 10
|
|
612
|
+
- uses: actions/setup-node@v4
|
|
613
|
+
with:
|
|
614
|
+
node-version: "22"
|
|
615
|
+
cache: "pnpm"
|
|
616
|
+
registry-url: "https://registry.npmjs.org"
|
|
617
|
+
- run: pnpm install --frozen-lockfile
|
|
618
|
+
- name: Create Release PR or Publish
|
|
619
|
+
uses: changesets/action@v1
|
|
620
|
+
with:
|
|
621
|
+
publish: pnpm changeset publish
|
|
622
|
+
env:
|
|
623
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Quality Gate Checklist
|
|
627
|
+
|
|
628
|
+
Add to `package.json`:
|
|
629
|
+
|
|
630
|
+
```json
|
|
631
|
+
{
|
|
632
|
+
"scripts": {
|
|
633
|
+
"prepublishOnly": "pnpm build && pnpm test && pnpm typecheck",
|
|
634
|
+
"quality": "npx publint && npx attw --pack ."
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### Bun Migration Verdict
|
|
640
|
+
|
|
641
|
+
**Recommendation: Wait, but prepare**
|
|
642
|
+
|
|
643
|
+
**Reasons to wait:**
|
|
644
|
+
|
|
645
|
+
1. `hnswlib-node` and `tiktoken` are native addons - potential compatibility issues
|
|
646
|
+
2. mdcontext is a CLI tool users install globally - Node.js compatibility is safer
|
|
647
|
+
3. pnpm + tsup workflow is working well
|
|
648
|
+
4. 34% compatibility challenge rate is still significant
|
|
649
|
+
|
|
650
|
+
**Reasons to consider later:**
|
|
651
|
+
|
|
652
|
+
1. CLI tools benefit most from Bun's fast startup
|
|
653
|
+
2. Anthropic backing means long-term support
|
|
654
|
+
3. Direct TypeScript execution simplifies development
|
|
655
|
+
4. Could offer Bun-compiled binary as alternative distribution
|
|
656
|
+
|
|
657
|
+
**Recommended approach:**
|
|
658
|
+
|
|
659
|
+
1. Keep Node.js as primary target for npm package
|
|
660
|
+
2. Test with Bun locally for development speed
|
|
661
|
+
3. Consider offering a Bun-compiled binary in the future
|
|
662
|
+
4. Re-evaluate in 6-12 months as ecosystem matures
|
|
663
|
+
|
|
664
|
+
### Common Pitfalls to Avoid
|
|
665
|
+
|
|
666
|
+
1. **Not testing actual CLI binary** - Always run `node dist/cli/main.js --help` in CI
|
|
667
|
+
2. **Missing `--no-git-checks`** - Required for pnpm in GitHub Actions
|
|
668
|
+
3. **Wrong permission for OIDC** - Need `id-token: write`
|
|
669
|
+
4. **pnpm after setup-node** - Must be before for caching
|
|
670
|
+
5. **Not checking types with attw** - TypeScript issues are common
|
|
671
|
+
6. **Skipping cross-platform tests** - Windows path handling differs
|
|
672
|
+
7. **Auto-rollback on failure** - Manual intervention is usually safer
|
|
673
|
+
|
|
674
|
+
---
|
|
675
|
+
|
|
676
|
+
## Sources
|
|
677
|
+
|
|
678
|
+
### npm Publishing and OIDC
|
|
679
|
+
|
|
680
|
+
- [npm Trusted Publishing with OIDC (GitHub Blog)](https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/)
|
|
681
|
+
- [npm Trusted Publishers Documentation](https://docs.npmjs.com/trusted-publishers/)
|
|
682
|
+
- [Zach Leatherman: npm Security Best Practices](https://www.zachleat.com/web/npm-security)
|
|
683
|
+
- [Auto publish with pnpm and GitHub Actions (DEV.to)](https://dev.to/receter/automatically-publish-your-node-package-to-npm-with-pnpm-and-github-actions-22eg)
|
|
684
|
+
|
|
685
|
+
### Changelog and Versioning
|
|
686
|
+
|
|
687
|
+
- [Using Changesets with pnpm](https://pnpm.io/next/using-changesets)
|
|
688
|
+
- [conventional-changelog (GitHub)](https://github.com/conventional-changelog/conventional-changelog)
|
|
689
|
+
- [git-cliff](https://git-cliff.org/)
|
|
690
|
+
- [Changesets vs Semantic Release Comparison](https://brianschiller.com/blog/2023/09/18/changesets-vs-semantic-release)
|
|
691
|
+
- [np - A Better npm publish](https://github.com/sindresorhus/np)
|
|
692
|
+
|
|
693
|
+
### Quality Tools
|
|
694
|
+
|
|
695
|
+
- [publint](https://publint.dev/)
|
|
696
|
+
- [Are The Types Wrong?](https://arethetypeswrong.github.io/)
|
|
697
|
+
- [Bundlephobia](https://bundlephobia.com/)
|
|
698
|
+
- [@arethetypeswrong/cli (npm)](https://www.npmjs.com/package/@arethetypeswrong/cli)
|
|
699
|
+
|
|
700
|
+
### Testing
|
|
701
|
+
|
|
702
|
+
- [GitHub Actions Matrix Strategy Guide](https://codefresh.io/learn/github-actions/github-actions-matrix/)
|
|
703
|
+
- [TypeScript Test Matrix (TypeScript.tv)](https://typescript.tv/best-practices/create-a-typescript-test-matrix-using-github-actions/)
|
|
704
|
+
|
|
705
|
+
### Bun
|
|
706
|
+
|
|
707
|
+
- [Bun Official Site](https://bun.com)
|
|
708
|
+
- [Bun Workspaces Documentation](https://bun.com/docs/pm/workspaces)
|
|
709
|
+
- [Bun vs Node.js 2025 (Strapi)](https://strapi.io/blog/bun-vs-nodejs-performance-comparison-guide)
|
|
710
|
+
- [Is Bun Production-Ready in 2026? (DEV.to)](https://dev.to/last9/is-bun-production-ready-in-2026-a-practical-assessment-181h)
|
|
711
|
+
- [Why We Ditched Node for Bun in 2026 (DEV.to)](https://dev.to/rayenmabrouk/why-we-ditched-node-for-bun-in-2026-and-why-you-should-too-48kg)
|
|
712
|
+
- [Bun Package Manager Reality Check 2026](https://vocal.media/01/bun-package-manager-reality-check-2026)
|
|
713
|
+
|
|
714
|
+
### Error Handling
|
|
715
|
+
|
|
716
|
+
- [Emergency Rollback Workflows (Latenode Community)](https://community.latenode.com/t/emergency-rollback-workflows-after-failed-npm-updates/40265)
|
|
717
|
+
- [semantic-release npm publish recovery](https://github.com/semantic-release/npm/issues/54)
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
|
|
721
|
+
_Last updated: January 2026_
|
|
722
|
+
_Research conducted for mdcontext CLI tool publishing workflow optimization_
|