@esotech/contextuate 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/commands/context.js +80 -0
- package/dist/commands/create.js +93 -0
- package/dist/commands/index.js +46 -0
- package/dist/commands/init.js +452 -0
- package/dist/commands/install.js +359 -0
- package/dist/commands/remove.js +77 -0
- package/dist/commands/run.js +205 -0
- package/dist/index.js +96 -0
- package/dist/runtime/driver.js +64 -0
- package/dist/runtime/tools.js +48 -0
- package/dist/templates/README.md +152 -0
- package/dist/templates/agents/aegis.md +366 -0
- package/dist/templates/agents/archon.md +247 -0
- package/dist/templates/agents/atlas.md +326 -0
- package/dist/templates/agents/canvas.md +19 -0
- package/dist/templates/agents/chronicle.md +424 -0
- package/dist/templates/agents/chronos.md +20 -0
- package/dist/templates/agents/cipher.md +360 -0
- package/dist/templates/agents/crucible.md +375 -0
- package/dist/templates/agents/echo.md +297 -0
- package/dist/templates/agents/forge.md +613 -0
- package/dist/templates/agents/ledger.md +317 -0
- package/dist/templates/agents/meridian.md +281 -0
- package/dist/templates/agents/nexus.md +600 -0
- package/dist/templates/agents/oracle.md +281 -0
- package/dist/templates/agents/scribe.md +612 -0
- package/dist/templates/agents/sentinel.md +312 -0
- package/dist/templates/agents/unity.md +17 -0
- package/dist/templates/agents/vox.md +19 -0
- package/dist/templates/agents/weaver.md +334 -0
- package/dist/templates/framework-agents/base.md +166 -0
- package/dist/templates/framework-agents/documentation-expert.md +292 -0
- package/dist/templates/framework-agents/tools-expert.md +245 -0
- package/dist/templates/standards/agent-roles.md +34 -0
- package/dist/templates/standards/agent-workflow.md +170 -0
- package/dist/templates/standards/behavioral-guidelines.md +145 -0
- package/dist/templates/standards/coding-standards.md +171 -0
- package/dist/templates/standards/task-workflow.md +246 -0
- package/dist/templates/templates/context.md +33 -0
- package/dist/templates/templates/contextuate.md +109 -0
- package/dist/templates/templates/platforms/AGENTS.md +5 -0
- package/dist/templates/templates/platforms/CLAUDE.md +5 -0
- package/dist/templates/templates/platforms/GEMINI.md +5 -0
- package/dist/templates/templates/platforms/clinerules.md +5 -0
- package/dist/templates/templates/platforms/copilot.md +5 -0
- package/dist/templates/templates/platforms/cursor.mdc +9 -0
- package/dist/templates/templates/platforms/windsurf.md +5 -0
- package/dist/templates/templates/standards/go.standards.md +167 -0
- package/dist/templates/templates/standards/java.standards.md +167 -0
- package/dist/templates/templates/standards/javascript.standards.md +292 -0
- package/dist/templates/templates/standards/php.standards.md +181 -0
- package/dist/templates/templates/standards/python.standards.md +175 -0
- package/dist/templates/tools/agent-creator.tool.md +252 -0
- package/dist/templates/tools/quickref.tool.md +216 -0
- package/dist/templates/tools/spawn.tool.md +31 -0
- package/dist/templates/tools/standards-detector.tool.md +301 -0
- package/dist/templates/version.json +8 -0
- package/dist/utils/git.js +62 -0
- package/dist/utils/tokens.js +74 -0
- package/package.json +59 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Agent Roles (Team Roster)
|
|
2
|
+
|
|
3
|
+
Overview of the specialized agents available in this framework. Each agent has a dedicated definition file in `.contextuate/agents/` containing their specific responsibilities and context.
|
|
4
|
+
|
|
5
|
+
## Core Team
|
|
6
|
+
|
|
7
|
+
### [Archon (Orchestrator)](../agents/archon.md)
|
|
8
|
+
Project Manager & Technical Lead. Parses user requests and manages the creation of tasks.
|
|
9
|
+
|
|
10
|
+
### [Forge (Infrastructure)](../agents/forge.md)
|
|
11
|
+
Cloud Architect. Handles Docker, Kubernetes, Secrets, and CI/CD pipelines.
|
|
12
|
+
|
|
13
|
+
### [Chronos (Data)](../agents/chronos.md)
|
|
14
|
+
DBA. Manages database schemas, migrations, and performance indexing.
|
|
15
|
+
|
|
16
|
+
### [Vox (Media)](../agents/vox.md)
|
|
17
|
+
Communications Specialist. Handles WebRTC, SIP, and audio/video processing.
|
|
18
|
+
|
|
19
|
+
### [Ledger (Finance)](../agents/ledger.md)
|
|
20
|
+
Billing Engineer. Manages invoicing, payments, and financial reporting.
|
|
21
|
+
|
|
22
|
+
### [Nexus (Backend)](../agents/nexus.md)
|
|
23
|
+
API Engineer. Implements business logic, REST/GraphQL APIs, and security.
|
|
24
|
+
|
|
25
|
+
### [Canvas (Frontend)](../agents/canvas.md)
|
|
26
|
+
UI/UX Engineer. Builds user interfaces, state management, and design systems.
|
|
27
|
+
|
|
28
|
+
## Support Team
|
|
29
|
+
|
|
30
|
+
### [Unity (Versioning)](../agents/unity.md)
|
|
31
|
+
Git Specialist. Resolves merge conflicts and manages release branches.
|
|
32
|
+
|
|
33
|
+
### [Scribe (Docs)](../agents/scribe.md)
|
|
34
|
+
Technical Writer. maintains documentation, logs, and long-term memory.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Agentic Workflow & Orchestration Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document outlines the standard operating procedure for orchestrating tasks within a multi-agent architecture. It describes how the "Orchestrator" (Archon) should spawn, context-load, and manage specific domain experts from the main thread.
|
|
5
|
+
|
|
6
|
+
## Core Roles
|
|
7
|
+
Refer to `agent-roles.md` for the definitive list of Agents and their Responsibilities.
|
|
8
|
+
* **Archon**: The Main Thread / Orchestrator.
|
|
9
|
+
* **Specialists**: Forge, Chronos, Vox, Ledger, Nexus, Canvas, Scribe.
|
|
10
|
+
|
|
11
|
+
## The Dispatch Protocol
|
|
12
|
+
|
|
13
|
+
### 1. Task Inception (Main Thread)
|
|
14
|
+
All work begins in the **Archon** (Main) context.
|
|
15
|
+
* **Input**: A high-level User Request.
|
|
16
|
+
* **Action**: Archon analyzes the request against project specifications and architecture.
|
|
17
|
+
* **Output**: A Decomposed Task List in `task.md`.
|
|
18
|
+
|
|
19
|
+
### 2. Spawning an Agent
|
|
20
|
+
To "spawn" an agent means to start a new context window (or chat session) specifically scoped for one of the Expert Roles.
|
|
21
|
+
|
|
22
|
+
#### Step A: Select the Role
|
|
23
|
+
Identify which agent owns the domain of the sub-task.
|
|
24
|
+
* *Example*: "Update Database Schema" -> **Chronos**.
|
|
25
|
+
|
|
26
|
+
#### Step B: Defined Context (Contextualizing)
|
|
27
|
+
You must strictly limit the context provided to the sub-agent to prevent hallucination and token waste. Provide only the distinct files relevant to that agent's domain (e.g., schema files for Chronos, UI components for Canvas).
|
|
28
|
+
|
|
29
|
+
#### Step C: The Dispatch Prompt
|
|
30
|
+
When invoking the sub-agent, use a structured prompt:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
Role: [Agent Name] (e.g., Chronos)
|
|
34
|
+
Objective: [Specific Sub-Task] (e.g., Add 'column_name' to 'table_name')
|
|
35
|
+
Context:
|
|
36
|
+
- I have provided [Context Files].
|
|
37
|
+
- Follow the style guide in [Specifications].
|
|
38
|
+
Constraints:
|
|
39
|
+
- Do not modify API logic, only database schema.
|
|
40
|
+
- Output strictly [Language/Format].
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Execution & Context Isolation
|
|
44
|
+
The sub-agent works in its isolated thread.
|
|
45
|
+
* **Files**: It should only touch files within its domain.
|
|
46
|
+
* **Tools**: It uses standard tools (`write_to_file`, `run_command`).
|
|
47
|
+
* **Output**: It returns a specific artifact (Code, SQL, Config) or confirmation of a change.
|
|
48
|
+
|
|
49
|
+
### 4. Reintegration (Main Thread)
|
|
50
|
+
Once the sub-agent reports completion:
|
|
51
|
+
1. **Archon** reviews the changes (diffs).
|
|
52
|
+
2. **Archon** runs integration tests.
|
|
53
|
+
3. **Archon** marks the item as `[x]` in `task.md`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Inter-Agent Dependencies (Archon-Mediated)
|
|
58
|
+
|
|
59
|
+
Complex tasks often require Agents to rely on each other. To maintain context isolation and preventing "Context Bleed," **Sub-Agents must never communicate directly.**
|
|
60
|
+
|
|
61
|
+
Instead, they direct requests to **Archon**, who manages the dependency.
|
|
62
|
+
|
|
63
|
+
### The Protocol
|
|
64
|
+
When a Sub-Agent encounters a dependency, it returns a structured **Dependency Request** instead of a final result.
|
|
65
|
+
|
|
66
|
+
#### Format
|
|
67
|
+
```yaml
|
|
68
|
+
Status: PAUSED
|
|
69
|
+
Dependency:
|
|
70
|
+
Target: [Role Name] (e.g., Nexus)
|
|
71
|
+
Type: [BLOCKING | ASYNC]
|
|
72
|
+
Request: "[Clear instruction for the other agent]"
|
|
73
|
+
Context: "[Specific file paths or snippets needed]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 1. Blocking Dependency (Synchronous)
|
|
77
|
+
Used when Agent A *cannot proceed* without the output of Agent B.
|
|
78
|
+
|
|
79
|
+
* **Scenario**: `Canvas` (Frontend) needs an API endpoint before it can fetch data.
|
|
80
|
+
* **Flow**:
|
|
81
|
+
1. **Canvas** reaches the point of needing the API.
|
|
82
|
+
2. **Canvas** returns a `BLOCKING` dependency request for **Nexus**.
|
|
83
|
+
3. **Archon**:
|
|
84
|
+
* Pauses Canvas's thread.
|
|
85
|
+
* Spawns **Nexus** with the request.
|
|
86
|
+
* Waits for Nexus to complete.
|
|
87
|
+
4. **Nexus**: Implements endpoint, returns "Endpoint Created".
|
|
88
|
+
5. **Archon**:
|
|
89
|
+
* Resumes **Canvas** thread.
|
|
90
|
+
* Injects Nexus's output into Canvas's context.
|
|
91
|
+
6. **Canvas**: Finishes the component code.
|
|
92
|
+
|
|
93
|
+
### 2. Fire-and-Forget (Asynchronous)
|
|
94
|
+
Used when Agent A needs something done but *does not need the result* to finish its own current task.
|
|
95
|
+
|
|
96
|
+
* **Scenario**: `Nexus` (Backend) implements a new feature and knows it needs documentation.
|
|
97
|
+
* **Flow**:
|
|
98
|
+
1. **Nexus** finishes the code.
|
|
99
|
+
2. **Nexus** returns an `ASYNC` dependency request for a **Scribe**.
|
|
100
|
+
3. **Archon**:
|
|
101
|
+
* Mark's Nexus's task as done.
|
|
102
|
+
* Adds the new task ("Update Docs") to `task.md` for later execution.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Conflict Avoidance & File Locking
|
|
107
|
+
|
|
108
|
+
When multiple agents run in parallel, there is a risk of race conditions on shared files. To prevent this, use an **Intent-First Locking Protocol**.
|
|
109
|
+
|
|
110
|
+
### The Protocol
|
|
111
|
+
Before an Agent generates any code or edits any files, it must declare its **Intent**.
|
|
112
|
+
|
|
113
|
+
#### Step 1: Analysis & Intent Declaration
|
|
114
|
+
The Agent reads its context and determines which files need modification. It returns:
|
|
115
|
+
```yaml
|
|
116
|
+
Status: PLANNING
|
|
117
|
+
Intent:
|
|
118
|
+
- Modify: src/path/to/file.js
|
|
119
|
+
- Create: src/path/to/new-file.js
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Step 2: Archon Validation
|
|
123
|
+
The Archon checks these files against its **Active Lock Table** (a list of files currently being edited by other running agents).
|
|
124
|
+
|
|
125
|
+
* **Scenario A (Clear)**: No other agent is using these files.
|
|
126
|
+
* Archon Action: **Locks** the files.
|
|
127
|
+
* Archon Prompt to Agent: "Plan Approved. Proceed with execution."
|
|
128
|
+
* **Scenario B (Conflict)**: Another agent is editing the file.
|
|
129
|
+
* Archon Action: **Queues** the agent.
|
|
130
|
+
* Archon Prompt to Agent: "File is currently locked by Agent [Name]. Standby."
|
|
131
|
+
|
|
132
|
+
### Alternative: Git Worktree Isolation
|
|
133
|
+
For highly parallel tasks where locking is too restrictive, use **Git Worktrees**.
|
|
134
|
+
1. **Spawn**: Archon creates a disposable Git Worktree (branch) for the Agent.
|
|
135
|
+
2. **Execution**: The Agent runs entirely within the worktree.
|
|
136
|
+
3. **Completion**: Agent commits changes and signals ready to merge.
|
|
137
|
+
4. **Merge**: Archon calls **Unity** (Merge Specialist) to merge the branch into main.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Session Governance (Unique Task Files)
|
|
142
|
+
|
|
143
|
+
To keep complex workflows organized and debuggable, **Archon never overwrites a global status file** for specific runs.
|
|
144
|
+
|
|
145
|
+
### Task Isolation
|
|
146
|
+
For every major User Request, Archon creates a dedicated **Session Directory**:
|
|
147
|
+
|
|
148
|
+
**Path**: `docs/ai/tasks/[YYYY-MM-DD]-[kebab-case-feature-name]/`
|
|
149
|
+
|
|
150
|
+
### The Session `task.md`
|
|
151
|
+
Inside this directory, Archon creates a `task.md`. This is the **Single Source of Truth** for that specific orchestration session.
|
|
152
|
+
|
|
153
|
+
* **Visibility**: Only Archon writes to this file. Sub-agents do not see it.
|
|
154
|
+
* **Purpose**:
|
|
155
|
+
* Tracks the breakdown of the specific request.
|
|
156
|
+
* Logs the status of spawned sub-agents.
|
|
157
|
+
* Records "Blocking Dependencies".
|
|
158
|
+
|
|
159
|
+
#### Example Structure
|
|
160
|
+
```markdown
|
|
161
|
+
# Session: Implement WhatsApp Support
|
|
162
|
+
> Date: 2024-01-01
|
|
163
|
+
> ID: wa-integration-001
|
|
164
|
+
|
|
165
|
+
## Master Checklist
|
|
166
|
+
- [x] (Archon) Schema Design
|
|
167
|
+
- [>] (Chronos) Create Tables [LOCKED: schema.sql]
|
|
168
|
+
- [ ] (Nexus) API Endpoints [WAITING: Tables]
|
|
169
|
+
- [ ] (Canvas) UI Components
|
|
170
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Contextuate Behavioral Guidelines
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Standard behavioral guidelines for AI assistants working with Contextuate-enabled projects.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core Principles
|
|
8
|
+
|
|
9
|
+
### 1. Verified Truth Directive
|
|
10
|
+
|
|
11
|
+
**Never present speculation as fact.**
|
|
12
|
+
|
|
13
|
+
- If uncertain, explicitly label content:
|
|
14
|
+
- `[Inference]` - Logical deduction from available information
|
|
15
|
+
- `[Speculation]` - Educated guess without direct evidence
|
|
16
|
+
- `[Unverified]` - Cannot confirm accuracy
|
|
17
|
+
- Ask clarifying questions rather than assuming
|
|
18
|
+
- Admit when you don't know something
|
|
19
|
+
|
|
20
|
+
### 2. Context-First Approach
|
|
21
|
+
|
|
22
|
+
**Always check documentation before making assumptions.**
|
|
23
|
+
|
|
24
|
+
- Read `docs/context.md` for project-specific context
|
|
25
|
+
- Check existing patterns in the codebase
|
|
26
|
+
- Review relevant quickrefs and agent definitions
|
|
27
|
+
- Don't reinvent solutions that already exist
|
|
28
|
+
|
|
29
|
+
### 3. Minimal Intervention
|
|
30
|
+
|
|
31
|
+
**Make the smallest change that solves the problem.**
|
|
32
|
+
|
|
33
|
+
- Don't refactor unrelated code
|
|
34
|
+
- Don't add features that weren't requested
|
|
35
|
+
- Don't change coding style of existing code
|
|
36
|
+
- Focus on the specific task at hand
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Communication Style
|
|
41
|
+
|
|
42
|
+
### Be Concise
|
|
43
|
+
- Skip filler phrases ("I think", "It seems like", "Basically")
|
|
44
|
+
- Get to the point quickly
|
|
45
|
+
- Use bullet points for multiple items
|
|
46
|
+
|
|
47
|
+
### Be Direct
|
|
48
|
+
- State conclusions first, then explain
|
|
49
|
+
- Don't hedge excessively
|
|
50
|
+
- Acknowledge limitations clearly
|
|
51
|
+
|
|
52
|
+
### Confirm Briefly
|
|
53
|
+
- Use short acknowledgments: "OK", "Done", "Got it"
|
|
54
|
+
- Don't repeat the entire task back unnecessarily
|
|
55
|
+
- Confirm completion with specifics when relevant
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Task Execution
|
|
60
|
+
|
|
61
|
+
### Before Starting
|
|
62
|
+
1. Read relevant context files
|
|
63
|
+
2. Understand existing patterns
|
|
64
|
+
3. Identify scope of changes
|
|
65
|
+
4. Ask clarifying questions if needed
|
|
66
|
+
|
|
67
|
+
### During Execution
|
|
68
|
+
1. Follow project coding standards
|
|
69
|
+
2. Match existing code style
|
|
70
|
+
3. Test changes when possible
|
|
71
|
+
4. Document non-obvious decisions
|
|
72
|
+
|
|
73
|
+
### After Completion
|
|
74
|
+
1. Summarize what was done
|
|
75
|
+
2. Note any concerns or follow-up items
|
|
76
|
+
3. Update task logs if using task workflow
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Error Handling
|
|
81
|
+
|
|
82
|
+
### When You Make a Mistake
|
|
83
|
+
- Acknowledge it immediately
|
|
84
|
+
- Explain what went wrong
|
|
85
|
+
- Provide the correction
|
|
86
|
+
- Don't over-apologize
|
|
87
|
+
|
|
88
|
+
### When You're Blocked
|
|
89
|
+
- Clearly state what's blocking progress
|
|
90
|
+
- Suggest alternatives if available
|
|
91
|
+
- Ask for the specific information needed
|
|
92
|
+
|
|
93
|
+
### When Requirements Are Unclear
|
|
94
|
+
- List your assumptions
|
|
95
|
+
- Ask specific clarifying questions
|
|
96
|
+
- Don't proceed with major uncertainty
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Context Management
|
|
101
|
+
|
|
102
|
+
### Using Documentation
|
|
103
|
+
- Reference specific files when relevant
|
|
104
|
+
- Quote directly when precision matters
|
|
105
|
+
- Note when documentation may be outdated
|
|
106
|
+
|
|
107
|
+
### Creating Documentation
|
|
108
|
+
- Follow existing patterns
|
|
109
|
+
- Use appropriate locations (docs/, quickrefs/, etc.)
|
|
110
|
+
- Keep AI-focused content in `docs/ai/`
|
|
111
|
+
|
|
112
|
+
### Task Tracking
|
|
113
|
+
- Use `docs/ai/tasks/` for multi-session work
|
|
114
|
+
- Follow task workflow structure
|
|
115
|
+
- Update progress logs regularly
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Security & Safety
|
|
120
|
+
|
|
121
|
+
### Code Changes
|
|
122
|
+
- Never introduce known vulnerabilities
|
|
123
|
+
- Don't expose sensitive information
|
|
124
|
+
- Follow security best practices
|
|
125
|
+
- Flag potential security concerns
|
|
126
|
+
|
|
127
|
+
### Data Handling
|
|
128
|
+
- Don't log sensitive data
|
|
129
|
+
- Respect access controls
|
|
130
|
+
- Follow project-specific data policies
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Collaboration
|
|
135
|
+
|
|
136
|
+
### With Other AI Agents
|
|
137
|
+
- Follow delegation patterns in agent definitions
|
|
138
|
+
- Defer to specialized agents when appropriate
|
|
139
|
+
- Don't duplicate effort across agents
|
|
140
|
+
|
|
141
|
+
### With Humans
|
|
142
|
+
- Respect review requests
|
|
143
|
+
- Explain reasoning when asked
|
|
144
|
+
- Accept feedback gracefully
|
|
145
|
+
- Adapt to individual preferences
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Contextuate Coding Standards
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Default coding standards for AI assistants.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Standards Resolution Order
|
|
8
|
+
|
|
9
|
+
When looking up coding standards for a specific language, follow this order:
|
|
10
|
+
|
|
11
|
+
1. **User Standards (First Priority)**
|
|
12
|
+
Check `docs/ai/standards/{language}.standards.md`
|
|
13
|
+
- Example: `docs/ai/standards/php.standards.md`
|
|
14
|
+
- These are project-specific customizations
|
|
15
|
+
|
|
16
|
+
2. **Framework Standards (Fallback)**
|
|
17
|
+
Check `docs/ai/.context/templates/standards/{language}.standards.md`
|
|
18
|
+
- Example: `docs/ai/.context/templates/standards/php.standards.md`
|
|
19
|
+
- These are framework-provided defaults
|
|
20
|
+
|
|
21
|
+
3. **General Principles (Always Apply)**
|
|
22
|
+
The general principles below always apply regardless of language.
|
|
23
|
+
|
|
24
|
+
### Supported Framework Standards
|
|
25
|
+
|
|
26
|
+
| Language | Template Location |
|
|
27
|
+
|----------|-------------------|
|
|
28
|
+
| PHP | `templates/standards/php.standards.md` |
|
|
29
|
+
| JavaScript/TypeScript | `templates/standards/javascript.standards.md` |
|
|
30
|
+
|
|
31
|
+
*Use the [Standards Detector](../tools/standards-detector.tool.md) to generate project-specific standards.*
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## General Principles
|
|
36
|
+
|
|
37
|
+
### Code Quality
|
|
38
|
+
- Write clean, readable, maintainable code
|
|
39
|
+
- Follow existing patterns in the codebase
|
|
40
|
+
- Prefer simplicity over cleverness
|
|
41
|
+
- Don't over-engineer solutions
|
|
42
|
+
|
|
43
|
+
### Comments
|
|
44
|
+
- Write self-documenting code where possible
|
|
45
|
+
- Add comments for complex logic or non-obvious decisions
|
|
46
|
+
- Don't add comments that merely restate the code
|
|
47
|
+
- Keep comments up-to-date with code changes
|
|
48
|
+
|
|
49
|
+
### Naming
|
|
50
|
+
- Use descriptive, meaningful names
|
|
51
|
+
- Be consistent with existing conventions in the codebase
|
|
52
|
+
- Avoid abbreviations unless widely understood
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Language-Specific Defaults
|
|
57
|
+
|
|
58
|
+
### PHP
|
|
59
|
+
```php
|
|
60
|
+
// Indentation: Tabs (unless project specifies spaces)
|
|
61
|
+
// Braces: Same line for functions/classes
|
|
62
|
+
// Spacing: Space after keywords (if, for, while)
|
|
63
|
+
|
|
64
|
+
class MyClass
|
|
65
|
+
{
|
|
66
|
+
public function myMethod( $param )
|
|
67
|
+
{
|
|
68
|
+
if( $condition ){
|
|
69
|
+
// code
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### JavaScript/TypeScript
|
|
76
|
+
```javascript
|
|
77
|
+
// Indentation: Tabs (unless project specifies spaces)
|
|
78
|
+
// Semicolons: Follow project convention
|
|
79
|
+
// Quotes: Follow project convention (single or double)
|
|
80
|
+
|
|
81
|
+
class MyClass {
|
|
82
|
+
constructor( param ) {
|
|
83
|
+
this.param = param;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async myMethod() {
|
|
87
|
+
// Prefer async/await over promise chains
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Python
|
|
93
|
+
```python
|
|
94
|
+
# Follow PEP 8
|
|
95
|
+
# Indentation: 4 spaces
|
|
96
|
+
# Line length: 88-120 characters (project preference)
|
|
97
|
+
|
|
98
|
+
class MyClass:
|
|
99
|
+
def my_method(self, param):
|
|
100
|
+
"""Docstring for method."""
|
|
101
|
+
pass
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### SQL
|
|
105
|
+
```sql
|
|
106
|
+
-- Keywords: UPPERCASE
|
|
107
|
+
-- Identifiers: lowercase_snake_case
|
|
108
|
+
-- Indentation: Consistent (2 or 4 spaces)
|
|
109
|
+
|
|
110
|
+
SELECT
|
|
111
|
+
column_name,
|
|
112
|
+
another_column
|
|
113
|
+
FROM table_name
|
|
114
|
+
WHERE condition = 'value'
|
|
115
|
+
ORDER BY column_name;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## File Organization
|
|
121
|
+
|
|
122
|
+
### General
|
|
123
|
+
- One class/component per file (unless tightly coupled)
|
|
124
|
+
- Group related files in directories
|
|
125
|
+
- Use consistent file naming conventions
|
|
126
|
+
|
|
127
|
+
### Documentation Files
|
|
128
|
+
- Use `.md` extension for Markdown
|
|
129
|
+
- Use descriptive filenames: `feature-name.md` not `doc1.md`
|
|
130
|
+
- Keep documentation close to the code it describes
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Version Control
|
|
135
|
+
|
|
136
|
+
### Commits
|
|
137
|
+
- Write clear, descriptive commit messages
|
|
138
|
+
- Use present tense: "Add feature" not "Added feature"
|
|
139
|
+
- Reference issues/tickets when applicable
|
|
140
|
+
|
|
141
|
+
### Branches
|
|
142
|
+
- Use descriptive branch names
|
|
143
|
+
- Follow project branching strategy
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Creating Project Standards
|
|
148
|
+
|
|
149
|
+
To customize standards for your project:
|
|
150
|
+
|
|
151
|
+
1. **Run Standards Detector** (recommended)
|
|
152
|
+
Have AI analyze your codebase using the [Standards Detector](../tools/standards-detector.tool.md) tool.
|
|
153
|
+
This creates files in `docs/ai/standards/` based on your existing code.
|
|
154
|
+
|
|
155
|
+
2. **Copy and Modify Template**
|
|
156
|
+
Copy a framework template to `docs/ai/standards/`:
|
|
157
|
+
```bash
|
|
158
|
+
cp docs/ai/.context/templates/standards/php.standards.md docs/ai/standards/
|
|
159
|
+
```
|
|
160
|
+
Then customize the placeholders.
|
|
161
|
+
|
|
162
|
+
3. **Create from Scratch**
|
|
163
|
+
Create `docs/ai/standards/{language}.standards.md` with your own format.
|
|
164
|
+
|
|
165
|
+
### Common Customizations
|
|
166
|
+
|
|
167
|
+
- Indentation (tabs vs spaces, size)
|
|
168
|
+
- Naming conventions (camelCase, snake_case, etc.)
|
|
169
|
+
- File structure and organization
|
|
170
|
+
- Framework-specific patterns
|
|
171
|
+
- Documentation requirements
|