Function bodies 330 total
showFileDetail function · typescript · L67-L86 (20 LOC)packages/cli/src/commands/context/show.ts
async function showFileDetail(
cwd: string,
name: string,
exists: boolean,
ctx: { files: Record<string, unknown> },
): Promise<void> {
if (!exists) return;
const filePath = resolveFilePath(ctx.files[name]);
if (!filePath) return;
const fullPath = fs.getReqordDir(cwd, filePath);
try {
const content = await fs.readText(fullPath);
console.log(chalk.cyan(`--- ${name} (${filePath}) ---`));
console.log(content);
} catch {
// skip unreadable files
}
}loadPatchFile function · typescript · L73-L80 (8 LOC)packages/cli/src/commands/context/update.ts
async function loadPatchFile(path: string): Promise<Record<string, unknown>> {
const content = await fs.readText(path);
try {
return JSON.parse(content) as Record<string, unknown>;
} catch {
throw new Error(`Invalid JSON in patch file: ${path}`);
}
}parsePositiveInt function · typescript · L8-L14 (7 LOC)packages/cli/src/commands/impact/analyze.ts
function parsePositiveInt(value: string): number {
const n = Number.parseInt(value, 10);
if (!Number.isInteger(n) || n <= 0) {
throw new Error("Depth must be a positive integer");
}
return n;
}displayResult function · typescript · L38-L46 (9 LOC)packages/cli/src/commands/impact/analyze.ts
function displayResult(result: ImpactAnalysis): void {
console.log(chalk.bold(`\nImpact analysis: ${result.sourceId}\n`));
if (result.sourceType === "requirement") {
displayRequirementResult(result);
} else {
displaySpecificationResult(result);
}
}displayRequirementResult function · typescript · L48-L85 (38 LOC)packages/cli/src/commands/impact/analyze.ts
function displayRequirementResult(result: ImpactAnalysis): void {
// Direct impacts
console.log(chalk.bold("Direct impacts:"));
if (result.directImpacts.length === 0) {
console.log(" None\n");
} else {
const directTable = new Table({
head: ["ID", "Relation", "Title"],
style: { head: [], border: [] },
});
for (const impact of result.directImpacts) {
directTable.push([impact.id, impact.relation, impact.title]);
}
console.log(directTable.toString());
console.log("");
}
// Indirect impacts
console.log(chalk.bold("Indirect impacts:"));
if (result.indirectImpacts.length === 0) {
console.log(" None\n");
} else {
const indirectTable = new Table({
head: ["ID", "Via", "Title"],
style: { head: [], border: [] },
});
for (const impact of result.indirectImpacts) {
const via = impact.path.slice(1, -1).join(" → ");
indirectTable.push([impact.id, via, impact.title]);
}
console.log(indirectdisplaySpecificationResult function · typescript · L87-L94 (8 LOC)packages/cli/src/commands/impact/analyze.ts
function displaySpecificationResult(result: ImpactAnalysis): void {
if (result.parentRequirement) {
console.log(chalk.bold("Parent Requirement:"));
console.log(` ${result.parentRequirement.id} (${result.parentRequirement.title})\n`);
}
displaySpecifications(result);
displayIssues(result);
}displaySpecifications function · typescript · L96-L111 (16 LOC)packages/cli/src/commands/impact/analyze.ts
function displaySpecifications(result: ImpactAnalysis): void {
console.log(chalk.bold("Related Specifications:"));
if (result.relatedSpecifications.length === 0) {
console.log(" None\n");
} else {
const specTable = new Table({
head: ["ID", "Req ID", "Status"],
style: { head: [], border: [] },
});
for (const spec of result.relatedSpecifications) {
specTable.push([spec.id, spec.requirementId, spec.status]);
}
console.log(specTable.toString());
console.log("");
}
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
displayIssues function · typescript · L113-L128 (16 LOC)packages/cli/src/commands/impact/analyze.ts
function displayIssues(result: ImpactAnalysis): void {
console.log(chalk.bold("Related Issues:"));
if (result.relatedIssues.length === 0) {
console.log(" None\n");
} else {
const issueTable = new Table({
head: ["#", "Status", "Title"],
style: { head: [], border: [] },
});
for (const issue of result.relatedIssues) {
issueTable.push([`#${issue.number}`, issue.status, issue.title]);
}
console.log(issueTable.toString());
console.log("");
}
}displayCircularDependencies function · typescript · L130-L138 (9 LOC)packages/cli/src/commands/impact/analyze.ts
function displayCircularDependencies(result: ImpactAnalysis): void {
if (result.circularDependencies.length === 0) return;
console.log(chalk.bold.yellow("Circular dependencies:"));
for (const cycle of result.circularDependencies) {
console.log(` ⚠ ${cycle.join(" → ")}`);
}
console.log("");
}displayNotifyResult function · typescript · L24-L36 (13 LOC)packages/cli/src/commands/impact/notify.ts
function displayNotifyResult(id: string, result: NotifyResult): void {
if (result.notified.length === 0 && result.skipped.length === 0) {
console.log(chalk.bold(`\nImpact notification: ${id}\n`));
console.log("No issues to notify.");
return;
}
if (result.dryRun) {
displayDryRunResult(id, result);
} else {
displayActualResult(id, result);
}
}displayDryRunResult function · typescript · L38-L66 (29 LOC)packages/cli/src/commands/impact/notify.ts
function displayDryRunResult(id: string, result: NotifyResult): void {
console.log(chalk.bold(`\nImpact notification preview: ${id}\n`));
if (result.notified.length > 0) {
console.log("Notify targets:");
for (const entry of result.notified) {
console.log(` #${entry.number} ${entry.title}`);
}
console.log("");
}
if (result.skipped.length > 0) {
console.log("Skipped:");
for (const entry of result.skipped) {
console.log(` #${entry.number} (${entry.reason})`);
}
console.log("");
}
// Show notification message preview
const firstWithComment = result.notified.find((e) => e.comment);
if (firstWithComment?.comment) {
console.log(chalk.bold("Notification message:"));
console.log(firstWithComment.comment);
console.log("");
}
console.log("To actually send notifications, remove --dry-run and run again.");
}displayActualResult function · typescript · L68-L88 (21 LOC)packages/cli/src/commands/impact/notify.ts
function displayActualResult(id: string, result: NotifyResult): void {
console.log(chalk.bold(`\nImpact notification: ${id}\n`));
if (result.notified.length > 0) {
console.log("Notified:");
for (const entry of result.notified) {
console.log(` ✓ #${entry.number} ${entry.title}`);
}
console.log("");
}
if (result.skipped.length > 0) {
console.log("Skipped:");
for (const entry of result.skipped) {
console.log(` - #${entry.number} (${entry.reason})`);
}
console.log("");
}
console.log(`Sent ${result.notified.length} notification(s).`);
}confirm function · typescript · L7-L15 (9 LOC)packages/cli/src/commands/req/delete.ts
async function confirm(message: string): Promise<boolean> {
const rl = createInterface({ input: process.stdin, output: process.stdout });
try {
const answer = await rl.question(`${message} (y/N) `);
return answer.toLowerCase() === "y";
} finally {
rl.close();
}
}formatScore function · typescript · L71-L77 (7 LOC)packages/cli/src/commands/req/validate.ts
function formatScore(score: number): string {
const percent = Math.round(score * 100);
const bar = "█".repeat(Math.round(score * 10)) + "░".repeat(10 - Math.round(score * 10));
if (score >= 0.7) return chalk.green(`${bar} ${percent}%`);
if (score >= 0.4) return chalk.yellow(`${bar} ${percent}%`);
return chalk.red(`${bar} ${percent}%`);
}showProjectStatus function · typescript · L41-L105 (65 LOC)packages/cli/src/commands/status.ts
async function showProjectStatus(
cwd: string,
options: { json?: boolean; quiet?: boolean },
): Promise<void> {
const status = await getProjectStatus(cwd);
if (options.json) {
console.log(JSON.stringify(status, null, 2));
return;
}
if (options.quiet) {
console.log(String(status.requirements.implementedPercentage));
return;
}
console.log(chalk.bold.cyan("\nreqord Project Status\n"));
// Requirements
console.log(chalk.bold("Requirements:"));
printStatusBars(status.requirements.byStatus, status.requirements.total);
// Specifications
console.log(chalk.bold("\nSpecifications:"));
printStatusBars(status.specifications.byStatus, status.specifications.total);
// Issues
console.log(chalk.bold("\nIssues:"));
if (status.issues.total > 0) {
const closedPct = status.issues.closedPercentage;
const openPct = 100 - closedPct;
console.log(
` closed ${renderProgressBar(closedPct)} ${closedPct}% (${status.issues.closed}/${statCitation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
printStatusBars function · typescript · L107-L126 (20 LOC)packages/cli/src/commands/status.ts
function printStatusBars(
byStatus: Record<string, number>,
total: number,
): void {
const statusOrder = ["implemented", "approved", "draft", "deprecated"];
const entries = Object.entries(byStatus).sort((a, b) => {
const ai = statusOrder.indexOf(a[0]);
const bi = statusOrder.indexOf(b[0]);
return (ai === -1 ? 999 : ai) - (bi === -1 ? 999 : bi);
});
for (const [status, count] of entries) {
const pct = total > 0 ? Math.round((count / total) * 100) : 0;
const colorFn = STATUS_COLORS[status] ?? identityColor;
const label = status.padEnd(12);
console.log(
` ${colorFn(label)} ${renderProgressBar(pct)} ${pct}% (${count}/${total})`,
);
}
}showRequirementStatus function · typescript · L128-L213 (86 LOC)packages/cli/src/commands/status.ts
async function showRequirementStatus(
cwd: string,
reqId: string,
options: { json?: boolean; quiet?: boolean },
): Promise<void> {
const status = await getRequirementStatus(cwd, reqId);
if (options.json) {
console.log(JSON.stringify(status, null, 2));
return;
}
if (options.quiet) {
const pct =
status.issueProgress.total > 0
? Math.round(
(status.issueProgress.completed / status.issueProgress.total) *
100,
)
: 0;
console.log(String(pct));
return;
}
const req = status.requirement;
const statusColor = STATUS_COLORS[req.status] ?? identityColor;
const priorityColor = PRIORITY_COLORS[req.priority] ?? identityColor;
console.log(
chalk.bold.cyan(`\nRequirement Status: ${req.id} (${req.title})\n`),
);
console.log(` Status: ${statusColor(req.status)}`);
console.log(` Priority: ${priorityColor(req.priority)}`);
if (req.estimatedComplexity) {
console.log(` CompleshowSpecificationStatus function · typescript · L215-L282 (68 LOC)packages/cli/src/commands/status.ts
async function showSpecificationStatus(
cwd: string,
specId: string,
options: { json?: boolean; quiet?: boolean },
): Promise<void> {
const status = await getSpecificationStatus(cwd, specId);
if (options.json) {
console.log(JSON.stringify(status, null, 2));
return;
}
if (options.quiet) {
const pct =
status.issueProgress.total > 0
? Math.round(
(status.issueProgress.completed / status.issueProgress.total) *
100,
)
: 0;
console.log(String(pct));
return;
}
const spec = status.specification;
const statusColor = STATUS_COLORS[spec.status] ?? identityColor;
console.log(
chalk.bold.cyan(
`\nSpecification Status: ${spec.id} (${spec.title ?? spec.id})\n`,
),
);
console.log(` Status: ${statusColor(spec.status)}`);
if (status.requirement) {
const reqColor = STATUS_COLORS[status.requirement.status] ?? identityColor;
console.log(
` Requirement: ${statudisplayResult function · typescript · L40-L63 (24 LOC)packages/cli/src/commands/task/create.ts
function displayResult(result: CreateIssuesResult, dryRun?: boolean): void {
if (dryRun) {
console.log(chalk.yellow("Dry run - no issues created\n"));
} else {
console.log(chalk.green(`Created ${result.issues.length} issues for ${result.specId}\n`));
}
const table = new Table({
head: dryRun
? ["#", "Title", "Priority", "Est. Hours", "Labels"]
: ["#", "Title", "Priority", "Est. Hours", "Issue#", "URL"],
});
result.issues.forEach((issue, index) => {
if (dryRun) {
table.push([index + 1, issue.title, issue.priority, issue.estimatedHours, issue.labels.join(", ")]);
} else {
table.push([index + 1, issue.title, issue.priority, issue.estimatedHours, issue.number ?? "-", issue.url ?? "-"]);
}
});
console.log(table.toString());
console.log(`\nTotal estimated hours: ${result.totalEstimatedHours}`);
}displayResult function · typescript · L30-L75 (46 LOC)packages/cli/src/commands/task/fetch.ts
function displayResult(result: FetchResult, dryRun?: boolean): void {
if (dryRun) {
console.log(chalk.yellow("Dry run - no files updated\n"));
}
console.log(
`Fetched ${result.totalIssuesFetched} issues, ${result.totalIssuesWithTag} with reqord tags\n`,
);
if (result.specsUpdated.length > 0) {
const table = new Table({
head: ["Spec ID", "Issues", "Est. Hours", "Previous Issues", "Status"],
});
for (const spec of result.specsUpdated) {
const change = spec.previousIssueCount !== spec.issueCount
? chalk.yellow(`${spec.previousIssueCount} → ${spec.issueCount}`)
: String(spec.issueCount);
table.push([
spec.specId,
change,
spec.totalEstimatedHours,
spec.previousIssueCount,
spec.updated ? chalk.green("updated") : chalk.gray("preview"),
]);
}
console.log(table.toString());
} else {
console.log(chalk.gray("No specs to update."));
}
if (result.issuesWithoutSpec.ledisplaySyncResult function · typescript · L50-L68 (19 LOC)packages/cli/src/commands/task/sync.ts
function displaySyncResult(result: SyncResult): void {
console.log(chalk.bold(`Syncing ${result.specId}...`));
for (const issue of result.synced) {
const arrow = issue.changed ? chalk.yellow("→") : "-";
const status = issue.changed
? `${issue.previousStatus} ${arrow} ${issue.currentStatus}`
: issue.currentStatus;
const icon = issue.changed ? chalk.green("✓") : "-";
console.log(` Issue #${issue.number}: "${issue.title}" ${status} ${icon}`);
}
for (const error of result.errors) {
console.log(chalk.red(` Issue #${error.issueNumber}: Error - ${error.message}`));
}
const { progress } = result;
console.log(`\nProgress: ${progress.completed}/${progress.total} (${progress.percentage}%) completed`);
}validateSpecTasks function · typescript · L20-L44 (25 LOC)packages/cli/src/commands/task/validate.ts
export function validateSpecTasks(
specId: string,
tasks: TaskEntry[],
): ValidateResult {
const issues: ValidationIssue[] = [];
if (tasks.length === 0) {
issues.push({
type: "warning",
message: "No tasks found in tasks.yaml for this specification",
});
return { specId, issues, valid: true };
}
const hasSyncedAt = tasks.some((t) => t.syncedAt);
if (!hasSyncedAt) {
issues.push({
type: "info",
message: "No progress data. Run `reqord task sync` to calculate progress",
});
return { specId, issues, valid: true };
}
return { specId, issues, valid: true };
}loadTasksForSpec function · typescript · L46-L58 (13 LOC)packages/cli/src/commands/task/validate.ts
async function loadTasksForSpec(
cwd: string,
specId: string,
): Promise<TaskEntry[]> {
const tasksPath = fs.joinPath(cwd, REQORD_DIR, ISSUES_DIR, "tasks.yaml");
const raw = await fs.readYAML(tasksPath).catch(() => null);
if (!raw) return [];
const parsed = TasksIndexSchema.safeParse(raw);
if (!parsed.success) return [];
return parsed.data.tasks.filter((t) =>
t.linkedTo.specifications.includes(specId),
);
}Same scanner, your repo: https://repobility.com — Repobility
displayValidateResult function · typescript · L110-L118 (9 LOC)packages/cli/src/commands/task/validate.ts
function displayValidateResult(result: ValidateResult): void {
const status = result.valid ? chalk.green("VALID") : chalk.red("INVALID");
console.log(`${result.specId}: ${status}`);
for (const issue of result.issues) {
const icon = ISSUE_ICONS[issue.type] ?? chalk.blue("ℹ");
console.log(` ${icon} ${issue.message}`);
}
}ensureReqordInitialized function · typescript · L4-L12 (9 LOC)packages/cli/src/middleware/reqord-check.ts
export async function ensureReqordInitialized(cwd: string): Promise<void> {
const reqordDir = getReqordDir(cwd);
if (!(await exists(reqordDir))) {
throw new AppError(
".reqord/ directory not found. Run 'reqord init' first.",
ErrorCode.UNINITIALIZED,
);
}
}loadIndex function · typescript · L15-L26 (12 LOC)packages/cli/src/repositories/feedback.ts
export async function loadIndex(cwd: string): Promise<FeedbackIndex> {
const indexPath = getIndexPath(cwd);
if (!(await fs.exists(indexPath))) {
return { feedbacks: [] };
}
const raw = await fs.readYAML<unknown>(indexPath);
const result = FeedbackIndexSchema.safeParse(raw);
if (!result.success) {
throw new Error(`Invalid feedback index: ${result.error.message}`);
}
return result.data;
}saveIndex function · typescript · L28-L34 (7 LOC)packages/cli/src/repositories/feedback.ts
export async function saveIndex(cwd: string, index: FeedbackIndex): Promise<void> {
const feedbackDir = getFeedbackDir(cwd);
await fs.mkdirp(feedbackDir);
const indexPath = getIndexPath(cwd);
const validated = FeedbackIndexSchema.parse(index);
await fs.writeYAML(indexPath, validated);
}findFeedbackByIssue function · typescript · L36-L42 (7 LOC)packages/cli/src/repositories/feedback.ts
export async function findFeedbackByIssue(
cwd: string,
issueNumber: number,
): Promise<FeedbackEntry | undefined> {
const index = await loadIndex(cwd);
return index.feedbacks.find((f) => f.githubIssue === issueNumber);
}findUnresolvedByArtifactId function · typescript · L44-L63 (20 LOC)packages/cli/src/repositories/feedback.ts
export async function findUnresolvedByArtifactId(
cwd: string,
artifactId: string,
): Promise<FeedbackEntry[]> {
const index = await loadIndex(cwd);
return index.feedbacks.filter((f) => {
const linked = [
...f.linkedTo.requirements,
...(f.linkedTo.createdRequirements ?? []),
...f.linkedTo.specifications,
...(f.linkedTo.createdSpecifications ?? []),
];
if (!linked.includes(artifactId)) return false;
const resolved = [
...(f.linkedTo.resolved?.requirements ?? []),
...(f.linkedTo.resolved?.specifications ?? []),
];
return !resolved.includes(artifactId);
});
}upsertFeedback function · typescript · L65-L79 (15 LOC)packages/cli/src/repositories/feedback.ts
export async function upsertFeedback(
cwd: string,
feedback: FeedbackEntry,
): Promise<void> {
const index = await loadIndex(cwd);
const existingIndex = index.feedbacks.findIndex(
(f) => f.githubIssue === feedback.githubIssue,
);
if (existingIndex >= 0) {
index.feedbacks[existingIndex] = feedback;
} else {
index.feedbacks.push(feedback);
}
await saveIndex(cwd, index);
}exists function · typescript · L5-L12 (8 LOC)packages/cli/src/repositories/file-system.ts
export async function exists(path: string): Promise<boolean> {
try {
await access(path);
return true;
} catch {
return false;
}
}All rows above produced by Repobility · https://repobility.com
isDirectory function · typescript · L14-L21 (8 LOC)packages/cli/src/repositories/file-system.ts
export async function isDirectory(path: string): Promise<boolean> {
try {
const s = await stat(path);
return s.isDirectory();
} catch {
return false;
}
}readdirFiles function · typescript · L44-L54 (11 LOC)packages/cli/src/repositories/file-system.ts
export async function readdirFiles(
dirPath: string,
filter?: (name: string) => boolean,
): Promise<string[]> {
try {
const entries = await readdir(dirPath);
return filter ? entries.filter(filter) : entries;
} catch {
return [];
}
}fixUnquotedHash function · typescript · L68-L159 (92 LOC)packages/cli/src/repositories/file-system.ts
export function fixUnquotedHash(content: string, filePath: string): string {
const lines = content.split("\n");
const fixedLines: string[] = [];
let modified = false;
let inBlockScalar = false;
let blockIndent = -1;
for (const line of lines) {
// Skip empty lines
if (line.trim() === "") {
fixedLines.push(line);
continue;
}
// Skip comment-only lines
if (/^\s*#/.test(line)) {
fixedLines.push(line);
continue;
}
// Detect block scalar indicators (>-, |, >, |-)
if (/:\s+[>|][-+]?\s*$/.test(line)) {
inBlockScalar = true;
blockIndent = -1;
fixedLines.push(line);
continue;
}
// If in block scalar, check indentation to detect end
if (inBlockScalar) {
const currentIndent = line.length - line.trimStart().length;
if (blockIndent === -1) {
blockIndent = currentIndent;
fixedLines.push(line);
continue;
}
if (currentIndent >= blockIndent && blockIreadYAML function · typescript · L161-L171 (11 LOC)packages/cli/src/repositories/file-system.ts
export async function readYAML<T>(filePath: string): Promise<T> {
const content = await readFile(filePath, "utf-8");
const fixed = fixUnquotedHash(content, filePath);
try {
return yamlLoad(fixed, { schema: JSON_SCHEMA }) as T;
} catch (error) {
throw new Error(
`YAML syntax error (${filePath}): ${error instanceof Error ? error.message : String(error)}`,
);
}
}writeYAML function · typescript · L173-L182 (10 LOC)packages/cli/src/repositories/file-system.ts
export async function writeYAML(filePath: string, data: unknown): Promise<void> {
const yamlContent = yamlDump(data, {
indent: 2,
lineWidth: 120,
noRefs: true,
sortKeys: false,
schema: JSON_SCHEMA,
});
await writeFile(filePath, yamlContent, "utf-8");
}runGhWithStdin function · typescript · L6-L19 (14 LOC)packages/cli/src/repositories/github.ts
function runGhWithStdin(args: string[], stdin: string): Promise<void> {
return new Promise((resolve, reject) => {
const proc = spawn("gh", args);
proc.stdin.write(stdin);
proc.stdin.end();
let stderr = "";
proc.stderr.on("data", (chunk: Buffer) => { stderr += chunk.toString(); });
proc.on("close", (code) => {
if (code === 0) resolve();
else reject(new Error(`gh ${args[0]} ${args[1] ?? ""} failed (code ${code}): ${stderr}`.trim()));
});
proc.on("error", reject);
});
}createPullRequest function · typescript · L34-L58 (25 LOC)packages/cli/src/repositories/github.ts
export async function createPullRequest(options: CreatePrOptions): Promise<PrInfo> {
const args = [
"pr", "create",
"--title", options.title,
"--body-file", "-",
"--head", options.head,
];
if (options.base) {
args.push("--base", options.base);
}
if (options.draft) {
args.push("--draft");
}
// Pass body via stdin to avoid shell escaping issues
await runGhWithStdin(args, options.body);
// Get the PR info from the branch
const { stdout } = await execFileAsync("gh", [
"pr", "view", options.head,
"--json", "number,url",
]);
const data = JSON.parse(stdout);
return { number: data.number, url: data.url };
}createIssueComment function · typescript · L60-L66 (7 LOC)packages/cli/src/repositories/github.ts
export async function createIssueComment(
issueNumber: number,
body: string,
): Promise<void> {
const args = ["issue", "comment", String(issueNumber), "--body-file", "-"];
await runGhWithStdin(args, body);
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
createPrComment function · typescript · L68-L74 (7 LOC)packages/cli/src/repositories/github.ts
export async function createPrComment(
prNumber: number,
body: string,
): Promise<void> {
const args = ["pr", "comment", String(prNumber), "--body-file", "-"];
await runGhWithStdin(args, body);
}load function · typescript · L12-L25 (14 LOC)packages/cli/src/repositories/project-context.ts
export async function load(cwd: string): Promise<ProjectContext | null> {
const yamlPath = getContextYamlPath(cwd);
if (!(await fs.exists(yamlPath))) {
return null;
}
const raw = await fs.readYAML<unknown>(yamlPath);
const result = ProjectContextSchema.safeParse(raw);
if (!result.success) {
throw new Error(`Invalid context.yaml: ${result.error.message}`);
}
return result.data;
}loadContextFile function · typescript · L43-L49 (7 LOC)packages/cli/src/repositories/project-context.ts
export async function loadContextFile(cwd: string, fileType: ContextFileType): Promise<unknown | null> {
const filePath = getContextFilePath(cwd, fileType);
if (!(await fs.exists(filePath))) {
return null;
}
return fs.readYAML<unknown>(filePath);
}saveDescription function · typescript · L14-L23 (10 LOC)packages/cli/src/repositories/requirement.ts
export async function saveDescription(
cwd: string,
id: string,
content: string,
): Promise<void> {
const reqDir = getRequirementsDir(cwd);
const descDir = fs.joinPath(reqDir, id);
await fs.mkdirp(descDir);
await fs.writeText(fs.joinPath(descDir, "description.md"), content);
}findByIdOrThrow function · typescript · L25-L31 (7 LOC)packages/cli/src/repositories/requirement.ts
export async function findByIdOrThrow(cwd: string, id: string): Promise<Requirement> {
const requirement = await findById(cwd, id);
if (!requirement) {
throw new Error(`Requirement ${id} not found.`);
}
return requirement;
}findById function · typescript · L33-L47 (15 LOC)packages/cli/src/repositories/requirement.ts
export async function findById(cwd: string, id: string): Promise<Requirement | null> {
const reqDir = getRequirementsDir(cwd);
const yamlPath = fs.joinPath(reqDir, `${id}.yaml`);
if (!(await fs.exists(yamlPath))) {
return null;
}
const raw = await fs.readYAML<unknown>(yamlPath);
const result = RequirementSchema.safeParse(raw);
if (!result.success) {
throw new Error(`Validation error for requirement ${id}:\n${formatZodError(result.error)}`);
}
return result.data;
}loadDescription function · typescript · L49-L58 (10 LOC)packages/cli/src/repositories/requirement.ts
export async function loadDescription(cwd: string, id: string): Promise<string | null> {
const reqDir = getRequirementsDir(cwd);
const descPath = fs.joinPath(reqDir, id, "description.md");
if (!(await fs.exists(descPath))) {
return null;
}
return fs.readText(descPath);
}deleteById function · typescript · L60-L67 (8 LOC)packages/cli/src/repositories/requirement.ts
export async function deleteById(cwd: string, id: string): Promise<void> {
const reqDir = getRequirementsDir(cwd);
const yamlPath = fs.joinPath(reqDir, `${id}.yaml`);
const descDir = fs.joinPath(reqDir, id);
await fs.remove(yamlPath);
await fs.remove(descDir);
}Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
findAll function · typescript · L69-L84 (16 LOC)packages/cli/src/repositories/requirement.ts
export async function findAll(cwd: string): Promise<Requirement[]> {
const reqDir = getRequirementsDir(cwd);
const files = await fs.readdirFiles(reqDir, (name) =>
/^req-\d{6}\.yaml$/.test(name),
);
const requirements: Requirement[] = [];
for (const file of files.sort()) {
const raw = await fs.readYAML<unknown>(fs.joinPath(reqDir, file));
const result = RequirementSchema.safeParse(raw);
if (result.success) {
requirements.push(result.data);
}
}
return requirements;
}saveFile function · typescript · L19-L28 (10 LOC)packages/cli/src/repositories/specification.ts
export async function saveFile(
cwd: string,
id: string,
filename: string,
content: string,
): Promise<void> {
const specDir = fs.joinPath(getSpecificationsDir(cwd), id);
await fs.mkdirp(specDir);
await fs.writeText(fs.joinPath(specDir, filename), content);
}loadFile function · typescript · L30-L42 (13 LOC)packages/cli/src/repositories/specification.ts
export async function loadFile(
cwd: string,
id: string,
filename: string,
): Promise<string | null> {
const filePath = fs.joinPath(getSpecificationsDir(cwd), id, filename);
if (!(await fs.exists(filePath))) {
return null;
}
return fs.readText(filePath);
}page 1 / 7next ›