ralphctl 0.5.0 → 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-67UFUI54.mjs +0 -17
- package/dist/add-DVPVHENV.mjs +0 -18
- package/dist/bootstrap-FMHG6DRY.mjs +0 -11
- package/dist/chunk-62HYDA7L.mjs +0 -1128
- package/dist/chunk-747KW2RW.mjs +0 -24
- package/dist/chunk-BSB4EDGR.mjs +0 -260
- package/dist/chunk-BT5FKIZX.mjs +0 -787
- package/dist/chunk-CBMFRQ4Y.mjs +0 -441
- package/dist/chunk-CFUVE2BP.mjs +0 -16
- package/dist/chunk-D6QZNEYN.mjs +0 -5520
- package/dist/chunk-FNAAA32W.mjs +0 -103
- package/dist/chunk-GQ2WFKBN.mjs +0 -269
- package/dist/chunk-IWXBJD2D.mjs +0 -27
- package/dist/chunk-OGEXYSFS.mjs +0 -228
- package/dist/chunk-VAZ3LJBI.mjs +0 -179
- package/dist/chunk-WDMLPXOD.mjs +0 -363
- package/dist/chunk-XN2UIHBY.mjs +0 -589
- package/dist/chunk-ZE2BRQA2.mjs +0 -5542
- package/dist/create-Z635FQKO.mjs +0 -15
- package/dist/handle-23EFF3BE.mjs +0 -22
- package/dist/mount-NCYR22SN.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-T34NI3LF.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
|
-
};
|
package/dist/chunk-OGEXYSFS.mjs
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
addTicket,
|
|
4
|
-
fetchIssueFromUrl,
|
|
5
|
-
truncate
|
|
6
|
-
} from "./chunk-GQ2WFKBN.mjs";
|
|
7
|
-
import {
|
|
8
|
-
EXIT_ERROR,
|
|
9
|
-
exitWithCode
|
|
10
|
-
} from "./chunk-CFUVE2BP.mjs";
|
|
11
|
-
import {
|
|
12
|
-
getPrompt
|
|
13
|
-
} from "./chunk-747KW2RW.mjs";
|
|
14
|
-
import {
|
|
15
|
-
getProjectById
|
|
16
|
-
} from "./chunk-BSB4EDGR.mjs";
|
|
17
|
-
import {
|
|
18
|
-
getCurrentSprintOrThrow
|
|
19
|
-
} from "./chunk-CBMFRQ4Y.mjs";
|
|
20
|
-
import {
|
|
21
|
-
createSpinner,
|
|
22
|
-
emoji,
|
|
23
|
-
error,
|
|
24
|
-
field,
|
|
25
|
-
fieldMultiline,
|
|
26
|
-
icons,
|
|
27
|
-
log,
|
|
28
|
-
renderCard,
|
|
29
|
-
showError,
|
|
30
|
-
showSuccess,
|
|
31
|
-
showWarning
|
|
32
|
-
} from "./chunk-XN2UIHBY.mjs";
|
|
33
|
-
import {
|
|
34
|
-
ensureError,
|
|
35
|
-
wrapAsync
|
|
36
|
-
} from "./chunk-IWXBJD2D.mjs";
|
|
37
|
-
import {
|
|
38
|
-
IOError,
|
|
39
|
-
SprintStatusError
|
|
40
|
-
} from "./chunk-VAZ3LJBI.mjs";
|
|
41
|
-
|
|
42
|
-
// src/integration/cli/commands/ticket/add.ts
|
|
43
|
-
import { Result as Result2 } from "typescript-result";
|
|
44
|
-
|
|
45
|
-
// src/integration/ui/prompts/editor-input.ts
|
|
46
|
-
import { Result } from "typescript-result";
|
|
47
|
-
async function editorInput(options) {
|
|
48
|
-
try {
|
|
49
|
-
const result = await getPrompt().editor({
|
|
50
|
-
message: options.message,
|
|
51
|
-
default: options.default,
|
|
52
|
-
kind: "markdown"
|
|
53
|
-
});
|
|
54
|
-
if (result === null) {
|
|
55
|
-
return Result.error(new IOError("Editor cancelled"));
|
|
56
|
-
}
|
|
57
|
-
return Result.ok(result);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
return Result.error(
|
|
60
|
-
new IOError(
|
|
61
|
-
`Editor failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
62
|
-
err instanceof Error ? err : void 0
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/integration/cli/commands/ticket/add.ts
|
|
69
|
-
function tryFetchIssue(url) {
|
|
70
|
-
const spinner = createSpinner("Fetching issue data...");
|
|
71
|
-
spinner.start();
|
|
72
|
-
const fetchR = Result2.try(() => fetchIssueFromUrl(url));
|
|
73
|
-
if (!fetchR.ok) {
|
|
74
|
-
spinner.fail("Could not fetch issue data");
|
|
75
|
-
showWarning(fetchR.error.message);
|
|
76
|
-
log.newline();
|
|
77
|
-
return void 0;
|
|
78
|
-
}
|
|
79
|
-
const data = fetchR.value;
|
|
80
|
-
if (!data) {
|
|
81
|
-
spinner.stop();
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
spinner.succeed("Issue data fetched");
|
|
85
|
-
log.newline();
|
|
86
|
-
const bodyPreview = truncate(data.body, 200);
|
|
87
|
-
const cardLines = [`Title: ${data.title}`, "", bodyPreview];
|
|
88
|
-
if (data.comments.length > 0) {
|
|
89
|
-
cardLines.push("", `${String(data.comments.length)} comment(s)`);
|
|
90
|
-
}
|
|
91
|
-
console.log(renderCard(`${icons.info} Fetched Issue`, cardLines));
|
|
92
|
-
log.newline();
|
|
93
|
-
return data;
|
|
94
|
-
}
|
|
95
|
-
function validateUrl(url) {
|
|
96
|
-
try {
|
|
97
|
-
new URL(url);
|
|
98
|
-
return true;
|
|
99
|
-
} catch {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async function addSingleTicketNonInteractive(options) {
|
|
104
|
-
const errors = [];
|
|
105
|
-
const trimmedTitle = options.title?.trim();
|
|
106
|
-
if (!trimmedTitle) {
|
|
107
|
-
errors.push("--title is required");
|
|
108
|
-
}
|
|
109
|
-
if (options.link && !validateUrl(options.link)) {
|
|
110
|
-
errors.push("--link must be a valid URL");
|
|
111
|
-
}
|
|
112
|
-
if (errors.length > 0 || !trimmedTitle) {
|
|
113
|
-
showError("Validation failed");
|
|
114
|
-
for (const e of errors) {
|
|
115
|
-
log.item(error(e));
|
|
116
|
-
}
|
|
117
|
-
log.newline();
|
|
118
|
-
exitWithCode(EXIT_ERROR);
|
|
119
|
-
}
|
|
120
|
-
const title = trimmedTitle;
|
|
121
|
-
const trimmedDesc = options.description?.trim();
|
|
122
|
-
const description = trimmedDesc === "" ? void 0 : trimmedDesc;
|
|
123
|
-
const trimmedLink = options.link?.trim();
|
|
124
|
-
const link = trimmedLink === "" ? void 0 : trimmedLink;
|
|
125
|
-
const addR = await wrapAsync(() => addTicket({ title, description, link }), ensureError);
|
|
126
|
-
if (!addR.ok) {
|
|
127
|
-
handleTicketError(addR.error);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
await showTicketResult(addR.value);
|
|
131
|
-
}
|
|
132
|
-
async function addSingleTicketInteractive(options) {
|
|
133
|
-
const link = await getPrompt().input({
|
|
134
|
-
message: `${icons.info} Issue link (optional):`,
|
|
135
|
-
default: options.link?.trim(),
|
|
136
|
-
validate: (v) => {
|
|
137
|
-
if (!v) return true;
|
|
138
|
-
return validateUrl(v) ? true : "Invalid URL format";
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
const trimmedLink = link.trim();
|
|
142
|
-
const normalizedLink = trimmedLink === "" ? void 0 : trimmedLink;
|
|
143
|
-
let prefill;
|
|
144
|
-
if (normalizedLink) {
|
|
145
|
-
prefill = tryFetchIssue(normalizedLink);
|
|
146
|
-
}
|
|
147
|
-
let title = await getPrompt().input({
|
|
148
|
-
message: `${icons.ticket} Title:`,
|
|
149
|
-
default: prefill?.title ?? options.title?.trim(),
|
|
150
|
-
validate: (v) => v.trim().length > 0 ? true : "Title is required"
|
|
151
|
-
});
|
|
152
|
-
const descR = await editorInput({
|
|
153
|
-
message: "Description (recommended):",
|
|
154
|
-
default: prefill?.body ?? options.description?.trim()
|
|
155
|
-
});
|
|
156
|
-
if (!descR.ok) {
|
|
157
|
-
showError(`Editor input failed: ${descR.error.message}`);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
const description = descR.value;
|
|
161
|
-
title = title.trim();
|
|
162
|
-
const trimmedDescription = description.trim();
|
|
163
|
-
const normalizedDescription = trimmedDescription === "" ? void 0 : trimmedDescription;
|
|
164
|
-
const addR = await wrapAsync(
|
|
165
|
-
() => addTicket({ title, description: normalizedDescription, link: normalizedLink }),
|
|
166
|
-
ensureError
|
|
167
|
-
);
|
|
168
|
-
if (!addR.ok) {
|
|
169
|
-
handleTicketError(addR.error);
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
await showTicketResult(addR.value);
|
|
173
|
-
return addR.value;
|
|
174
|
-
}
|
|
175
|
-
async function showTicketResult(ticket) {
|
|
176
|
-
const sprintR = await wrapAsync(() => getCurrentSprintOrThrow(), ensureError);
|
|
177
|
-
const projectLabel = sprintR.ok ? await wrapAsync(() => getProjectById(sprintR.value.projectId), ensureError).then(
|
|
178
|
-
(r) => r.ok ? `${r.value.displayName} (${r.value.name})` : sprintR.value.projectId
|
|
179
|
-
) : "unknown";
|
|
180
|
-
showSuccess("Ticket added!", [
|
|
181
|
-
["ID", ticket.id],
|
|
182
|
-
["Title", ticket.title],
|
|
183
|
-
["Project", projectLabel]
|
|
184
|
-
]);
|
|
185
|
-
if (ticket.description) {
|
|
186
|
-
console.log(fieldMultiline("Description", ticket.description));
|
|
187
|
-
}
|
|
188
|
-
if (ticket.link) {
|
|
189
|
-
console.log(field("Link", ticket.link));
|
|
190
|
-
}
|
|
191
|
-
console.log("");
|
|
192
|
-
}
|
|
193
|
-
function handleTicketError(err) {
|
|
194
|
-
if (err instanceof SprintStatusError) {
|
|
195
|
-
showError(err.message);
|
|
196
|
-
} else if (err instanceof Error && err.message.includes("does not exist")) {
|
|
197
|
-
showError(err.message);
|
|
198
|
-
} else {
|
|
199
|
-
throw err;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
async function ticketAddCommand(options = {}) {
|
|
203
|
-
if (options.interactive === false) {
|
|
204
|
-
await addSingleTicketNonInteractive(options);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
let count = 0;
|
|
208
|
-
while (true) {
|
|
209
|
-
const ticket = await addSingleTicketInteractive(options);
|
|
210
|
-
if (ticket) {
|
|
211
|
-
count++;
|
|
212
|
-
log.dim(`${String(count)} ticket(s) added in this session`);
|
|
213
|
-
} else {
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
const another = await getPrompt().confirm({
|
|
217
|
-
message: `${emoji.donut} Add another ticket?`,
|
|
218
|
-
default: true
|
|
219
|
-
});
|
|
220
|
-
if (!another) break;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export {
|
|
225
|
-
editorInput,
|
|
226
|
-
addSingleTicketInteractive,
|
|
227
|
-
ticketAddCommand
|
|
228
|
-
};
|