@mamoun-code/cli 0.0.0-stage → 0.1.2
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 +102 -2
- package/bin/mamoun.js +94 -0
- package/package.json +23 -4
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Mamoun Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An AI coding agent in your terminal. It reads your project, edits files, and runs commands with your approval.
|
|
4
|
+
|
|
5
|
+
Mamoun Code is in a private beta. You need a Mamoun account that is on the beta list.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
You need Node.js 18 or newer.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm i -g @mamoun-code/cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This installs the `mamoun` command and the binary for your system: macOS, Linux or Windows, on x64 or arm64.
|
|
16
|
+
|
|
17
|
+
## Log in
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
mamoun login
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Mamoun shows a link and a code. Open the link, check that the code matches, and approve. The terminal then says `Logged in.`
|
|
24
|
+
|
|
25
|
+
## Your first task
|
|
26
|
+
|
|
27
|
+
In a project folder, run `mamoun` and type what you want:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
mamoun
|
|
31
|
+
> Why does the cart test fail? Fix it.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Mamoun shows each file edit and command before it happens and waits for your approval.
|
|
35
|
+
|
|
36
|
+
For one task without the interactive screen:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
mamoun -p "Explain what src/cart.js does"
|
|
40
|
+
mamoun -p "Fix the failing test in test/cart.test.js" --allow-edits
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
In this mode, Mamoun edits files only when you pass `--allow-edits`. It runs only the commands you allow:
|
|
44
|
+
- with an always-allow rule saved in the interactive screen;
|
|
45
|
+
- with `--allow-command "npm test"` for this run only.
|
|
46
|
+
|
|
47
|
+
## Effort
|
|
48
|
+
|
|
49
|
+
`--effort low|medium|high`, or `/effort` in the interactive screen, sets how hard Mamoun works on a task. The default is medium.
|
|
50
|
+
- **Low** is quick and cheap, for small questions.
|
|
51
|
+
- **High** reads more and thinks longer, for hard bugs.
|
|
52
|
+
|
|
53
|
+
Higher effort uses more of your plan's allowance. `/usage` shows how much you have used.
|
|
54
|
+
|
|
55
|
+
## Useful commands
|
|
56
|
+
|
|
57
|
+
| You type | What it does |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `@path/to/file` | Attach a file or folder to your message |
|
|
60
|
+
| `!npm test` | Run a command yourself; Mamoun sees its output |
|
|
61
|
+
| `/undo` | Undo Mamoun's latest file edit |
|
|
62
|
+
| `/compact` | Summarize the conversation so far, to keep long sessions fast |
|
|
63
|
+
| `/resume` | Continue an earlier session in this project (or start with `mamoun --resume`) |
|
|
64
|
+
| `/usage` | Show how much of your allowance you have used |
|
|
65
|
+
| `/help` | List every command |
|
|
66
|
+
|
|
67
|
+
`mamoun --continue` reopens the latest session in this project.
|
|
68
|
+
|
|
69
|
+
## What is stored where
|
|
70
|
+
|
|
71
|
+
- **On the Mamoun server:** only usage numbers, such as how many steps ran, at which effort, and what they cost. Never your files, prompts, answers or command output.
|
|
72
|
+
- **On your machine:** your conversations, in `~/.mamoun`. Old sessions are cleaned up automatically.
|
|
73
|
+
- Mamoun never reads files your `.gitignore` or `.mamounignore` excludes, or files that look like secrets.
|
|
74
|
+
|
|
75
|
+
## Unsigned builds
|
|
76
|
+
|
|
77
|
+
The beta builds are not yet code-signed.
|
|
78
|
+
- **macOS and Linux:** installs through npm run normally.
|
|
79
|
+
- **Windows with Smart App Control on** (Windows 11): unsigned programs are blocked, and there is no "Run anyway";
|
|
80
|
+
`mamoun` says "Windows blocked …". Use WSL until the builds are signed. In an Ubuntu terminal:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
sudo apt update && sudo apt install -y npm
|
|
84
|
+
sudo npm i -g @mamoun-code/cli
|
|
85
|
+
mamoun login
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Your Windows folders are under `/mnt/c/...` there.
|
|
89
|
+
- **Windows with SmartScreen:** if it warns about `mamoun.exe`, choose **More info**, then **Run anyway**.
|
|
90
|
+
|
|
91
|
+
## Update, log out, uninstall
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
npm i -g @mamoun-code/cli@latest # update; Mamoun also tells you once a day when a newer version exists
|
|
95
|
+
mamoun logout # log out on this machine
|
|
96
|
+
npm rm -g @mamoun-code/cli # uninstall
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can also disconnect a machine from the web app: open the account menu at the foot of the sidebar and choose **Connected CLIs**.
|
|
100
|
+
|
|
101
|
+
## Feedback
|
|
102
|
+
|
|
103
|
+
Send bugs and ideas to your beta contact. For a bug, include what you ran and what happened. If you can, also run it again with `--debug` and attach the log it names. The log holds ids and sizes, never file contents.
|
package/bin/mamoun.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// Runs the Mamoun Code binary from the platform package npm installed for this machine.
|
|
4
|
+
|
|
5
|
+
const { spawn } = require("node:child_process");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
// Each platform and CPU npm reports, and the package that holds its binary. Kept in step with platforms.mjs by a test.
|
|
9
|
+
const PACKAGES = {
|
|
10
|
+
"darwin-x64": "@mamoun-code/cli-darwin-x64",
|
|
11
|
+
"darwin-arm64": "@mamoun-code/cli-darwin-arm64",
|
|
12
|
+
"linux-x64": "@mamoun-code/cli-linux-x64",
|
|
13
|
+
"linux-arm64": "@mamoun-code/cli-linux-arm64",
|
|
14
|
+
"win32-x64": "@mamoun-code/cli-win32-x64",
|
|
15
|
+
"win32-arm64": "@mamoun-code/cli-win32-arm64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function packageFor(platform, arch) {
|
|
19
|
+
return Object.hasOwn(PACKAGES, `${platform}-${arch}`) ? PACKAGES[`${platform}-${arch}`] : undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function binaryPath(platform, arch, resolve) {
|
|
23
|
+
const target = `${platform}-${arch}`;
|
|
24
|
+
const name = packageFor(platform, arch);
|
|
25
|
+
if (!name) {
|
|
26
|
+
throw new Error(`Mamoun Code has no build for ${target}. It runs on macOS, Linux and Windows, on x64 and arm64.`);
|
|
27
|
+
}
|
|
28
|
+
let manifest;
|
|
29
|
+
try {
|
|
30
|
+
manifest = resolve(`${name}/package.json`);
|
|
31
|
+
} catch {
|
|
32
|
+
throw new Error(`The Mamoun Code binary for ${target} (${name}) is not installed. npm may have skipped optional `
|
|
33
|
+
+ `dependencies: reinstall with "npm i -g @mamoun-code/cli", without --omit=optional or --no-optional.`);
|
|
34
|
+
}
|
|
35
|
+
return path.join(path.dirname(manifest), "bin", platform === "win32" ? "mamoun.exe" : "mamoun");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The codes Windows gives when it refuses to run a program, such as an unsigned one under Smart App Control.
|
|
39
|
+
const WINDOWS_BLOCKED = new Set(["UNKNOWN", "EACCES", "EPERM"]);
|
|
40
|
+
|
|
41
|
+
// startFailure is what to tell the developer when the binary could not be started.
|
|
42
|
+
function startFailure(binary, err, platform) {
|
|
43
|
+
if (platform === "win32" && WINDOWS_BLOCKED.has(err.code)) {
|
|
44
|
+
return `Windows blocked ${binary}. Smart App Control only runs signed programs, and this beta build is not `
|
|
45
|
+
+ `signed yet. Use Mamoun Code in WSL for now: inside Ubuntu, run "npm i -g @mamoun-code/cli".`;
|
|
46
|
+
}
|
|
47
|
+
return `Could not start ${binary}: ${err.message}. Reinstall with "npm i -g @mamoun-code/cli".`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// launch runs the binary on this terminal with these arguments, and ends this process the way the binary ended.
|
|
51
|
+
// Ctrl+C already reaches the binary, because the terminal signals the whole process group, so SIGINT only keeps this
|
|
52
|
+
// process alive to pass the exit code on; forwarding it would be a second Ctrl+C, which force-quits. SIGTERM and SIGHUP
|
|
53
|
+
// are sent to this process alone, so they are passed on.
|
|
54
|
+
function launch(binary, args) {
|
|
55
|
+
let child;
|
|
56
|
+
try {
|
|
57
|
+
child = spawn(binary, args, { stdio: "inherit" });
|
|
58
|
+
} catch (err) {
|
|
59
|
+
// Windows refuses a blocked program here, at once, rather than through the "error" event.
|
|
60
|
+
console.error(startFailure(binary, err, process.platform));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
process.on("SIGINT", () => {});
|
|
64
|
+
for (const signal of ["SIGTERM", "SIGHUP"]) {
|
|
65
|
+
process.on(signal, () => child.kill(signal));
|
|
66
|
+
}
|
|
67
|
+
child.on("error", (err) => {
|
|
68
|
+
console.error(startFailure(binary, err, process.platform));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
child.on("exit", (code, signal) => {
|
|
72
|
+
if (signal) {
|
|
73
|
+
process.removeAllListeners(signal);
|
|
74
|
+
process.kill(process.pid, signal);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
process.exit(code ?? 1);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function main() {
|
|
82
|
+
let binary;
|
|
83
|
+
try {
|
|
84
|
+
binary = binaryPath(process.platform, process.arch, require.resolve);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(err.message);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
launch(binary, process.argv.slice(2));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { packageFor, binaryPath, launch, startFailure, PACKAGES };
|
|
93
|
+
|
|
94
|
+
if (require.main === module) main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mamoun-code/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Mamoun Code: an AI coding agent in your terminal.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"mamoun": "bin/mamoun.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"optionalDependencies": {
|
|
13
|
+
"@mamoun-code/cli-darwin-x64": "0.1.2",
|
|
14
|
+
"@mamoun-code/cli-darwin-arm64": "0.1.2",
|
|
15
|
+
"@mamoun-code/cli-linux-x64": "0.1.2",
|
|
16
|
+
"@mamoun-code/cli-linux-arm64": "0.1.2",
|
|
17
|
+
"@mamoun-code/cli-win32-x64": "0.1.2",
|
|
18
|
+
"@mamoun-code/cli-win32-arm64": "0.1.2"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"license": "UNLICENSED",
|
|
24
|
+
"homepage": "https://mamoun.app"
|
|
25
|
+
}
|