mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-26 08:56:22 +02:00
app navigation
This commit is contained in:
parent
8f1adfb6a5
commit
d150294af1
9 changed files with 433 additions and 1 deletions
22
apps/x/packages/shared/src/bases.ts
Normal file
22
apps/x/packages/shared/src/bases.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Shared types for the Bases view (saved filtered views over the knowledge graph).
|
||||
*/
|
||||
|
||||
export type SortDir = 'asc' | 'desc';
|
||||
|
||||
export interface ActiveFilter {
|
||||
category: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface BaseConfig {
|
||||
filters: ActiveFilter[];
|
||||
columns: string[];
|
||||
sort?: { field: string; dir: SortDir };
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_BASE_CONFIG: BaseConfig = {
|
||||
filters: [],
|
||||
columns: [],
|
||||
};
|
||||
60
apps/x/packages/shared/src/frontmatter.ts
Normal file
60
apps/x/packages/shared/src/frontmatter.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* Frontmatter parsing utilities for knowledge base markdown files.
|
||||
* Used by core (get-base-state) to scan knowledge files for available properties.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse a markdown file's YAML frontmatter into key-value pairs.
|
||||
* Handles both scalar values (`key: value`) and list values (`key:\n - item`).
|
||||
* Returns `{ fields, body }` where fields maps keys to string or string[].
|
||||
*/
|
||||
export function parseFrontmatter(content: string): { fields: Record<string, string | string[]>; body: string } {
|
||||
if (!content.startsWith('---')) {
|
||||
return { fields: {}, body: content };
|
||||
}
|
||||
const endIndex = content.indexOf('\n---', 3);
|
||||
if (endIndex === -1) {
|
||||
return { fields: {}, body: content };
|
||||
}
|
||||
|
||||
const rawBlock = content.slice(4, endIndex); // skip opening '---\n'
|
||||
const body = content.slice(endIndex + 4).replace(/^\n/, '');
|
||||
const fields: Record<string, string | string[]> = {};
|
||||
let currentKey: string | null = null;
|
||||
|
||||
for (const line of rawBlock.split('\n')) {
|
||||
if (line.trim() === '' || line === '---') {
|
||||
currentKey = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Top-level key: value
|
||||
const topMatch = line.match(/^(\w[\w\s]*\w|\w+):\s*(.*)$/);
|
||||
if (topMatch) {
|
||||
const key = topMatch[1];
|
||||
const value = topMatch[2].trim();
|
||||
if (value) {
|
||||
fields[key] = value;
|
||||
currentKey = null;
|
||||
} else {
|
||||
// List will follow
|
||||
currentKey = key;
|
||||
fields[key] = [];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// List item under current key
|
||||
if (currentKey) {
|
||||
const itemMatch = line.match(/^\s+-\s+(.+)$/);
|
||||
if (itemMatch) {
|
||||
const arr = fields[currentKey];
|
||||
if (Array.isArray(arr)) {
|
||||
arr.push(itemMatch[1].trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { fields, body };
|
||||
}
|
||||
|
|
@ -8,4 +8,6 @@ export * as agentSchedule from './agent-schedule.js';
|
|||
export * as agentScheduleState from './agent-schedule-state.js';
|
||||
export * as serviceEvents from './service-events.js'
|
||||
export * as inlineTask from './inline-task.js';
|
||||
export * as frontmatter from './frontmatter.js';
|
||||
export * as bases from './bases.js';
|
||||
export { PrefixLogger };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue