Skip to content

Fix docset writing#17

Merged
mrsimpson merged 7 commits intomainfrom
fix-docset-writing
Mar 20, 2026
Merged

Fix docset writing#17
mrsimpson merged 7 commits intomainfrom
fix-docset-writing

Conversation

@mrsimpson
Copy link
Copy Markdown
Contributor

No description provided.

## Intent

The `Option.docsets[]` field on Option was a second, parallel way to
declare knowledge sources — distinct from the recipe-based provision
writers that everything else uses. This made the model inconsistent and
added a separate confirmation step in `setup` for docsets. Collapsing
docsets into a `docset` provision writer (already how skills work) makes
the catalog model uniform and removes unnecessary per-item opt-out UX.

## Key changes

- Added `docset` provision writer (core/src/writers/docset.ts) that maps
  `{ id, label, origin, description }` config to a `KnowledgeSource`
- Registered `docsetWriter` in `createDefaultRegistry()`
- Exported `docsetWriter` from core public API
- Migrated all catalog options (architecture: tanstack/nodejs-backend/
  java-backend; practices: conventional-commits) from `docsets:[]` to
  `{ writer: "docset", config: {...} }` recipe entries
- Removed dead `knowledge` provision writer and its tests
- Removed `collectDocsets()` from resolver and `Option.docsets?` /
  `excluded_docsets` from types
- Removed docset confirmation multiselect block from CLI setup command
- Wired `installKnowledge()` into both setup and install commands so
  `.knowledge/config.yaml` is written on every run
- Updated all tests to use the new recipe-entry model

## Dependencies and side effects

- `ProvisionWriter` union type now includes `"docset"` (was already
  present from a prior WIP commit); `"knowledge"` is removed
- `UserConfig.excluded_docsets` removed — existing config files that
  happen to have this field will silently ignore it (unknown field)
- Setup command now has one fewer multiselect prompt step for harnesses
  users who previously selected/deselected individual docsets
## Intent

Skills have an opt-in confirmation prompt during setup; knowledge sources
were silently configured and the user had to discover the manual init
command on their own. Parity with the skills UX makes the flow consistent
and surfaces the initialization step at the right moment.

## Key changes

- Added a clack.confirm prompt after knowledge sources are resolved,
  listing each source name (matching the skills prompt style)
- Default answer is false (defer) — initializing large doc repos is
  slow and network-dependent, so opt-in is the right default
- On "No": shows the existing deferred hint (npx @codemcp/knowledge init)
- On "Yes": calls installKnowledge immediately
- Updated knowledge-docset.integration.spec.ts to supply explicit
  confirm mock values for skills and knowledge prompts separately
## Intent

Two small UX fixes to the knowledge source initialization prompt:
the deferred hint was missing the docset name so users could not
copy-paste individual init commands, and confirming yes did not force
re-initialization for docsets that were already partially set up.

## Key changes

- Deferred hint now lists one command per source:
    npx @codemcp/knowledge init <name>
- Same per-source command list shown inside the confirm prompt
- installKnowledge() accepts an options.force flag; setup passes
  force: true when the user explicitly confirms
…fix createDocset idempotency

## Intent

Two bugs in knowledge source initialization: (1) createDocset always used
preset "git-repo" even for archive or local-folder sources; (2) createDocset
threw on re-run because the docset was already registered, blocking the
force re-init that the user explicitly requested.

## Key changes

- Added DocsetPreset type alias and optional preset field to KnowledgeSource
- docsetWriter passes preset from config through to the KnowledgeSource
- installKnowledge uses source.preset ?? "git-repo" for the createDocset call
- "already exists" errors from createDocset are swallowed so initDocset
  (with force: true) still runs — enabling re-initialization
- Updated knowledge-installer.spec.ts: renamed the "real failure" test to
  use a non-ambiguous error message; added new test for the already-exists
  → proceed-to-init path; added preset passthrough test
- DocsetPreset exported from core public API
…ter refactor

Remove all references to Option.docsets[], DocsetDef, excluded_docsets,
collectDocsets, and the knowledge provision writer. Replace with the
docset provision writer model throughout.
@mrsimpson mrsimpson merged commit 4ac2a78 into main Mar 20, 2026
1 check passed
@mrsimpson mrsimpson deleted the fix-docset-writing branch March 20, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant