peppa/packages/shared/src/task-key.ts
Асель 4168e8c867 Bootstrap Peppa monorepo, DB schema, OpenSpec and project template
- pnpm workspace: apps/web (Next.js), apps/bot, packages/{db,shared,mcp,runner}
- Drizzle schema: projects, goals, tasks, sessions, questions, events
- Postgres via infra/docker-compose.yml
- template/: AGENTS.md workflow on OpenSpec, Claude hooks, peppa MCP config
- scripts to push template and bootstrap projects in Gitea

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 19:13:16 +05:00

29 lines
945 B
TypeScript

// Task keys look like "PEP-42": project key + per-project sequence number.
const KEY_RE = /^([A-Z][A-Z0-9]{1,9})-(\d+)$/;
export interface TaskKey {
projectKey: string;
number: number;
}
export function formatTaskKey(projectKey: string, number: number): string {
return `${projectKey}-${number}`;
}
/** Parses "PEP-42", "pep-42" or a bare "42" (resolved against `defaultProjectKey`). */
export function parseTaskKey(input: string, defaultProjectKey?: string): TaskKey | null {
const s = input.trim().toUpperCase().replace(/^#/, "");
const m = KEY_RE.exec(s);
if (m) return { projectKey: m[1]!, number: Number(m[2]) };
if (/^\d+$/.test(s) && defaultProjectKey) return { projectKey: defaultProjectKey, number: Number(s) };
return null;
}
/** Contents of `.peppa/project.json`, written into every project repo at init. */
export interface PeppaProjectFile {
slug: string;
key: string;
name: string;
peppaUrl: string;
}