mantiz-cli 0.1.2 → 0.2.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 +15 -2
- package/package.json +2 -2
- package/src/index.ts +29 -4
package/README.md
CHANGED
|
@@ -28,9 +28,15 @@ mantiz-scan --json
|
|
|
28
28
|
# Scan a specific diff file
|
|
29
29
|
mantiz-scan --diff "$(cat my-diff.diff)"
|
|
30
30
|
|
|
31
|
-
# Cloud scan with API token
|
|
31
|
+
# Cloud scan with API token (results saved to your history)
|
|
32
32
|
mantiz-scan --token mtz_abc123
|
|
33
33
|
|
|
34
|
+
# Cloud scan + persist results to your Mantiz history
|
|
35
|
+
mantiz-scan --token mtz_abc123 --save
|
|
36
|
+
|
|
37
|
+
# Enable AI-assisted detection (LLM-powered semantic analysis)
|
|
38
|
+
mantiz-scan --token mtz_abc123 --ai
|
|
39
|
+
|
|
34
40
|
# Help
|
|
35
41
|
mantiz-scan --help
|
|
36
42
|
```
|
|
@@ -47,7 +53,7 @@ jobs:
|
|
|
47
53
|
steps:
|
|
48
54
|
- uses: actions/checkout@v4
|
|
49
55
|
- uses: actions/setup-node@v4
|
|
50
|
-
- run: npx @mantiz/cli --token ${{ secrets.MANTIZ_API_TOKEN }}
|
|
56
|
+
- run: npx @mantiz/cli --token ${{ secrets.MANTIZ_API_TOKEN }} --save --ai
|
|
51
57
|
```
|
|
52
58
|
|
|
53
59
|
Get your API token at: https://mantiz-wine.vercel.app/settings
|
|
@@ -63,3 +69,10 @@ Get your API token at: https://mantiz-wine.vercel.app/settings
|
|
|
63
69
|
|----------|-------------|
|
|
64
70
|
| `MANTIZ_API_TOKEN` | API token for cloud scan mode |
|
|
65
71
|
| `MANTIZ_API_URL` | API URL (default: https://mantiz-wine.vercel.app) |
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- **`--save`** — Persist scan results to your Mantiz cloud history (requires `--token`)
|
|
76
|
+
- **`--ai`** — Enable AI-assisted detection using LLM (Fireworks/Groq)
|
|
77
|
+
- **`--json`** — Output results as JSON for CI/CD pipelines
|
|
78
|
+
- **Threshold** — Default 70. Configure per-user in [Settings](https://mantiz-wine.vercel.app/settings)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mantiz-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Mantiz CLI — AI lie detector for coding agents. Scan git diffs for cheating patterns.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"scan": "tsx src/index.ts"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"mantiz-core": "0.
|
|
18
|
+
"@farhank15/mantiz-core": "0.2.2",
|
|
19
19
|
"tsx": "^4.19.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* mantiz-scan # Scan local git diff
|
|
7
7
|
* mantiz-scan --diff <str> # Scan provided diff text
|
|
8
8
|
* mantiz-scan --token x # Send to Mantiz API for cloud scan
|
|
9
|
+
mantiz-scan --token x --save # Save results to cloud history
|
|
9
10
|
* mantiz-scan --help # Show help
|
|
10
11
|
*
|
|
11
12
|
* Install:
|
|
@@ -92,6 +93,8 @@ EXAMPLES
|
|
|
92
93
|
cat my-diff.txt | mantiz-scan --diff -
|
|
93
94
|
mantiz-scan --json | jq '.trustScore'
|
|
94
95
|
mantiz-scan --token mtz_abc123
|
|
96
|
+
mantiz-scan --token mtz_abc123 --save # Save to cloud
|
|
97
|
+
mantiz-scan --token mtz_abc123 --ai # Enable AI detection
|
|
95
98
|
`)
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -104,13 +107,14 @@ async function main(): Promise<void> {
|
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
const jsonOutput = args.includes('--json')
|
|
110
|
+
const saveToCloud = args.includes('--save')
|
|
107
111
|
const tokenIndex = args.indexOf('--token')
|
|
108
112
|
const token = tokenIndex !== -1 ? args[tokenIndex + 1] : process.env.MANTIZ_API_TOKEN
|
|
109
113
|
const diffIndex = args.indexOf('--diff')
|
|
110
114
|
const diffArg = diffIndex !== -1 ? args[diffIndex + 1] : undefined
|
|
111
115
|
|
|
112
116
|
let diffText: string
|
|
113
|
-
if (diffArg) {
|
|
117
|
+
if (diffArg !== undefined) {
|
|
114
118
|
diffText = diffArg === '-' ? execSync('cat', { encoding: 'utf-8' }) : diffArg
|
|
115
119
|
} else {
|
|
116
120
|
diffText = getGitDiff()
|
|
@@ -125,16 +129,37 @@ async function main(): Promise<void> {
|
|
|
125
129
|
process.exit(1)
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
if (token) {
|
|
132
|
+
if (token || saveToCloud) {
|
|
133
|
+
const apiToken = token || process.env.MANTIZ_API_TOKEN
|
|
134
|
+
|
|
135
|
+
if (!apiToken) {
|
|
136
|
+
if (jsonOutput) {
|
|
137
|
+
console.log(JSON.stringify({ error: 'No API token found. Use --token or set MANTIZ_API_TOKEN', trustScore: 0 }))
|
|
138
|
+
} else {
|
|
139
|
+
console.log('\x1b[33m⚠️ --save requires an API token. Use --token <key> or set MANTIZ_API_TOKEN env var.\x1b[0m')
|
|
140
|
+
console.log('\x1b[33m Falling back to local scan (results not saved to cloud).\x1b[0m')
|
|
141
|
+
}
|
|
142
|
+
// Fall back to local scan
|
|
143
|
+
const result = scanDiff(diffText)
|
|
144
|
+
if (jsonOutput) {
|
|
145
|
+
console.log(JSON.stringify({ ...result, passed: result.trustScore >= PASS_THRESHOLD }, null, 2))
|
|
146
|
+
} else {
|
|
147
|
+
printResults(result)
|
|
148
|
+
}
|
|
149
|
+
process.exit(result.trustScore < PASS_THRESHOLD ? 1 : 0)
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
|
|
129
153
|
const apiUrl = process.env.MANTIZ_API_URL || 'https://mantiz-wine.vercel.app'
|
|
130
154
|
try {
|
|
131
155
|
const res = await fetch(`${apiUrl}/api/scan`, {
|
|
132
156
|
method: 'POST',
|
|
133
157
|
headers: {
|
|
134
158
|
'Content-Type': 'application/json',
|
|
135
|
-
'Authorization': `Bearer ${
|
|
159
|
+
'Authorization': `Bearer ${apiToken}`,
|
|
160
|
+
'X-Mantiz-Source': 'cli',
|
|
136
161
|
},
|
|
137
|
-
body: JSON.stringify({ diff: diffText }),
|
|
162
|
+
body: JSON.stringify({ diff: diffText, useAi: args.includes('--ai') }),
|
|
138
163
|
})
|
|
139
164
|
|
|
140
165
|
if (!res.ok) {
|