2 Commits

Author SHA1 Message Date
5072970c91 Add types and validation (#3) 2026-02-08 09:31:58 +00:00
ec6bc71eff Add directive parser and plan linter (#2) 2026-02-08 09:30:08 +00:00
4 changed files with 30 additions and 0 deletions

11
src/linter.ts Normal file
View File

@@ -0,0 +1,11 @@
// Plan linter
import { parse } from "./parser";
export function lint(plan: string) {
const lines = parse(plan);
const warnings: string[] = [];
for (const line of lines) {
if (line.includes("ASAP")) warnings.push("Ambiguous urgency: ASAP");
}
return warnings;
}

9
src/parser.ts Normal file
View File

@@ -0,0 +1,9 @@
// Directive parser v2
export function parse(raw: string): string[] {
return raw.split("\n").map(l => l.trim()).filter(Boolean);
}
export function parseTimestamp(line: string): Date | null {
const match = line.match(/\d{4}-\d{2}-\d{2}/);
return match ? new Date(match[0]) : null;
}

5
src/types.ts Normal file
View File

@@ -0,0 +1,5 @@
export interface Directive {
text: string;
timestamp?: Date;
source: string;
}

5
src/validate.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Directive } from "./types";
export function validate(d: Directive): boolean {
return d.text.length > 0 && d.source.length > 0;
}