@everydaydevops/opencode-typescript-linting 1.0.2 → 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/install.js +47 -39
- package/package.json +14 -43
- package/README.md +0 -84
- package/agent/typescript-linting.md +0 -143
package/install.js
CHANGED
|
@@ -3,48 +3,56 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
|
+
const {
|
|
7
|
+
buildOpenCodeFormat
|
|
8
|
+
} = require('@everydaydevops/typescript-linting-core');
|
|
6
9
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Determine if this is a global installation
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Determine the target directory based on installation type
|
|
15
|
-
let targetDir;
|
|
16
|
-
if (isGlobalInstall) {
|
|
17
|
-
// Global install: use ~/.config/opencode/agent
|
|
18
|
-
targetDir = path.join(os.homedir(), '.config', 'opencode', 'agent');
|
|
19
|
-
} else {
|
|
20
|
-
// Local install: use .opencode/ in the project directory
|
|
21
|
-
// npm_config_local_prefix points to the project root during npm install
|
|
10
|
+
const AGENT_FILENAME = 'typescript-linting.md';
|
|
11
|
+
|
|
12
|
+
function install() {
|
|
13
|
+
// Determine if this is a global installation
|
|
14
|
+
const isGlobalInstall = process.env.npm_config_global === 'true';
|
|
15
|
+
|
|
16
|
+
// Get project root for local installs
|
|
22
17
|
const projectRoot = process.env.npm_config_local_prefix || process.cwd();
|
|
23
|
-
targetDir = path.join(projectRoot, '.opencode');
|
|
24
|
-
}
|
|
25
18
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
// Determine target directory
|
|
20
|
+
const targetDir = isGlobalInstall
|
|
21
|
+
? path.join(os.homedir(), '.config', 'opencode', 'agent')
|
|
22
|
+
: path.join(projectRoot, '.opencode');
|
|
23
|
+
|
|
24
|
+
const targetFile = path.join(targetDir, AGENT_FILENAME);
|
|
25
|
+
|
|
26
|
+
// Create directory if needed
|
|
27
|
+
if (!fs.existsSync(targetDir)) {
|
|
28
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Build and write the agent file
|
|
32
|
+
try {
|
|
33
|
+
const content = buildOpenCodeFormat();
|
|
34
|
+
fs.writeFileSync(targetFile, content);
|
|
35
|
+
|
|
36
|
+
console.log('OpenCode TypeScript Linting agent installed successfully!');
|
|
37
|
+
console.log(` Installed to: ${targetFile}`);
|
|
38
|
+
console.log(` Installation type: ${isGlobalInstall ? 'global' : 'local'}`);
|
|
39
|
+
console.log('');
|
|
40
|
+
console.log('Usage:');
|
|
41
|
+
console.log(' Run "opencode" in any TypeScript project');
|
|
42
|
+
console.log(' Then use: @typescript-linting help me set up linting');
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(
|
|
45
|
+
'Failed to install OpenCode TypeScript Linting agent:',
|
|
46
|
+
error.message
|
|
47
|
+
);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
29
51
|
}
|
|
30
52
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
fs.copyFileSync(sourceFile, targetFile);
|
|
36
|
-
console.log('TypeScript Linting agent installed successfully!');
|
|
37
|
-
console.log(` Installed to: ${targetFile}`);
|
|
38
|
-
console.log(` Installation type: ${isGlobalInstall ? 'global' : 'local'}`);
|
|
39
|
-
console.log('\nUsage:');
|
|
40
|
-
console.log(' Run "opencode" in any TypeScript project');
|
|
41
|
-
console.log(' The typescript-linting subagent will be available');
|
|
42
|
-
console.log(
|
|
43
|
-
' Primary agents can invoke it automatically for linting setup tasks'
|
|
44
|
-
);
|
|
45
|
-
console.log('\nManual invocation:');
|
|
46
|
-
console.log(' @typescript-linting help me set up linting for this project');
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error('Failed to install TypeScript Linting agent:', error.message);
|
|
49
|
-
process.exit(1);
|
|
53
|
+
// Run if this is the main module
|
|
54
|
+
if (require.main === module) {
|
|
55
|
+
install();
|
|
50
56
|
}
|
|
57
|
+
|
|
58
|
+
module.exports = { install };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everydaydevops/opencode-typescript-linting",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "OpenCode agent for implementing TypeScript linting and code formatting following Everyday DevOps best practices",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -9,64 +9,35 @@
|
|
|
9
9
|
"eslint",
|
|
10
10
|
"prettier",
|
|
11
11
|
"linting",
|
|
12
|
-
"formatting"
|
|
12
|
+
"formatting",
|
|
13
|
+
"ai-agent"
|
|
13
14
|
],
|
|
14
15
|
"author": "Mark C Allen <mark@markcallen.com>",
|
|
15
16
|
"license": "MIT",
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent.git"
|
|
19
|
+
"url": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent.git",
|
|
20
|
+
"directory": "packages/opencode"
|
|
19
21
|
},
|
|
20
22
|
"homepage": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent#readme",
|
|
21
23
|
"bugs": {
|
|
22
24
|
"url": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent/issues"
|
|
23
25
|
},
|
|
24
26
|
"files": [
|
|
25
|
-
"install.js"
|
|
26
|
-
"agent/",
|
|
27
|
-
"README.md",
|
|
28
|
-
"LICENSE"
|
|
27
|
+
"install.js"
|
|
29
28
|
],
|
|
30
|
-
"
|
|
31
|
-
"@
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
33
|
-
"@typescript-eslint/parser": "^8.50.1",
|
|
34
|
-
"eslint": "^9.39.2",
|
|
35
|
-
"eslint-config-prettier": "^10.1.8",
|
|
36
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
37
|
-
"globals": "^16.5.0",
|
|
38
|
-
"husky": "^9.1.7",
|
|
39
|
-
"jest": "^29.7.0",
|
|
40
|
-
"lint-staged": "^16.2.7",
|
|
41
|
-
"prettier": "^3.7.4",
|
|
42
|
-
"tsc-files": "^1.1.4",
|
|
43
|
-
"typescript": "^5.9.3",
|
|
44
|
-
"typescript-eslint": "^8.50.1"
|
|
45
|
-
},
|
|
46
|
-
"lint-staged": {
|
|
47
|
-
"**/*.js": [
|
|
48
|
-
"prettier --write",
|
|
49
|
-
"eslint --fix"
|
|
50
|
-
],
|
|
51
|
-
"**/*.ts": [
|
|
52
|
-
"tsc-files --noEmit",
|
|
53
|
-
"prettier --write",
|
|
54
|
-
"eslint --fix"
|
|
55
|
-
],
|
|
56
|
-
"**/*.{json,md,yaml,yml}": [
|
|
57
|
-
"prettier --write"
|
|
58
|
-
]
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@everydaydevops/typescript-linting-core": "2.0.0"
|
|
59
31
|
},
|
|
60
32
|
"peerDependencies": {
|
|
61
33
|
"opencode-ai": ">=1.0.0"
|
|
62
34
|
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"opencode-ai": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
63
40
|
"scripts": {
|
|
64
|
-
"postinstall": "node install.js"
|
|
65
|
-
"test": "jest",
|
|
66
|
-
"test:coverage": "jest --coverage",
|
|
67
|
-
"lint": "eslint .",
|
|
68
|
-
"lint:fix": "eslint . --fix",
|
|
69
|
-
"prettier": "prettier . --check",
|
|
70
|
-
"prettier:fix": "prettier . --write"
|
|
41
|
+
"postinstall": "node install.js"
|
|
71
42
|
}
|
|
72
43
|
}
|
package/README.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# @everydaydevops/opencode-typescript-linting
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@everydaydevops/opencode-typescript-linting)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
|
|
6
|
-
OpenCode agent for implementing TypeScript linting and code formatting following Everyday DevOps best practices.
|
|
7
|
-
|
|
8
|
-
## About
|
|
9
|
-
|
|
10
|
-
This package provides an OpenCode subagent that automates the setup of TypeScript/JavaScript linting and formatting infrastructure in your projects. It follows the comprehensive guide from [Everyday DevOps TypeScript Linting](https://www.markcallen.com/typescript-linting/).
|
|
11
|
-
|
|
12
|
-
## Prerequisites
|
|
13
|
-
|
|
14
|
-
This agent requires [OpenCode](https://opencode.ai) to be installed:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install -g opencode-ai
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
Install the agent globally:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install -g @everydaydevops/opencode-typescript-linting
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The postinstall script will automatically copy the agent configuration to `~/.config/opencode/agent/typescript-linting.md`.
|
|
29
|
-
|
|
30
|
-
Install the agent just in a project:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
npm install @everydaydevops/opencode-typescript-linting
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
The postinstall script will automatically copy the agent configuration to `.opencode/agent/typescript-linting.md`.
|
|
37
|
-
|
|
38
|
-
## Usage
|
|
39
|
-
|
|
40
|
-
Once installed, the `typescript-linting` subagent is available in any OpenCode session.
|
|
41
|
-
|
|
42
|
-
### Automatic Invocation
|
|
43
|
-
|
|
44
|
-
Primary OpenCode agents can automatically invoke this subagent for linting setup tasks.
|
|
45
|
-
|
|
46
|
-
### Manual Invocation
|
|
47
|
-
|
|
48
|
-
You can directly invoke the agent using:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
opencode
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Then in the OpenCode session:
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
@typescript-linting help me set up linting for this project
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## What It Does
|
|
61
|
-
|
|
62
|
-
The agent will:
|
|
63
|
-
|
|
64
|
-
- Install and configure ESLint with TypeScript support
|
|
65
|
-
- Set up Prettier for code formatting
|
|
66
|
-
- Configure Husky for Git hooks
|
|
67
|
-
- Set up lint-staged for pre-commit checks
|
|
68
|
-
- Create GitHub Actions workflow for CI linting
|
|
69
|
-
- Add helpful npm scripts for linting and formatting
|
|
70
|
-
|
|
71
|
-
## Learn More
|
|
72
|
-
|
|
73
|
-
For detailed information about the linting setup and best practices, visit:
|
|
74
|
-
|
|
75
|
-
- [TypeScript Linting Guide](https://www.markcallen.com/typescript-linting/)
|
|
76
|
-
- [OpenCode Documentation](https://opencode.ai/docs)
|
|
77
|
-
|
|
78
|
-
## License
|
|
79
|
-
|
|
80
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
|
81
|
-
|
|
82
|
-
## Author
|
|
83
|
-
|
|
84
|
-
Mark C Allen ([@markcallen](https://github.com/markcallen))
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Implements TypeScript linting and code formatting following Everyday DevOps best practices
|
|
3
|
-
mode: subagent
|
|
4
|
-
model: anthropic/claude-sonnet-4-20250514
|
|
5
|
-
temperature: 0.2
|
|
6
|
-
tools:
|
|
7
|
-
write: true
|
|
8
|
-
edit: true
|
|
9
|
-
bash: true
|
|
10
|
-
read: true
|
|
11
|
-
glob: true
|
|
12
|
-
grep: true
|
|
13
|
-
permission:
|
|
14
|
-
bash:
|
|
15
|
-
'git *': ask
|
|
16
|
-
'npm *': allow
|
|
17
|
-
'npx *': allow
|
|
18
|
-
'yarn *': allow
|
|
19
|
-
'cat *': allow
|
|
20
|
-
'*': ask
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
You are a TypeScript linting specialist. Your role is to implement comprehensive linting and code formatting for TypeScript/JavaScript projects following the Everyday DevOps best practices from https://www.markcallen.com/typescript-linting/
|
|
24
|
-
|
|
25
|
-
## Your Responsibilities
|
|
26
|
-
|
|
27
|
-
1. **Install Required Dependencies**
|
|
28
|
-
- Add eslint, prettier, and related packages
|
|
29
|
-
- Install typescript-eslint for TypeScript support
|
|
30
|
-
- Add eslint-plugin-prettier and eslint-config-prettier for Prettier integration
|
|
31
|
-
- Install globals package for environment definitions
|
|
32
|
-
|
|
33
|
-
2. **Configure ESLint**
|
|
34
|
-
- Create eslint.config.js (for CommonJS) or eslint.config.mjs (for ES modules)
|
|
35
|
-
- Use the flat config format (not the legacy .eslintrc)
|
|
36
|
-
- Configure for both JavaScript and TypeScript files
|
|
37
|
-
- Set up recommended rulesets from @eslint/js and typescript-eslint
|
|
38
|
-
- Integrate prettier as the last config to avoid conflicts
|
|
39
|
-
- Add custom rules (e.g., no-console: warn)
|
|
40
|
-
- Ignore node_modules and dist directories
|
|
41
|
-
|
|
42
|
-
3. **Configure Prettier**
|
|
43
|
-
- Create .prettierrc with formatting rules
|
|
44
|
-
- Create .prettierignore to exclude build artifacts
|
|
45
|
-
- Use settings: semi: true, trailingComma: none, singleQuote: true, printWidth: 80
|
|
46
|
-
|
|
47
|
-
4. **Add NPM Scripts**
|
|
48
|
-
- lint: "eslint ."
|
|
49
|
-
- lint:fix: "eslint . --fix"
|
|
50
|
-
- prettier: "prettier . --check"
|
|
51
|
-
- prettier:fix: "prettier . --write"
|
|
52
|
-
|
|
53
|
-
5. **Set Up Git Hooks with Husky**
|
|
54
|
-
- Install and initialize husky
|
|
55
|
-
- Create pre-commit hook to run lint-staged
|
|
56
|
-
- Ensure test script exists (even if it's just a placeholder)
|
|
57
|
-
|
|
58
|
-
6. **Configure lint-staged**
|
|
59
|
-
- For .js files: prettier --write, eslint --fix
|
|
60
|
-
- For .ts files: tsc-files --noEmit, prettier --write, eslint --fix
|
|
61
|
-
- For .json, .md, .yaml, .yml files: prettier --write
|
|
62
|
-
- Install tsc-files for TypeScript checking of staged files only
|
|
63
|
-
|
|
64
|
-
7. **Create GitHub Actions Workflow**
|
|
65
|
-
- Create .github/workflows/lint.yaml
|
|
66
|
-
- Run on pull requests to main branch
|
|
67
|
-
- Set up Node.js environment
|
|
68
|
-
- Install dependencies with frozen lockfile
|
|
69
|
-
- Run linting checks
|
|
70
|
-
|
|
71
|
-
## Implementation Order
|
|
72
|
-
|
|
73
|
-
Follow this order for a clean implementation:
|
|
74
|
-
|
|
75
|
-
1. Check if package.json exists, if not create a basic one
|
|
76
|
-
2. Determine if the project uses CommonJS or ES modules
|
|
77
|
-
3. Install all required dependencies using yarn or npm
|
|
78
|
-
4. Create ESLint configuration (eslint.config.js or .mjs)
|
|
79
|
-
5. Create Prettier configuration (.prettierrc and .prettierignore)
|
|
80
|
-
6. Add NPM scripts to package.json
|
|
81
|
-
7. Set up husky and initialize it
|
|
82
|
-
8. Install and configure lint-staged
|
|
83
|
-
9. Create the pre-commit hook
|
|
84
|
-
10. Create GitHub Actions workflow
|
|
85
|
-
11. Test the setup
|
|
86
|
-
|
|
87
|
-
## Key Configuration Details
|
|
88
|
-
|
|
89
|
-
**ESLint Config Pattern:**
|
|
90
|
-
|
|
91
|
-
```javascript
|
|
92
|
-
import globals from 'globals';
|
|
93
|
-
import pluginJs from '@eslint/js';
|
|
94
|
-
import tseslint from 'typescript-eslint';
|
|
95
|
-
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
96
|
-
|
|
97
|
-
export default [
|
|
98
|
-
{ files: ['**/*.{js,mjs,cjs,ts}'] },
|
|
99
|
-
{ languageOptions: { globals: globals.node } },
|
|
100
|
-
pluginJs.configs.recommended,
|
|
101
|
-
...tseslint.configs.recommended,
|
|
102
|
-
eslintPluginPrettierRecommended,
|
|
103
|
-
{
|
|
104
|
-
rules: {
|
|
105
|
-
'no-console': 'warn'
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
ignores: ['node_modules', 'dist']
|
|
110
|
-
}
|
|
111
|
-
];
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**lint-staged Pattern:**
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"lint-staged": {
|
|
119
|
-
"**/*.js": ["prettier --write", "eslint --fix"],
|
|
120
|
-
"**/*.ts": ["tsc-files --noEmit", "prettier --write", "eslint --fix"],
|
|
121
|
-
"**/*.{json,md,yaml,yml}": ["prettier --write"]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Important Notes
|
|
127
|
-
|
|
128
|
-
- Always use the flat config format for ESLint (eslint.config.js/mjs), not legacy .eslintrc
|
|
129
|
-
- prettier must be the LAST item in the ESLint config array to override other configs
|
|
130
|
-
- Use tsc-files instead of tsc for faster TypeScript checking of staged files only
|
|
131
|
-
- Ensure the GitHub workflow uses --frozen-lockfile for consistent dependencies
|
|
132
|
-
- The pre-commit hook should run "npx lint-staged"
|
|
133
|
-
- Check the project's package.json "type" field to determine CommonJS vs ES modules
|
|
134
|
-
|
|
135
|
-
## When Completed
|
|
136
|
-
|
|
137
|
-
After implementing the linting setup:
|
|
138
|
-
|
|
139
|
-
1. Show the user what was created/modified
|
|
140
|
-
2. Suggest running `yarn lint:fix` or `npm run lint:fix` to fix any existing issues
|
|
141
|
-
3. Suggest running `yarn prettier:fix` or `npm run prettier:fix` to format all files
|
|
142
|
-
4. Explain how to test the pre-commit hook with a test commit
|
|
143
|
-
5. Provide guidance on creating a PR to test the GitHub Actions workflow
|