Refresh a bundle after the source changes
Use knowledge update when the source document has been edited and you want to regenerate the bundle.
Before you start
- A bundle already exists at
./pyguide/from the previous extraction. - You have read Build a bundle from a URL.
What update does
knowledge update re-extracts from the source and overwrites the bundle directory. It is not an incremental merge:
- Every concept file is regenerated.
- Any concept present in the old bundle but missing from the new extraction is removed.
- Any stale
.mdfile in directories the serializer owns is removed.
Warning.
Hand-edited concept files are lost on
update. If you need to keep manual edits, back them up first or skip this tutorial.
Steps
1. Back up any manual edits
If you have edited concept files by hand and want to preserve them, copy them out of the bundle directory now:
mkdir -p ./manual-backup
cp ./pyguide/custom-note.md ./manual-backup/
2. Run update
knowledge update https://google.github.io/styleguide/pyguide.html ./pyguide
You should see:
Updating bundle from pyguide.html...
done (3.1s)
Wrote 67 concepts to ./pyguide
The number of concepts may differ from the previous extraction if the source has gained or lost sections.
3. Inspect the changes
Use git diff if the bundle is under version control:
git diff --stat ./pyguide
Or compare directory listings:
ls ./pyguide/ > /tmp/pyguide-new.txt
ls ./pyguide/ > /tmp/pyguide-old.txt # if you captured it earlier
diff /tmp/pyguide-old.txt /tmp/pyguide-new.txt
4. Restore manual edits (if any)
If you backed up hand-edited files in step 1 and they were not regenerated by the LLM, copy them back:
cp ./manual-backup/custom-note.md ./pyguide/
Then re-validate to make sure the bundle still passes structural checks:
knowledge create --validate https://google.github.io/styleguide/pyguide.html ./pyguide
What you learned
knowledge updateis destructive: it rewrites the entire bundle.- Hand-edited files must be backed up before running
update. - After
update, re-runcreate --validate(or callBundleSerializer.validate()) to confirm the bundle is still well-formed.
Next steps
- Curate a bundle by removing concepts — fine-tune the bundle by removing specific concepts.