ralphctl 0.4.6 → 0.6.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 +29 -16
- package/dist/absolute-path-WUTZQ37D.mjs +8 -0
- package/dist/chunk-6RDMCLWU.mjs +108 -0
- package/dist/chunk-HIU74KTO.mjs +1046 -0
- package/dist/chunk-S3PTDH57.mjs +78 -0
- package/dist/chunk-WV4D2CPG.mjs +26 -0
- package/dist/cli.mjs +22413 -717
- package/dist/manifest.json +24 -0
- package/dist/prompt-adapter-JQICGVX7.mjs +7 -0
- package/dist/prompts/ideate.md +3 -1
- package/dist/prompts/plan-auto.md +23 -8
- package/dist/prompts/plan-common-examples.md +3 -3
- package/dist/prompts/plan-common.md +6 -5
- package/dist/prompts/plan-interactive.md +30 -7
- package/dist/prompts/repo-onboard.md +154 -64
- package/dist/prompts/signals-task.md +3 -0
- package/dist/prompts/sprint-feedback.md +3 -0
- package/dist/prompts/task-evaluation.md +74 -53
- package/dist/prompts/task-execution.md +65 -21
- package/dist/prompts/ticket-refine.md +11 -8
- package/dist/prompts/validation-checklist.md +3 -2
- package/dist/skills/default/abstraction-first/SKILL.md +45 -0
- package/dist/skills/default/alignment/SKILL.md +46 -0
- package/dist/skills/default/iterative-review/SKILL.md +48 -0
- package/dist/skills/exec/.gitkeep +0 -0
- package/dist/skills/plan/.gitkeep +0 -0
- package/dist/skills/refine/.gitkeep +0 -0
- package/dist/storage-paths-IPNZZM5D.mjs +15 -0
- package/dist/validation-error-QT6Q7FYU.mjs +7 -0
- package/package.json +9 -4
- package/dist/add-DVPVHENV.mjs +0 -18
- package/dist/add-YVXM34RP.mjs +0 -17
- package/dist/bootstrap-FMHG6DRY.mjs +0 -11
- package/dist/chunk-747KW2RW.mjs +0 -24
- package/dist/chunk-B3RCOHW3.mjs +0 -5519
- package/dist/chunk-BSB4EDGR.mjs +0 -260
- package/dist/chunk-CBMFRQ4Y.mjs +0 -441
- package/dist/chunk-CFUVE2BP.mjs +0 -16
- package/dist/chunk-FNAAA32W.mjs +0 -103
- package/dist/chunk-GQ2WFKBN.mjs +0 -269
- package/dist/chunk-IWXBJD2D.mjs +0 -27
- package/dist/chunk-O566EEDL.mjs +0 -5542
- package/dist/chunk-OGEXYSFS.mjs +0 -228
- package/dist/chunk-PYZEQ2VK.mjs +0 -787
- package/dist/chunk-VAZ3LJBI.mjs +0 -179
- package/dist/chunk-WDMLPXOD.mjs +0 -363
- package/dist/chunk-XN2UIHBY.mjs +0 -589
- package/dist/chunk-ZLWSPLWI.mjs +0 -1117
- package/dist/create-Z635FQKO.mjs +0 -15
- package/dist/handle-23EFF3BE.mjs +0 -22
- package/dist/mount-B3MLHNVY.mjs +0 -7434
- package/dist/project-DQHF4ISP.mjs +0 -34
- package/dist/prompts/check-script-discover.md +0 -69
- package/dist/prompts/ideate-auto.md +0 -195
- package/dist/prompts/task-evaluation-resume.md +0 -41
- package/dist/resolver-OVPYVW6Q.mjs +0 -163
- package/dist/sprint-4E26AB5F.mjs +0 -38
- package/dist/start-FP7MVN5P.mjs +0 -19
package/dist/chunk-FNAAA32W.mjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
EXIT_ERROR,
|
|
4
|
-
exitWithCode
|
|
5
|
-
} from "./chunk-CFUVE2BP.mjs";
|
|
6
|
-
import {
|
|
7
|
-
getPrompt
|
|
8
|
-
} from "./chunk-747KW2RW.mjs";
|
|
9
|
-
import {
|
|
10
|
-
listProjects
|
|
11
|
-
} from "./chunk-BSB4EDGR.mjs";
|
|
12
|
-
import {
|
|
13
|
-
createSprint
|
|
14
|
-
} from "./chunk-CBMFRQ4Y.mjs";
|
|
15
|
-
import {
|
|
16
|
-
emoji,
|
|
17
|
-
field,
|
|
18
|
-
formatSprintStatus,
|
|
19
|
-
icons,
|
|
20
|
-
setCurrentSprint,
|
|
21
|
-
showError,
|
|
22
|
-
showNextStep,
|
|
23
|
-
showRandomQuote,
|
|
24
|
-
showSuccess
|
|
25
|
-
} from "./chunk-XN2UIHBY.mjs";
|
|
26
|
-
|
|
27
|
-
// src/integration/cli/commands/sprint/create.ts
|
|
28
|
-
async function sprintCreateCommand(options = {}) {
|
|
29
|
-
const projects = await listProjects();
|
|
30
|
-
if (projects.length === 0) {
|
|
31
|
-
showError("No projects configured.");
|
|
32
|
-
showNextStep("ralphctl project add", "add a project first");
|
|
33
|
-
if (options.interactive === false) exitWithCode(EXIT_ERROR);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
let projectId;
|
|
37
|
-
const projectFlag = options.project?.trim();
|
|
38
|
-
if (projectFlag) {
|
|
39
|
-
const match = projects.find((p) => p.name === projectFlag || p.id === projectFlag);
|
|
40
|
-
if (!match) {
|
|
41
|
-
showError(`Project not found: ${projectFlag}`);
|
|
42
|
-
if (options.interactive === false) exitWithCode(EXIT_ERROR);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
projectId = match.id;
|
|
46
|
-
} else if (options.interactive === false) {
|
|
47
|
-
showError("--project is required in non-interactive mode");
|
|
48
|
-
exitWithCode(EXIT_ERROR);
|
|
49
|
-
} else if (projects.length === 1 && projects[0]) {
|
|
50
|
-
projectId = projects[0].id;
|
|
51
|
-
} else {
|
|
52
|
-
projectId = await getPrompt().select({
|
|
53
|
-
message: `${icons.project} Project:`,
|
|
54
|
-
choices: projects.map((p) => ({ label: p.displayName, value: p.id, description: p.description }))
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
if (!projectId) {
|
|
58
|
-
showError("No project selected.");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const pickedProject = projects.find((p) => p.id === projectId);
|
|
62
|
-
let name;
|
|
63
|
-
if (options.interactive === false) {
|
|
64
|
-
const trimmed = options.name?.trim();
|
|
65
|
-
name = trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
66
|
-
} else {
|
|
67
|
-
const inputName = await getPrompt().input({
|
|
68
|
-
message: `${icons.sprint} Sprint name (optional):`,
|
|
69
|
-
default: options.name?.trim()
|
|
70
|
-
});
|
|
71
|
-
const trimmed = inputName.trim();
|
|
72
|
-
name = trimmed.length > 0 ? trimmed : void 0;
|
|
73
|
-
}
|
|
74
|
-
const sprint = await createSprint({ projectId, name });
|
|
75
|
-
let setAsCurrent = true;
|
|
76
|
-
if (options.interactive) {
|
|
77
|
-
setAsCurrent = await getPrompt().confirm({
|
|
78
|
-
message: `${emoji.donut} Set as current sprint?`,
|
|
79
|
-
default: true
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (setAsCurrent) {
|
|
83
|
-
await setCurrentSprint(sprint.id);
|
|
84
|
-
}
|
|
85
|
-
showSuccess("Sprint created!", [
|
|
86
|
-
["ID", sprint.id],
|
|
87
|
-
["Name", sprint.name],
|
|
88
|
-
["Project", pickedProject ? `${pickedProject.displayName} (${pickedProject.name})` : projectId],
|
|
89
|
-
["Status", formatSprintStatus(sprint.status)]
|
|
90
|
-
]);
|
|
91
|
-
showRandomQuote();
|
|
92
|
-
if (setAsCurrent) {
|
|
93
|
-
console.log(field("Current", "Yes (this sprint is now active target)"));
|
|
94
|
-
showNextStep("ralphctl ticket add", "add tickets to this sprint");
|
|
95
|
-
} else {
|
|
96
|
-
console.log(field("Current", "No"));
|
|
97
|
-
showNextStep(`ralphctl sprint current ${sprint.id}`, "set as current later");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
sprintCreateCommand
|
|
103
|
-
};
|
package/dist/chunk-GQ2WFKBN.mjs
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
assertSprintStatus,
|
|
4
|
-
resolveSprintId
|
|
5
|
-
} from "./chunk-CBMFRQ4Y.mjs";
|
|
6
|
-
import {
|
|
7
|
-
unwrapOrThrow
|
|
8
|
-
} from "./chunk-IWXBJD2D.mjs";
|
|
9
|
-
import {
|
|
10
|
-
SprintSchema,
|
|
11
|
-
generateUuid8,
|
|
12
|
-
getSprintFilePath,
|
|
13
|
-
readValidatedJson,
|
|
14
|
-
writeValidatedJson
|
|
15
|
-
} from "./chunk-WDMLPXOD.mjs";
|
|
16
|
-
import {
|
|
17
|
-
IssueFetchError,
|
|
18
|
-
TicketNotFoundError
|
|
19
|
-
} from "./chunk-VAZ3LJBI.mjs";
|
|
20
|
-
|
|
21
|
-
// src/domain/strings.ts
|
|
22
|
-
function truncate(str, max) {
|
|
23
|
-
if (str.length <= max) return str;
|
|
24
|
-
if (max <= 1) return "\u2026".slice(0, Math.max(0, max));
|
|
25
|
-
return str.slice(0, max - 1) + "\u2026";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/integration/persistence/ticket.ts
|
|
29
|
-
async function getSprintData(sprintId) {
|
|
30
|
-
const id = await resolveSprintId(sprintId);
|
|
31
|
-
const result = await readValidatedJson(getSprintFilePath(id), SprintSchema);
|
|
32
|
-
if (!result.ok) throw result.error;
|
|
33
|
-
return result.value;
|
|
34
|
-
}
|
|
35
|
-
async function saveSprintData(sprint) {
|
|
36
|
-
const result = await writeValidatedJson(getSprintFilePath(sprint.id), sprint, SprintSchema);
|
|
37
|
-
if (!result.ok) throw result.error;
|
|
38
|
-
}
|
|
39
|
-
async function addTicket(input, sprintId) {
|
|
40
|
-
const sprint = await getSprintData(sprintId);
|
|
41
|
-
assertSprintStatus(sprint, ["draft"], "add tickets");
|
|
42
|
-
const ticket = {
|
|
43
|
-
id: generateUuid8(),
|
|
44
|
-
title: input.title,
|
|
45
|
-
description: input.description,
|
|
46
|
-
link: input.link,
|
|
47
|
-
affectedRepoIds: input.affectedRepoIds,
|
|
48
|
-
requirementStatus: "pending"
|
|
49
|
-
};
|
|
50
|
-
sprint.tickets.push(ticket);
|
|
51
|
-
await saveSprintData(sprint);
|
|
52
|
-
return ticket;
|
|
53
|
-
}
|
|
54
|
-
async function updateTicket(ticketId, updates, sprintId) {
|
|
55
|
-
const sprint = await getSprintData(sprintId);
|
|
56
|
-
assertSprintStatus(sprint, ["draft"], "update tickets");
|
|
57
|
-
const ticketIdx = sprint.tickets.findIndex((t) => t.id === ticketId);
|
|
58
|
-
if (ticketIdx === -1) {
|
|
59
|
-
throw new TicketNotFoundError(ticketId);
|
|
60
|
-
}
|
|
61
|
-
const ticket = sprint.tickets[ticketIdx];
|
|
62
|
-
if (!ticket) {
|
|
63
|
-
throw new TicketNotFoundError(ticketId);
|
|
64
|
-
}
|
|
65
|
-
if (updates.title !== void 0) {
|
|
66
|
-
ticket.title = updates.title;
|
|
67
|
-
}
|
|
68
|
-
if (updates.description !== void 0) {
|
|
69
|
-
ticket.description = updates.description || void 0;
|
|
70
|
-
}
|
|
71
|
-
if (updates.link !== void 0) {
|
|
72
|
-
ticket.link = updates.link || void 0;
|
|
73
|
-
}
|
|
74
|
-
await saveSprintData(sprint);
|
|
75
|
-
return ticket;
|
|
76
|
-
}
|
|
77
|
-
async function removeTicket(ticketId, sprintId) {
|
|
78
|
-
const sprint = await getSprintData(sprintId);
|
|
79
|
-
assertSprintStatus(sprint, ["draft"], "remove tickets");
|
|
80
|
-
const index = sprint.tickets.findIndex((t) => t.id === ticketId);
|
|
81
|
-
if (index === -1) {
|
|
82
|
-
throw new TicketNotFoundError(ticketId);
|
|
83
|
-
}
|
|
84
|
-
sprint.tickets.splice(index, 1);
|
|
85
|
-
await saveSprintData(sprint);
|
|
86
|
-
}
|
|
87
|
-
async function listTickets(sprintId) {
|
|
88
|
-
const sprint = await getSprintData(sprintId);
|
|
89
|
-
return sprint.tickets;
|
|
90
|
-
}
|
|
91
|
-
async function getTicket(ticketId, sprintId) {
|
|
92
|
-
const sprint = await getSprintData(sprintId);
|
|
93
|
-
const ticket = sprint.tickets.find((t) => t.id === ticketId);
|
|
94
|
-
if (!ticket) {
|
|
95
|
-
throw new TicketNotFoundError(ticketId);
|
|
96
|
-
}
|
|
97
|
-
return ticket;
|
|
98
|
-
}
|
|
99
|
-
function allRequirementsApproved(tickets) {
|
|
100
|
-
return tickets.length > 0 && tickets.every((t) => t.requirementStatus === "approved");
|
|
101
|
-
}
|
|
102
|
-
function getPendingRequirements(tickets) {
|
|
103
|
-
return tickets.filter((t) => t.requirementStatus === "pending");
|
|
104
|
-
}
|
|
105
|
-
function formatTicketDisplay(ticket) {
|
|
106
|
-
return `[${ticket.id}] ${ticket.title}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/integration/external/issue-fetch.ts
|
|
110
|
-
import { spawnSync } from "child_process";
|
|
111
|
-
import { Result } from "typescript-result";
|
|
112
|
-
var MAX_COMMENTS = 20;
|
|
113
|
-
function parseIssueUrl(url) {
|
|
114
|
-
let parsed;
|
|
115
|
-
try {
|
|
116
|
-
parsed = new URL(url);
|
|
117
|
-
} catch {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
124
|
-
if (parsed.hostname === "github.com") {
|
|
125
|
-
const owner = segments[0];
|
|
126
|
-
const repo = segments[1];
|
|
127
|
-
if (segments.length >= 4 && segments[2] === "issues" && owner && repo) {
|
|
128
|
-
const num = Number(segments[3]);
|
|
129
|
-
if (Number.isInteger(num) && num > 0) {
|
|
130
|
-
return { host: "github", hostname: parsed.hostname, owner, repo, number: num };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const dashIdx = segments.indexOf("-");
|
|
136
|
-
if (dashIdx >= 2 && segments[dashIdx + 1] === "issues") {
|
|
137
|
-
const num = Number(segments[dashIdx + 2]);
|
|
138
|
-
if (Number.isInteger(num) && num > 0) {
|
|
139
|
-
const repo = segments[dashIdx - 1];
|
|
140
|
-
if (repo) {
|
|
141
|
-
const owner = segments.slice(0, dashIdx - 1).join("/");
|
|
142
|
-
return { host: "gitlab", hostname: parsed.hostname, owner, repo, number: num };
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
function fetchGitHubIssueResult(parsed) {
|
|
149
|
-
const result = spawnSync(
|
|
150
|
-
"gh",
|
|
151
|
-
[
|
|
152
|
-
"issue",
|
|
153
|
-
"view",
|
|
154
|
-
String(parsed.number),
|
|
155
|
-
"--repo",
|
|
156
|
-
`${parsed.owner}/${parsed.repo}`,
|
|
157
|
-
"--json",
|
|
158
|
-
"title,body,comments"
|
|
159
|
-
],
|
|
160
|
-
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], timeout: 3e4 }
|
|
161
|
-
);
|
|
162
|
-
if (result.status !== 0) {
|
|
163
|
-
const stderr = result.stderr.trim();
|
|
164
|
-
return Result.error(new IssueFetchError(`gh issue view failed: ${stderr || "unknown error"}`));
|
|
165
|
-
}
|
|
166
|
-
const data = JSON.parse(result.stdout);
|
|
167
|
-
const comments = (data.comments ?? []).slice(-MAX_COMMENTS).map((c) => ({
|
|
168
|
-
author: c.author?.login ?? "unknown",
|
|
169
|
-
createdAt: c.createdAt ?? "",
|
|
170
|
-
body: c.body ?? ""
|
|
171
|
-
}));
|
|
172
|
-
return Result.ok({
|
|
173
|
-
title: data.title ?? "",
|
|
174
|
-
body: data.body ?? "",
|
|
175
|
-
comments,
|
|
176
|
-
url: `https://${parsed.hostname}/${parsed.owner}/${parsed.repo}/issues/${String(parsed.number)}`
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function fetchGitLabIssueResult(parsed) {
|
|
180
|
-
const result = spawnSync(
|
|
181
|
-
"glab",
|
|
182
|
-
["issue", "view", String(parsed.number), "--repo", `${parsed.owner}/${parsed.repo}`, "--output", "json"],
|
|
183
|
-
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], timeout: 3e4 }
|
|
184
|
-
);
|
|
185
|
-
if (result.status !== 0) {
|
|
186
|
-
const stderr = result.stderr.trim();
|
|
187
|
-
return Result.error(new IssueFetchError(`glab issue view failed: ${stderr || "unknown error"}`));
|
|
188
|
-
}
|
|
189
|
-
const data = JSON.parse(result.stdout);
|
|
190
|
-
const notesResult = spawnSync(
|
|
191
|
-
"glab",
|
|
192
|
-
["issue", "note", "list", String(parsed.number), "--repo", `${parsed.owner}/${parsed.repo}`, "--output", "json"],
|
|
193
|
-
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], timeout: 3e4 }
|
|
194
|
-
);
|
|
195
|
-
let comments = [];
|
|
196
|
-
if (notesResult.status === 0 && notesResult.stdout.trim()) {
|
|
197
|
-
try {
|
|
198
|
-
const notes = JSON.parse(notesResult.stdout);
|
|
199
|
-
comments = notes.slice(-MAX_COMMENTS).map((n) => ({
|
|
200
|
-
author: n.author?.username ?? "unknown",
|
|
201
|
-
createdAt: n.created_at ?? "",
|
|
202
|
-
body: n.body ?? ""
|
|
203
|
-
}));
|
|
204
|
-
} catch {
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return Result.ok({
|
|
208
|
-
title: data.title ?? "",
|
|
209
|
-
body: data.description ?? "",
|
|
210
|
-
comments,
|
|
211
|
-
url: `https://${parsed.hostname}/${parsed.owner}/${parsed.repo}/-/issues/${String(parsed.number)}`
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function fetchIssueResult(parsed) {
|
|
215
|
-
if (parsed.host === "github") {
|
|
216
|
-
return fetchGitHubIssueResult(parsed);
|
|
217
|
-
}
|
|
218
|
-
return fetchGitLabIssueResult(parsed);
|
|
219
|
-
}
|
|
220
|
-
function fetchIssue(parsed) {
|
|
221
|
-
return unwrapOrThrow(fetchIssueResult(parsed));
|
|
222
|
-
}
|
|
223
|
-
function fetchIssueFromUrl(url) {
|
|
224
|
-
const parsed = parseIssueUrl(url);
|
|
225
|
-
if (!parsed) return null;
|
|
226
|
-
return fetchIssue(parsed);
|
|
227
|
-
}
|
|
228
|
-
function formatIssueContext(data) {
|
|
229
|
-
const lines = [];
|
|
230
|
-
lines.push("## Source Issue Data");
|
|
231
|
-
lines.push("");
|
|
232
|
-
lines.push(`> Fetched live from ${data.url}`);
|
|
233
|
-
lines.push("");
|
|
234
|
-
lines.push(`**Title:** ${data.title}`);
|
|
235
|
-
lines.push("");
|
|
236
|
-
if (data.body) {
|
|
237
|
-
lines.push("**Body:**");
|
|
238
|
-
lines.push("");
|
|
239
|
-
lines.push(data.body);
|
|
240
|
-
lines.push("");
|
|
241
|
-
}
|
|
242
|
-
if (data.comments.length > 0) {
|
|
243
|
-
lines.push(`**Comments (${String(data.comments.length)}):**`);
|
|
244
|
-
lines.push("");
|
|
245
|
-
for (const comment of data.comments) {
|
|
246
|
-
const timestamp = comment.createdAt ? ` (${comment.createdAt})` : "";
|
|
247
|
-
lines.push(`---`);
|
|
248
|
-
lines.push(`**@${comment.author}**${timestamp}:`);
|
|
249
|
-
lines.push("");
|
|
250
|
-
lines.push(comment.body);
|
|
251
|
-
lines.push("");
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return lines.join("\n");
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export {
|
|
258
|
-
truncate,
|
|
259
|
-
addTicket,
|
|
260
|
-
updateTicket,
|
|
261
|
-
removeTicket,
|
|
262
|
-
listTickets,
|
|
263
|
-
getTicket,
|
|
264
|
-
allRequirementsApproved,
|
|
265
|
-
getPendingRequirements,
|
|
266
|
-
formatTicketDisplay,
|
|
267
|
-
fetchIssueFromUrl,
|
|
268
|
-
formatIssueContext
|
|
269
|
-
};
|
package/dist/chunk-IWXBJD2D.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/integration/utils/result-helpers.ts
|
|
4
|
-
import { Result } from "typescript-result";
|
|
5
|
-
async function wrapAsync(fn, mapError) {
|
|
6
|
-
try {
|
|
7
|
-
const value = await fn();
|
|
8
|
-
return Result.ok(value);
|
|
9
|
-
} catch (err) {
|
|
10
|
-
return Result.error(mapError(err));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
function ensureError(err) {
|
|
14
|
-
return err instanceof Error ? err : new Error(String(err));
|
|
15
|
-
}
|
|
16
|
-
function unwrapOrThrow(result) {
|
|
17
|
-
if (result.ok) {
|
|
18
|
-
return result.value;
|
|
19
|
-
}
|
|
20
|
-
throw result.error;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
wrapAsync,
|
|
25
|
-
ensureError,
|
|
26
|
-
unwrapOrThrow
|
|
27
|
-
};
|