|
1 | 1 | # Copilot Instructions for ash-studio VS Code Extension |
2 | 2 |
|
| 3 | +## Quick Reference & Table of Contents |
| 4 | + |
| 5 | +- [Project Overview](#project-overview) |
| 6 | +- [Architecture & Patterns](#architecture--patterns) |
| 7 | +- [Developer Workflows](#developer-workflows) |
| 8 | +- [Project Conventions](#project-conventions) |
| 9 | +- [Integration Points](#integration-points) |
| 10 | +- [AI Coding Preferences](#ai-coding-preferences) |
| 11 | +- [Modularization & Interface-Driven Architecture](#modularization--interface-driven-architecture) |
| 12 | +- [Build & Test After Each Change](#build--test-after-each-change) |
| 13 | +- [Release Process](RELEASE.md) |
| 14 | +- [Contributing Guidelines](CONTRIBUTING.md) |
| 15 | + |
3 | 16 | ## Project Overview |
4 | 17 |
|
5 | 18 | - This is a VS Code extension to enhance development for the Ash Framework (Elixir). |
|
55 | 68 | - No external APIs or services; all logic is local to the extension. |
56 | 69 | - Relies on VS Code extension API and Elixir language configuration. |
57 | 70 |
|
58 | | -## Examples |
59 | | - |
60 | | -- See `src/ashSidebarProvider.ts` for sidebar logic and section detail display. |
61 | | -- See `src/ashSectionUtils.ts` and `src/ashSectionDetailUtils.ts` for block and section detail |
62 | | - parsing. |
63 | | -- See `feature-plan.md` for current and planned features. |
64 | | - |
65 | 71 | ## AI Coding Preferences |
66 | 72 |
|
67 | | -- **Prefer declarative approaches over inferred/heuristic logic.** |
68 | | - - For example, always use explicit fields (like a `command` property) in configuration and data |
69 | | - structures, rather than inferring intent from names, titles, or other heuristics. |
70 | | - - This ensures maintainability, clarity, and reduces ambiguity for both humans and AI agents. |
71 | | - |
72 | | -- **Design semantic APIs and service interfaces.** |
73 | | - - Method names and parameters should express the caller's intent, not implementation details. |
74 | | - - For example, use `getBlockStartLineNumber()` and `getBlockEndLineNumber()` instead of |
75 | | - `getLineNumber()` and `getLineNumberFromRegexMatch()`. |
76 | | - - The caller should not need to understand internal implementation quirks (like regex match |
77 | | - positions including newlines) to use the API correctly. |
78 | | - - Service boundaries should be based on domain concepts, not technical implementation details. |
79 | | - - Function signatures should make the purpose and usage clear without requiring knowledge of |
80 | | - internal algorithms or data structures. |
81 | | - |
82 | | -- **Favor pipeline-style processing with helper functions.** |
83 | | - - When implementing logic that involves filtering, mapping, or transforming collections, prefer a |
84 | | - pipeline of array methods (`filter`, `map`, `flatMap`, etc.) with small, well-named helper |
85 | | - functions for each transformation step. |
86 | | - - This style should resemble Elixir's `Enum` pipelines: break up complex logic into a series of |
87 | | - focused, composable steps. |
88 | | - - Avoid deeply nested loops or imperative code when a pipeline with helpers would be clearer. |
89 | | - - Use early returns and guard clauses in helpers to keep each step focused and readable. |
90 | | - - Example: Instead of a large nested loop, use chained array methods and extract the innermost |
91 | | - logic into a named function. |
| 73 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for AI coding preferences and detailed development |
| 74 | +guidelines. |
92 | 75 |
|
93 | 76 | ## Modularization & Interface-Driven Architecture |
94 | 77 |
|
|
101 | 84 | private. |
102 | 85 | - When adding new features, first define the interface and types, then implement the logic. |
103 | 86 |
|
104 | | -## Commenting and Documentation Guidance |
105 | | - |
106 | | -- **Prefer comprehensive source code documentation over separate markdown files.** |
107 | | - - Write detailed JSDoc comments for all public classes, methods, and interfaces. |
108 | | - - Focus on explaining WHAT the code does and HOW it works in its current state. |
109 | | - - Document the purpose, responsibilities, and behavior of each component. |
110 | | - - Include architectural patterns and design decisions that are currently in use. |
111 | | - - Document complex algorithms, business logic, and non-obvious implementation details inline. |
112 | | - |
113 | | -- **Source code should be self-documenting:** |
114 | | - - Comments should explain the "what" and "how" of current functionality. |
115 | | - - Include examples of usage in JSDoc when helpful. |
116 | | - - Document parameters, return types, and thrown exceptions thoroughly. |
117 | | - - Add comments explaining any non-trivial regex patterns, algorithms, or workarounds. |
118 | | - - Reference related methods/classes in comments when there are important relationships. |
119 | | - - Explain the architecture and responsibilities of each service/class. |
120 | | - |
121 | | -- **Avoid redundant external documentation:** |
122 | | - - Don't create separate markdown files that duplicate information better captured in code |
123 | | - comments. |
124 | | - - Keep README files focused on setup, overview, and getting started. |
125 | | - - Use inline documentation for implementation details, API usage, and architectural notes. |
126 | | - |
127 | | -- **Maintenance guidelines for comments:** |
128 | | - - Do not leave comments about obsolete or deprecated functionality in the codebase. |
129 | | - - Avoid lengthy refactoring history or "before/after" comparisons in comments. |
130 | | - - Always update or rewrite comments to reflect the current, intended functionality and usage. |
131 | | - - Remove files that are no longer needed, rather than leaving placeholders or deprecation notes. |
132 | | - - Documentation and comments should help future maintainers understand the present state and |
133 | | - current architecture. |
134 | | - |
135 | 87 | ## Build & Test After Each Change |
136 | 88 |
|
137 | 89 | - After making any code change (especially refactors or type/interface moves), always: |
|
142 | 94 | - When a test fails and the cause is unclear, ask for clarification. Sometimes the source is wrong, |
143 | 95 | sometimes the test is wrong—ask for help to determine which. |
144 | 96 |
|
145 | | -## General Development Guidelines |
146 | | - |
147 | | -- **Use Class-Based Registries and Singletons:** |
148 | | - For shared registries or service-like modules, define a class with clear public methods and export |
149 | | - a singleton instance. This approach improves testability, extensibility, and aligns with familiar |
150 | | - patterns from C# and Elixir. |
151 | | - |
152 | | -- **Centralize Shared Types and Interfaces:** |
153 | | - Move all shared interfaces and types to a dedicated types file (e.g., `src/types/ash.ts`). Update |
154 | | - all imports to use these centralized definitions, and ensure only the shared types module exports |
155 | | - them. |
156 | | - |
157 | | -- **Separate Pure Logic from VS Code Integration:** |
158 | | - Keep parsing, data modeling, and utility logic free of VS Code API dependencies. Place all VS |
159 | | - Code-dependent code (such as providers, commands, and UI) in a dedicated directory (e.g., |
160 | | - `src/features/`). |
161 | | - |
162 | | -- **Define Clear Public and Private APIs:** |
163 | | - Only export public interfaces and functions. Mark helpers and internal functions as private or |
164 | | - leave them unexported. |
165 | | - |
166 | | -- **Document Module Boundaries and APIs:** |
167 | | - Add module-level comments describing the public API and intended usage for each module. |
168 | | - |
169 | | -- **Maintain and Expand Tests:** |
170 | | - Ensure tests import only public APIs. Add or expand unit tests for pure logic modules, especially |
171 | | - when extracting or refactoring types and interfaces. |
172 | | - |
173 | | -- **Keep Documentation Up to Date:** |
174 | | - Revise documentation files to reflect the current structure and conventions after any significant |
175 | | - change. |
176 | | - |
177 | | -- **Build and Test After Every Change:** |
178 | | - Run all tests (`npm test`) after any code change. Fix all errors and warnings before proceeding. |
| 97 | +For the full release workflow, see [RELEASE.md](RELEASE.md). For detailed contribution and |
| 98 | +documentation guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md). |
0 commit comments