@ottocode/server 0.1.259 → 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.
Files changed (69) hide show
  1. package/package.json +4 -3
  2. package/src/index.ts +5 -4
  3. package/src/openapi/register.ts +92 -0
  4. package/src/openapi/route.ts +22 -0
  5. package/src/routes/ask.ts +210 -99
  6. package/src/routes/auth.ts +1701 -626
  7. package/src/routes/branch.ts +281 -90
  8. package/src/routes/config/agents.ts +79 -32
  9. package/src/routes/config/cwd.ts +46 -14
  10. package/src/routes/config/debug.ts +159 -30
  11. package/src/routes/config/defaults.ts +182 -64
  12. package/src/routes/config/main.ts +109 -73
  13. package/src/routes/config/models.ts +304 -137
  14. package/src/routes/config/providers.ts +462 -166
  15. package/src/routes/config/utils.ts +2 -2
  16. package/src/routes/doctor.ts +395 -161
  17. package/src/routes/files.ts +650 -260
  18. package/src/routes/git/branch.ts +143 -52
  19. package/src/routes/git/commit.ts +347 -141
  20. package/src/routes/git/diff.ts +239 -116
  21. package/src/routes/git/init.ts +103 -23
  22. package/src/routes/git/pull.ts +167 -65
  23. package/src/routes/git/push.ts +222 -117
  24. package/src/routes/git/remote.ts +401 -100
  25. package/src/routes/git/staging.ts +502 -141
  26. package/src/routes/git/status.ts +171 -78
  27. package/src/routes/mcp.ts +1129 -404
  28. package/src/routes/openapi.ts +27 -4
  29. package/src/routes/ottorouter.ts +1221 -389
  30. package/src/routes/provider-usage.ts +153 -36
  31. package/src/routes/research.ts +817 -370
  32. package/src/routes/root.ts +50 -6
  33. package/src/routes/session-approval.ts +228 -54
  34. package/src/routes/session-files.ts +265 -134
  35. package/src/routes/session-messages.ts +330 -150
  36. package/src/routes/session-stream.ts +83 -2
  37. package/src/routes/sessions.ts +1830 -780
  38. package/src/routes/skills.ts +849 -161
  39. package/src/routes/terminals.ts +469 -103
  40. package/src/routes/tunnel.ts +394 -118
  41. package/src/runtime/agent/runner-reasoning.ts +38 -3
  42. package/src/runtime/agent/runner.ts +1 -0
  43. package/src/runtime/ask/service.ts +1 -0
  44. package/src/runtime/message/compaction-limits.ts +3 -3
  45. package/src/runtime/provider/reasoning.ts +18 -7
  46. package/src/runtime/session/db-operations.ts +4 -3
  47. package/src/runtime/utils/token.ts +7 -2
  48. package/src/tools/adapter.ts +21 -0
  49. package/src/openapi/paths/ask.ts +0 -81
  50. package/src/openapi/paths/auth.ts +0 -687
  51. package/src/openapi/paths/branch.ts +0 -102
  52. package/src/openapi/paths/config.ts +0 -485
  53. package/src/openapi/paths/doctor.ts +0 -165
  54. package/src/openapi/paths/files.ts +0 -236
  55. package/src/openapi/paths/git.ts +0 -690
  56. package/src/openapi/paths/mcp.ts +0 -339
  57. package/src/openapi/paths/messages.ts +0 -103
  58. package/src/openapi/paths/ottorouter.ts +0 -594
  59. package/src/openapi/paths/provider-usage.ts +0 -59
  60. package/src/openapi/paths/research.ts +0 -227
  61. package/src/openapi/paths/session-approval.ts +0 -93
  62. package/src/openapi/paths/session-extras.ts +0 -336
  63. package/src/openapi/paths/session-files.ts +0 -91
  64. package/src/openapi/paths/sessions.ts +0 -210
  65. package/src/openapi/paths/skills.ts +0 -377
  66. package/src/openapi/paths/stream.ts +0 -26
  67. package/src/openapi/paths/terminals.ts +0 -226
  68. package/src/openapi/paths/tunnel.ts +0 -163
  69. package/src/openapi/spec.ts +0 -73
@@ -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
- app.get('/v1/git/status', async (c) => {
16
- try {
17
- const query = gitStatusSchema.parse({
18
- project: c.req.query('project'),
19
- });
20
-
21
- const requestedPath = query.project || process.cwd();
22
-
23
- const validation = await validateAndGetGitRoot(requestedPath);
24
- if ('error' in validation) {
25
- return c.json(
26
- { status: 'error', error: validation.error, code: validation.code },
27
- 400,
28
- );
29
- }
30
-
31
- const { gitRoot } = validation;
32
-
33
- const { stdout: statusOutput } = await execFileAsync(
34
- 'git',
35
- ['status', '--porcelain=v2'],
36
- { cwd: gitRoot },
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
- const { staged, unstaged, untracked, conflicted } = parseGitStatus(
40
- statusOutput,
41
- gitRoot,
42
- );
113
+ const requestedPath = query.project || process.cwd();
43
114
 
44
- const { ahead, behind } = await getAheadBehind(gitRoot);
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
- const branch = await getCurrentBranch(gitRoot);
123
+ const { gitRoot } = validation;
47
124
 
48
- let hasUpstream = false;
49
- try {
50
- await execFileAsync(
125
+ const { stdout: statusOutput } = await execFileAsync(
51
126
  'git',
52
- ['rev-parse', '--abbrev-ref', '@{upstream}'],
127
+ ['status', '--porcelain=v2'],
53
128
  { cwd: gitRoot },
54
129
  );
55
- hasUpstream = true;
56
- } catch {}
57
130
 
58
- let remotes: string[] = [];
59
- try {
60
- const { stdout: remotesOutput } = await execFileAsync(
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
- const hasChanges =
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
- const hasConflicts = conflicted.length > 0;
138
+ const branch = await getCurrentBranch(gitRoot);
75
139
 
76
- return c.json({
77
- status: 'ok',
78
- data: {
79
- branch,
80
- ahead,
81
- behind,
82
- hasUpstream,
83
- remotes,
84
- gitRoot,
85
- workingDir: requestedPath,
86
- staged,
87
- unstaged,
88
- untracked,
89
- conflicted,
90
- hasChanges,
91
- hasConflicts,
92
- },
93
- });
94
- } catch (error) {
95
- return c.json(
96
- {
97
- status: 'error',
98
- error:
99
- error instanceof Error ? error.message : 'Failed to get status',
100
- },
101
- 500,
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
  }