Merged
Conversation
- CopilotParser implementing SessionParser interface with Matches() and ParseFile() - Platform-aware directory discovery for Code and Code Insiders - Typed Go structs for Copilot Chat JSONL format (snapshot+patch model) - Registration in parser.go and query scanning in query.go - ToolCopilot constant in config/session Closes #28 Supersedes #29 Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- VS Code extension with @ctx chat participant and slash commands - .vscode/mcp.json generation in init and hook paths - VS Code-specific context overrides (CONSTITUTION, CONVENTIONS, etc.) - Session event CLI command for VS Code lifecycle integration - Detection ring: terminal watcher for dangerous commands - Detection ring: file edit watcher for sensitive file patterns - Violation recording to .context/state/violations.json - Extension tests and init/hook integration tests Supersedes #36 Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- Governance checker (CheckGovernance) appends contextual warnings to every MCP tool response: session-not-started, context-not-loaded, drift-stale, persist-nudge, and violation escalation - Per-tool state recording: RecordSessionStart, RecordContextLoaded, RecordDriftCheck, RecordContextWrite, IncrementCallsSinceWrite - Violation reading from .context/state/violations.json with automatic cleanup after escalation (read-and-clear pattern) - Governance wired into route/tool dispatch with appendGovernance - RecordSessionStart called on session event handler - copilot-instructions.md template with governance rules and detection ring documentation - 24 governance tests covering all check paths and edge cases Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- Set activationEvents to onStartupFinished for reliable activation - Add /diag slash command for extension diagnostics - Add OutputChannel logging for activation tracing - Pass --force --caller vscode to init to prevent stdin hang - Skip stdin overwrite prompt when caller is set (run.go) - Add test-insiders-sim.js to .vscodeignore Root cause: VS Code Insiders 1.112 uses extensions.experimental.affinity to run GitHub.copilot-chat in a separate extension host process. Chat requests only route to that host. The fix requires adding activememory.ctx-context to the same affinity group in user settings. Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- Fix gosec G101 lint path in .golangci.yml (constants moved to config/embed) - Fix TestTextDescKeysResolve path in embed_test.go - Add license header and doc.go for internal/config/embed - Add VS Code marketplace fields (extensionDependencies, pricing) - Add CHANGELOG.md and update .vscodeignore Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- cmd.go: rename cmd.Flags() to c.Flags() (upstream variable rename) - sessionevent/cmd.go: update import core -> core/state (package split) - copilot.go: prefix Session/Message/ToolUse with entity. (types moved) DCO-1.1-Signed-off-by: ersan bilik <ersanbilik@gmail.com> Signed-off-by: ersan bilik <ersanbilik@gmail.com>
DCO-1.1-Signed-off-by: ersan bilik <ersanbilik@gmail.com> Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Add cross-platform hook generation for GitHub Copilot CLI integration. ctx hook copilot-cli --write generates .github/hooks/ctx-hooks.json with dual bash/PowerShell scripts for sessionStart, preToolUse, postToolUse, and sessionEnd lifecycle events. New files: - Embedded hook templates: ctx-hooks.json + 8 scripts (.sh/.ps1) - Asset readers: CopilotCLIHooksJSON(), CopilotCLIScripts() - WriteCopilotCLIHooks() in hook command run.go - Feature matrix spec: specs/copilot-cli-integration.md Constants added: ToolCopilotCLI, CLI event names, asset paths, text description keys, write output functions. DCO-1.1-Signed-off-by: ersan bilik <ersanbilik@gmail.com> Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Add AGENTS.md generation (ctx hook agents --write) with universal agent instructions readable by all AI coding tools. Add Copilot CLI extras: .github/agents/ctx.md custom agent and .github/instructions/context.instructions.md path-specific guide. WriteCopilotCLIHooks now also generates agents/ctx.md and instructions/context.instructions.md alongside the hook scripts. WriteAgentsMd supports marker-based merge with existing AGENTS.md. New templates: agents.md, agents-ctx.md, instructions-context.md New constants: ToolAgents, AgentsMarker*, text keys, write functions DCO-1.1-Signed-off-by: ersan bilik <ersanbilik@gmail.com> Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Phase 3A: MCP Registration - Add ensureCopilotCLIMCPConfig() to register ctx MCP server in ~/.copilot/mcp-config.json (respects COPILOT_HOME env var) - Merge-safe: reads existing config, adds ctx server, writes back - Uses official Copilot CLI mcpServers format with type=local - Called automatically from WriteCopilotCLIHooks() - Add DirCopilotHome, EnvCopilotHome, FileMCPConfigJSON constants Phase 3B: Copilot CLI Session Parser - Create CopilotCLIParser implementing SessionParser interface - Add ToolCopilotCLI constant to config/session/tool.go - Register parser in registeredParsers (parser.go) - Add CopilotCLISessionDirs() scanning ~/.copilot/sessions/, ~/.copilot/history/, and Windows LOCALAPPDATA paths - Wire into findSessionsWithFilter() query scanning (query.go) - Extract osWindows constant to satisfy goconst linter - Parser skeleton ready for format discovery as Copilot CLI session storage format stabilizes Ref: specs/copilot-cli-integration.md Phase 3 Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Add 5 embedded skill templates for GitHub Copilot CLI integration: - ctx-status: context summary and health check - ctx-recall: session history browsing - ctx-drift: context drift detection - ctx-compact: archive completed tasks - ctx-next: advance to next task Each skill is written to .github/skills/<name>/SKILL.md when 'ctx hook copilot-cli --write' is invoked. Skills use YAML frontmatter (name, description) with Markdown instructions, following the Copilot CLI skill format. Wiring: - embed.go: glob for hooks/copilot-cli/skills/*/SKILL.md - agent.go: CopilotCLISkills() reader function - run.go: writeCopilotCLISkills() called from WriteCopilotCLIHooks() - asset.go: DirHooksCopilotCLISkills constant - hook.go: DirGitHubSkills, FileSKILLMd constants - text/hook.go: DescKeyWriteHookCopilotCLISkills key Signed-off-by: ersan bilik <ersanbilik@gmail.com>
Resolve merge conflicts caused by recent refactoring on main: - recall → journal package rename: relocate copilot parser files - Type/constructor renames: CopilotParser → Copilot, SessionParser → Session - Function renames: CreateProjectDirs → CreateDirs, EnablePluginGlobally → EnableGlobally, HandleClaudeMd → HandleMd - Marker renames: CopilotMarkerStart → CopilotStart, add AgentsStart/AgentsEnd - log → log/event split: fix AppendEvent → event.Append - ValidateBoundary → Boundary, keep osWindows const - Grandfather PR's new cmd/ functions in compliance tests - Document sessionevent subcommand in system/doc.go - Take main's .context/ docs, combine .gitignore entries Signed-off-by: Jose Alekhinne <jose@ctx.ist>
These files were explicitly removed on 2026-03-25 (decision: "Prompt templates removed — skills are the single agent instruction mechanism"). The PR was based on older code and reintroduced them. Removed: - .context/PROMPT.md (session prompt — replaced by AGENT_PLAYBOOK.md) - .context/prompts/code-review.md (replaced by /ctx-code-review skill) - .context/prompts/explain.md (replaced by /ctx-explain skill) - .context/prompts/refactor.md (replaced by /ctx-refactor skill) MCP Prompts (internal/mcp/server/def/prompt/) are kept — those are the protocol-level equivalent per the 2026-03-06 decision and do not overlap with skills. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Deploying ctx with
|
| Latest commit: |
6d8de4c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f9ff6eb4.ctx-bhl.pages.dev |
| Branch Preview URL: | https://pr-45-resolve.ctx-bhl.pages.dev |
.context/sessions/ is not part of the ctx context hierarchy. The contributor's rebase notes are useful reference for the PR review but don't belong in the context directory. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
ctx skills are the source of truth. Copilot CLI skills with matching names are now generated from them (stripping the Claude Code-specific allowed-tools frontmatter key). - New sync script in the project scripts directory - make sync-copilot-skills: runs the sync (added to build deps) - make check-copilot-skills: drift check (added to audit target) - Copilot-only skills (ctx-compact, ctx-recall) with no ctx counterpart are left untouched - Synced ctx-status (42->100 lines), ctx-drift (41->251), ctx-next (34->150) from their full ctx versions Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Two renames that eliminate "hook" overloading: 1. CLI command: ctx hook → ctx setup "hook" has a specific meaning in ctx (PreToolUse/PostToolUse handlers). The setup command generates AI tool integration configs — it's not a hook. 2. Embedded assets: internal/assets/hooks/ → internal/assets/integrations/ Contains Copilot instructions, CLI scripts/skills, AGENTS.md templates, and hook message templates — all integration assets, not hooks themselves. Also fixed: string concatenation → path.Join in agent.go, renamed PathHookRegistry → PathMessageRegistry. Updated: Go source (constants, imports, package name, tests), YAML command definitions, 10+ doc files, VS Code extension, specs, architecture diagram. Released specs left as historical. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Hook message templates belong under hooks/ — they ARE the hook system's message templates. The previous commit over-corrected by moving them into integrations/. Now that the CLI command is "setup" (not "hook"), there's no naming collision. - assets/integrations/messages/ → assets/hooks/messages/ - Restore original Go import path and asset constants - Update embed directives and doc references Signed-off-by: Jose Alekhinne <jose@ctx.ist>
assets/overrides/vscode/ contained 4 context template files (AGENT_PLAYBOOK.md, CLAUDE.md, CONSTITUTION.md, CONVENTIONS.md) that were never embedded, never loaded, and never used by any code path. The caller parameter in ctx init skips PATH checks and interactive prompts — it does not select alternate templates. These would silently drift from the real templates with no detection mechanism. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Code quality cleanup of PR #45's vscode.go: Extract config constants: - New config/vscode/ package: Dir, file names, extension ID, JSON keys, task config values, task definitions - New config/file/ext.go: ExtSh, ExtPs1 - New config/flag: Caller flag constant - New config/embed/flag: DescKeyInitializeCaller with YAML entry Split monolithic vscode.go into focused files: - vscode.go: public CreateVSCodeArtifacts (orchestrator only) - extensions.go: writeExtensionsJSON with secure read (io.SafeReadUserFile) - tasks.go: writeTasksJSON with typed structs (no interface{}) - mcp.go: writeMCPJSON with typed structs Move terminal output to write layer: - New write/vscode/ package: InfoCreated, InfoExistsSkipped, InfoRecommendationExists, InfoAddManually, InfoWarnNonFatal Fix agent.go magic extensions: ".sh"/".ps1" -> file.ExtSh/file.ExtPs1 Fix cmd.go magic "caller" flag -> cFlag.Caller with YAML description Signed-off-by: Jose Alekhinne <jose@ctx.ist>
VS Code artifact files (vscode.go, extensions.go, tasks.go, mcp.go) were the only domain-specific files sitting directly in core/ instead of their own subdirectory. Moved to core/vscode/ to match the pattern of core/claude/, core/plugin/, core/merge/, etc. Also replaced magic '\n' byte appends with token.NewlineLF. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
copilot-instructions.md is Copilot-specific and doesn't belong at the integrations/ root alongside tool-agnostic files. Moved to integrations/copilot/ to match the integrations/copilot-cli/ pattern. agents.md stays at integrations/ root — it targets GitHub's AGENTS.md feature, which is tool-agnostic (not Copilot-specific). Filed task: sync CLAUDE.md, agents.md, and copilot-instructions.md from a single source template to prevent drift (all three convey the same instructions but have already diverged). Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Structural fixes: - Rename sessionevent/ → session_event/, extract Run() to run.go - Rename write/hook/ → write/setup/ (matches ctx setup command) - Extract vscode types to types.go (project convention) - Move osWindows to config/env.OSWindows (shared constant) Magic string extraction: - Governance thresholds → config/mcp/governance/ - Session event types/categories → config/event/ - VS Code output strings → YAML assets via desc.Text() - Session-event flag names → config/flag constants - MCP tool name → config/mcp/tool.SessionEvent - Violations filename → config/file.Violations New packages: - config/mcp/governance: DriftCheckInterval, PersistNudgeAfter/Repeat - config/vscode/doc.go: enriched package documentation - config/embed/text/vscode.go: write format string keys - write/vscode/testmain_test.go: lookup init for asset tests Convention alignment: - Enriched vscode/doc.go from two-liner to proper godoc - Private runSessionEvent → public Run() in own file - write/setup doc.go references ctx setup not ctx hook - All write/setup consumers updated (19 files) Signed-off-by: Jose Alekhinne <jose@ctx.ist>
vscode package: - Rename write* → create* (they create files, not terminal output) - Fix all docstrings to Parameters/Returns convention - Extract types to types.go with Fields blocks - Enrich config/vscode/doc.go package documentation - Add testmain_test.go for YAML asset lookup session_event package: - Extract all magic strings to YAML assets (commands, flags, errors) - fmt.Errorf → errSession.EventInvalidType (internal/err convention) - cmd.Println → wSession.Event (internal/write convention) - New config/embed/flag/system.go, config/embed/text/pause.go keys - New err/session, write/session packages copilot parsers: - Define symbolic constants for Kind values (0→Snapshot, 1→Scalar, 2→Object) - Add docstrings to all public types and methods - Extract repeated JSON keys to parser-internal constants - fmt.Errorf → errParser constructors in copilot_cli.go - Fix copilot_raw.go type and field documentation governance + dispatch: - Move all warning messages to YAML assets (6 DescKeyGov* keys) - Replace hardcoded MCP tool names with tool.* constants - Replace "---" with token.Separator, "..." with token.Ellipsis - Move appendGovernance to its own governance.go file - Fix all docstrings and type Fields blocks - Add testmain_test.go for YAML asset lookup Signed-off-by: Jose Alekhinne <jose@ctx.ist>
setup/cmd/root/run.go: - Fix Run() docstring: "hook command" → "setup command" - ensureVSCodeMCPJSON: replace magic strings with cfgVscode.* and mcpServer.* constants, cmd.Println → writeSetup.* - ensureCopilotCLIMCPConfig: replace magic "ctx", "local", "mcpServers", etc. with cfgHook.* and mcpServer.* constants, cmd.Println → writeSetup.*, '\n' → token.NewlineLF - Add Parameters/Returns blocks to all private function docstrings - Add testmain_test.go for YAML asset lookup vscode/mcp.go: - Replace "ctx"/"mcp"/"serve" with mcpServer.Name/Command/Args() config/mcp/server: - Add Command, SubcommandServe constants and Args() helper config/hook: - Add KeyMCPServers, MCPServerType, KeyType, KeyCommand, KeyArgs, KeyTools, ToolsWildcard for Copilot CLI MCP config JSON vscode package: - Rename write* → create* prefix (they create files, not output) - Fix all docstrings to Parameters/Returns convention - Enrich config/vscode/doc.go Signed-off-by: Jose Alekhinne <jose@ctx.ist>
run.go now contains only Run() — all deployment logic moved to domain-specific core packages under internal/cli/setup/core/: core/copilot/: - DeployInstructions (was WriteCopilotInstructions) - ensureVSCodeMCP helper (was ensureVSCodeMCPJSON) core/copilot_cli/: - DeployHooks (was WriteCopilotCLIHooks) - deployAgent, deployInstructions, deploySkills helpers - ensureMCPConfig (was ensureCopilotCLIMCPConfig) core/agents/: - Deploy (was WriteAgentsMd) Each package has doc.go. Tests moved to core/copilot/. "Write" prefix replaced with "Deploy" — these functions create integration files, not terminal output. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
- Move ensureVSCodeMCP from copilot.go to vscode.go (private methods do not colocate with public methods by convention) - Rename copilotcli.DeployHooks → copilotcli.Deploy (the package name provides context; "hooks" is overloaded with Claude Code hooks — this function deploys the full Copilot CLI integration) Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Replace hardcoded " (exists, skipped)" string concatenation with writeSetup.InfoCopilotCLISkipped in agent.go, instructions.go, and skills.go. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Refactor 548-line copilot.go into 5 focused files: - copilot_const.go: all constants (kind values, key paths, VS Code storage paths — 10 new constants extracted from magic strings) - copilot.go: public interface only (Copilot struct, NewCopilot, Tool, Matches, ParseFile, ParseLine, CopilotSessionDirs) - copilot_patch.go: private patch methods (applyScalarPatch, applyPatch, parseKeyPath) - copilot_build.go: private session building (buildSession, buildAssistantMessage, parseToolInvocation) - copilot_path.go: private path resolution (resolveWorkspaceCWD, fileURIToPath) No private methods colocated with public methods. All functions have proper godoc with Parameters/Returns blocks. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Add detail to RecordSessionStart, RecordContextWrite, and IncrementCallsSinceWrite — explain side effects (timestamp reset, counter reset, dispatch frequency). Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Rename extensions.go → extension.go (singular per convention). Extract magic binary sizes to copilot_const.go: - copilotScanBufInit (64KB), copilotScanBufMax (4MB), copilotScanBufMatchMax (1MB) — used in both copilot.go and copilot_cli.go Matches/ParseFile Extract magic values in copilot_build.go: - Preview truncation: session.PreviewMaxLen + token.Ellipsis - Tool ID split: copilotToolIDSeparator constant Fix copilot_cli.go: - Log file close error via warn.Warn instead of silently discarding - Scanner buffers use shared constants - Preview uses session.PreviewMaxLen + token.Ellipsis - Magic app name → copilotCLIAppName constant - All functions have full godoc with Parameters/Returns Fix governance.go docstrings (third revision): - RecordSessionStart, RecordContextLoaded, RecordDriftCheck, RecordContextWrite, IncrementCallsSinceWrite now have multi-line docstrings explaining behavior, side effects, and call sites Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Replace raw cmd.Println with writeErr.WarnFile using the cfgHook.FileMCPConfigJSON constant. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
All configurable constants extracted from parser/copilot_const.go to config/copilot/copilot.go: JSON keys, response kinds, scanner buffer sizes, VS Code storage paths, CLI app name, tool ID separator, session directory names. Only the wire-format Kind discriminators (0/1/2) remain in the parser as copilotKindSnapshot/ScalarPatch/ObjectPatch — these are parser-internal, not configurable. Also fixed copilot_cli.go magic "sessions"/"history" strings → cfgCopilot.DirSessions/DirHistory. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
- Move violation and violationsData types to types.go (convention) - Convert readAndClearViolations from receiver to plain function taking contextDir — it only uses that field, no State dependency - Extract to violations.go (private function in own file) - Clean up unused imports in governance.go Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Contributor
|
thanks mate ^^ ur the man! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey @bilersan — thanks for this massive contribution! The Copilot governance engine, VS Code extension, session parsers, and Copilot CLI integration are exactly the kind of multi-tool
support ctx needs.
I've resolved the merge conflicts (our recent refactoring marathons caused most of them) and done a code quality pass to align with current conventions. The changes are on pr-45-resolve
— here's what happened:
Merge resolution:
Cleanup (conventions alignment):
Also, resolve merge conflicts caused by recent refactoring on main:
recall → journal package rename: relocate copilot parser files
Type/constructor renames: CopilotParser → Copilot, SessionParser → Session
Function renames: CreateProjectDirs → CreateDirs, EnablePluginGlobally → EnableGlobally, HandleClaudeMd → HandleMd
Marker renames: CopilotMarkerStart → CopilotStart, add AgentsStart/AgentsEnd
log → log/event split: fix AppendEvent → event.Append
ValidateBoundary → Boundary, keep osWindows const
Grandfather PR's new cmd/ functions in compliance tests
Document sessionevent subcommand in system/doc.go
Take main's .context/ docs, combine .gitignore entries
Two follow-up tasks filed:
Nothing was removed from your feature.
it's all here, just reorganized to match the codebase as it stands today.
Continuity preserved.
Cognition persisted.
Evolution consisted.
Verification is our vibe.
🐟 .