@ottocode/server 0.1.260 → 0.1.261
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/branch.ts
CHANGED
|
@@ -7,69 +7,160 @@ import {
|
|
|
7
7
|
getAheadBehind,
|
|
8
8
|
getCurrentBranch,
|
|
9
9
|
} from './utils.ts';
|
|
10
|
+
import { openApiRoute } from '../../openapi/route.ts';
|
|
10
11
|
|
|
11
12
|
const execFileAsync = promisify(execFile);
|
|
12
13
|
|
|
13
14
|
export function registerBranchRoute(app: Hono) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
openApiRoute(
|
|
16
|
+
app,
|
|
17
|
+
{
|
|
18
|
+
method: 'get',
|
|
19
|
+
path: '/v1/git/branch',
|
|
20
|
+
tags: ['git'],
|
|
21
|
+
operationId: 'getGitBranch',
|
|
22
|
+
summary: 'Get git branch information',
|
|
23
|
+
parameters: [
|
|
24
|
+
{
|
|
25
|
+
in: 'query',
|
|
26
|
+
name: 'project',
|
|
27
|
+
required: false,
|
|
28
|
+
schema: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
description:
|
|
32
|
+
'Project root override (defaults to current working directory).',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
responses: {
|
|
36
|
+
'200': {
|
|
37
|
+
description: 'OK',
|
|
38
|
+
content: {
|
|
39
|
+
'application/json': {
|
|
40
|
+
schema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
status: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
enum: ['ok'],
|
|
46
|
+
},
|
|
47
|
+
data: {
|
|
48
|
+
$ref: '#/components/schemas/GitBranch',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ['status', 'data'],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
'400': {
|
|
57
|
+
description: 'Error',
|
|
58
|
+
content: {
|
|
59
|
+
'application/json': {
|
|
60
|
+
schema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
status: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
enum: ['error'],
|
|
66
|
+
},
|
|
67
|
+
error: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
},
|
|
70
|
+
code: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
required: ['status', 'error'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
'500': {
|
|
80
|
+
description: 'Error',
|
|
81
|
+
content: {
|
|
82
|
+
'application/json': {
|
|
83
|
+
schema: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
status: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
enum: ['error'],
|
|
89
|
+
},
|
|
90
|
+
error: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
},
|
|
93
|
+
code: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
required: ['status', 'error'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
async (c) => {
|
|
105
|
+
try {
|
|
106
|
+
const query = gitStatusSchema.parse({
|
|
107
|
+
project: c.req.query('project'),
|
|
108
|
+
});
|
|
19
109
|
|
|
20
|
-
|
|
110
|
+
const requestedPath = query.project || process.cwd();
|
|
21
111
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
112
|
+
const validation = await validateAndGetGitRoot(requestedPath);
|
|
113
|
+
if ('error' in validation) {
|
|
114
|
+
return c.json(
|
|
115
|
+
{ status: 'error', error: validation.error, code: validation.code },
|
|
116
|
+
400,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
29
119
|
|
|
30
|
-
|
|
120
|
+
const { gitRoot } = validation;
|
|
31
121
|
|
|
32
|
-
|
|
122
|
+
const branch = await getCurrentBranch(gitRoot);
|
|
33
123
|
|
|
34
|
-
|
|
124
|
+
const { ahead, behind } = await getAheadBehind(gitRoot);
|
|
35
125
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
126
|
+
try {
|
|
127
|
+
const { stdout: remotes } = await execFileAsync('git', ['remote'], {
|
|
128
|
+
cwd: gitRoot,
|
|
129
|
+
});
|
|
130
|
+
const remoteList = remotes.trim().split('\n').filter(Boolean);
|
|
41
131
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
132
|
+
return c.json({
|
|
133
|
+
status: 'ok',
|
|
134
|
+
data: {
|
|
135
|
+
branch,
|
|
136
|
+
ahead,
|
|
137
|
+
behind,
|
|
138
|
+
remotes: remoteList,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
} catch {
|
|
142
|
+
return c.json({
|
|
143
|
+
status: 'ok',
|
|
144
|
+
data: {
|
|
145
|
+
branch,
|
|
146
|
+
ahead,
|
|
147
|
+
behind,
|
|
148
|
+
remotes: [],
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return c.json(
|
|
154
|
+
{
|
|
155
|
+
status: 'error',
|
|
156
|
+
error:
|
|
157
|
+
error instanceof Error
|
|
158
|
+
? error.message
|
|
159
|
+
: 'Failed to get branch info',
|
|
59
160
|
},
|
|
60
|
-
|
|
161
|
+
500,
|
|
162
|
+
);
|
|
61
163
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
status: 'error',
|
|
66
|
-
error:
|
|
67
|
-
error instanceof Error
|
|
68
|
-
? error.message
|
|
69
|
-
: 'Failed to get branch info',
|
|
70
|
-
},
|
|
71
|
-
500,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
164
|
+
},
|
|
165
|
+
);
|
|
75
166
|
}
|