mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
refactor: trim memory wiki helper exports
This commit is contained in:
@@ -26,7 +26,7 @@ const GENERATED_END = "<!-- openclaw:wiki:generated:end -->";
|
||||
const HUMAN_START = "<!-- openclaw:human:start -->";
|
||||
const HUMAN_END = "<!-- openclaw:human:end -->";
|
||||
|
||||
export type CreateSynthesisMemoryWikiMutation = {
|
||||
type CreateSynthesisMemoryWikiMutation = {
|
||||
op: "create_synthesis";
|
||||
title: string;
|
||||
body: string;
|
||||
@@ -38,7 +38,7 @@ export type CreateSynthesisMemoryWikiMutation = {
|
||||
status?: string;
|
||||
};
|
||||
|
||||
export type UpdateMetadataMemoryWikiMutation = {
|
||||
type UpdateMetadataMemoryWikiMutation = {
|
||||
op: "update_metadata";
|
||||
lookup: string;
|
||||
sourceIds?: string[];
|
||||
@@ -53,7 +53,7 @@ export type ApplyMemoryWikiMutation =
|
||||
| CreateSynthesisMemoryWikiMutation
|
||||
| UpdateMetadataMemoryWikiMutation;
|
||||
|
||||
export type ApplyMemoryWikiMutationResult = {
|
||||
type ApplyMemoryWikiMutationResult = {
|
||||
changed: boolean;
|
||||
operation: ApplyMemoryWikiMutation["op"];
|
||||
pagePath: string;
|
||||
|
||||
@@ -78,7 +78,7 @@ type ChatGptConversationRecord = {
|
||||
|
||||
type ChatGptImportOperation = "create" | "update" | "skip";
|
||||
|
||||
export type ChatGptImportAction = {
|
||||
type ChatGptImportAction = {
|
||||
conversationId: string;
|
||||
title: string;
|
||||
pagePath: string;
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { WikiClaim, WikiPageSummary } from "./markdown.js";
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
export const WIKI_AGING_DAYS = 30;
|
||||
export const WIKI_STALE_DAYS = 90;
|
||||
const WIKI_STALE_DAYS = 90;
|
||||
|
||||
const CONTESTED_CLAIM_STATUSES = new Set(["contested", "contradicted", "refuted", "superseded"]);
|
||||
|
||||
@@ -143,7 +143,7 @@ export function assessClaimFreshness(params: {
|
||||
return buildFreshnessFromTimestamp({ timestamp: latestTimestamp, now: params.now });
|
||||
}
|
||||
|
||||
export function buildWikiClaimHealth(params: {
|
||||
function buildWikiClaimHealth(params: {
|
||||
page: WikiPageSummary;
|
||||
claim: WikiClaim;
|
||||
index: number;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ResolvedMemoryWikiConfig } from "./config.js";
|
||||
import { parseWikiMarkdown } from "./markdown.js";
|
||||
import { readQueryableWikiPages } from "./query.js";
|
||||
|
||||
export type MemoryWikiImportInsightItem = {
|
||||
type MemoryWikiImportInsightItem = {
|
||||
pagePath: string;
|
||||
title: string;
|
||||
riskLevel: "low" | "medium" | "high" | "unknown";
|
||||
@@ -25,7 +25,7 @@ export type MemoryWikiImportInsightItem = {
|
||||
updatedAt?: string;
|
||||
};
|
||||
|
||||
export type MemoryWikiImportInsightCluster = {
|
||||
type MemoryWikiImportInsightCluster = {
|
||||
key: string;
|
||||
label: string;
|
||||
itemCount: number;
|
||||
@@ -36,7 +36,7 @@ export type MemoryWikiImportInsightCluster = {
|
||||
items: MemoryWikiImportInsightItem[];
|
||||
};
|
||||
|
||||
export type MemoryWikiImportInsightsStatus = {
|
||||
type MemoryWikiImportInsightsStatus = {
|
||||
sourceType: "chatgpt";
|
||||
totalItems: number;
|
||||
totalClusters: number;
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import type { ResolvedMemoryWikiConfig } from "./config.js";
|
||||
|
||||
export type MemoryWikiImportRunSummary = {
|
||||
type MemoryWikiImportRunSummary = {
|
||||
runId: string;
|
||||
importType: string;
|
||||
appliedAt: string;
|
||||
@@ -18,7 +18,7 @@ export type MemoryWikiImportRunSummary = {
|
||||
samplePaths: string[];
|
||||
};
|
||||
|
||||
export type MemoryWikiImportRunsStatus = {
|
||||
type MemoryWikiImportRunsStatus = {
|
||||
runs: MemoryWikiImportRunSummary[];
|
||||
totalRuns: number;
|
||||
activeRuns: number;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { appendMemoryWikiLog } from "./log.js";
|
||||
import { renderMarkdownFence, renderWikiMarkdown, slugifyWikiSegment } from "./markdown.js";
|
||||
import { initializeMemoryWikiVault } from "./vault.js";
|
||||
|
||||
export type IngestMemoryWikiSourceResult = {
|
||||
type IngestMemoryWikiSourceResult = {
|
||||
sourcePath: string;
|
||||
pageId: string;
|
||||
pagePath: string;
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { ResolvedMemoryWikiConfig } from "./config.js";
|
||||
import { appendMemoryWikiLog } from "./log.js";
|
||||
import { renderWikiMarkdown, type WikiPageSummary } from "./markdown.js";
|
||||
|
||||
export type MemoryWikiLintIssue = {
|
||||
type MemoryWikiLintIssue = {
|
||||
severity: "error" | "warning";
|
||||
category: "structure" | "provenance" | "links" | "contradictions" | "open-questions" | "quality";
|
||||
code:
|
||||
@@ -38,7 +38,7 @@ export type MemoryWikiLintIssue = {
|
||||
message: string;
|
||||
};
|
||||
|
||||
export type LintMemoryWikiResult = {
|
||||
type LintMemoryWikiResult = {
|
||||
vaultRoot: string;
|
||||
issueCount: number;
|
||||
issues: MemoryWikiLintIssue[];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
export type MemoryWikiLogEntry = {
|
||||
type MemoryWikiLogEntry = {
|
||||
type: "init" | "ingest" | "compile" | "lint";
|
||||
timestamp: string;
|
||||
details?: Record<string, unknown>;
|
||||
|
||||
@@ -7,13 +7,13 @@ import {
|
||||
} from "openclaw/plugin-sdk/text-runtime";
|
||||
import YAML from "yaml";
|
||||
|
||||
export const WIKI_PAGE_KINDS = ["entity", "concept", "source", "synthesis", "report"] as const;
|
||||
const WIKI_PAGE_KINDS = ["entity", "concept", "source", "synthesis", "report"] as const;
|
||||
export const WIKI_RELATED_START_MARKER = "<!-- openclaw:wiki:related:start -->";
|
||||
export const WIKI_RELATED_END_MARKER = "<!-- openclaw:wiki:related:end -->";
|
||||
|
||||
export type WikiPageKind = (typeof WIKI_PAGE_KINDS)[number];
|
||||
|
||||
export type ParsedWikiMarkdown = {
|
||||
type ParsedWikiMarkdown = {
|
||||
frontmatter: Record<string, unknown>;
|
||||
body: string;
|
||||
};
|
||||
@@ -39,7 +39,7 @@ export type WikiClaim = {
|
||||
updatedAt?: string;
|
||||
};
|
||||
|
||||
export type WikiPersonCard = {
|
||||
type WikiPersonCard = {
|
||||
canonicalId?: string;
|
||||
handles: string[];
|
||||
socials: string[];
|
||||
@@ -180,7 +180,7 @@ export function renderWikiMarkdown(params: {
|
||||
return `---\n${frontmatter}\n---\n\n${params.body.trimStart()}`;
|
||||
}
|
||||
|
||||
export function extractTitleFromMarkdown(body: string): string | undefined {
|
||||
function extractTitleFromMarkdown(body: string): string | undefined {
|
||||
const match = body.match(/^#\s+(.+?)\s*$/m);
|
||||
return normalizeOptionalString(match?.[1]);
|
||||
}
|
||||
@@ -365,7 +365,7 @@ function normalizeWikiRelationships(value: unknown): WikiRelationship[] {
|
||||
});
|
||||
}
|
||||
|
||||
export function extractWikiLinks(markdown: string): string[] {
|
||||
function extractWikiLinks(markdown: string): string[] {
|
||||
const searchable = markdown.replace(RELATED_BLOCK_PATTERN, "");
|
||||
const links: string[] = [];
|
||||
for (const match of searchable.matchAll(OBSIDIAN_LINK_PATTERN)) {
|
||||
|
||||
@@ -12,7 +12,7 @@ const PALACE_KIND_LABELS: Record<WikiPageKind, string> = {
|
||||
report: "Reports",
|
||||
};
|
||||
|
||||
export type MemoryWikiPalaceItem = {
|
||||
type MemoryWikiPalaceItem = {
|
||||
pagePath: string;
|
||||
title: string;
|
||||
kind: WikiPageKind;
|
||||
@@ -28,7 +28,7 @@ export type MemoryWikiPalaceItem = {
|
||||
snippet?: string;
|
||||
};
|
||||
|
||||
export type MemoryWikiPalaceCluster = {
|
||||
type MemoryWikiPalaceCluster = {
|
||||
key: WikiPageKind;
|
||||
label: string;
|
||||
itemCount: number;
|
||||
@@ -39,7 +39,7 @@ export type MemoryWikiPalaceCluster = {
|
||||
items: MemoryWikiPalaceItem[];
|
||||
};
|
||||
|
||||
export type MemoryWikiPalaceStatus = {
|
||||
type MemoryWikiPalaceStatus = {
|
||||
totalItems: number;
|
||||
totalClaims: number;
|
||||
totalQuestions: number;
|
||||
|
||||
@@ -7,12 +7,12 @@ import type { ResolvedMemoryWikiConfig } from "./config.js";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
export type ObsidianCliProbe = {
|
||||
type ObsidianCliProbe = {
|
||||
available: boolean;
|
||||
command: string | null;
|
||||
};
|
||||
|
||||
export type ObsidianCliResult = {
|
||||
type ObsidianCliResult = {
|
||||
command: string;
|
||||
argv: string[];
|
||||
stdout: string;
|
||||
@@ -33,7 +33,7 @@ async function isExecutableFile(inputPath: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function resolveCommandOnPath(command: string): Promise<string | null> {
|
||||
async function resolveCommandOnPath(command: string): Promise<string | null> {
|
||||
const pathValue = process.env.PATH ?? "";
|
||||
const pathEntries = pathValue.split(path.delimiter).filter(Boolean);
|
||||
const windowsExts =
|
||||
@@ -72,7 +72,7 @@ export async function probeObsidianCli(
|
||||
};
|
||||
}
|
||||
|
||||
export async function runObsidianCli(params: {
|
||||
async function runObsidianCli(params: {
|
||||
config: ResolvedMemoryWikiConfig;
|
||||
subcommand: string;
|
||||
args?: string[];
|
||||
|
||||
@@ -127,7 +127,7 @@ type QueryDigestBundle = {
|
||||
claims: QueryDigestClaim[];
|
||||
};
|
||||
|
||||
export type WikiSearchResult = {
|
||||
type WikiSearchResult = {
|
||||
corpus: "wiki" | "memory";
|
||||
path: string;
|
||||
title: string;
|
||||
@@ -156,7 +156,7 @@ export type WikiSearchResult = {
|
||||
evidenceSourceIds?: string[];
|
||||
};
|
||||
|
||||
export type WikiGetResult = {
|
||||
type WikiGetResult = {
|
||||
corpus: "wiki" | "memory";
|
||||
path: string;
|
||||
title: string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
|
||||
export type MemoryWikiImportedSourceGroup = "bridge" | "unsafe-local";
|
||||
|
||||
export type MemoryWikiImportedSourceStateEntry = {
|
||||
type MemoryWikiImportedSourceStateEntry = {
|
||||
group: MemoryWikiImportedSourceGroup;
|
||||
pagePath: string;
|
||||
sourcePath: string;
|
||||
@@ -22,7 +22,7 @@ const EMPTY_STATE: MemoryWikiImportedSourceState = {
|
||||
entries: {},
|
||||
};
|
||||
|
||||
export function resolveMemoryWikiSourceSyncStatePath(vaultRoot: string): string {
|
||||
function resolveMemoryWikiSourceSyncStatePath(vaultRoot: string): string {
|
||||
return path.join(vaultRoot, ".openclaw-wiki", "source-sync.json");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { ResolvedMemoryWikiConfig } from "./config.js";
|
||||
import { inferWikiPageKind, toWikiPageSummary, type WikiPageKind } from "./markdown.js";
|
||||
import { probeObsidianCli } from "./obsidian.js";
|
||||
|
||||
export type MemoryWikiStatusWarning = {
|
||||
type MemoryWikiStatusWarning = {
|
||||
code:
|
||||
| "vault-missing"
|
||||
| "obsidian-cli-missing"
|
||||
@@ -46,7 +46,7 @@ export type MemoryWikiStatus = {
|
||||
warnings: MemoryWikiStatusWarning[];
|
||||
};
|
||||
|
||||
export type MemoryWikiDoctorFix = {
|
||||
type MemoryWikiDoctorFix = {
|
||||
code: MemoryWikiStatusWarning["code"];
|
||||
message: string;
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ export const WIKI_VAULT_DIRECTORIES = [
|
||||
".openclaw-wiki/cache",
|
||||
] as const;
|
||||
|
||||
export type InitializeMemoryWikiVaultResult = {
|
||||
type InitializeMemoryWikiVaultResult = {
|
||||
rootDir: string;
|
||||
created: boolean;
|
||||
createdDirectories: string[];
|
||||
|
||||
Reference in New Issue
Block a user