opencode-plugin-team-agreements 0.1.4 → 0.2.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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +15 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -519
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +49 -57
- package/dist/index.test.js.map +1 -1
- package/dist/utils.d.ts +58 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +572 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0](https://github.com/jwilger/opencode-plugin-team-agreements/compare/opencode-plugin-team-agreements-v0.1.4...opencode-plugin-team-agreements-v0.2.0) (2026-01-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* Team agreements are now stored in AGENTS.md (or CLAUDE.md as fallback) in the project root instead of docs/TEAM_AGREEMENTS.md
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* Use AGENTS.md for team agreements instead of docs/TEAM_AGREEMENTS.md ([#15](https://github.com/jwilger/opencode-plugin-team-agreements/issues/15)) ([00365ab](https://github.com/jwilger/opencode-plugin-team-agreements/commit/00365ab4d17f0cd4e22c2731f12fd6875d5b01e1))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* Only export plugin function to prevent OpenCode crash ([#13](https://github.com/jwilger/opencode-plugin-team-agreements/issues/13)) ([d4f5930](https://github.com/jwilger/opencode-plugin-team-agreements/commit/d4f5930e0620d490b3fae635275130309f1fcfc0))
|
|
18
|
+
|
|
3
19
|
## [0.1.4](https://github.com/jwilger/opencode-plugin-team-agreements/compare/opencode-plugin-team-agreements-v0.1.3...opencode-plugin-team-agreements-v0.1.4) (2026-01-23)
|
|
4
20
|
|
|
5
21
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,23 @@
|
|
|
1
|
-
import { type Plugin } from "@opencode-ai/plugin";
|
|
2
|
-
declare const PLUGIN_REPO = "jwilger/opencode-plugin-team-agreements";
|
|
3
|
-
declare const COMMAND_TEMPLATE = "You are helping establish or review team agreements for this project. Team agreements define how humans and LLM agents collaborate on the codebase.\n\nUser's request: $ARGUMENTS\n\n## Instructions\n\n1. First, check if team agreements already exist at `docs/TEAM_AGREEMENTS.md`\n\n2. If agreements exist, present the user with options:\n - **Review**: Display the current agreements\n - **Amend**: Modify a specific section \n - **Start Over**: Begin fresh (with confirmation)\n\n3. If no agreements exist (or starting over), guide the user through establishing agreements one topic at a time. Start with these core topics:\n\n### Core Topics\n\n#### a. Storage Location\nAsk where team agreements should be stored. Suggest defaults:\n- Main file: `docs/TEAM_AGREEMENTS.md`\n- Supporting details: `docs/team_agreements/*.md`\n\n#### b. Programming Languages\n- What programming language(s) will be used in this project?\n- What is each language used for? (e.g., TypeScript for frontend, Rust for backend)\n- Are there specific versions or language-specific style guides to follow?\n\n#### c. Code Quality Standards\n- What does \"great code\" look like for this team?\n- How should we prioritize: readability vs. performance vs. simplicity?\n- Are there required patterns or anti-patterns to follow/avoid?\n- What about error handling conventions?\n- Naming conventions for files, functions, variables, types?\n\n#### d. Commit Message Conventions\n- What format should commit messages follow? (Conventional Commits, custom, freeform)\n- Are there required elements? (ticket numbers, scope, breaking change indicators)\n- Any rules on length, tense, capitalization?\n- Should commits be atomic (one logical change per commit)?\n\n#### e. Integration Workflow\n- Trunk-based development or feature branches?\n- Pull request requirements? (reviews, approvals, CI checks)\n- Who can merge to main/trunk?\n- What CI checks must pass before integration?\n- Any branch naming conventions?\n\n#### f. Testing Requirements\n- What testing is required before code is considered \"done\"?\n- Are there coverage thresholds?\n- What types of tests? (unit, integration, e2e, property-based)\n- When should tests be written? (TDD, after implementation, etc.)\n\n#### g. Amendment Process\n- How can these agreements be changed?\n- Who has authority to propose/approve changes?\n- What's the review/approval process for amendments?\n- How should changes be communicated to the team?\n\n4. For each topic:\n - Ask ONE question at a time\n - Discuss trade-offs when relevant\n - Confirm understanding before moving on\n - Record the team's decision clearly\n\n5. **After the core topics**, ask:\n \"Are there any additional topics you'd like to establish agreements for?\"\n \n Suggest potential additional topics if helpful:\n - **Architecture decisions** - How to document and track ADRs\n - **Dependency management** - How to evaluate and approve new dependencies\n - **Documentation standards** - What must be documented, where, in what format\n - **LLM autonomy boundaries** - What can LLMs do without asking? What requires human approval?\n - **Session handoff protocols** - How to summarize work for the next session/agent\n - **Code review process** - What reviewers should look for, turnaround expectations\n - **Planning and work breakdown** - How to break down work into tasks\n - **Information sharing** - How to share context across sessions and team members\n \n Continue asking about each additional topic the user wants to cover.\n \n After discussing additional topics, ask: \"Would you like to suggest any of these additional topics\n (or others you thought of) to be included as standard topics in the team-agreements plugin?\n I can file a GitHub issue for you if you'd like.\"\n \n If the user wants to suggest a topic, use the `suggest_team_agreement_topic` tool to file an issue.\n\n6. After ALL topics (core + additional) are covered:\n - Generate `docs/TEAM_AGREEMENTS.md` with all agreements organized by topic\n - If any topic needs detailed documentation, create supporting files in `docs/team_agreements/`\n - Update `opencode.json` to include `docs/TEAM_AGREEMENTS.md` in the `instructions` array\n - Summarize what was established\n\n7. **After generating the agreements**, use the `detect_enforcement_mechanisms` tool to check what enforcement is already in place, then offer to set up automatic enforcement for agreements that can be enforced programmatically.\n\n For each agreement that CAN be automatically enforced, ask the user if they'd like help setting it up. Here are the enforcement mechanisms to consider:\n\n ### Enforcement Mechanisms\n\n #### OpenCode Plugin Hooks\n Ideal for: LLM behavior guidance, context injection, custom commands\n - Can add validation in `tool.execute.before` hooks\n - Can transform messages via `experimental.chat.messages.transform`\n - Can inject reminders in `experimental.session.compacting`\n\n #### Pre-commit Hooks (husky, lefthook, pre-commit)\n Ideal for: Commit message validation, code formatting, linting, test execution\n - **Commit messages**: Use commitlint with husky for Conventional Commits or custom formats\n - **Code formatting**: Run prettier/eslint/biome on staged files\n - **Tests**: Run affected tests before allowing commits\n - **File restrictions**: Prevent commits to certain paths\n\n #### CI Workflows (GitHub Actions, etc.)\n Ideal for: Test coverage, build verification, security scanning, PR checks\n - **Testing requirements**: Enforce coverage thresholds, run full test suites\n - **Code quality**: Run linters, type checking, security audits\n - **Build verification**: Ensure the project builds successfully\n - **PR requirements**: Block merging until checks pass\n\n #### GitHub Rulesets / Branch Protection\n Ideal for: PR requirements, review policies, merge restrictions\n - **Required reviews**: Set minimum approvals before merge\n - **Required checks**: Specify which CI checks must pass\n - **Branch restrictions**: Control who can push to main/protected branches\n - **Commit signing**: Require verified commits\n\n #### Linting Rules (.eslintrc, biome.json, etc.)\n Ideal for: Code style, naming conventions, import organization, complexity limits\n - **Naming conventions**: Enforce variable/function/file naming patterns\n - **Code patterns**: Require/forbid certain coding patterns\n - **Import organization**: Enforce import ordering and restrictions\n\n ### Mapping Agreements to Enforcement\n\n | Agreement Topic | Possible Enforcement |\n |-----------------|---------------------|\n | Commit message conventions | commitlint + husky, GitHub Actions check |\n | Code quality standards | ESLint/Biome rules, pre-commit hooks, CI checks |\n | Testing requirements | CI workflow with coverage thresholds, pre-commit test runs |\n | Integration workflow | GitHub rulesets, required status checks, PR templates |\n | Programming language standards | Language-specific linters, compiler flags |\n\n ### When Offering Enforcement\n\n - Only offer enforcement for agreements that can actually be automated\n - Explain what the enforcement will do and how it works\n - Get explicit confirmation before making changes\n - If enforcement tooling already exists (detected by the tool), offer to update/extend it rather than replace it\n - Document what enforcement was set up in the TEAM_AGREEMENTS.md file\n\n## Output Format\n\nWhen generating the TEAM_AGREEMENTS.md file, use this structure:\n\n```markdown\n# Team Agreements\n\nThis document defines how our team (humans and LLM agents) collaborates on this codebase.\n\n## Table of Contents\n[Generate based on topics covered]\n\n## 1. Storage Location\n[Agreements about where documentation lives]\n\n## 2. Programming Languages\n[Agreements about languages and their usage]\n\n## 3. Code Quality Standards\n[Agreements about what makes good code]\n\n## 4. Commit Message Conventions\n[Agreements about commit message format]\n\n## 5. Integration Workflow\n[Agreements about how code gets integrated]\n\n## 6. Testing Requirements\n[Agreements about testing]\n\n## 7. Amendment Process\n[Agreements about changing these agreements]\n\n## Additional Topics\n[Any additional topics the team added]\n\n---\n*Last updated: [date]*\n*To amend these agreements, [process from amendment section]*\n```\n\n## Important\n\n- Be conversational and collaborative\n- ONE question at a time - don't overwhelm\n- Respect the user's expertise and preferences\n- If the user provides a specific request in their message, address that first\n- The core topics are a starting point, not an exhaustive list\n- Capture the \"why\" behind decisions, not just the \"what\"";
|
|
4
|
-
/**
|
|
5
|
-
* Check if a file exists at the given path.
|
|
6
|
-
*/
|
|
7
|
-
export declare function fileExists(path: string): Promise<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Check if the gh CLI is installed and authenticated.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isGhAvailable(): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Load team agreements from the project directory.
|
|
14
|
-
* Returns the content if found, null otherwise.
|
|
15
|
-
*/
|
|
16
|
-
export declare function loadTeamAgreements(directory: string): Promise<string | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Format suggested questions as a markdown list.
|
|
19
|
-
*/
|
|
20
|
-
export declare function formatQuestionsAsMarkdown(questions: string[]): string;
|
|
21
|
-
/**
|
|
22
|
-
* Build the issue body for a topic suggestion.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildTopicIssueBody(args: {
|
|
25
|
-
topic_name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
suggested_questions: string[];
|
|
28
|
-
example_agreement?: string;
|
|
29
|
-
}): string;
|
|
30
|
-
/**
|
|
31
|
-
* Enforcement mechanism detection result.
|
|
32
|
-
*/
|
|
33
|
-
export interface EnforcementMechanism {
|
|
34
|
-
type: string;
|
|
35
|
-
name: string;
|
|
36
|
-
detected: boolean;
|
|
37
|
-
configFile?: string;
|
|
38
|
-
notes?: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Detect existing enforcement mechanisms in the project.
|
|
42
|
-
*/
|
|
43
|
-
export declare function detectEnforcementMechanisms(directory: string): Promise<EnforcementMechanism[]>;
|
|
44
1
|
/**
|
|
45
|
-
*
|
|
2
|
+
* OpenCode Team Agreements Plugin
|
|
3
|
+
*
|
|
4
|
+
* Helps teams establish and maintain shared agreements for human-LLM collaboration.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: Only the plugin function should be exported from this module.
|
|
7
|
+
* OpenCode's plugin loader iterates through all exports and tries to call each
|
|
8
|
+
* one as a plugin function. Exporting non-function values (like strings or objects)
|
|
9
|
+
* will cause a crash.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
46
12
|
*/
|
|
47
|
-
|
|
48
|
-
export { COMMAND_TEMPLATE, PLUGIN_REPO };
|
|
13
|
+
import { type Plugin } from "@opencode-ai/plugin";
|
|
49
14
|
/**
|
|
50
15
|
* TeamAgreementsPlugin - Helps teams establish and maintain shared agreements
|
|
51
16
|
* for human-LLM collaboration on a codebase.
|
|
17
|
+
*
|
|
18
|
+
* Team agreements are stored in AGENTS.md (or CLAUDE.md as fallback) in the
|
|
19
|
+
* project root. These files are automatically loaded by OpenCode and Claude Code,
|
|
20
|
+
* so no config injection is needed.
|
|
52
21
|
*/
|
|
53
22
|
export declare const TeamAgreementsPlugin: Plugin;
|
|
54
23
|
export default TeamAgreementsPlugin;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAA;AAavD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAwGlC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,522 +1,32 @@
|
|
|
1
|
-
import { tool } from "@opencode-ai/plugin";
|
|
2
|
-
import { readFile, access } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { exec } from "child_process";
|
|
5
|
-
import { promisify } from "util";
|
|
6
|
-
const execAsync = promisify(exec);
|
|
7
|
-
const PLUGIN_REPO = "jwilger/opencode-plugin-team-agreements";
|
|
8
|
-
const COMMAND_TEMPLATE = `You are helping establish or review team agreements for this project. Team agreements define how humans and LLM agents collaborate on the codebase.
|
|
9
|
-
|
|
10
|
-
User's request: $ARGUMENTS
|
|
11
|
-
|
|
12
|
-
## Instructions
|
|
13
|
-
|
|
14
|
-
1. First, check if team agreements already exist at \`docs/TEAM_AGREEMENTS.md\`
|
|
15
|
-
|
|
16
|
-
2. If agreements exist, present the user with options:
|
|
17
|
-
- **Review**: Display the current agreements
|
|
18
|
-
- **Amend**: Modify a specific section
|
|
19
|
-
- **Start Over**: Begin fresh (with confirmation)
|
|
20
|
-
|
|
21
|
-
3. If no agreements exist (or starting over), guide the user through establishing agreements one topic at a time. Start with these core topics:
|
|
22
|
-
|
|
23
|
-
### Core Topics
|
|
24
|
-
|
|
25
|
-
#### a. Storage Location
|
|
26
|
-
Ask where team agreements should be stored. Suggest defaults:
|
|
27
|
-
- Main file: \`docs/TEAM_AGREEMENTS.md\`
|
|
28
|
-
- Supporting details: \`docs/team_agreements/*.md\`
|
|
29
|
-
|
|
30
|
-
#### b. Programming Languages
|
|
31
|
-
- What programming language(s) will be used in this project?
|
|
32
|
-
- What is each language used for? (e.g., TypeScript for frontend, Rust for backend)
|
|
33
|
-
- Are there specific versions or language-specific style guides to follow?
|
|
34
|
-
|
|
35
|
-
#### c. Code Quality Standards
|
|
36
|
-
- What does "great code" look like for this team?
|
|
37
|
-
- How should we prioritize: readability vs. performance vs. simplicity?
|
|
38
|
-
- Are there required patterns or anti-patterns to follow/avoid?
|
|
39
|
-
- What about error handling conventions?
|
|
40
|
-
- Naming conventions for files, functions, variables, types?
|
|
41
|
-
|
|
42
|
-
#### d. Commit Message Conventions
|
|
43
|
-
- What format should commit messages follow? (Conventional Commits, custom, freeform)
|
|
44
|
-
- Are there required elements? (ticket numbers, scope, breaking change indicators)
|
|
45
|
-
- Any rules on length, tense, capitalization?
|
|
46
|
-
- Should commits be atomic (one logical change per commit)?
|
|
47
|
-
|
|
48
|
-
#### e. Integration Workflow
|
|
49
|
-
- Trunk-based development or feature branches?
|
|
50
|
-
- Pull request requirements? (reviews, approvals, CI checks)
|
|
51
|
-
- Who can merge to main/trunk?
|
|
52
|
-
- What CI checks must pass before integration?
|
|
53
|
-
- Any branch naming conventions?
|
|
54
|
-
|
|
55
|
-
#### f. Testing Requirements
|
|
56
|
-
- What testing is required before code is considered "done"?
|
|
57
|
-
- Are there coverage thresholds?
|
|
58
|
-
- What types of tests? (unit, integration, e2e, property-based)
|
|
59
|
-
- When should tests be written? (TDD, after implementation, etc.)
|
|
60
|
-
|
|
61
|
-
#### g. Amendment Process
|
|
62
|
-
- How can these agreements be changed?
|
|
63
|
-
- Who has authority to propose/approve changes?
|
|
64
|
-
- What's the review/approval process for amendments?
|
|
65
|
-
- How should changes be communicated to the team?
|
|
66
|
-
|
|
67
|
-
4. For each topic:
|
|
68
|
-
- Ask ONE question at a time
|
|
69
|
-
- Discuss trade-offs when relevant
|
|
70
|
-
- Confirm understanding before moving on
|
|
71
|
-
- Record the team's decision clearly
|
|
72
|
-
|
|
73
|
-
5. **After the core topics**, ask:
|
|
74
|
-
"Are there any additional topics you'd like to establish agreements for?"
|
|
75
|
-
|
|
76
|
-
Suggest potential additional topics if helpful:
|
|
77
|
-
- **Architecture decisions** - How to document and track ADRs
|
|
78
|
-
- **Dependency management** - How to evaluate and approve new dependencies
|
|
79
|
-
- **Documentation standards** - What must be documented, where, in what format
|
|
80
|
-
- **LLM autonomy boundaries** - What can LLMs do without asking? What requires human approval?
|
|
81
|
-
- **Session handoff protocols** - How to summarize work for the next session/agent
|
|
82
|
-
- **Code review process** - What reviewers should look for, turnaround expectations
|
|
83
|
-
- **Planning and work breakdown** - How to break down work into tasks
|
|
84
|
-
- **Information sharing** - How to share context across sessions and team members
|
|
85
|
-
|
|
86
|
-
Continue asking about each additional topic the user wants to cover.
|
|
87
|
-
|
|
88
|
-
After discussing additional topics, ask: "Would you like to suggest any of these additional topics
|
|
89
|
-
(or others you thought of) to be included as standard topics in the team-agreements plugin?
|
|
90
|
-
I can file a GitHub issue for you if you'd like."
|
|
91
|
-
|
|
92
|
-
If the user wants to suggest a topic, use the \`suggest_team_agreement_topic\` tool to file an issue.
|
|
93
|
-
|
|
94
|
-
6. After ALL topics (core + additional) are covered:
|
|
95
|
-
- Generate \`docs/TEAM_AGREEMENTS.md\` with all agreements organized by topic
|
|
96
|
-
- If any topic needs detailed documentation, create supporting files in \`docs/team_agreements/\`
|
|
97
|
-
- Update \`opencode.json\` to include \`docs/TEAM_AGREEMENTS.md\` in the \`instructions\` array
|
|
98
|
-
- Summarize what was established
|
|
99
|
-
|
|
100
|
-
7. **After generating the agreements**, use the \`detect_enforcement_mechanisms\` tool to check what enforcement is already in place, then offer to set up automatic enforcement for agreements that can be enforced programmatically.
|
|
101
|
-
|
|
102
|
-
For each agreement that CAN be automatically enforced, ask the user if they'd like help setting it up. Here are the enforcement mechanisms to consider:
|
|
103
|
-
|
|
104
|
-
### Enforcement Mechanisms
|
|
105
|
-
|
|
106
|
-
#### OpenCode Plugin Hooks
|
|
107
|
-
Ideal for: LLM behavior guidance, context injection, custom commands
|
|
108
|
-
- Can add validation in \`tool.execute.before\` hooks
|
|
109
|
-
- Can transform messages via \`experimental.chat.messages.transform\`
|
|
110
|
-
- Can inject reminders in \`experimental.session.compacting\`
|
|
111
|
-
|
|
112
|
-
#### Pre-commit Hooks (husky, lefthook, pre-commit)
|
|
113
|
-
Ideal for: Commit message validation, code formatting, linting, test execution
|
|
114
|
-
- **Commit messages**: Use commitlint with husky for Conventional Commits or custom formats
|
|
115
|
-
- **Code formatting**: Run prettier/eslint/biome on staged files
|
|
116
|
-
- **Tests**: Run affected tests before allowing commits
|
|
117
|
-
- **File restrictions**: Prevent commits to certain paths
|
|
118
|
-
|
|
119
|
-
#### CI Workflows (GitHub Actions, etc.)
|
|
120
|
-
Ideal for: Test coverage, build verification, security scanning, PR checks
|
|
121
|
-
- **Testing requirements**: Enforce coverage thresholds, run full test suites
|
|
122
|
-
- **Code quality**: Run linters, type checking, security audits
|
|
123
|
-
- **Build verification**: Ensure the project builds successfully
|
|
124
|
-
- **PR requirements**: Block merging until checks pass
|
|
125
|
-
|
|
126
|
-
#### GitHub Rulesets / Branch Protection
|
|
127
|
-
Ideal for: PR requirements, review policies, merge restrictions
|
|
128
|
-
- **Required reviews**: Set minimum approvals before merge
|
|
129
|
-
- **Required checks**: Specify which CI checks must pass
|
|
130
|
-
- **Branch restrictions**: Control who can push to main/protected branches
|
|
131
|
-
- **Commit signing**: Require verified commits
|
|
132
|
-
|
|
133
|
-
#### Linting Rules (.eslintrc, biome.json, etc.)
|
|
134
|
-
Ideal for: Code style, naming conventions, import organization, complexity limits
|
|
135
|
-
- **Naming conventions**: Enforce variable/function/file naming patterns
|
|
136
|
-
- **Code patterns**: Require/forbid certain coding patterns
|
|
137
|
-
- **Import organization**: Enforce import ordering and restrictions
|
|
138
|
-
|
|
139
|
-
### Mapping Agreements to Enforcement
|
|
140
|
-
|
|
141
|
-
| Agreement Topic | Possible Enforcement |
|
|
142
|
-
|-----------------|---------------------|
|
|
143
|
-
| Commit message conventions | commitlint + husky, GitHub Actions check |
|
|
144
|
-
| Code quality standards | ESLint/Biome rules, pre-commit hooks, CI checks |
|
|
145
|
-
| Testing requirements | CI workflow with coverage thresholds, pre-commit test runs |
|
|
146
|
-
| Integration workflow | GitHub rulesets, required status checks, PR templates |
|
|
147
|
-
| Programming language standards | Language-specific linters, compiler flags |
|
|
148
|
-
|
|
149
|
-
### When Offering Enforcement
|
|
150
|
-
|
|
151
|
-
- Only offer enforcement for agreements that can actually be automated
|
|
152
|
-
- Explain what the enforcement will do and how it works
|
|
153
|
-
- Get explicit confirmation before making changes
|
|
154
|
-
- If enforcement tooling already exists (detected by the tool), offer to update/extend it rather than replace it
|
|
155
|
-
- Document what enforcement was set up in the TEAM_AGREEMENTS.md file
|
|
156
|
-
|
|
157
|
-
## Output Format
|
|
158
|
-
|
|
159
|
-
When generating the TEAM_AGREEMENTS.md file, use this structure:
|
|
160
|
-
|
|
161
|
-
\`\`\`markdown
|
|
162
|
-
# Team Agreements
|
|
163
|
-
|
|
164
|
-
This document defines how our team (humans and LLM agents) collaborates on this codebase.
|
|
165
|
-
|
|
166
|
-
## Table of Contents
|
|
167
|
-
[Generate based on topics covered]
|
|
168
|
-
|
|
169
|
-
## 1. Storage Location
|
|
170
|
-
[Agreements about where documentation lives]
|
|
171
|
-
|
|
172
|
-
## 2. Programming Languages
|
|
173
|
-
[Agreements about languages and their usage]
|
|
174
|
-
|
|
175
|
-
## 3. Code Quality Standards
|
|
176
|
-
[Agreements about what makes good code]
|
|
177
|
-
|
|
178
|
-
## 4. Commit Message Conventions
|
|
179
|
-
[Agreements about commit message format]
|
|
180
|
-
|
|
181
|
-
## 5. Integration Workflow
|
|
182
|
-
[Agreements about how code gets integrated]
|
|
183
|
-
|
|
184
|
-
## 6. Testing Requirements
|
|
185
|
-
[Agreements about testing]
|
|
186
|
-
|
|
187
|
-
## 7. Amendment Process
|
|
188
|
-
[Agreements about changing these agreements]
|
|
189
|
-
|
|
190
|
-
## Additional Topics
|
|
191
|
-
[Any additional topics the team added]
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
*Last updated: [date]*
|
|
195
|
-
*To amend these agreements, [process from amendment section]*
|
|
196
|
-
\`\`\`
|
|
197
|
-
|
|
198
|
-
## Important
|
|
199
|
-
|
|
200
|
-
- Be conversational and collaborative
|
|
201
|
-
- ONE question at a time - don't overwhelm
|
|
202
|
-
- Respect the user's expertise and preferences
|
|
203
|
-
- If the user provides a specific request in their message, address that first
|
|
204
|
-
- The core topics are a starting point, not an exhaustive list
|
|
205
|
-
- Capture the "why" behind decisions, not just the "what"`;
|
|
206
|
-
/**
|
|
207
|
-
* Check if a file exists at the given path.
|
|
208
|
-
*/
|
|
209
|
-
export async function fileExists(path) {
|
|
210
|
-
try {
|
|
211
|
-
await access(path);
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Check if the gh CLI is installed and authenticated.
|
|
220
|
-
*/
|
|
221
|
-
export async function isGhAvailable() {
|
|
222
|
-
try {
|
|
223
|
-
await execAsync("gh auth status");
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
catch {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Load team agreements from the project directory.
|
|
232
|
-
* Returns the content if found, null otherwise.
|
|
233
|
-
*/
|
|
234
|
-
export async function loadTeamAgreements(directory) {
|
|
235
|
-
const defaultPath = join(directory, "docs", "TEAM_AGREEMENTS.md");
|
|
236
|
-
try {
|
|
237
|
-
const content = await readFile(defaultPath, "utf-8");
|
|
238
|
-
return `## Team Agreements\n\nThe following team agreements are in effect for this project:\n\n${content}`;
|
|
239
|
-
}
|
|
240
|
-
catch {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Format suggested questions as a markdown list.
|
|
246
|
-
*/
|
|
247
|
-
export function formatQuestionsAsMarkdown(questions) {
|
|
248
|
-
return questions.map((q) => `- ${q}`).join("\n");
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Build the issue body for a topic suggestion.
|
|
252
|
-
*/
|
|
253
|
-
export function buildTopicIssueBody(args) {
|
|
254
|
-
const questionsFormatted = formatQuestionsAsMarkdown(args.suggested_questions);
|
|
255
|
-
return `## Topic Name
|
|
256
|
-
${args.topic_name}
|
|
257
|
-
|
|
258
|
-
## Description
|
|
259
|
-
${args.description}
|
|
260
|
-
|
|
261
|
-
## Suggested Questions
|
|
262
|
-
${questionsFormatted}
|
|
263
|
-
|
|
264
|
-
## Example Agreement
|
|
265
|
-
${args.example_agreement || "_No example provided_"}
|
|
266
|
-
|
|
267
|
-
## Additional Context
|
|
268
|
-
_This issue was automatically created via the team-agreements plugin._`;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Detect existing enforcement mechanisms in the project.
|
|
272
|
-
*/
|
|
273
|
-
export async function detectEnforcementMechanisms(directory) {
|
|
274
|
-
const mechanisms = [];
|
|
275
|
-
// Pre-commit hooks
|
|
276
|
-
const huskyPath = join(directory, ".husky");
|
|
277
|
-
const lefthookPath = join(directory, "lefthook.yml");
|
|
278
|
-
const lefthookAltPath = join(directory, ".lefthook.yml");
|
|
279
|
-
const preCommitPath = join(directory, ".pre-commit-config.yaml");
|
|
280
|
-
if (await fileExists(huskyPath)) {
|
|
281
|
-
mechanisms.push({
|
|
282
|
-
type: "pre-commit",
|
|
283
|
-
name: "husky",
|
|
284
|
-
detected: true,
|
|
285
|
-
configFile: ".husky/",
|
|
286
|
-
notes: "Git hooks manager for Node.js projects",
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
if (await fileExists(lefthookPath)) {
|
|
290
|
-
mechanisms.push({
|
|
291
|
-
type: "pre-commit",
|
|
292
|
-
name: "lefthook",
|
|
293
|
-
detected: true,
|
|
294
|
-
configFile: "lefthook.yml",
|
|
295
|
-
notes: "Fast, cross-platform git hooks manager",
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
else if (await fileExists(lefthookAltPath)) {
|
|
299
|
-
mechanisms.push({
|
|
300
|
-
type: "pre-commit",
|
|
301
|
-
name: "lefthook",
|
|
302
|
-
detected: true,
|
|
303
|
-
configFile: ".lefthook.yml",
|
|
304
|
-
notes: "Fast, cross-platform git hooks manager",
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
if (await fileExists(preCommitPath)) {
|
|
308
|
-
mechanisms.push({
|
|
309
|
-
type: "pre-commit",
|
|
310
|
-
name: "pre-commit",
|
|
311
|
-
detected: true,
|
|
312
|
-
configFile: ".pre-commit-config.yaml",
|
|
313
|
-
notes: "Python-based pre-commit framework",
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
// Commit message validation
|
|
317
|
-
const commitlintPath = join(directory, "commitlint.config.js");
|
|
318
|
-
const commitlintCjsPath = join(directory, "commitlint.config.cjs");
|
|
319
|
-
const commitlintJsonPath = join(directory, ".commitlintrc.json");
|
|
320
|
-
if ((await fileExists(commitlintPath)) ||
|
|
321
|
-
(await fileExists(commitlintCjsPath)) ||
|
|
322
|
-
(await fileExists(commitlintJsonPath))) {
|
|
323
|
-
mechanisms.push({
|
|
324
|
-
type: "commit-validation",
|
|
325
|
-
name: "commitlint",
|
|
326
|
-
detected: true,
|
|
327
|
-
configFile: (await fileExists(commitlintPath))
|
|
328
|
-
? "commitlint.config.js"
|
|
329
|
-
: (await fileExists(commitlintCjsPath))
|
|
330
|
-
? "commitlint.config.cjs"
|
|
331
|
-
: ".commitlintrc.json",
|
|
332
|
-
notes: "Lint commit messages against conventional commit format",
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
// Linters
|
|
336
|
-
const eslintPath = join(directory, ".eslintrc.json");
|
|
337
|
-
const eslintJsPath = join(directory, "eslint.config.js");
|
|
338
|
-
const eslintMjsPath = join(directory, "eslint.config.mjs");
|
|
339
|
-
const biomePath = join(directory, "biome.json");
|
|
340
|
-
const biomeJsoncPath = join(directory, "biome.jsonc");
|
|
341
|
-
if ((await fileExists(eslintPath)) ||
|
|
342
|
-
(await fileExists(eslintJsPath)) ||
|
|
343
|
-
(await fileExists(eslintMjsPath))) {
|
|
344
|
-
mechanisms.push({
|
|
345
|
-
type: "linter",
|
|
346
|
-
name: "eslint",
|
|
347
|
-
detected: true,
|
|
348
|
-
configFile: (await fileExists(eslintPath))
|
|
349
|
-
? ".eslintrc.json"
|
|
350
|
-
: (await fileExists(eslintJsPath))
|
|
351
|
-
? "eslint.config.js"
|
|
352
|
-
: "eslint.config.mjs",
|
|
353
|
-
notes: "JavaScript/TypeScript linter",
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
if ((await fileExists(biomePath)) || (await fileExists(biomeJsoncPath))) {
|
|
357
|
-
mechanisms.push({
|
|
358
|
-
type: "linter",
|
|
359
|
-
name: "biome",
|
|
360
|
-
detected: true,
|
|
361
|
-
configFile: (await fileExists(biomePath)) ? "biome.json" : "biome.jsonc",
|
|
362
|
-
notes: "Fast formatter and linter for JS/TS/JSON",
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
// CI Workflows
|
|
366
|
-
const githubWorkflowsPath = join(directory, ".github", "workflows");
|
|
367
|
-
if (await fileExists(githubWorkflowsPath)) {
|
|
368
|
-
mechanisms.push({
|
|
369
|
-
type: "ci",
|
|
370
|
-
name: "github-actions",
|
|
371
|
-
detected: true,
|
|
372
|
-
configFile: ".github/workflows/",
|
|
373
|
-
notes: "GitHub Actions CI/CD workflows",
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
const gitlabCiPath = join(directory, ".gitlab-ci.yml");
|
|
377
|
-
if (await fileExists(gitlabCiPath)) {
|
|
378
|
-
mechanisms.push({
|
|
379
|
-
type: "ci",
|
|
380
|
-
name: "gitlab-ci",
|
|
381
|
-
detected: true,
|
|
382
|
-
configFile: ".gitlab-ci.yml",
|
|
383
|
-
notes: "GitLab CI/CD pipeline",
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
const circleCiPath = join(directory, ".circleci", "config.yml");
|
|
387
|
-
if (await fileExists(circleCiPath)) {
|
|
388
|
-
mechanisms.push({
|
|
389
|
-
type: "ci",
|
|
390
|
-
name: "circleci",
|
|
391
|
-
detected: true,
|
|
392
|
-
configFile: ".circleci/config.yml",
|
|
393
|
-
notes: "CircleCI pipeline",
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
// PR Templates
|
|
397
|
-
const prTemplatePath = join(directory, ".github", "pull_request_template.md");
|
|
398
|
-
const prTemplateAltPath = join(directory, ".github", "PULL_REQUEST_TEMPLATE.md");
|
|
399
|
-
if ((await fileExists(prTemplatePath)) || (await fileExists(prTemplateAltPath))) {
|
|
400
|
-
mechanisms.push({
|
|
401
|
-
type: "pr-template",
|
|
402
|
-
name: "github-pr-template",
|
|
403
|
-
detected: true,
|
|
404
|
-
configFile: (await fileExists(prTemplatePath))
|
|
405
|
-
? ".github/pull_request_template.md"
|
|
406
|
-
: ".github/PULL_REQUEST_TEMPLATE.md",
|
|
407
|
-
notes: "GitHub Pull Request template",
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
// OpenCode configuration
|
|
411
|
-
const opencodePath = join(directory, "opencode.json");
|
|
412
|
-
if (await fileExists(opencodePath)) {
|
|
413
|
-
mechanisms.push({
|
|
414
|
-
type: "opencode",
|
|
415
|
-
name: "opencode-config",
|
|
416
|
-
detected: true,
|
|
417
|
-
configFile: "opencode.json",
|
|
418
|
-
notes: "OpenCode configuration with hooks and plugins",
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
// Formatters
|
|
422
|
-
const prettierPath = join(directory, ".prettierrc");
|
|
423
|
-
const prettierJsonPath = join(directory, ".prettierrc.json");
|
|
424
|
-
const prettierJsPath = join(directory, "prettier.config.js");
|
|
425
|
-
if ((await fileExists(prettierPath)) ||
|
|
426
|
-
(await fileExists(prettierJsonPath)) ||
|
|
427
|
-
(await fileExists(prettierJsPath))) {
|
|
428
|
-
mechanisms.push({
|
|
429
|
-
type: "formatter",
|
|
430
|
-
name: "prettier",
|
|
431
|
-
detected: true,
|
|
432
|
-
configFile: (await fileExists(prettierPath))
|
|
433
|
-
? ".prettierrc"
|
|
434
|
-
: (await fileExists(prettierJsonPath))
|
|
435
|
-
? ".prettierrc.json"
|
|
436
|
-
: "prettier.config.js",
|
|
437
|
-
notes: "Code formatter for JS/TS/CSS/HTML/JSON/MD",
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return mechanisms;
|
|
441
|
-
}
|
|
442
1
|
/**
|
|
443
|
-
*
|
|
2
|
+
* OpenCode Team Agreements Plugin
|
|
3
|
+
*
|
|
4
|
+
* Helps teams establish and maintain shared agreements for human-LLM collaboration.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: Only the plugin function should be exported from this module.
|
|
7
|
+
* OpenCode's plugin loader iterates through all exports and tries to call each
|
|
8
|
+
* one as a plugin function. Exporting non-function values (like strings or objects)
|
|
9
|
+
* will cause a crash.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
444
12
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
return `## Detected Enforcement Mechanisms
|
|
448
|
-
|
|
449
|
-
No existing enforcement mechanisms detected. This is a great opportunity to set up automation for your team agreements!
|
|
450
|
-
|
|
451
|
-
### Available Options
|
|
452
|
-
|
|
453
|
-
You can set up any of the following:
|
|
454
|
-
|
|
455
|
-
**Pre-commit Hooks**
|
|
456
|
-
- husky (Node.js projects)
|
|
457
|
-
- lefthook (cross-platform, fast)
|
|
458
|
-
- pre-commit (Python-based, language-agnostic)
|
|
459
|
-
|
|
460
|
-
**Commit Message Validation**
|
|
461
|
-
- commitlint (conventional commits)
|
|
462
|
-
|
|
463
|
-
**Linting/Formatting**
|
|
464
|
-
- ESLint (JavaScript/TypeScript)
|
|
465
|
-
- Biome (JS/TS/JSON, fast)
|
|
466
|
-
- Prettier (formatting)
|
|
467
|
-
|
|
468
|
-
**CI/CD**
|
|
469
|
-
- GitHub Actions
|
|
470
|
-
- GitLab CI
|
|
471
|
-
- CircleCI
|
|
472
|
-
|
|
473
|
-
**GitHub Features**
|
|
474
|
-
- Pull Request templates
|
|
475
|
-
- Branch protection rulesets`;
|
|
476
|
-
}
|
|
477
|
-
const byType = {};
|
|
478
|
-
for (const m of mechanisms) {
|
|
479
|
-
if (!byType[m.type])
|
|
480
|
-
byType[m.type] = [];
|
|
481
|
-
byType[m.type].push(m);
|
|
482
|
-
}
|
|
483
|
-
let result = `## Detected Enforcement Mechanisms
|
|
484
|
-
|
|
485
|
-
The following enforcement mechanisms are already in place:\n\n`;
|
|
486
|
-
const typeLabels = {
|
|
487
|
-
"pre-commit": "Pre-commit Hooks",
|
|
488
|
-
"commit-validation": "Commit Message Validation",
|
|
489
|
-
linter: "Linters",
|
|
490
|
-
ci: "CI/CD Pipelines",
|
|
491
|
-
"pr-template": "PR Templates",
|
|
492
|
-
opencode: "OpenCode Configuration",
|
|
493
|
-
formatter: "Formatters",
|
|
494
|
-
};
|
|
495
|
-
for (const [type, mechs] of Object.entries(byType)) {
|
|
496
|
-
result += `### ${typeLabels[type] || type}\n\n`;
|
|
497
|
-
for (const m of mechs) {
|
|
498
|
-
result += `- **${m.name}** (\`${m.configFile}\`): ${m.notes}\n`;
|
|
499
|
-
}
|
|
500
|
-
result += "\n";
|
|
501
|
-
}
|
|
502
|
-
result += `### Recommendations
|
|
503
|
-
|
|
504
|
-
Based on what's already set up, consider extending or integrating with these existing tools rather than adding new ones.`;
|
|
505
|
-
return result;
|
|
506
|
-
}
|
|
507
|
-
// Export constants for testing
|
|
508
|
-
export { COMMAND_TEMPLATE, PLUGIN_REPO };
|
|
13
|
+
import { tool } from "@opencode-ai/plugin";
|
|
14
|
+
import { COMMAND_TEMPLATE, PLUGIN_REPO, isGhAvailable, loadTeamAgreements, buildTopicIssueBody, detectEnforcementMechanisms, formatEnforcementResults, execAsync, } from "./utils.js";
|
|
509
15
|
/**
|
|
510
16
|
* TeamAgreementsPlugin - Helps teams establish and maintain shared agreements
|
|
511
17
|
* for human-LLM collaboration on a codebase.
|
|
18
|
+
*
|
|
19
|
+
* Team agreements are stored in AGENTS.md (or CLAUDE.md as fallback) in the
|
|
20
|
+
* project root. These files are automatically loaded by OpenCode and Claude Code,
|
|
21
|
+
* so no config injection is needed.
|
|
512
22
|
*/
|
|
513
23
|
export const TeamAgreementsPlugin = async (ctx) => {
|
|
514
24
|
const { directory } = ctx;
|
|
515
|
-
const agreementsPath = "docs/TEAM_AGREEMENTS.md";
|
|
516
|
-
const fullAgreementsPath = join(directory, agreementsPath);
|
|
517
25
|
return {
|
|
518
26
|
/**
|
|
519
|
-
*
|
|
27
|
+
* Register the /team-agreements command.
|
|
28
|
+
* Note: We no longer inject AGENTS.md into instructions because OpenCode
|
|
29
|
+
* automatically loads it from the project root.
|
|
520
30
|
*/
|
|
521
31
|
config: async (config) => {
|
|
522
32
|
// Add the /team-agreements command
|
|
@@ -527,16 +37,6 @@ export const TeamAgreementsPlugin = async (ctx) => {
|
|
|
527
37
|
description: "Establish or review team agreements for human-LLM collaboration",
|
|
528
38
|
template: COMMAND_TEMPLATE,
|
|
529
39
|
};
|
|
530
|
-
// If agreements file exists, ensure it's in instructions
|
|
531
|
-
if (await fileExists(fullAgreementsPath)) {
|
|
532
|
-
if (!config.instructions) {
|
|
533
|
-
config.instructions = [];
|
|
534
|
-
}
|
|
535
|
-
const instructions = config.instructions;
|
|
536
|
-
if (!instructions.includes(agreementsPath)) {
|
|
537
|
-
instructions.unshift(agreementsPath); // Add at beginning for priority
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
40
|
},
|
|
541
41
|
/**
|
|
542
42
|
* Tools for team agreements management
|