Sign In

@adrkit/core

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adrkit/core - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+16
dist/schema/ref.d.ts
/**
* @adrkit/core — ADR reference parsing.
*
* The single shared primitive for splitting an `AdrRef` string into its optional
* `log` qualifier and its bare `id`. Promoted from the private `parseRef` formerly
* duplicated in `packages/evaluator/src/rules/no-orphan-refs.ts`, and consumed by
* `@adrkit/mcp` to detect whether a caller-supplied ref is log-qualified.
*
* There is deliberately no inverse `formatAdrRef`: nothing re-serializes a
* `(log, id)` pair; every ref echoed to a caller reuses the original string verbatim.
*/
export interface ParsedAdrRef {
readonly id: string;
readonly log?: string;
}
export declare function parseAdrRef(ref: string): ParsedAdrRef;
/**
* @adrkit/core — ADR reference parsing.
*
* The single shared primitive for splitting an `AdrRef` string into its optional
* `log` qualifier and its bare `id`. Promoted from the private `parseRef` formerly
* duplicated in `packages/evaluator/src/rules/no-orphan-refs.ts`, and consumed by
* `@adrkit/mcp` to detect whether a caller-supplied ref is log-qualified.
*
* There is deliberately no inverse `formatAdrRef`: nothing re-serializes a
* `(log, id)` pair; every ref echoed to a caller reuses the original string verbatim.
*/
export interface ParsedAdrRef {
readonly id: string;
readonly log?: string;
}
// Splits on the first ':'. A leading ':' or no ':' at all is unqualified and
// returns { id: ref } with `id` the untouched original string (never split in that
// case); a qualified ref returns { log, id } split on the first colon. This is the
// behavior- and object-shape-preserving promotion of no-orphan-refs.ts's private copy.
export function parseAdrRef(ref: string): ParsedAdrRef {
const idx = ref.indexOf(':');
if (idx <= 0) return { id: ref };
return { log: ref.slice(0, idx), id: ref.slice(idx + 1) };
}
+1
-0
export * from './schema/index.js';
export * from './schema/ref.js';
export * from './parse/frontmatter.js';

@@ -3,0 +4,0 @@ export * from './load/corpus.js';

@@ -196,2 +196,9 @@ // src/schema/adr.schema.ts

}
// src/schema/ref.ts
function parseAdrRef(ref) {
const idx = ref.indexOf(":");
if (idx <= 0)
return { id: ref };
return { log: ref.slice(0, idx), id: ref.slice(idx + 1) };
}
// src/parse/frontmatter.ts

@@ -1718,2 +1725,3 @@ import { parseDocument } from "yaml";

parseFrontmatter,
parseAdrRef,
parseAdrFile,

@@ -1720,0 +1728,0 @@ normalizeSourceBody,

+1
-1
{
"name": "@adrkit/core",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pure ADR parsing, validation, migration, and affects resolution for adrkit.",

@@ -5,0 +5,0 @@ "type": "module",

export * from './schema/index.ts';
export * from './schema/ref.ts';
export * from './parse/frontmatter.ts';

@@ -3,0 +4,0 @@ export * from './load/corpus.ts';