@ottocode/server 0.1.260 → 0.1.262
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/package.json +4 -3
- package/src/index.ts +5 -4
- package/src/openapi/register.ts +92 -0
- package/src/openapi/route.ts +22 -0
- package/src/routes/ask.ts +210 -99
- package/src/routes/auth.ts +1701 -626
- package/src/routes/branch.ts +281 -90
- package/src/routes/config/agents.ts +79 -32
- package/src/routes/config/cwd.ts +46 -14
- package/src/routes/config/debug.ts +159 -30
- package/src/routes/config/defaults.ts +182 -64
- package/src/routes/config/main.ts +109 -73
- package/src/routes/config/models.ts +304 -137
- package/src/routes/config/providers.ts +462 -166
- package/src/routes/config/utils.ts +2 -2
- package/src/routes/doctor.ts +395 -161
- package/src/routes/files.ts +650 -260
- package/src/routes/git/branch.ts +143 -52
- package/src/routes/git/commit.ts +347 -141
- package/src/routes/git/diff.ts +239 -116
- package/src/routes/git/init.ts +103 -23
- package/src/routes/git/pull.ts +167 -65
- package/src/routes/git/push.ts +222 -117
- package/src/routes/git/remote.ts +401 -100
- package/src/routes/git/staging.ts +502 -141
- package/src/routes/git/status.ts +171 -78
- package/src/routes/mcp.ts +1129 -404
- package/src/routes/openapi.ts +27 -4
- package/src/routes/ottorouter.ts +1221 -389
- package/src/routes/provider-usage.ts +153 -36
- package/src/routes/research.ts +817 -370
- package/src/routes/root.ts +50 -6
- package/src/routes/session-approval.ts +228 -54
- package/src/routes/session-files.ts +265 -134
- package/src/routes/session-messages.ts +330 -150
- package/src/routes/session-stream.ts +83 -2
- package/src/routes/sessions.ts +1830 -780
- package/src/routes/skills.ts +849 -161
- package/src/routes/terminals.ts +469 -103
- package/src/routes/tunnel.ts +394 -118
- package/src/runtime/ask/service.ts +1 -0
- package/src/runtime/message/compaction-limits.ts +3 -3
- package/src/runtime/provider/reasoning.ts +2 -1
- package/src/runtime/session/db-operations.ts +4 -3
- package/src/runtime/utils/token.ts +7 -2
- package/src/tools/adapter.ts +21 -0
- package/src/openapi/paths/ask.ts +0 -81
- package/src/openapi/paths/auth.ts +0 -687
- package/src/openapi/paths/branch.ts +0 -102
- package/src/openapi/paths/config.ts +0 -485
- package/src/openapi/paths/doctor.ts +0 -165
- package/src/openapi/paths/files.ts +0 -236
- package/src/openapi/paths/git.ts +0 -690
- package/src/openapi/paths/mcp.ts +0 -339
- package/src/openapi/paths/messages.ts +0 -103
- package/src/openapi/paths/ottorouter.ts +0 -594
- package/src/openapi/paths/provider-usage.ts +0 -59
- package/src/openapi/paths/research.ts +0 -227
- package/src/openapi/paths/session-approval.ts +0 -93
- package/src/openapi/paths/session-extras.ts +0 -336
- package/src/openapi/paths/session-files.ts +0 -91
- package/src/openapi/paths/sessions.ts +0 -210
- package/src/openapi/paths/skills.ts +0 -377
- package/src/openapi/paths/stream.ts +0 -26
- package/src/openapi/paths/terminals.ts +0 -226
- package/src/openapi/paths/tunnel.ts +0 -163
- package/src/openapi/spec.ts +0 -73
package/src/routes/git/status.ts
CHANGED
|
@@ -8,98 +8,191 @@ import {
|
|
|
8
8
|
getAheadBehind,
|
|
9
9
|
getCurrentBranch,
|
|
10
10
|
} from './utils.ts';
|
|
11
|
+
import { openApiRoute } from '../../openapi/route.ts';
|
|
11
12
|
|
|
12
13
|
const execFileAsync = promisify(execFile);
|
|
13
14
|
|
|
14
15
|
export function registerStatusRoute(app: Hono) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
openApiRoute(
|
|
17
|
+
app,
|
|
18
|
+
{
|
|
19
|
+
method: 'get',
|
|
20
|
+
path: '/v1/git/status',
|
|
21
|
+
tags: ['git'],
|
|
22
|
+
operationId: 'getGitStatus',
|
|
23
|
+
summary: 'Get git status',
|
|
24
|
+
description:
|
|
25
|
+
'Returns current git status including staged, unstaged, and untracked files',
|
|
26
|
+
parameters: [
|
|
27
|
+
{
|
|
28
|
+
in: 'query',
|
|
29
|
+
name: 'project',
|
|
30
|
+
required: false,
|
|
31
|
+
schema: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
},
|
|
34
|
+
description:
|
|
35
|
+
'Project root override (defaults to current working directory).',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
responses: {
|
|
39
|
+
'200': {
|
|
40
|
+
description: 'OK',
|
|
41
|
+
content: {
|
|
42
|
+
'application/json': {
|
|
43
|
+
schema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
status: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
enum: ['ok'],
|
|
49
|
+
},
|
|
50
|
+
data: {
|
|
51
|
+
$ref: '#/components/schemas/GitStatus',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ['status', 'data'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
'400': {
|
|
60
|
+
description: 'Error',
|
|
61
|
+
content: {
|
|
62
|
+
'application/json': {
|
|
63
|
+
schema: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
status: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
enum: ['error'],
|
|
69
|
+
},
|
|
70
|
+
error: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
},
|
|
73
|
+
code: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ['status', 'error'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
'500': {
|
|
83
|
+
description: 'Error',
|
|
84
|
+
content: {
|
|
85
|
+
'application/json': {
|
|
86
|
+
schema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
status: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
enum: ['error'],
|
|
92
|
+
},
|
|
93
|
+
error: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
},
|
|
96
|
+
code: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ['status', 'error'],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
async (c) => {
|
|
108
|
+
try {
|
|
109
|
+
const query = gitStatusSchema.parse({
|
|
110
|
+
project: c.req.query('project'),
|
|
111
|
+
});
|
|
38
112
|
|
|
39
|
-
|
|
40
|
-
statusOutput,
|
|
41
|
-
gitRoot,
|
|
42
|
-
);
|
|
113
|
+
const requestedPath = query.project || process.cwd();
|
|
43
114
|
|
|
44
|
-
|
|
115
|
+
const validation = await validateAndGetGitRoot(requestedPath);
|
|
116
|
+
if ('error' in validation) {
|
|
117
|
+
return c.json(
|
|
118
|
+
{ status: 'error', error: validation.error, code: validation.code },
|
|
119
|
+
400,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
45
122
|
|
|
46
|
-
|
|
123
|
+
const { gitRoot } = validation;
|
|
47
124
|
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
await execFileAsync(
|
|
125
|
+
const { stdout: statusOutput } = await execFileAsync(
|
|
51
126
|
'git',
|
|
52
|
-
['
|
|
127
|
+
['status', '--porcelain=v2'],
|
|
53
128
|
{ cwd: gitRoot },
|
|
54
129
|
);
|
|
55
|
-
hasUpstream = true;
|
|
56
|
-
} catch {}
|
|
57
130
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'git',
|
|
62
|
-
['remote'],
|
|
63
|
-
{ cwd: gitRoot },
|
|
131
|
+
const { staged, unstaged, untracked, conflicted } = parseGitStatus(
|
|
132
|
+
statusOutput,
|
|
133
|
+
gitRoot,
|
|
64
134
|
);
|
|
65
|
-
remotes = remotesOutput.trim().split('\n').filter(Boolean);
|
|
66
|
-
} catch {}
|
|
67
135
|
|
|
68
|
-
|
|
69
|
-
staged.length > 0 ||
|
|
70
|
-
unstaged.length > 0 ||
|
|
71
|
-
untracked.length > 0 ||
|
|
72
|
-
conflicted.length > 0;
|
|
136
|
+
const { ahead, behind } = await getAheadBehind(gitRoot);
|
|
73
137
|
|
|
74
|
-
|
|
138
|
+
const branch = await getCurrentBranch(gitRoot);
|
|
75
139
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
140
|
+
let hasUpstream = false;
|
|
141
|
+
try {
|
|
142
|
+
await execFileAsync(
|
|
143
|
+
'git',
|
|
144
|
+
['rev-parse', '--abbrev-ref', '@{upstream}'],
|
|
145
|
+
{ cwd: gitRoot },
|
|
146
|
+
);
|
|
147
|
+
hasUpstream = true;
|
|
148
|
+
} catch {}
|
|
149
|
+
|
|
150
|
+
let remotes: string[] = [];
|
|
151
|
+
try {
|
|
152
|
+
const { stdout: remotesOutput } = await execFileAsync(
|
|
153
|
+
'git',
|
|
154
|
+
['remote'],
|
|
155
|
+
{ cwd: gitRoot },
|
|
156
|
+
);
|
|
157
|
+
remotes = remotesOutput.trim().split('\n').filter(Boolean);
|
|
158
|
+
} catch {}
|
|
159
|
+
|
|
160
|
+
const hasChanges =
|
|
161
|
+
staged.length > 0 ||
|
|
162
|
+
unstaged.length > 0 ||
|
|
163
|
+
untracked.length > 0 ||
|
|
164
|
+
conflicted.length > 0;
|
|
165
|
+
|
|
166
|
+
const hasConflicts = conflicted.length > 0;
|
|
167
|
+
|
|
168
|
+
return c.json({
|
|
169
|
+
status: 'ok',
|
|
170
|
+
data: {
|
|
171
|
+
branch,
|
|
172
|
+
ahead,
|
|
173
|
+
behind,
|
|
174
|
+
hasUpstream,
|
|
175
|
+
remotes,
|
|
176
|
+
gitRoot,
|
|
177
|
+
workingDir: requestedPath,
|
|
178
|
+
staged,
|
|
179
|
+
unstaged,
|
|
180
|
+
untracked,
|
|
181
|
+
conflicted,
|
|
182
|
+
hasChanges,
|
|
183
|
+
hasConflicts,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
} catch (error) {
|
|
187
|
+
return c.json(
|
|
188
|
+
{
|
|
189
|
+
status: 'error',
|
|
190
|
+
error:
|
|
191
|
+
error instanceof Error ? error.message : 'Failed to get status',
|
|
192
|
+
},
|
|
193
|
+
500,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
);
|
|
105
198
|
}
|