This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
50 lines (43 loc) · 1.77 KB
/
install.js
File metadata and controls
50 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
const agentName = 'typescript-linting.md';
const sourceFile = path.join(__dirname, 'agent', agentName);
// Determine if this is a global installation
// npm sets npm_config_global=true when installing globally
const isGlobalInstall = process.env.npm_config_global === 'true';
// Determine the target directory based on installation type
let targetDir;
if (isGlobalInstall) {
// Global install: use ~/.config/opencode/agent
targetDir = path.join(os.homedir(), '.config', 'opencode', 'agent');
} else {
// Local install: use .opencode/ in the project directory
// npm_config_local_prefix points to the project root during npm install
const projectRoot = process.env.npm_config_local_prefix || process.cwd();
targetDir = path.join(projectRoot, '.opencode');
}
// Create the directory if it doesn't exist
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir, { recursive: true });
}
const targetFile = path.join(targetDir, agentName);
// Copy the agent file
try {
fs.copyFileSync(sourceFile, targetFile);
console.log('TypeScript Linting agent installed successfully!');
console.log(` Installed to: ${targetFile}`);
console.log(` Installation type: ${isGlobalInstall ? 'global' : 'local'}`);
console.log('\nUsage:');
console.log(' Run "opencode" in any TypeScript project');
console.log(' The typescript-linting subagent will be available');
console.log(
' Primary agents can invoke it automatically for linting setup tasks'
);
console.log('\nManual invocation:');
console.log(' @typescript-linting help me set up linting for this project');
} catch (error) {
console.error('Failed to install TypeScript Linting agent:', error.message);
process.exit(1);
}