Skip to content

feat: VS Code extension with full CLI parity, encoding compliance guards#36

Open
bilersan wants to merge 7 commits intoActiveMemory:mainfrom
bilersan:pr/vscode-extension
Open

feat: VS Code extension with full CLI parity, encoding compliance guards#36
bilersan wants to merge 7 commits intoActiveMemory:mainfrom
bilersan:pr/vscode-extension

Conversation

@bilersan
Copy link
Contributor

@bilersan bilersan commented Mar 7, 2026

Summary

Adds a comprehensive VS Code extension that provides full CLI parity through the Copilot Chat participant, along with caller-specific context template overrides for VS Code workflows.

Merge Order

Merge last — after #29 and #31.
Suggested order: #29#31#36

⚠️ Overlap with #31: This PR includes the same Windows boundary check fix (case-insensitive path comparison in validation/path.go). If #31 merges first, expect a trivial merge conflict in that file — both sides make the identical change. Rebase to resolve.

Changes

1. Caller-specific context template overrides

  • ctx init --caller vscode produces VS Code-tailored context files
  • Creates .vscode/extensions.json, tasks.json, and copilot-instructions.md
  • Override template system via internal/assets/overrides/<caller>/
  • TemplateForCaller() API with fallback to default templates

2. Windows boundary check fixes

  • Case-insensitive path comparison on NTFS (EvalSymlinks normalizes casing differently than os.Getwd)
  • Fixes false 'outside project root' errors when VS Code passes lowercase drive letters
  • cli_test.go: adds .exe suffix for Windows binary builds

3. VS Code extension — full CLI parity

  • 45 slash commands via @ctx /command chat participant
  • 45 Command Palette entries (Ctrl+Shift+P > ctx: Init, etc.)
  • 7 background hooks: onDidSave task-completion, Git post-commit nudge, FileSystemWatcher (.context/** + deps), heartbeat (5min), status bar reminder, session start/end ceremonies
  • Context gate: non-init commands require .context/ to exist
  • Session lifecycle: ctx system session-event --type start|end --caller vscode
  • Extension README with installation and usage documentation
  • Feature parity specification in specs/vscode-feature-parity.md

4. Bug fix: remove --no-color from CLI calls

  • Removed --no-color flag from all 48 runCtx invocations
  • Updated all 53 test assertions to match

5. Compliance: BOM and mojibake detection

  • TestNoUTF8BOM (rule 21): rejects files starting with a UTF-8 byte-order mark
  • TestNoMojibake (rule 22): detects double-encoded UTF-8 (Windows encoding corruption)
  • Catches the exact class of corruption encountered during the --no-color removal

Excluded from this PR (infrastructure-only)

Testing

  • 53/53 unit tests pass (vitest)
  • 22/22 compliance tests pass (including new BOM + mojibake checks)
  • Build compiles clean on both Windows and Linux

Commits

Commit Description
1 feat: caller-specific context template overrides
2 fix: Windows boundary check case sensitivity
3 feat(vscode): VS Code extension with full CLI parity (squashed)
4 fix(vscode): remove --no-color flag from all ctx CLI calls
5 feat(compliance): add BOM and mojibake detection tests

@bilersan bilersan requested a review from josealekhine as a code owner March 7, 2026 21:25
@bilersan bilersan force-pushed the pr/vscode-extension branch from 6f20d62 to 7283ef1 Compare March 7, 2026 21:30
@bilersan bilersan changed the title feat: VS Code extension with full CLI parity + caller-specific overrides feat: VS Code extension with full CLI parity, encoding compliance guards Mar 7, 2026
@bilersan bilersan force-pushed the pr/vscode-extension branch 2 times, most recently from 2d4cce6 to a279886 Compare March 7, 2026 23:39
bilersan added 7 commits March 8, 2026 02:41
Add a --caller flag to 'ctx init' that lets calling tools (e.g. VS Code
extension) identify themselves so ctx can emit tailored context files.

When --caller is set, TemplateForCaller checks for a caller-specific
override in overrides/<caller>/<template>.md before falling back to the
default template. This allows different AI tools to get optimized
playbooks without changing the core template set.

Includes a VS Code-specific AGENT_PLAYBOOK.md override (268 lines) that
provides VS Code-aware instructions: workspace API patterns, extension
lifecycle, Copilot Chat participant conventions, and VS Code-specific
debugging workflows.

Changes:
- internal/assets/embed.go: add TemplateForCaller() + embed overrides
- internal/assets/overrides/vscode/AGENT_PLAYBOOK.md: VS Code playbook
- internal/cli/initialize/cmd/root/run.go: accept caller, use override
- internal/cli/initialize/init.go: add --caller flag

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
…ages

- ValidateBoundary: use case-insensitive comparison on Windows (NTFS)
- Root command: set SilenceErrors to prevent Cobra double-printing errors
- Extension: add mergeOutput helper to deduplicate stdout/stderr

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- 45 slash commands via @ctx chat participant covering all CLI operations
- 45 Command Palette entries (Ctrl+Shift+P) for discoverability
- 7 background hooks: onDidSave task-completion, Git post-commit nudge,
  FileSystemWatcher (.context/** + deps), heartbeat (5min), status bar
  reminder, session start/end ceremonies
- ctx init --caller vscode creates .vscode/extensions.json, tasks.json,
  and copilot-instructions.md
- Context gate: non-init commands require .context/ to exist
- Session lifecycle: session-event start/end via ctx system session-event
- VS Code README with installation and usage docs

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Adds two new compliance tests:
- TestNoUTF8BOM: rejects files starting with a UTF-8 byte-order mark
- TestNoMojibake: detects double-encoded UTF-8 (Windows encoding corruption)

These catch the exact class of corruption we hit when --no-color was
removed: a Windows editor re-encoded the UTF-8 files through
Windows-1252, turning em dashes and arrows into multi-byte garbage.

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- Guard Claude Code-specific steps (permissions, plugin, Makefile) behind
  caller check so they are skipped for editor callers
- Add ClaudeMdForCaller() to support caller-specific CLAUDE.md overrides;
  HandleClaudeMd now runs for all callers using the override system
- Filter .claude/ entries from .gitignore when caller is set
- Add journal and journal-serve tasks to VS Code tasks.json
- Fix UTF-8 mojibake in overrides/vscode/AGENT_PLAYBOOK.md
- Add language-agnostic VS Code overrides for CONVENTIONS.md,
  CONSTITUTION.md, and CLAUDE.md

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Signed-off-by: ersan bilik <ersanbilik@gmail.com>
@bilersan bilersan force-pushed the pr/vscode-extension branch from a279886 to 1a48958 Compare March 7, 2026 23:41
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