gent-cli 26.0.0 → 27.0.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 +1 -1
- package/package.json +3 -3
- package/src/commands/ai.js +1 -1
- package/src/commands/doctor.js +1 -1
- package/src/commands/resolve.js +11 -8
- package/src/utils/ai-service.js +29 -8
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Beyond a faithful git-like workflow, Gent adds:
|
|
|
24
24
|
- **`gent undo` / `gent redo`** — a one-command safety net over an operation journal (friendlier than `git reflog`).
|
|
25
25
|
- **`gent resolve`** — an interactive conflict resolver (ours / theirs / both / edit / AI).
|
|
26
26
|
- **`gent summary`** — a repository health dashboard, plus **`gent log --graph`**.
|
|
27
|
-
- **
|
|
27
|
+
- **Managed AI** (`gent chat`, `gent review`, `gent merge --ai`, `gent resolve --ai`) — low-latency AI through the signed-in Gent account, with task-specific prompts and no user API-key setup.
|
|
28
28
|
- **Genti, your terminal mascot** — a mint one-eyed sky-jelly that *acts out* your workflow: it floats a file crate to the cloud on `gent push`, carries one home on `gent pull`, and reconciles two branches on `gent merge`. It plays once (in place, no scrollback spam) after a successful command. Meet it directly with `gent pet` (add `--loop` to keep it running; try `gent pet push|pull|merge|auth`). Set `GENT_NO_PET=1` (or run in CI / a non-interactive shell) to turn the celebrations off.
|
|
29
29
|
|
|
30
30
|
See [docs/COMMANDS.md](docs/COMMANDS.md) for the full reference and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gent-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0",
|
|
4
4
|
"description": "A modern, Git-like version control CLI with cloud sync, AI-powered superpowers (ask/review/docs/changelog), and zero-friction setup (gent setup/doctor/config).",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node src/index.js",
|
|
11
|
-
"test": "node --check src/index.js && node --test tests/diff.test.js tests/merge.test.js tests/hash.test.js tests/merge-base.test.js tests/file-system.test.js tests/web-urls.test.js tests/repos.test.js tests/ai-service.test.js tests/auth-storage.test.js && node tests/offline-e2e.js && node tests/ai-merge.e2e.js && node --test tests/git-compat/engine.test.js tests/git-compat/cli.test.js tests/git-compat/transport.test.js tests/git-compat/migrate.test.js",
|
|
12
|
-
"test:unit": "node --test tests/diff.test.js tests/merge.test.js tests/hash.test.js tests/merge-base.test.js tests/file-system.test.js tests/web-urls.test.js tests/repos.test.js tests/ai-service.test.js tests/auth-storage.test.js",
|
|
11
|
+
"test": "node --check src/index.js && node --test tests/diff.test.js tests/merge.test.js tests/hash.test.js tests/merge-base.test.js tests/file-system.test.js tests/web-urls.test.js tests/repos.test.js tests/ai-service.test.js tests/auth-storage.test.js tests/resolve-options.test.js && node tests/offline-e2e.js && node tests/ai-merge.e2e.js && node --test tests/git-compat/engine.test.js tests/git-compat/cli.test.js tests/git-compat/transport.test.js tests/git-compat/migrate.test.js",
|
|
12
|
+
"test:unit": "node --test tests/diff.test.js tests/merge.test.js tests/hash.test.js tests/merge-base.test.js tests/file-system.test.js tests/web-urls.test.js tests/repos.test.js tests/ai-service.test.js tests/auth-storage.test.js tests/resolve-options.test.js",
|
|
13
13
|
"test:e2e": "node tests/offline-e2e.js",
|
|
14
14
|
"test:remote:e2e": "node tests/remote-e2e.js",
|
|
15
15
|
"demo": "bash demo.sh",
|
package/src/commands/ai.js
CHANGED
|
@@ -28,7 +28,7 @@ async function status() {
|
|
|
28
28
|
|
|
29
29
|
console.log(chalk.bold.cyan('\nGent AI status\n'));
|
|
30
30
|
if (available) {
|
|
31
|
-
console.log(` ${chalk.green('●')} Service: ${chalk.white(
|
|
31
|
+
console.log(` ${chalk.green('●')} Service: ${chalk.white(source)}`);
|
|
32
32
|
} else {
|
|
33
33
|
console.log(` ${chalk.gray('○')} Service: ${chalk.gray('unavailable')}`);
|
|
34
34
|
console.log(chalk.gray(' ↳ ' + ai.disabledHint()));
|
package/src/commands/doctor.js
CHANGED
|
@@ -145,7 +145,7 @@ async function checkAiKey(probe) {
|
|
|
145
145
|
return {
|
|
146
146
|
name: 'AI service',
|
|
147
147
|
status: 'pass',
|
|
148
|
-
detail:
|
|
148
|
+
detail: `${source}, model: ${await ai.resolveModel()} (use --ai to live-test)`,
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
package/src/commands/resolve.js
CHANGED
|
@@ -33,6 +33,13 @@ const journal = require('../utils/journal');
|
|
|
33
33
|
const ai = require('../utils/ai-service');
|
|
34
34
|
const reviewCommand = require('./review');
|
|
35
35
|
|
|
36
|
+
function resolutionModes() {
|
|
37
|
+
return [
|
|
38
|
+
{ name: 'Resolve with AI (fast) — resolve, commit, then review', value: 'ai' },
|
|
39
|
+
{ name: 'Resolve manually — choose each conflict', value: 'manual' },
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
async function resolve(options = {}) {
|
|
37
44
|
try {
|
|
38
45
|
await ai.prime();
|
|
@@ -65,15 +72,12 @@ async function resolve(options = {}) {
|
|
|
65
72
|
return;
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
if (!options.ai &&
|
|
75
|
+
if (!options.ai && process.stdin.isTTY && process.stdout.isTTY) {
|
|
69
76
|
const { mode } = await inquirer.prompt([{
|
|
70
77
|
type: 'list',
|
|
71
78
|
name: 'mode',
|
|
72
79
|
message: 'How should Gent resolve this merge?',
|
|
73
|
-
choices:
|
|
74
|
-
{ name: 'Merge with AI (fast) — resolve, commit, then review', value: 'ai' },
|
|
75
|
-
{ name: 'Resolve manually — choose each conflict', value: 'manual' },
|
|
76
|
-
],
|
|
80
|
+
choices: resolutionModes(),
|
|
77
81
|
}]);
|
|
78
82
|
options.ai = mode === 'ai';
|
|
79
83
|
}
|
|
@@ -190,9 +194,7 @@ async function resolveHunk(seg, file, idx, total, options = {}) {
|
|
|
190
194
|
{ name: 'Keep both (ours then theirs)', value: 'both' },
|
|
191
195
|
{ name: 'Edit manually', value: 'edit' }
|
|
192
196
|
];
|
|
193
|
-
|
|
194
|
-
choices.splice(3, 0, { name: `Ask AI (${ai.getModel()})`, value: 'ai' });
|
|
195
|
-
}
|
|
197
|
+
choices.splice(3, 0, { name: `Resolve with AI (${ai.getModel()})`, value: 'ai' });
|
|
196
198
|
choices.push({ name: 'Skip the rest of this file', value: 'skip' });
|
|
197
199
|
|
|
198
200
|
if (options.ai) {
|
|
@@ -324,3 +326,4 @@ async function finalizeMerge(gentPath, staging, mergeState, entriesByName) {
|
|
|
324
326
|
}
|
|
325
327
|
|
|
326
328
|
module.exports = resolve;
|
|
329
|
+
module.exports.resolutionModes = resolutionModes;
|
package/src/utils/ai-service.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Managed AI client for Gent commands, with a direct local-development override. */
|
|
2
2
|
|
|
3
3
|
const axios = require('axios');
|
|
4
|
+
const apiClient = require('./api-client');
|
|
5
|
+
const authStorage = require('./auth-storage');
|
|
4
6
|
|
|
5
7
|
const API_URL = 'https://api.openai.com/v1/responses';
|
|
6
8
|
const DEFAULT_MODEL = 'gpt-4.1-mini';
|
|
9
|
+
let managedEnabled = false;
|
|
7
10
|
|
|
8
11
|
const PROMPTS = Object.freeze({
|
|
9
12
|
chat: 'Answer as a concise senior engineer. Use the repository context. Give the direct answer first.',
|
|
@@ -30,7 +33,9 @@ function getApiUrl() {
|
|
|
30
33
|
|
|
31
34
|
async function resolveKey() {
|
|
32
35
|
const value = getApiKey();
|
|
33
|
-
return { value, source:
|
|
36
|
+
if (value) return { value, source: 'local Gent installation' };
|
|
37
|
+
managedEnabled = Boolean(await authStorage.getAccessToken());
|
|
38
|
+
return { value: managedEnabled ? 'managed' : null, source: managedEnabled ? 'managed Gent service' : 'unset' };
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
async function resolveModel() {
|
|
@@ -42,11 +47,11 @@ async function prime() {
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
function isEnabled() {
|
|
45
|
-
return Boolean(getApiKey());
|
|
50
|
+
return Boolean(getApiKey()) || managedEnabled;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
function disabledHint() {
|
|
49
|
-
return 'Gent AI is unavailable in
|
|
54
|
+
return 'Gent AI is unavailable. Sign in with `gent login` and try again.';
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
function extractText(payload) {
|
|
@@ -62,10 +67,21 @@ function extractText(payload) {
|
|
|
62
67
|
|
|
63
68
|
async function complete({ prompt, system, profile = 'chat', maxTokens = 1024 }) {
|
|
64
69
|
const apiKey = getApiKey();
|
|
65
|
-
if (!apiKey)
|
|
66
|
-
|
|
70
|
+
if (!apiKey && !managedEnabled) await resolveKey();
|
|
71
|
+
if (!apiKey && !managedEnabled) throw new Error(disabledHint());
|
|
67
72
|
const instructions = [PROMPTS[profile], system].filter(Boolean).join('\n\n');
|
|
68
73
|
try {
|
|
74
|
+
if (!apiKey) {
|
|
75
|
+
const response = await apiClient.post('/api/ai/complete/', {
|
|
76
|
+
profile,
|
|
77
|
+
prompt,
|
|
78
|
+
system,
|
|
79
|
+
max_tokens: maxTokens,
|
|
80
|
+
});
|
|
81
|
+
const text = response?.output_text?.trim();
|
|
82
|
+
if (!text) throw new Error('Gent AI returned an empty response');
|
|
83
|
+
return text;
|
|
84
|
+
}
|
|
69
85
|
const response = await axios.post(getApiUrl(), {
|
|
70
86
|
model: getModel(),
|
|
71
87
|
input: prompt,
|
|
@@ -90,10 +106,15 @@ async function complete({ prompt, system, profile = 'chat', maxTokens = 1024 })
|
|
|
90
106
|
function enrichAiError(error) {
|
|
91
107
|
const status = error?.response?.status;
|
|
92
108
|
const apiError = error?.response?.data?.error;
|
|
93
|
-
|
|
94
|
-
if (
|
|
109
|
+
const apiCode = typeof apiError === 'object' ? apiError?.code : null;
|
|
110
|
+
if (status === 401) return new Error('Sign in with `gent login` to use Gent AI.');
|
|
111
|
+
if (status === 404) return new Error('Gent AI is not available on this Gent server yet.');
|
|
112
|
+
if (status === 403) return new Error('Gent AI access was rejected.');
|
|
113
|
+
if (status === 503) return new Error('Gent AI is temporarily unavailable.');
|
|
114
|
+
if (apiCode === 'insufficient_quota') return new Error('Gent AI quota is exhausted.');
|
|
95
115
|
if (status === 429) return new Error('Gent AI is busy. Retry in a moment.');
|
|
96
116
|
if (apiError?.message) return new Error(`Gent AI failed: ${apiError.message}`);
|
|
117
|
+
if (typeof apiError === 'string') return new Error(apiError);
|
|
97
118
|
return error;
|
|
98
119
|
}
|
|
99
120
|
|