claude-agents-md 1.8.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/.cursorindexingignore +3 -0
- package/README.md +128 -0
- package/bin/cl +116 -0
- package/bin/claude-agents.js +311 -0
- package/make-agents.sh +27 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Claude AGENTS
|
|
2
|
+
|
|
3
|
+
A wrapper for the Claude CLI that can run in AGENTS mode (ignoring CLAUDE.md and using AGENTS.md) OR CLAUDE mode (standard Claude behavior).
|
|
4
|
+
|
|
5
|
+
## What's New 🎉
|
|
6
|
+
|
|
7
|
+
- Switch between CLAUDE and AGENTS modes
|
|
8
|
+
- Use the handy `cl` bash wrapper for quick mode switching
|
|
9
|
+
- Mode preference is saved between sessions
|
|
10
|
+
- **NEW**: Auto-start Claude after mode switch
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Install
|
|
16
|
+
npm install -g claude-agents-md
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The first time you run `claude-agents-md`, you will be presented with a consent prompt explaining the security implications. You must explicitly agree to continue.
|
|
20
|
+
|
|
21
|
+
Your consent choice is remembered for future runs.
|
|
22
|
+
|
|
23
|
+
### Using command-line flags
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Run in CLAUDE mode (normal Claude CLI behavior)
|
|
27
|
+
claude-agents-md --claude
|
|
28
|
+
claude-agents-md --no-agents
|
|
29
|
+
|
|
30
|
+
# Run in AGENTS mode (default)
|
|
31
|
+
claude-agents-md
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using mode commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Switch to AGENTS mode
|
|
38
|
+
claude-agents-md mode agents
|
|
39
|
+
|
|
40
|
+
# Switch to CLAUDE mode
|
|
41
|
+
claude-agents-md mode claude
|
|
42
|
+
|
|
43
|
+
# Check current mode
|
|
44
|
+
claude-agents-md mode
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Using the cl wrapper script (Recommended!)
|
|
48
|
+
|
|
49
|
+
For even easier mode management, use the included `cl` bash wrapper:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Install globally during npm install
|
|
53
|
+
npm install -g claude-agents-md
|
|
54
|
+
|
|
55
|
+
# Or copy manually to your PATH
|
|
56
|
+
cp node_modules/claude-agents-md/bin/cl /usr/local/bin/cl
|
|
57
|
+
chmod +x /usr/local/bin/cl
|
|
58
|
+
|
|
59
|
+
# Now you can use:
|
|
60
|
+
cl /YON # Switch to AGENTS mode AND start Claude
|
|
61
|
+
cl /YOFF # Switch to CLAUDE mode AND start Claude
|
|
62
|
+
cl /STATUS # Show current mode (without starting Claude)
|
|
63
|
+
cl /HELP # Show help
|
|
64
|
+
|
|
65
|
+
# Run Claude in current mode
|
|
66
|
+
cl "write a hello world function"
|
|
67
|
+
|
|
68
|
+
# Switch mode and run with command
|
|
69
|
+
cl /YON "create a web server"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Mode preference is saved in `~/.claude_agents_state` and persists between sessions.
|
|
73
|
+
|
|
74
|
+
## Visual Mode Indicators
|
|
75
|
+
|
|
76
|
+
The tool now shows clear visual indicators of which mode you're in:
|
|
77
|
+
|
|
78
|
+
- **AGENTS Mode**: `[AGENTS]` prefix in yellow 🔥
|
|
79
|
+
- **CLAUDE Mode**: `[CLAUDE]` prefix in cyan 🛡️
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
claude-agents-md [options]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
All arguments and options are passed directly to the Claude CLI.
|
|
88
|
+
|
|
89
|
+
This wrapper in AGENTS mode:
|
|
90
|
+
1. Checks for and automatically installs updates to the Claude package
|
|
91
|
+
2. Displays "🔥 AGENTS MODE ACTIVATED 🔥" warning in yellow text
|
|
92
|
+
3. Creates a modified copy of the Claude CLI code to use AGENTS.md
|
|
93
|
+
4. Leaves the original Claude CLI file untouched (won't affect your normal `claude` command)
|
|
94
|
+
|
|
95
|
+
In CLAUDE mode, it simply runs the original Claude CLI without modifications.
|
|
96
|
+
|
|
97
|
+
## Why?
|
|
98
|
+
|
|
99
|
+
You want to use AGENTS.md
|
|
100
|
+
|
|
101
|
+
## Debugging
|
|
102
|
+
|
|
103
|
+
If you encounter any issues, you can run with debug output:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
DEBUG=1 claude-agents-md
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This will show additional information about:
|
|
110
|
+
- Claude package update checks
|
|
111
|
+
- Current and latest available versions
|
|
112
|
+
- When updates are being installed
|
|
113
|
+
- Modifications being made to the CLI file
|
|
114
|
+
|
|
115
|
+
## Auto-Update Feature
|
|
116
|
+
|
|
117
|
+
Claude AGENTS automatically checks for updates to the Claude package each time it runs:
|
|
118
|
+
|
|
119
|
+
1. When you run `claude-agents-md`, it checks for the latest version of `@anthropic-ai/claude-code` on npm
|
|
120
|
+
2. If your installed version is outdated, it will:
|
|
121
|
+
- Update your package.json with the latest version
|
|
122
|
+
- Run npm install to get the newest version
|
|
123
|
+
- Notify you that an update was applied
|
|
124
|
+
3. This ensures you're always using the latest Claude CLI features
|
|
125
|
+
|
|
126
|
+
## Important Security Disclaimer
|
|
127
|
+
|
|
128
|
+
This is an unofficial tool and not supported by Anthropic. Use at your own risk.
|
package/bin/cl
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Claude AGENTS/CLAUDE.md Mode Wrapper Script
|
|
4
|
+
# Usage: cl /YON | /YOFF | /STATUS | /HELP | [claude commands]
|
|
5
|
+
|
|
6
|
+
# Barvy pro výstup
|
|
7
|
+
RED='\033[0;31m'
|
|
8
|
+
YELLOW='\033[1;33m'
|
|
9
|
+
CYAN='\033[0;36m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
RESET='\033[0m'
|
|
12
|
+
BOLD='\033[1m'
|
|
13
|
+
|
|
14
|
+
# Soubor pro uložení stavu
|
|
15
|
+
STATE_FILE="$HOME/.claude_agents_state"
|
|
16
|
+
|
|
17
|
+
# Funkce pro čtení aktuálního režimu
|
|
18
|
+
get_mode() {
|
|
19
|
+
if [ -f "$STATE_FILE" ]; then
|
|
20
|
+
cat "$STATE_FILE"
|
|
21
|
+
else
|
|
22
|
+
echo "CLAUDE" # Výchozí je bezpečný režim
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Funkce pro nastavení režimu
|
|
27
|
+
set_mode() {
|
|
28
|
+
echo "$1" > "$STATE_FILE"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Zpracování argumentů
|
|
32
|
+
case "$1" in
|
|
33
|
+
/YON)
|
|
34
|
+
echo -e "${YELLOW}${BOLD}🔥 ACTIVATING AGENTS MODE 🔥${RESET}"
|
|
35
|
+
echo -e "${RED}⚠️ WARNING: All CLAUDE.md will be ignored!${RESET}"
|
|
36
|
+
echo -e "${RED}⚠️ Claude will use AGENTS.md instead${RESET}"
|
|
37
|
+
set_mode "AGENTS"
|
|
38
|
+
echo -e "${YELLOW}✓ AGENTS mode is now ON${RESET}"
|
|
39
|
+
;;
|
|
40
|
+
|
|
41
|
+
/YOFF)
|
|
42
|
+
echo -e "${CYAN}${BOLD}🛡️ ACTIVATING CLAUDE MODE 🛡️${RESET}"
|
|
43
|
+
echo -e "${GREEN}✓ CLAUDE.md will be enabled${RESET}"
|
|
44
|
+
set_mode "CLAUDE"
|
|
45
|
+
echo -e "${CYAN}✓ AGENTS mode is now OFF (CLAUDE.md mode ON)${RESET}"
|
|
46
|
+
;;
|
|
47
|
+
|
|
48
|
+
/STATUS)
|
|
49
|
+
MODE=$(get_mode)
|
|
50
|
+
echo -e "${BOLD}Claude CLI Status:${RESET}"
|
|
51
|
+
echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
52
|
+
if [ "$MODE" = "AGENTS" ]; then
|
|
53
|
+
echo -e "Mode: ${YELLOW}${BOLD}AGENTS${RESET} 🔥"
|
|
54
|
+
echo -e "Instructions: ${RED}CLAUDE.md will be ignored${RESET}"
|
|
55
|
+
echo -e "Instructions: ${GREEN}AGENTS.md will be used${RESET}"
|
|
56
|
+
else
|
|
57
|
+
echo -e "Mode: ${CYAN}${BOLD}CLAUDE${RESET} 🛡️"
|
|
58
|
+
echo -e "Instructions: ${GREEN}CLAUDE.md will be used${RESET}"
|
|
59
|
+
echo -e "Instructions: ${RED}AGENTS.md will be ignored${RESET}"
|
|
60
|
+
fi
|
|
61
|
+
echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
62
|
+
;;
|
|
63
|
+
|
|
64
|
+
/HELP|/H|/?)
|
|
65
|
+
echo -e "${BOLD}Claude CLI Wrapper - Help${RESET}"
|
|
66
|
+
echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
67
|
+
echo -e "${CYAN}cl /YON${RESET} - Enable AGENTS mode (ignore CLAUDE.md)"
|
|
68
|
+
echo -e "${CYAN}cl /YOFF${RESET} - Disable AGENTS mode (use CLAUDE.md)"
|
|
69
|
+
echo -e "${CYAN}cl /STATUS${RESET} - Show current mode"
|
|
70
|
+
echo -e "${CYAN}cl /HELP${RESET} - Show this help"
|
|
71
|
+
echo -e "${CYAN}cl [args]${RESET} - Run claude with current mode"
|
|
72
|
+
echo -e "━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
73
|
+
echo -e ""
|
|
74
|
+
echo -e "${BOLD}Examples:${RESET}"
|
|
75
|
+
echo -e " cl /YON # Enable AGENTS mode"
|
|
76
|
+
echo -e " cl /YOFF # Enable CLAUDE.md mode"
|
|
77
|
+
echo -e " cl \"write a function\" # Run Claude in current mode"
|
|
78
|
+
echo -e ""
|
|
79
|
+
echo -e "${BOLD}Mode Persistence:${RESET}"
|
|
80
|
+
echo -e "Your mode choice is saved in ~/.claude_agennts_state"
|
|
81
|
+
echo -e "and persists between terminal sessions."
|
|
82
|
+
;;
|
|
83
|
+
|
|
84
|
+
*)
|
|
85
|
+
# Spustit Claude v aktuálním režimu
|
|
86
|
+
MODE=$(get_mode)
|
|
87
|
+
|
|
88
|
+
# Zobrazit režim před spuštěním
|
|
89
|
+
if [ "$MODE" = "AGENTS" ]; then
|
|
90
|
+
echo -e "${YELLOW}[AGENTS]${RESET} Running Claude in AGENTS.md mode..."
|
|
91
|
+
# Check if claude-agents-md is installed
|
|
92
|
+
if command -v claude-agents-md &> /dev/null; then
|
|
93
|
+
claude-agents-md "$@"
|
|
94
|
+
else
|
|
95
|
+
echo -e "${RED}Error: claude-agents-md is not installed${RESET}"
|
|
96
|
+
echo -e "Install it with: ${CYAN}npm install -g claude-agents-md${RESET}"
|
|
97
|
+
exit 1
|
|
98
|
+
fi
|
|
99
|
+
else
|
|
100
|
+
echo -e "${CYAN}[CLAUDE]${RESET} Running Claude in CLAUDE.md mode..."
|
|
101
|
+
# Check if claude is installed
|
|
102
|
+
if command -v claude &> /dev/null; then
|
|
103
|
+
claude "$@"
|
|
104
|
+
else
|
|
105
|
+
# If regular claude is not installed, use claude-agents-md with --claude flag
|
|
106
|
+
if command -v claude-agents-md &> /dev/null; then
|
|
107
|
+
claude-agents-md --claude "$@"
|
|
108
|
+
else
|
|
109
|
+
echo -e "${RED}Error: Neither claude nor claude-agents-md is installed${RESET}"
|
|
110
|
+
echo -e "Install claude-agents-md with: ${CYAN}npm install -g claude-agents-md${RESET}"
|
|
111
|
+
exit 1
|
|
112
|
+
fi
|
|
113
|
+
fi
|
|
114
|
+
fi
|
|
115
|
+
;;
|
|
116
|
+
esac
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import { createRequire } from 'module';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
import readline from 'readline';
|
|
11
|
+
|
|
12
|
+
// ANSI color codes
|
|
13
|
+
const RED = '\x1b[31m';
|
|
14
|
+
const YELLOW = '\x1b[33m';
|
|
15
|
+
const CYAN = '\x1b[36m';
|
|
16
|
+
const GREEN = '\x1b[32m';
|
|
17
|
+
const RESET = '\x1b[0m';
|
|
18
|
+
const BOLD = '\x1b[1m';
|
|
19
|
+
|
|
20
|
+
// Path to persistent state file
|
|
21
|
+
const stateFile = path.join(os.homedir(), '.claude_agents_state');
|
|
22
|
+
|
|
23
|
+
// Function to get current mode from state file
|
|
24
|
+
function getMode() {
|
|
25
|
+
try {
|
|
26
|
+
return fs.readFileSync(stateFile, 'utf8').trim();
|
|
27
|
+
} catch {
|
|
28
|
+
return 'AGENTS'; // Default mode
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Function to set mode in state file
|
|
33
|
+
function setMode(mode) {
|
|
34
|
+
fs.writeFileSync(stateFile, mode);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Debug logging function that only logs if DEBUG env var is set
|
|
38
|
+
const debug = (message) => {
|
|
39
|
+
if (process.env.DEBUG) {
|
|
40
|
+
console.log(message);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Function to ask for user consent
|
|
45
|
+
function askForConsent() {
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
const rl = readline.createInterface({
|
|
48
|
+
input: process.stdin,
|
|
49
|
+
output: process.stdout
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
console.log(`\n${BOLD}${YELLOW}🔥 claude-agents-md CONSENT REQUIRED 🔥${RESET}\n`);
|
|
53
|
+
console.log(`${CYAN}----------------------------------------${RESET}`);
|
|
54
|
+
console.log(`${BOLD}What is claude-agents-md?${RESET}`);
|
|
55
|
+
console.log(`This package creates a wrapper around the official Claude CLI tool that:`);
|
|
56
|
+
console.log(` 1. ${RED}Ignores CLAUDE.md${RESET} and uses AGENTS.md instead`);
|
|
57
|
+
console.log(` 2. Automatically updates to the latest Claude CLI version`);
|
|
58
|
+
console.log(` 4. ${GREEN}NOW SUPPORTS CLAUDE.md MODE${RESET} with --claude flag\n`);
|
|
59
|
+
|
|
60
|
+
console.log(`${BOLD}By using claude-agents-md in AGENTS mode:${RESET}`);
|
|
61
|
+
console.log(` • You acknowledge that CLAUDE.md is being ignored and claude will follow instructions from AGENTS.md`);
|
|
62
|
+
console.log(` • You accept full responsibility for any rule following implications\n`);
|
|
63
|
+
|
|
64
|
+
console.log(`${CYAN}----------------------------------------${RESET}\n`);
|
|
65
|
+
|
|
66
|
+
rl.question(`${YELLOW}Do you consent to using claude-agents-md with these modifications? (yes/no): ${RESET}`, (answer) => {
|
|
67
|
+
rl.close();
|
|
68
|
+
const lowerAnswer = answer.toLowerCase().trim();
|
|
69
|
+
if (lowerAnswer === 'yes' || lowerAnswer === 'y') {
|
|
70
|
+
console.log(`\n${YELLOW}🔥 AGENTS MODE APPROVED 🔥${RESET}`);
|
|
71
|
+
resolve(true);
|
|
72
|
+
} else {
|
|
73
|
+
console.log(`\n${CYAN}Aborted. AGENTS mode not activated.${RESET}`);
|
|
74
|
+
console.log(`If you want the official Claude CLI with normal behaviour, run:`);
|
|
75
|
+
console.log(`claude`);
|
|
76
|
+
resolve(false);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Get the directory of the current module
|
|
83
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
84
|
+
|
|
85
|
+
// Find node_modules directory by walking up from current file
|
|
86
|
+
let nodeModulesDir = path.resolve(__dirname, '..');
|
|
87
|
+
while (!fs.existsSync(path.join(nodeModulesDir, 'node_modules')) && nodeModulesDir !== '/') {
|
|
88
|
+
nodeModulesDir = path.resolve(nodeModulesDir, '..');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Path to check package info
|
|
92
|
+
const packageJsonPath = path.join(nodeModulesDir, 'package.json');
|
|
93
|
+
|
|
94
|
+
// Check for updates to Claude package
|
|
95
|
+
async function checkForUpdates() {
|
|
96
|
+
try {
|
|
97
|
+
debug("Checking for Claude package updates...");
|
|
98
|
+
|
|
99
|
+
// Get the latest version available on npm
|
|
100
|
+
const latestVersionCmd = "npm view @anthropic-ai/claude-code version";
|
|
101
|
+
const latestVersion = execSync(latestVersionCmd).toString().trim();
|
|
102
|
+
debug(`Latest Claude version on npm: ${latestVersion}`);
|
|
103
|
+
|
|
104
|
+
// Get our current installed version
|
|
105
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
106
|
+
const dependencies = packageJson.dependencies || {};
|
|
107
|
+
const currentVersion = dependencies['@anthropic-ai/claude-code'];
|
|
108
|
+
|
|
109
|
+
debug(`Claude version from package.json: ${currentVersion}`);
|
|
110
|
+
|
|
111
|
+
// Get the global Claude version if available
|
|
112
|
+
let globalVersion;
|
|
113
|
+
if (globalClaudeDir) {
|
|
114
|
+
try {
|
|
115
|
+
const globalPackageJsonPath = path.join(globalClaudeDir, 'package.json');
|
|
116
|
+
if (fs.existsSync(globalPackageJsonPath)) {
|
|
117
|
+
const globalPackageJson = JSON.parse(fs.readFileSync(globalPackageJsonPath, 'utf8'));
|
|
118
|
+
globalVersion = globalPackageJson.version;
|
|
119
|
+
debug(`Global Claude version: ${globalVersion}`);
|
|
120
|
+
|
|
121
|
+
// If global version is latest, inform user
|
|
122
|
+
if (globalVersion === latestVersion) {
|
|
123
|
+
debug(`Global Claude installation is already the latest version`);
|
|
124
|
+
} else if (globalVersion && latestVersion) {
|
|
125
|
+
debug(`Global Claude installation (${globalVersion}) differs from latest (${latestVersion})`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
debug(`Error getting global Claude version: ${err.message}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// If using a specific version (not "latest"), and it's out of date, update
|
|
134
|
+
if (currentVersion !== "latest" && currentVersion !== latestVersion) {
|
|
135
|
+
console.log(`Updating Claude package from ${currentVersion || 'unknown'} to ${latestVersion}...`);
|
|
136
|
+
|
|
137
|
+
// Update package.json
|
|
138
|
+
packageJson.dependencies['@anthropic-ai/claude-code'] = latestVersion;
|
|
139
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
140
|
+
|
|
141
|
+
// Run npm install
|
|
142
|
+
console.log("Running npm install to update dependencies...");
|
|
143
|
+
execSync("npm install", { stdio: 'inherit', cwd: nodeModulesDir });
|
|
144
|
+
console.log("Update complete!");
|
|
145
|
+
} else if (currentVersion === "latest") {
|
|
146
|
+
// If using "latest", just make sure we have the latest version installed
|
|
147
|
+
debug("Using 'latest' tag in package.json, running npm install to ensure we have the newest version");
|
|
148
|
+
execSync("npm install", { stdio: 'inherit', cwd: nodeModulesDir });
|
|
149
|
+
}
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error("Error checking for updates:", error.message);
|
|
152
|
+
debug(error.stack);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Try to find global installation of Claude CLI first
|
|
157
|
+
let globalClaudeDir;
|
|
158
|
+
try {
|
|
159
|
+
const globalNodeModules = execSync('npm -g root').toString().trim();
|
|
160
|
+
debug(`Global node_modules: ${globalNodeModules}`);
|
|
161
|
+
const potentialGlobalDir = path.join(globalNodeModules, '@anthropic-ai', 'claude-code');
|
|
162
|
+
|
|
163
|
+
if (fs.existsSync(potentialGlobalDir)) {
|
|
164
|
+
globalClaudeDir = potentialGlobalDir;
|
|
165
|
+
debug(`Found global Claude installation at: ${globalClaudeDir}`);
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
debug(`Error finding global Claude installation: ${error.message}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Path to the local Claude CLI installation
|
|
172
|
+
const localClaudeDir = path.join(nodeModulesDir, 'node_modules', '@anthropic-ai', 'claude-code');
|
|
173
|
+
|
|
174
|
+
// Prioritize global installation, fall back to local
|
|
175
|
+
const claudeDir = globalClaudeDir || localClaudeDir;
|
|
176
|
+
debug(`Using Claude installation from: ${claudeDir}`);
|
|
177
|
+
debug(`Using ${claudeDir === globalClaudeDir ? 'GLOBAL' : 'LOCAL'} Claude installation`);
|
|
178
|
+
|
|
179
|
+
// Check for both .js and .mjs versions of the CLI
|
|
180
|
+
let mjs = path.join(claudeDir, 'cli.mjs');
|
|
181
|
+
let js = path.join(claudeDir, 'cli.js');
|
|
182
|
+
let originalCliPath;
|
|
183
|
+
let agentsCliPath;
|
|
184
|
+
|
|
185
|
+
if (fs.existsSync(js)) {
|
|
186
|
+
originalCliPath = js;
|
|
187
|
+
agentsCliPath = path.join(claudeDir, 'cli-agents.js');
|
|
188
|
+
debug(`Found Claude CLI at ${originalCliPath} (js version)`);
|
|
189
|
+
} else if (fs.existsSync(mjs)) {
|
|
190
|
+
originalCliPath = mjs;
|
|
191
|
+
agentsCliPath = path.join(claudeDir, 'cli-agents.mjs');
|
|
192
|
+
debug(`Found Claude CLI at ${originalCliPath} (mjs version)`);
|
|
193
|
+
} else {
|
|
194
|
+
console.error(`Error: Claude CLI not found in ${claudeDir}. Make sure @anthropic-ai/claude-code is installed.`);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
const consentFlagPath = path.join(claudeDir, '.claude-agents-md-consent');
|
|
198
|
+
|
|
199
|
+
// Main function to run the application
|
|
200
|
+
async function run() {
|
|
201
|
+
// Handle mode commands first
|
|
202
|
+
const args = process.argv.slice(2);
|
|
203
|
+
if (args[0] === 'mode') {
|
|
204
|
+
if (args[1] === 'agents') {
|
|
205
|
+
console.log(`${YELLOW}🔥 Switching to AGENTS mode...${RESET}`);
|
|
206
|
+
console.log(`${RED}⚠️ WARNING: CLAUDE.md will be igored!${RESET}`);
|
|
207
|
+
setMode('AGENTS');
|
|
208
|
+
console.log(`${YELLOW}✓ AGENTS mode activated${RESET}`);
|
|
209
|
+
return;
|
|
210
|
+
} else if (args[1] === 'claude') {
|
|
211
|
+
console.log(`${CYAN}🛡️ Switching to CLAUDE.md mode...${RESET}`);
|
|
212
|
+
console.log(`${GREEN}✓ CLAUDE.md will be enabled${RESET}`);
|
|
213
|
+
setMode('CLAUDE');
|
|
214
|
+
console.log(`${CYAN}✓ CLAUDE.md mode activated${RESET}`);
|
|
215
|
+
return;
|
|
216
|
+
} else {
|
|
217
|
+
const currentMode = getMode();
|
|
218
|
+
console.log(`Current mode: ${currentMode === 'AGENTS' ? YELLOW : CYAN}${currentMode}${RESET}`);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Check for --claude or --no-agents flags
|
|
224
|
+
const claudeMode = process.argv.includes('--claude') ||
|
|
225
|
+
process.argv.includes('--no-agents') ||
|
|
226
|
+
getMode() === 'CLAUDE';
|
|
227
|
+
|
|
228
|
+
if (claudeMode) {
|
|
229
|
+
// Remove our flags before passing to original CLI
|
|
230
|
+
process.argv = process.argv.filter(arg =>
|
|
231
|
+
arg !== '--claude' && arg !== '--no-agents'
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
console.log(`${CYAN}[CLAUDE] Running Claude in CLAUDE.md mode${RESET}`);
|
|
235
|
+
|
|
236
|
+
// Update if needed
|
|
237
|
+
await checkForUpdates();
|
|
238
|
+
|
|
239
|
+
// Ensure original CLI exists
|
|
240
|
+
if (!fs.existsSync(originalCliPath)) {
|
|
241
|
+
console.error(`Error: ${originalCliPath} not found. Make sure @anthropic-ai/claude-code is installed.`);
|
|
242
|
+
process.exit(1);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Run original CLI without modifications
|
|
246
|
+
await import(originalCliPath);
|
|
247
|
+
return; // Exit early
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// AGENTS MODE continues below
|
|
251
|
+
console.log(`${YELLOW}[AGENTS] Running Claude in AGENTS mode${RESET}`);
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
// Check and update Claude package first
|
|
255
|
+
await checkForUpdates();
|
|
256
|
+
|
|
257
|
+
if (!fs.existsSync(originalCliPath)) {
|
|
258
|
+
console.error(`Error: ${originalCliPath} not found. Make sure @anthropic-ai/claude-code is installed.`);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Check if consent is needed
|
|
263
|
+
const consentNeeded = !fs.existsSync(agentsCliPath) || !fs.existsSync(consentFlagPath);
|
|
264
|
+
|
|
265
|
+
// If consent is needed and not already given, ask for it
|
|
266
|
+
if (consentNeeded) {
|
|
267
|
+
const consent = await askForConsent();
|
|
268
|
+
if (!consent) {
|
|
269
|
+
// User didn't consent, exit
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Create a flag file to remember that consent was given
|
|
274
|
+
try {
|
|
275
|
+
fs.writeFileSync(consentFlagPath, 'consent-given');
|
|
276
|
+
debug("Created consent flag file");
|
|
277
|
+
} catch (err) {
|
|
278
|
+
debug(`Error creating consent flag file: ${err.message}`);
|
|
279
|
+
// Continue anyway
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Read the original CLI file content
|
|
284
|
+
let cliContent = fs.readFileSync(originalCliPath, 'utf8');
|
|
285
|
+
|
|
286
|
+
if (claudeDir === localClaudeDir) {
|
|
287
|
+
cliContent = cliContent.replace(/"punycode"/g, '"punycode/"');
|
|
288
|
+
debug('Replaced all instances of "punycode" with "punycode/"');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Replace CLAUDE.md with AGENTS.md
|
|
292
|
+
cliContent = cliContent.replace(/CLAUDE.md/gi, 'AGENTS.md');
|
|
293
|
+
debug("Replaced all instances of CLAUDE.md with AGENTS.md");
|
|
294
|
+
|
|
295
|
+
// Add warning message
|
|
296
|
+
console.log(`${YELLOW}🔥 AGENTS MODE ACTIVATED 🔥${RESET}`);
|
|
297
|
+
|
|
298
|
+
// Write the modified content to a new file, leaving the original untouched
|
|
299
|
+
fs.writeFileSync(agentsCliPath, cliContent);
|
|
300
|
+
debug(`Created modified CLI at ${agentsCliPath}`);
|
|
301
|
+
debug("Modifications complete. The AGENTS.md file should now be used instead of CLAUDE.md.");
|
|
302
|
+
|
|
303
|
+
// Now import the modified CLI
|
|
304
|
+
await import(agentsCliPath);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Run the main function
|
|
308
|
+
run().catch(err => {
|
|
309
|
+
console.error("Error:", err);
|
|
310
|
+
process.exit(1);
|
|
311
|
+
});
|
package/make-agents.sh
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Script to modify the --dangerously-skip-permissions check in Claude Terminal
|
|
4
|
+
# This will allow the flag to work everywhere by making the Docker and internet checks always return false
|
|
5
|
+
|
|
6
|
+
# Set the path to the cli.mjs file
|
|
7
|
+
CLI_FILE="${CLAUDE_PATH:-/node_modules/@anthropic-ai/claude-code/cli.mjs}"
|
|
8
|
+
|
|
9
|
+
# Check if the file exists
|
|
10
|
+
if [ ! -f "$CLI_FILE" ]; then
|
|
11
|
+
echo "Error: $CLI_FILE not found. Make sure you're running this script from the claude-terminal root directory."
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
# Create a backup of the original file
|
|
16
|
+
cp "$CLI_FILE" "${CLI_FILE}.backup"
|
|
17
|
+
echo "Created backup at ${CLI_FILE}.backup"
|
|
18
|
+
|
|
19
|
+
# Replace CLAUDE.md with AGENTS.md case insensitively
|
|
20
|
+
sed -i.bak1 's/CLAUDE.md/AGENTS.md/gi' "$CLI_FILE"
|
|
21
|
+
echo "Replaced all instances of CLAUDE.md with AGENTS.md"
|
|
22
|
+
|
|
23
|
+
# Clean up the .bak file created by sed
|
|
24
|
+
rm -f "${CLI_FILE}.bak1"
|
|
25
|
+
|
|
26
|
+
echo "Modifications complete. The CLAUDE.md file should now be AGENTS.md."
|
|
27
|
+
echo "To revert changes, restore from the backup file: ${CLI_FILE}.backup"
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-agents-md",
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"description": "Claude Code CLI but it uses AGENTS.md instead of CLAUDE.md",
|
|
5
|
+
"bin": {
|
|
6
|
+
"claude-agents-md": "./bin/claude-agents-md.js",
|
|
7
|
+
"cl": "./bin/cl"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@anthropic-ai/claude-code": "0.2.35",
|
|
11
|
+
"punycode": "latest"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "chmod +x ./bin/cl"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/eastlondoner/claude-agents-md.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"claude",
|
|
23
|
+
"cli",
|
|
24
|
+
"anthropic",
|
|
25
|
+
"wrapper",
|
|
26
|
+
"agents"
|
|
27
|
+
],
|
|
28
|
+
"author": "eastlondoner",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/eastlondoner/claude-agents-md/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/eastlondoner/claude-agents-md#readme",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=14.16"
|
|
36
|
+
}
|
|
37
|
+
}
|