open-agreements
Version:
Open-source legal template filling CLI and library
73 lines • 3.68 kB
TypeScript
/**
* Shared content-listing module (open-agreements#635).
*
* Canonical helpers for enumerating the repository's non-template first-class
* legal content — practice guides, reviewer checklists, and law surveys — as a
* flat, deterministic catalog with stable IDs. Used by:
* - MCP `tools.ts` (`list_content` / `get_content`, via dynamic import or npm
* dependency), alongside `template-listing.ts` for templates
* - future hosted-MCP parity in the openagreements.org deploy (which already
* consumes `template-listing.ts` the same way)
*
* The content lives as markdown bundles at the repository root
* (`practice-guides/`, `checklists/`, `surveys/` — the product-line-first
* views; the topic-first `legal-practice-library/` duplicates the same
* documents and is intentionally NOT indexed to keep IDs unique). These
* directories are part of the git repository but are NOT shipped in the npm
* package (`files` in package.json), so callers must treat "no content roots
* present" as a valid runtime state, reported by
* `listDocContentTypesAvailable()`.
*/
/** Non-template content types served from local markdown bundles. */
export type DocContentType = 'practice_guide' | 'checklist' | 'survey';
/** Every content type addressable through the unified content catalog. */
export type ContentType = 'template' | DocContentType;
/** Repository directory backing each markdown-bundle content type. */
export declare const DOC_CONTENT_DIRS: Record<DocContentType, string>;
export declare const DOC_CONTENT_TYPES: DocContentType[];
export interface DocContentItem {
/** Stable ID: `<type>/<topic>/<doc path>`, e.g. `practice_guide/wage-and-hour/us`. */
content_id: string;
type: DocContentType;
title: string;
description: string | null;
/** First path segment under the content root, e.g. `wage-and-hour`. */
topic: string;
/**
* Jurisdiction path derived from the document location (`us`,
* `us/california`, `worldwide`, …), or null for non-jurisdictional docs.
*/
jurisdiction: string | null;
format: 'markdown';
/** Canonical public URL from frontmatter `resource`, when declared. */
source_url: string | null;
/** Frontmatter `timestamp` (review/update date), when declared. */
updated_at: string | null;
tags: string[];
/** Repository-relative markdown file path (provenance). */
repo_path: string;
}
export interface DocContentDetail extends DocContentItem {
/** Full canonical markdown file content, frontmatter included. */
markdown: string;
}
/**
* Which markdown-bundle content types are servable from `contentRoot` (the
* package root by default). The npm package does not ship these directories,
* so an installed-package runtime typically returns `[]` — callers should
* surface that as "content unavailable in this runtime", not as empty content.
*/
export declare function listDocContentTypesAvailable(contentRoot?: string): DocContentType[];
/**
* List every practice guide, checklist, and survey document as a flat catalog,
* sorted lexicographically by `content_id` (deterministic order). Missing
* content directories contribute zero items.
*/
export declare function listDocContentItems(contentRoot?: string): DocContentItem[];
/**
* Resolve one content ID (e.g. `checklist/safes/yc-post-money-safe-valuation-cap`)
* to its full canonical document. Returns undefined for unknown IDs, IDs of the
* wrong shape, and anything that would escape the content roots.
*/
export declare function findDocContentItem(contentId: string, contentRoot?: string): DocContentDetail | undefined;
//# sourceMappingURL=content-listing.d.ts.map