Skip to content

feat: add opt-in tldraw skill and local snapshot store#11

Merged
codejunkie99 merged 3 commits intomasterfrom
feat/tl-draw-visual-memory
Apr 27, 2026
Merged

feat: add opt-in tldraw skill and local snapshot store#11
codejunkie99 merged 3 commits intomasterfrom
feat/tl-draw-visual-memory

Conversation

@Siddharth11Roy
Copy link
Copy Markdown
Contributor

@Siddharth11Roy Siddharth11Roy commented Apr 21, 2026

Adds an opt-in, harness-agnostic tldraw skill plus a skill-local snapshot store.

Skill

  • Adds .agent/skills/tldraw/SKILL.md with triggers, tool guidance, constraints, and a self-rewrite hook.
  • Registers the skill in _index.md and _manifest.jsonl behind feature_flag: tldraw.
  • Updates skill_loader.py so flagged skills load only when .agent/memory/.features.json explicitly enables them.

Local snapshot store

  • Adds .agent/skills/tldraw/store.py with snapshot, list, load, and archive CLI/API support.
  • Stores runtime output beside the skill as ignored local files: snapshots.jsonl, snapshots/, and INDEX.md.
  • Keeps this as skill-local storage, not a fifth memory layer: no dream-cycle, clustering, recall, or semantic-memory integration.

Opt-in MCP setup

  • Keeps beta tldraw MCP wiring out of default adapter installs.
  • Adds adapters/_shared/tldraw-mcp.json as the canonical config users can manually merge after enabling the feature.
  • Documents where to merge that config for Claude Code, Cursor, and Antigravity.

Onboarding and docs

  • Adds the tldraw [BETA] onboarding feature flag, default off.
  • Updates README seed-skill count and optional-feature table.
  • Notes tldraw as an opt-in beta skill with local snapshots.

Review fixes

  • Rebased onto current master and resolved skill registry conflicts.
  • Updated tests to target .agent/skills/tldraw/store.py instead of removed .agent/memory/visual/visual_memory.py.
  • Renders INDEX.md while holding the JSONL lock to avoid stale concurrent renders.
  • Adds tests for feature-gated skill loading, no default MCP install, path traversal rejection, malformed JSONL recovery, and concurrent snapshots.

Verification

  • python3 test_tldraw_visual_memory.py passes: 52/52.
  • Data layer/flywheel unit tests pass.
  • verify_codex_fixes.py passes.
  • test_claude_code_hook.py passes: 54/54.
  • py_compile, jq, SVG parse, and git diff --check pass.

…er as well, to be worked with tl draw only at localhost 3000
Copilot AI review requested due to automatic review settings April 21, 2026 18:09
@codejunkie99 codejunkie99 requested review from codejunkie99 and removed request for Copilot April 21, 2026 18:11
@codejunkie99 codejunkie99 self-assigned this Apr 21, 2026
Copy link
Copy Markdown
Owner

@codejunkie99 codejunkie99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required changes before merge:

1. Rebase onto current master. This branch predates v0.8.0 and PR #9. CHANGELOG.md, test_claude_code_hook.py, verify_codex_fixes.py, adapters/claude-code/CLAUDE.md (+119), and the hook_patterns.json tip in onboard.py are drift, not tldraw work.

2. Drop the "5th memory layer" framing. .agent/memory/visual/ has no lifecycle, no clustering, no dream-cycle integration, no retrieval. auto_dream.py never touches it. Move to .agent/skills/tldraw/store.py or .agent/memory/working/canvases/. Update README + CHANGELOG accordingly.

3. Fix concurrency bugs in visual_memory.py:

  • :99-101 _append_jsonl — no lock; concurrent snapshots corrupt the JSONL.
  • :195-204 archive_snapshot — read-modify-rewrite race loses records appended between read and rewrite.
  • :94-95 _read_jsonl — silently swallows json.JSONDecodeError. Log to stderr.

Use the flock pattern from .agent/memory/render_lessons.py.

4. Validate sid in load_snapshot / archive_snapshot (:177-184). os.path.join(SNAPSHOTS_DIR, f"{sid}.json") accepts ../ traversal. Constrain sid to [A-Za-z0-9_-]+ before joining.

5. Bound the id-resample loop at :142-144 to ~8 attempts and raise. Currently unbounded.

6. Delete duplicate files:

  • adapters/antigravity/.mcp.json
  • adapters/claude-code/.mcp.json
  • adapters/cursor/.cursor/mcp.json

They are byte-identical to adapters/_shared/tldraw-mcp.json. Have install.sh / install.ps1 copy the shared file per adapter instead.

7. Delete .agent/skills/tldraw/KNOWLEDGE.md. 4-line empty placeholder. SKILL.md can instruct create-on-first-use.

8. Stop committing generated .agent/memory/visual/INDEX.md. Add it to .gitignore; let _render_index create it on first snapshot.

9. Delete adapters/claude-code/.claude/commands/tldraw.md. Redundant with SKILL.md triggers.

10. Remove status CLI subcommand + _cmd_status from visual_memory.py. list covers it.

11. Tests:

  • Delete structural tests (test_tldraw_visual_memory.py:57-111 — file-existence and manifest-key assertions).
  • Add a concurrency test: two threads appending snapshots concurrently, assert no JSONL corruption.
  • Add a malformed-JSONL-line recovery test.
  • Add a path-traversal test for sid.

…y, drop duplicates

  Relocate
    Move persistence out of .agent/memory/visual/ into the skill itself at
    .agent/skills/tldraw/store.py. The previous layout implied a fifth
    memory layer, but there is no lifecycle, clustering, dream-cycle, or
    recall integration — it's skill-local storage, not memory. Naming now
    matches behavior.

  Concurrency
    * JSONL mutations acquire an advisory exclusive flock on Unix and a
      process-local threading.RLock on Windows (fcntl unavailable).
    * Archive does read-modify-rewrite inside a single lock scope.
    * Atomic-write tmp names include 6 bytes of entropy so two threads
      writing the same target in the same millisecond can't race on the
      tmp file.
    * Snapshot id retries are bounded (_MAX_RESAMPLE = 8) so a degenerate
      RNG can't spin forever.

  Security
    load_snapshot / archive_snapshot validate the sid against
    ^[A-Za-z0-9_-]+$ before any os.path.join. Blocks traversal inputs
    like "../etc/passwd" at the API boundary.

  Robustness
    Malformed JSONL lines are logged to stderr and skipped rather than
    silently swallowed — the store exists to surface corruption, not hide
    it.

  Duplicates removed
    * adapters/{antigravity,claude-code}/.mcp.json and
      adapters/cursor/.cursor/mcp.json were byte-identical to
      adapters/_shared/tldraw-mcp.json. install.sh and install.ps1 now
      copy the shared file into the target per adapter.
    * Deleted .agent/skills/tldraw/KNOWLEDGE.md (placeholder) and
      adapters/claude-code/.claude/commands/tldraw.md (redundant with the
      skill).

  Gitignore
    INDEX.md, snapshots/, and snapshots.jsonl under the skill are runtime
    output — gitignored so installs start clean. The PR-local validation
    harness (test_tldraw_visual_memory.py) is also gitignored

  Tests (local)
    66/66 passing. New coverage: 16-thread concurrent snapshot writes with
    post-hoc jsonl parse + count check, malformed-line recovery.
Copilot AI review requested due to automatic review settings April 21, 2026 19:18
@codejunkie99 codejunkie99 requested review from ujjwalbaliyan007 and removed request for Copilot April 21, 2026 19:18
Copilot AI review requested due to automatic review settings April 27, 2026 08:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@codejunkie99 codejunkie99 changed the title Added tl draw mcp server and skill. Added the fifth visual memory lay… feat: add opt-in tldraw skill and local snapshot store Apr 27, 2026
@codejunkie99 codejunkie99 merged commit c892f9e into master Apr 27, 2026
@codejunkie99 codejunkie99 deleted the feat/tl-draw-visual-memory branch April 27, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants