atcoder-workspace 1.1.0-beta.1

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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/THIRD_PARTY_LICENSES +21 -0
  4. package/dist/atcoder/client.d.ts +2 -0
  5. package/dist/atcoder/client.js +23 -0
  6. package/dist/atcoder/new.d.ts +15 -0
  7. package/dist/atcoder/new.js +123 -0
  8. package/dist/atcoder/parser/contest-tasks.d.ts +6 -0
  9. package/dist/atcoder/parser/contest-tasks.js +86 -0
  10. package/dist/atcoder/parser/limits.d.ts +10 -0
  11. package/dist/atcoder/parser/limits.js +71 -0
  12. package/dist/atcoder/parser/problem-page.d.ts +12 -0
  13. package/dist/atcoder/parser/problem-page.js +136 -0
  14. package/dist/atcoder/parser/submission-status.d.ts +8 -0
  15. package/dist/atcoder/parser/submission-status.js +78 -0
  16. package/dist/atcoder/submit.d.ts +9 -0
  17. package/dist/atcoder/submit.js +182 -0
  18. package/dist/cli.d.ts +2 -0
  19. package/dist/cli.js +508 -0
  20. package/dist/config/config-store.d.ts +17 -0
  21. package/dist/config/config-store.js +92 -0
  22. package/dist/session/auth.d.ts +8 -0
  23. package/dist/session/auth.js +117 -0
  24. package/dist/session/store.d.ts +15 -0
  25. package/dist/session/store.js +75 -0
  26. package/dist/test-runner/diff.d.ts +7 -0
  27. package/dist/test-runner/diff.js +32 -0
  28. package/dist/test-runner/runner.d.ts +46 -0
  29. package/dist/test-runner/runner.js +274 -0
  30. package/dist/utils/errors.d.ts +15 -0
  31. package/dist/utils/errors.js +35 -0
  32. package/dist/utils/format.d.ts +9 -0
  33. package/dist/utils/format.js +89 -0
  34. package/dist/utils/i18n.d.ts +345 -0
  35. package/dist/utils/i18n.js +413 -0
  36. package/dist/utils/open.d.ts +8 -0
  37. package/dist/utils/open.js +50 -0
  38. package/dist/workspace/finder.d.ts +9 -0
  39. package/dist/workspace/finder.js +62 -0
  40. package/dist/workspace/initializer.d.ts +4 -0
  41. package/dist/workspace/initializer.js +109 -0
  42. package/package.json +38 -0
  43. package/src/atcoder/client.ts +21 -0
  44. package/src/atcoder/new.ts +107 -0
  45. package/src/atcoder/parser/contest-tasks.test.ts +37 -0
  46. package/src/atcoder/parser/contest-tasks.ts +61 -0
  47. package/src/atcoder/parser/limits.test.ts +52 -0
  48. package/src/atcoder/parser/limits.ts +75 -0
  49. package/src/atcoder/parser/problem-page.test.ts +68 -0
  50. package/src/atcoder/parser/problem-page.ts +126 -0
  51. package/src/atcoder/parser/submission-status.test.ts +36 -0
  52. package/src/atcoder/parser/submission-status.ts +54 -0
  53. package/src/atcoder/submit.ts +170 -0
  54. package/src/cli.ts +554 -0
  55. package/src/config/config-store.ts +72 -0
  56. package/src/session/auth.ts +87 -0
  57. package/src/session/store.ts +50 -0
  58. package/src/test-runner/diff.test.ts +26 -0
  59. package/src/test-runner/diff.ts +42 -0
  60. package/src/test-runner/runner.test.ts +70 -0
  61. package/src/test-runner/runner.ts +315 -0
  62. package/src/utils/errors.ts +31 -0
  63. package/src/utils/format.test.ts +69 -0
  64. package/src/utils/format.ts +95 -0
  65. package/src/utils/i18n.test.ts +74 -0
  66. package/src/utils/i18n.ts +418 -0
  67. package/src/utils/open.ts +47 -0
  68. package/src/workspace/finder.ts +29 -0
  69. package/src/workspace/initializer.ts +85 -0
  70. package/tsconfig.json +16 -0
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatOutputLines = formatOutputLines;
7
+ exports.formatErrorOutputLines = formatErrorOutputLines;
8
+ const picocolors_1 = __importDefault(require("picocolors"));
9
+ /**
10
+ * Formats multi-line output with line numbers, a left border,
11
+ * a mismatch pointer, and smart truncation for large outputs.
12
+ */
13
+ function formatOutputLines(output, firstDiffLine) {
14
+ if (output === undefined || output === null) {
15
+ return [` ${picocolors_1.default.gray('│')} ${picocolors_1.default.dim('(no output)')}`];
16
+ }
17
+ const rawLines = output.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
18
+ const lines = [...rawLines];
19
+ // Remove last empty line if it is just a trailing newline
20
+ if (lines.length > 0 && lines[lines.length - 1] === '') {
21
+ lines.pop();
22
+ }
23
+ if (lines.length === 0) {
24
+ return [` ${picocolors_1.default.gray('│')} ${picocolors_1.default.dim('(empty)')}`];
25
+ }
26
+ const totalLines = lines.length;
27
+ const border = picocolors_1.default.gray('│');
28
+ const sep = picocolors_1.default.gray('│');
29
+ // Decide which lines to show (window around the first mismatch)
30
+ const maxDisplay = 24;
31
+ let showLines = lines.map((line, idx) => ({ line, lineNum: idx + 1 }));
32
+ let truncatedBefore = false;
33
+ let truncatedAfter = false;
34
+ let truncatedBeforeCount = 0;
35
+ let truncatedAfterCount = 0;
36
+ if (totalLines > maxDisplay) {
37
+ const diffIdx = firstDiffLine ? firstDiffLine - 1 : 0;
38
+ let start = Math.max(0, diffIdx - Math.floor(maxDisplay / 2));
39
+ let end = Math.min(totalLines, start + maxDisplay);
40
+ if (end - start < maxDisplay) {
41
+ start = Math.max(0, end - maxDisplay);
42
+ }
43
+ showLines = showLines.slice(start, end);
44
+ if (start > 0) {
45
+ truncatedBefore = true;
46
+ truncatedBeforeCount = start;
47
+ }
48
+ if (end < totalLines) {
49
+ truncatedAfter = true;
50
+ truncatedAfterCount = totalLines - end;
51
+ }
52
+ }
53
+ const lineNumWidth = String(totalLines).length;
54
+ const result = [];
55
+ if (truncatedBefore) {
56
+ result.push(` ${border} ${picocolors_1.default.dim(`... (truncated ${truncatedBeforeCount} lines)`)}`);
57
+ }
58
+ for (const item of showLines) {
59
+ const isMismatch = item.lineNum === firstDiffLine;
60
+ const lineContent = isMismatch ? picocolors_1.default.yellow(item.line) : item.line;
61
+ if (totalLines === 1) {
62
+ result.push(` ${border} ${lineContent}`);
63
+ }
64
+ else {
65
+ const lineNumStr = String(item.lineNum).padStart(lineNumWidth);
66
+ const prefix = isMismatch ? picocolors_1.default.yellow('>') : ' ';
67
+ const numColor = isMismatch ? picocolors_1.default.yellow : picocolors_1.default.gray;
68
+ result.push(` ${border} ${prefix} ${numColor(lineNumStr)} ${sep} ${lineContent}`);
69
+ }
70
+ }
71
+ if (truncatedAfter) {
72
+ result.push(` ${border} ${picocolors_1.default.dim(`... (truncated ${truncatedAfterCount} lines)`)}`);
73
+ }
74
+ return result;
75
+ }
76
+ /**
77
+ * Formats error output with red text, a left border, and clean indents.
78
+ */
79
+ function formatErrorOutputLines(errorOutput) {
80
+ if (!errorOutput) {
81
+ return [];
82
+ }
83
+ const lines = errorOutput.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
84
+ if (lines.length > 0 && lines[lines.length - 1] === '') {
85
+ lines.pop();
86
+ }
87
+ const border = picocolors_1.default.gray('│');
88
+ return lines.map(line => ` ${border} ${picocolors_1.default.red(line)}`);
89
+ }
@@ -0,0 +1,345 @@
1
+ export type Language = 'en' | 'ja';
2
+ /**
3
+ * Detects the system language.
4
+ * Default is English. If Japanese is detected in environment variables, returns 'ja'.
5
+ */
6
+ export declare function getSystemLanguage(): Language;
7
+ /**
8
+ * Gets the current active language.
9
+ * Looks up the workspace config first, then falls back to system language.
10
+ */
11
+ export declare function getLanguage(workspaceRoot?: string): Language;
12
+ export declare const MESSAGES: {
13
+ workspaceNotFound: {
14
+ en: string;
15
+ ja: string;
16
+ };
17
+ descInit: {
18
+ en: string;
19
+ ja: string;
20
+ };
21
+ descLogin: {
22
+ en: string;
23
+ ja: string;
24
+ };
25
+ descLogout: {
26
+ en: string;
27
+ ja: string;
28
+ };
29
+ descWhoami: {
30
+ en: string;
31
+ ja: string;
32
+ };
33
+ descNew: {
34
+ en: string;
35
+ ja: string;
36
+ };
37
+ descTest: {
38
+ en: string;
39
+ ja: string;
40
+ };
41
+ descSubmit: {
42
+ en: string;
43
+ ja: string;
44
+ };
45
+ descLang: {
46
+ en: string;
47
+ ja: string;
48
+ };
49
+ initIntro: {
50
+ en: string;
51
+ ja: string;
52
+ };
53
+ initSelectLang: {
54
+ en: string;
55
+ ja: string;
56
+ };
57
+ initCancelled: {
58
+ en: string;
59
+ ja: string;
60
+ };
61
+ initSpinner: {
62
+ en: string;
63
+ ja: string;
64
+ };
65
+ initFilesSet: {
66
+ en: string;
67
+ ja: string;
68
+ };
69
+ initAlreadyInitialized: {
70
+ en: string;
71
+ ja: string;
72
+ };
73
+ initCreatedConfig: {
74
+ en: (lang: string) => string;
75
+ ja: (lang: string) => string;
76
+ };
77
+ initGitignoreUpdated: {
78
+ en: string;
79
+ ja: string;
80
+ };
81
+ initOutro: {
82
+ en: string;
83
+ ja: string;
84
+ };
85
+ loginIntro: {
86
+ en: string;
87
+ ja: string;
88
+ };
89
+ loginNote: {
90
+ en: string;
91
+ ja: string;
92
+ };
93
+ loginWelcome: {
94
+ en: (username: string) => string;
95
+ ja: (username: string) => string;
96
+ };
97
+ loginEnterCookie: {
98
+ en: string;
99
+ ja: string;
100
+ };
101
+ loginPlaceholder: {
102
+ en: string;
103
+ ja: string;
104
+ };
105
+ loginCookieNotEmpty: {
106
+ en: string;
107
+ ja: string;
108
+ };
109
+ loginCancelled: {
110
+ en: string;
111
+ ja: string;
112
+ };
113
+ loginVerifying: {
114
+ en: string;
115
+ ja: string;
116
+ };
117
+ loginVerifySuccess: {
118
+ en: string;
119
+ ja: string;
120
+ };
121
+ loginVerifyFailed: {
122
+ en: string;
123
+ ja: string;
124
+ };
125
+ loginRetryConfirm: {
126
+ en: string;
127
+ ja: string;
128
+ };
129
+ loginAborted: {
130
+ en: string;
131
+ ja: string;
132
+ };
133
+ logoutSuccess: {
134
+ en: string;
135
+ ja: string;
136
+ };
137
+ whoamiVerifying: {
138
+ en: string;
139
+ ja: string;
140
+ };
141
+ whoamiLoggedIn: {
142
+ en: (username: string) => string;
143
+ ja: (username: string) => string;
144
+ };
145
+ newContestDirExists: {
146
+ en: (contestId: string) => string;
147
+ ja: (contestId: string) => string;
148
+ };
149
+ newIntro: {
150
+ en: (contestId: string) => string;
151
+ ja: (contestId: string) => string;
152
+ };
153
+ newFetchingTasks: {
154
+ en: (contestId: string) => string;
155
+ ja: (contestId: string) => string;
156
+ };
157
+ newFoundTasks: {
158
+ en: (count: number) => string;
159
+ ja: (count: number) => string;
160
+ };
161
+ newNoTasksFound: {
162
+ en: (contestId: string) => string;
163
+ ja: (contestId: string) => string;
164
+ };
165
+ newLabelNotFound: {
166
+ en: (label: string, contestId: string, available: string) => string;
167
+ ja: (label: string, contestId: string, available: string) => string;
168
+ };
169
+ newMultiselectMessage: {
170
+ en: string;
171
+ ja: string;
172
+ };
173
+ newCancelled: {
174
+ en: string;
175
+ ja: string;
176
+ };
177
+ newSettingUpTask: {
178
+ en: (label: string, id: string) => string;
179
+ ja: (label: string, id: string) => string;
180
+ };
181
+ newSetupSuccess: {
182
+ en: (label: string, count: number) => string;
183
+ ja: (label: string, count: number) => string;
184
+ };
185
+ newScaffoldingComplete: {
186
+ en: (count: number) => string;
187
+ ja: (count: number) => string;
188
+ };
189
+ testIntro: {
190
+ en: (contestId: string, label: string) => string;
191
+ ja: (contestId: string, label: string) => string;
192
+ };
193
+ testRetrievingLimits: {
194
+ en: string;
195
+ ja: string;
196
+ };
197
+ testLoadedLimits: {
198
+ en: (limit: number) => string;
199
+ ja: (limit: number) => string;
200
+ };
201
+ testDefaultLimits: {
202
+ en: string;
203
+ ja: string;
204
+ };
205
+ testDefaultLimitsError: {
206
+ en: string;
207
+ ja: string;
208
+ };
209
+ testCompilingRunning: {
210
+ en: string;
211
+ ja: string;
212
+ };
213
+ testFinished: {
214
+ en: string;
215
+ ja: string;
216
+ };
217
+ testCompilationFailed: {
218
+ en: string;
219
+ ja: string;
220
+ };
221
+ testNoSamples: {
222
+ en: string;
223
+ ja: string;
224
+ };
225
+ testOutroPassed: {
226
+ en: string;
227
+ ja: string;
228
+ };
229
+ testOutroFailed: {
230
+ en: string;
231
+ ja: string;
232
+ };
233
+ submitPreparing: {
234
+ en: (contestId: string, label: string) => string;
235
+ ja: (contestId: string, label: string) => string;
236
+ };
237
+ submitRetrievingLimits: {
238
+ en: string;
239
+ ja: string;
240
+ };
241
+ submitRunningTests: {
242
+ en: string;
243
+ ja: string;
244
+ };
245
+ submitNoSamples: {
246
+ en: string;
247
+ ja: string;
248
+ };
249
+ submitTestsFailed: {
250
+ en: string;
251
+ ja: string;
252
+ };
253
+ submitConfirmMessage: {
254
+ en: string;
255
+ ja: string;
256
+ };
257
+ submitAborted: {
258
+ en: string;
259
+ ja: string;
260
+ };
261
+ submitTestsPassed: {
262
+ en: string;
263
+ ja: string;
264
+ };
265
+ submitSubmitting: {
266
+ en: string;
267
+ ja: string;
268
+ };
269
+ submitSuccess: {
270
+ en: (id: string) => string;
271
+ ja: (id: string) => string;
272
+ };
273
+ submitWaitingJudge: {
274
+ en: string;
275
+ ja: string;
276
+ };
277
+ submitJudgeFinished: {
278
+ en: (status: string) => string;
279
+ ja: (status: string) => string;
280
+ };
281
+ submitAccepted: {
282
+ en: string;
283
+ ja: string;
284
+ };
285
+ submitFailed: {
286
+ en: string;
287
+ ja: string;
288
+ };
289
+ submitTimeout: {
290
+ en: string;
291
+ ja: string;
292
+ };
293
+ submitTimeoutWarn: {
294
+ en: (url: string) => string;
295
+ ja: (url: string) => string;
296
+ };
297
+ submitTurnstileDetected: {
298
+ en: string;
299
+ ja: string;
300
+ };
301
+ submitRejected: {
302
+ en: string;
303
+ ja: string;
304
+ };
305
+ submitFallbackMessage: {
306
+ en: string;
307
+ ja: string;
308
+ };
309
+ submitFallbackMessageWithClipboard: {
310
+ en: string;
311
+ ja: string;
312
+ };
313
+ submitManualSubmission: {
314
+ en: string;
315
+ ja: string;
316
+ };
317
+ langSuccess: {
318
+ en: (l: string) => string;
319
+ ja: (l: string) => string;
320
+ };
321
+ langInvalid: {
322
+ en: string;
323
+ ja: string;
324
+ };
325
+ langWorkspaceRequired: {
326
+ en: string;
327
+ ja: string;
328
+ };
329
+ langCommandUsage: {
330
+ en: string;
331
+ ja: string;
332
+ };
333
+ submitSessionExpired: {
334
+ en: string;
335
+ ja: string;
336
+ };
337
+ submitLangSelectNotFound: {
338
+ en: string;
339
+ ja: string;
340
+ };
341
+ };
342
+ /**
343
+ * Translates a key into the active language.
344
+ */
345
+ export declare const t: (key: keyof typeof MESSAGES, lang: Language, ...args: any[]) => string;