freeai-code 0.1.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/README.md +61 -0
- package/bin/free-code +65 -0
- package/install.js +156 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# free-code
|
|
2
|
+
|
|
3
|
+
Free AI coding assistant for your terminal. A free alternative to Claude Code, Cursor, and GitHub Copilot.
|
|
4
|
+
|
|
5
|
+
Powered by [Free.ai](https://free.ai).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g free-code-ai
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or with pip:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install free-code
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or the universal one-liner:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
curl -fsSL https://free.ai/install | sh
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd your-project/
|
|
29
|
+
free-code # Interactive coding session
|
|
30
|
+
free-code ask "How does auth work?" # One-shot question
|
|
31
|
+
free-code run "Add unit tests" # Execute a task
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- Python 3.9+ (the npm package will attempt to install Python dependencies automatically)
|
|
37
|
+
- Node.js 14+ (for npm installation method only)
|
|
38
|
+
|
|
39
|
+
## What is this?
|
|
40
|
+
|
|
41
|
+
This npm package is a thin wrapper around the `free-code` Python CLI. On `npm install`, it automatically installs the Python package via pip. The `free-code` command then delegates to the Python binary.
|
|
42
|
+
|
|
43
|
+
If you already have Python, you can skip npm and install directly:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install free-code
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- AI-powered code reading, writing, and editing
|
|
52
|
+
- Shell command execution (with confirmation)
|
|
53
|
+
- Git integration
|
|
54
|
+
- Test runner auto-detection
|
|
55
|
+
- Streaming output with syntax highlighting
|
|
56
|
+
- Context-aware codebase understanding
|
|
57
|
+
- Multiple AI providers (Free.ai, OpenAI, Anthropic, Google, OpenRouter)
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/bin/free-code
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
# free-code — wrapper that finds and runs the Python free-code CLI
|
|
3
|
+
# Works on macOS, Linux, Windows (Git Bash, WSL, MSYS2)
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Find the free-code Python binary
|
|
8
|
+
find_free_code() {
|
|
9
|
+
# Check common locations
|
|
10
|
+
command -v free-code 2>/dev/null && return 0
|
|
11
|
+
|
|
12
|
+
# Check pip --user install locations
|
|
13
|
+
if [ -n "$HOME" ]; then
|
|
14
|
+
for dir in \
|
|
15
|
+
"$HOME/.local/bin/free-code" \
|
|
16
|
+
"$HOME/Library/Python/3.*/bin/free-code" \
|
|
17
|
+
"$HOME/AppData/Roaming/Python/Python3*/Scripts/free-code.exe" \
|
|
18
|
+
"$HOME/AppData/Roaming/Python/Python3*/Scripts/free-code" \
|
|
19
|
+
; do
|
|
20
|
+
# shellcheck disable=SC2086
|
|
21
|
+
for match in $dir; do
|
|
22
|
+
if [ -x "$match" ] 2>/dev/null; then
|
|
23
|
+
echo "$match"
|
|
24
|
+
return 0
|
|
25
|
+
fi
|
|
26
|
+
done
|
|
27
|
+
done
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Try running as Python module
|
|
31
|
+
for py in python3 python py; do
|
|
32
|
+
if command -v "$py" >/dev/null 2>&1; then
|
|
33
|
+
if "$py" -c "import free_code" 2>/dev/null; then
|
|
34
|
+
echo "PYTHON_MODULE:$py"
|
|
35
|
+
return 0
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
done
|
|
39
|
+
|
|
40
|
+
return 1
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
FREE_CODE_BIN=$(find_free_code) || true
|
|
44
|
+
|
|
45
|
+
if [ -z "$FREE_CODE_BIN" ]; then
|
|
46
|
+
echo "free-code: Python package not found." >&2
|
|
47
|
+
echo "" >&2
|
|
48
|
+
echo "Install it with:" >&2
|
|
49
|
+
echo " pip install free-code" >&2
|
|
50
|
+
echo "" >&2
|
|
51
|
+
echo "Or reinstall the npm package:" >&2
|
|
52
|
+
echo " npm install -g free-code" >&2
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# If we found it as a Python module, run via python -m
|
|
57
|
+
case "$FREE_CODE_BIN" in
|
|
58
|
+
PYTHON_MODULE:*)
|
|
59
|
+
PY_CMD="${FREE_CODE_BIN#PYTHON_MODULE:}"
|
|
60
|
+
exec "$PY_CMD" -m free_code "$@"
|
|
61
|
+
;;
|
|
62
|
+
*)
|
|
63
|
+
exec "$FREE_CODE_BIN" "$@"
|
|
64
|
+
;;
|
|
65
|
+
esac
|
package/install.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execSync, spawnSync } = require("child_process");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const MINIMUM_PYTHON = [3, 9];
|
|
8
|
+
|
|
9
|
+
function log(msg) {
|
|
10
|
+
console.log(`[free-code] ${msg}`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function warn(msg) {
|
|
14
|
+
console.warn(`[free-code] WARNING: ${msg}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function error(msg) {
|
|
18
|
+
console.error(`[free-code] ERROR: ${msg}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Try running a command, return stdout or null
|
|
22
|
+
function tryExec(cmd) {
|
|
23
|
+
try {
|
|
24
|
+
return execSync(cmd, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Find a working Python >= 3.9
|
|
31
|
+
function findPython() {
|
|
32
|
+
const candidates = os.platform() === "win32"
|
|
33
|
+
? ["py -3", "python", "python3"]
|
|
34
|
+
: ["python3", "python", "py"];
|
|
35
|
+
|
|
36
|
+
for (const cmd of candidates) {
|
|
37
|
+
const version = tryExec(`${cmd} --version`);
|
|
38
|
+
if (version) {
|
|
39
|
+
const match = version.match(/Python (\d+)\.(\d+)/);
|
|
40
|
+
if (match) {
|
|
41
|
+
const major = parseInt(match[1], 10);
|
|
42
|
+
const minor = parseInt(match[2], 10);
|
|
43
|
+
if (major > MINIMUM_PYTHON[0] || (major === MINIMUM_PYTHON[0] && minor >= MINIMUM_PYTHON[1])) {
|
|
44
|
+
return { cmd, version: `${major}.${minor}` };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Find a working pip
|
|
53
|
+
function findPip(pythonCmd) {
|
|
54
|
+
// Try pip as a module first (most reliable)
|
|
55
|
+
if (tryExec(`${pythonCmd} -m pip --version`) !== null) {
|
|
56
|
+
return { cmd: `${pythonCmd} -m pip`, type: "pip" };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const pipCandidates = os.platform() === "win32"
|
|
60
|
+
? ["pip", "pip3"]
|
|
61
|
+
: ["pip3", "pip"];
|
|
62
|
+
|
|
63
|
+
for (const cmd of pipCandidates) {
|
|
64
|
+
if (tryExec(`${cmd} --version`) !== null) {
|
|
65
|
+
return { cmd, type: "pip" };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Try pipx
|
|
70
|
+
if (tryExec("pipx --version") !== null) {
|
|
71
|
+
return { cmd: "pipx", type: "pipx" };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function main() {
|
|
78
|
+
log("Setting up free-code...");
|
|
79
|
+
|
|
80
|
+
// Check if free-code Python package is already installed
|
|
81
|
+
const existing = tryExec("free-code --version");
|
|
82
|
+
if (existing) {
|
|
83
|
+
log(`free-code is already installed (${existing})`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Find Python
|
|
88
|
+
const python = findPython();
|
|
89
|
+
if (!python) {
|
|
90
|
+
error("Python 3.9+ is required but not found.");
|
|
91
|
+
error("Install Python from https://python.org or https://free.ai/install");
|
|
92
|
+
console.error("");
|
|
93
|
+
error("After installing Python, run: pip install free-code");
|
|
94
|
+
process.exit(0); // Don't fail npm install, the bin script will show the error
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
log(`Found Python ${python.version} (${python.cmd})`);
|
|
98
|
+
|
|
99
|
+
// Find pip
|
|
100
|
+
const pip = findPip(python.cmd);
|
|
101
|
+
if (!pip) {
|
|
102
|
+
warn("pip not found. Trying to bootstrap it...");
|
|
103
|
+
const bootstrap = tryExec(`${python.cmd} -m ensurepip --upgrade`);
|
|
104
|
+
if (bootstrap === null) {
|
|
105
|
+
error("Could not find or install pip.");
|
|
106
|
+
error("Install pip manually: https://pip.pypa.io/en/stable/installation/");
|
|
107
|
+
error("Then run: pip install free-code");
|
|
108
|
+
process.exit(0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const pipInfo = pip || findPip(python.cmd);
|
|
113
|
+
if (!pipInfo) {
|
|
114
|
+
error("pip setup failed. Install manually: pip install free-code");
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
log(`Installing free-code Python package via ${pipInfo.type}...`);
|
|
119
|
+
|
|
120
|
+
let installCmd;
|
|
121
|
+
if (pipInfo.type === "pipx") {
|
|
122
|
+
installCmd = "pipx install free-code";
|
|
123
|
+
} else {
|
|
124
|
+
installCmd = `${pipInfo.cmd} install free-code`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const result = spawnSync(installCmd, {
|
|
128
|
+
shell: true,
|
|
129
|
+
stdio: "inherit",
|
|
130
|
+
env: { ...process.env },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (result.status !== 0) {
|
|
134
|
+
// Try with --user flag if regular install fails
|
|
135
|
+
if (pipInfo.type === "pip") {
|
|
136
|
+
log("Retrying with --user flag...");
|
|
137
|
+
const retry = spawnSync(`${pipInfo.cmd} install --user free-code`, {
|
|
138
|
+
shell: true,
|
|
139
|
+
stdio: "inherit",
|
|
140
|
+
});
|
|
141
|
+
if (retry.status !== 0) {
|
|
142
|
+
warn("pip install failed. You may need to run manually:");
|
|
143
|
+
warn(` ${pipInfo.cmd} install free-code`);
|
|
144
|
+
process.exit(0);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
warn("Installation failed. Run manually: pip install free-code");
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
log("free-code installed successfully!");
|
|
153
|
+
log("Run 'free-code' to start your AI coding assistant.");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "freeai-code",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Free AI coding assistant — free Claude Code alternative",
|
|
5
|
+
"bin": {
|
|
6
|
+
"free-code": "bin/free-code"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"ai",
|
|
13
|
+
"code",
|
|
14
|
+
"assistant",
|
|
15
|
+
"claude-code",
|
|
16
|
+
"cursor",
|
|
17
|
+
"copilot",
|
|
18
|
+
"free",
|
|
19
|
+
"coding",
|
|
20
|
+
"cli",
|
|
21
|
+
"terminal"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/nadermx/free-code"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://free.ai",
|
|
29
|
+
"author": "Free.ai",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=14"
|
|
32
|
+
}
|
|
33
|
+
}
|