Skip to content

DEV-7314: feat(knowledge): sync knowledge folder in sandbox and workspace push/pull#23

Merged
xano-izzy merged 8 commits into
devfrom
knowledge-tree-api-cli
Jun 25, 2026
Merged

DEV-7314: feat(knowledge): sync knowledge folder in sandbox and workspace push/pull#23
xano-izzy merged 8 commits into
devfrom
knowledge-tree-api-cli

Conversation

@xano-izzy

Copy link
Copy Markdown

Summary

  • Adds src/utils/knowledge-sync.ts: pull/push logic for agents.md, skills/, and docs/ knowledge folders — YAML frontmatter parsing, GUID writeback, dry-run support, and --sync --delete (full-sync) mode.
  • Wires knowledge sync into workspace pull/push (via GET/POST /api:meta/workspace/{id}/knowledge/sync) and sandbox pull/push (via GET/POST /api:meta/sandbox/knowledge/sync).
  • Adds test/utils/knowledge-sync.test.ts (288 lines, 80 tests passing).
  • Updates README.md with knowledge sync behavior for both commands.

Backend dependency

Workspace path (workspace pull/push) is fully testable today.

Sandbox path (sandbox pull/push) depends on GET/POST /api:meta/sandbox/knowledge/sync being deployed. The CLI gracefully no-ops (skips knowledge) when the endpoint returns 404, so this is safe to merge before the backend ships. A test runbook for the E2E validation is at .context/sandbox-knowledge-test-runbook.md — hand it to a test agent once the endpoint is live.

Test plan

  • npm run build — clean compile
  • npm test — 80 mocha tests pass (lint failures are pre-existing on main, none introduced by this branch)
  • xano workspace pull -d /tmp/wstest --verbose — verify knowledge/ layout and frontmatter
  • xano workspace push -d /tmp/wstest --dry-run --verbose — server-side dry-run 200, preview output
  • Sandbox E2E: follow .context/sandbox-knowledge-test-runbook.md once backend endpoint ships

🤖 Generated with Claude Code

@xano-izzy xano-izzy changed the base branch from main to dev June 25, 2026 21:50
xano-izzy and others added 6 commits June 25, 2026 17:13
Add workspace knowledge (agents.md, skills, docs) to `workspace pull`
and `workspace push`, mirroring the multidoc model: the backend returns
structured knowledge objects via `GET/POST workspace/{id}/knowledge/sync`
and the CLI owns the on-disk `knowledge/` layout and YAML frontmatter.

- new src/utils/knowledge-sync.ts: fetch/push/write/collect knowledge
  objects, build/parse frontmatter, guid writeback, client-side diff
  fallback when the server dry_run is unavailable
- multidoc-push.ts: optional knowledge hook folds knowledge into the
  single combined push preview + confirmation; honors branch,
  --sync/--delete, --dry-run, --include/--exclude, --guids
- workspace push/pull wired to .../knowledge/sync (sandbox unchanged)
- each distinct object gets a unique folder so duplicate names can never
  silently overwrite (identity travels via frontmatter guid)
- README + tests (79 passing)

Verified end-to-end against a local instance: pull, create, update,
idempotent re-push, and --sync --delete all round-trip correctly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend knowledge sync to `sandbox push`/`sandbox pull`, mirroring how the
workspace commands do it. Both target `.../api:meta/sandbox/knowledge/sync`
(no workspace id, branch=""), fold into the same combined push preview, and
degrade gracefully (404 → no-op) until the backend adds the sandbox endpoint.

- sandbox pull: fetch + write knowledge objects after the multidoc split
- sandbox push: pass the knowledge config to executePush
- README: note knowledge sync on sandbox push/pull

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The knowledge/sync API requires description/scope/mode/enabled on every
item; the CLI previously omitted them when a file's frontmatter had none,
so minimal/hand-authored knowledge files failed with a 400. Default them
(description="", scope="workspace", mode="auto", enabled=true) when absent.
Pulled files already carry these, so round-trips are unaffected.

Verified end-to-end: a minimal doc (name + knowledge_type only) now passes
the server dry_run (200, authoritative preview — no client-side fallback)
and creates + writes its guid back.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…owledge sync

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s empty

Previously, pushing a knowledge-only directory with all files removed
(triggering a delete-all via --sync --delete) would throw "No .xs files
found" because knowledgeOnly required knowledgeObjects.length > 0, and
the push/dry-run/summary guards all gated on the same condition. Now all
three guards also fire when shouldDelete is true, so an empty local
knowledge tree correctly sends items:[] with delete:true to the server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Clear multidoc when filteredEntries is empty on a partial push so
  a knowledge-only change doesn't also POST the full .xs document set
- Guard the multidoc POST against an empty body to skip it entirely
- Add scope to canonical() so scope-only frontmatter edits are caught
  by the client-side dry-run fallback change detection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xano-izzy xano-izzy force-pushed the knowledge-tree-api-cli branch from b80b449 to e3ca34f Compare June 25, 2026 23:14
@xano-izzy xano-izzy changed the title feat(knowledge): sync knowledge folder in sandbox and workspace push/pull DEV-7314: feat(knowledge): sync knowledge folder in sandbox and workspace push/pull Jun 25, 2026
xano-izzy and others added 2 commits June 25, 2026 17:25
- sandbox/pull: restore 'No documents found in response' guard (without
  early return so knowledge still pulls when documents are empty)
- sandbox/push: restore delete flag to its original position after
  directory flag

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ox examples

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@xano-izzy xano-izzy merged commit 96eae39 into dev Jun 25, 2026
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.

2 participants