@ignite-agent/agent 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/cli/index.js +87 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/ignite.css +10 -0
- package/dist/operator/ui.js +10 -0
- package/dist/operator/ui.js.map +1 -1
- package/dist/wiki-content/index.d.ts +30 -0
- package/dist/wiki-content/index.js +68 -0
- package/dist/wiki-content/index.js.map +1 -0
- package/dist/wiki-content/jsonld.d.ts +20 -0
- package/dist/wiki-content/jsonld.js +88 -0
- package/dist/wiki-content/jsonld.js.map +1 -0
- package/dist/wiki-content/load.d.ts +22 -0
- package/dist/wiki-content/load.js +92 -0
- package/dist/wiki-content/load.js.map +1 -0
- package/dist/wiki-content/metadata.d.ts +13 -0
- package/dist/wiki-content/metadata.js +61 -0
- package/dist/wiki-content/metadata.js.map +1 -0
- package/dist/wiki-content/pull.d.ts +23 -0
- package/dist/wiki-content/pull.js +160 -0
- package/dist/wiki-content/pull.js.map +1 -0
- package/dist/wiki-content/render.d.ts +29 -0
- package/dist/wiki-content/render.js +80 -0
- package/dist/wiki-content/render.js.map +1 -0
- package/dist/wiki-content/schema.d.ts +73 -0
- package/dist/wiki-content/schema.js +173 -0
- package/dist/wiki-content/schema.js.map +1 -0
- package/package.json +9 -5
- package/skills/ignite-brand-wiki/SKILL.md +130 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { parseWikiEntity, validateWikiSet } from './schema.js';
|
|
5
|
+
export const DEFAULT_WIKI_DIR = 'content/wiki';
|
|
6
|
+
export function wikiDir(explicit) {
|
|
7
|
+
return resolve(process.cwd(), explicit?.trim() || process.env.IGNITE_WIKI_DIR?.trim() || DEFAULT_WIKI_DIR);
|
|
8
|
+
}
|
|
9
|
+
// Reads every `<slug>.json` in the directory. Never throws for content problems: the issues list is the
|
|
10
|
+
// verdict, and `loadWikiEntities` turns a non-empty list into a build failure.
|
|
11
|
+
export function readWikiSet(dir) {
|
|
12
|
+
if (!existsSync(dir))
|
|
13
|
+
return { dir, entities: [], issues: [] };
|
|
14
|
+
const files = readdirSync(dir)
|
|
15
|
+
.filter((name) => name.endsWith('.json') && !name.startsWith('_'))
|
|
16
|
+
.sort()
|
|
17
|
+
.map((name) => join(dir, name));
|
|
18
|
+
const entities = [];
|
|
19
|
+
const issues = [];
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
let raw;
|
|
22
|
+
try {
|
|
23
|
+
raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
issues.push({ file, message: `invalid JSON: ${error.message}` });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const parsed = parseWikiEntity(file, raw);
|
|
30
|
+
issues.push(...parsed.issues);
|
|
31
|
+
if (parsed.entity)
|
|
32
|
+
entities.push({ file, entity: parsed.entity });
|
|
33
|
+
}
|
|
34
|
+
issues.push(...validateWikiSet(entities));
|
|
35
|
+
return { dir, entities, issues };
|
|
36
|
+
}
|
|
37
|
+
export class WikiContentError extends Error {
|
|
38
|
+
issues;
|
|
39
|
+
constructor(issues) {
|
|
40
|
+
super(`[@ignite-agent/agent] wiki content failed validation:\n${issues.map(formatIssue).join('\n')}`);
|
|
41
|
+
this.issues = issues;
|
|
42
|
+
this.name = 'WikiContentError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function formatIssue(issue) {
|
|
46
|
+
return `BUILD ERROR ${issue.file}: ${issue.message}`;
|
|
47
|
+
}
|
|
48
|
+
// The page loader. Throws on any drift so `next build` fails instead of shipping a page the gate refused.
|
|
49
|
+
export function loadWikiEntities(dir) {
|
|
50
|
+
const set = readWikiSet(wikiDir(dir));
|
|
51
|
+
if (set.issues.length > 0)
|
|
52
|
+
throw new WikiContentError(set.issues);
|
|
53
|
+
return set.entities.map((entry) => entry.entity);
|
|
54
|
+
}
|
|
55
|
+
export function findWikiEntity(slug, dir) {
|
|
56
|
+
return loadWikiEntities(dir).find((entity) => entity.slug === slug) ?? null;
|
|
57
|
+
}
|
|
58
|
+
// One source of truth for freshness: newest changelog date, else the import stamp, else the file's git
|
|
59
|
+
// commit date, else its mtime. Footer, JSON-LD, metadata and sitemap all read this.
|
|
60
|
+
export function lastReviewed(entity, file) {
|
|
61
|
+
const dates = entity.changelog.map((entry) => entry.date).sort();
|
|
62
|
+
const newest = dates[dates.length - 1];
|
|
63
|
+
if (newest)
|
|
64
|
+
return newest;
|
|
65
|
+
if (entity.imported_from?.dateModified)
|
|
66
|
+
return entity.imported_from.dateModified.slice(0, 10);
|
|
67
|
+
if (file && existsSync(file)) {
|
|
68
|
+
const committed = gitCommitDate(file);
|
|
69
|
+
if (committed)
|
|
70
|
+
return committed;
|
|
71
|
+
return statSync(file).mtime.toISOString().slice(0, 10);
|
|
72
|
+
}
|
|
73
|
+
return new Date().toISOString().slice(0, 10);
|
|
74
|
+
}
|
|
75
|
+
function gitCommitDate(file) {
|
|
76
|
+
try {
|
|
77
|
+
const out = execFileSync('git', ['log', '-1', '--format=%cs', '--', file], {
|
|
78
|
+
cwd: resolve(file, '..'),
|
|
79
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
80
|
+
})
|
|
81
|
+
.toString()
|
|
82
|
+
.trim();
|
|
83
|
+
return /^\d{4}-\d{2}-\d{2}$/.test(out) ? out : null;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export function entityFile(dir, slug) {
|
|
90
|
+
return join(dir, `${slug}.json`);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceR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AAC,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;YACzE,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;YACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC;aACC,QAAQ,EAAE;aACV,IAAI,EAAE,CAAC;QACV,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAY;IAClD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Metadata, MetadataRoute } from 'next';
|
|
2
|
+
import { type WikiSiteOptions } from './jsonld.js';
|
|
3
|
+
import { type WikiEntity } from './schema.js';
|
|
4
|
+
export declare const TITLE_MAX = 60;
|
|
5
|
+
export declare const DESCRIPTION_MIN = 130;
|
|
6
|
+
export declare const DESCRIPTION_MAX = 160;
|
|
7
|
+
export declare function entityTitle(entity: WikiEntity, siteName?: string | undefined): string;
|
|
8
|
+
export declare function entityDescription(entity: WikiEntity): string;
|
|
9
|
+
export declare function entityMetadata(entity: WikiEntity, options: WikiSiteOptions): Metadata;
|
|
10
|
+
export declare function wikiContentSitemap(entries: Array<{
|
|
11
|
+
entity: WikiEntity;
|
|
12
|
+
lastReviewed: string;
|
|
13
|
+
}>, options: WikiSiteOptions): MetadataRoute.Sitemap;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { entityUrl } from './jsonld.js';
|
|
2
|
+
import { definitionLede, entityTypeLabel } from './schema.js';
|
|
3
|
+
export const TITLE_MAX = 60;
|
|
4
|
+
export const DESCRIPTION_MIN = 130;
|
|
5
|
+
export const DESCRIPTION_MAX = 160;
|
|
6
|
+
// "{canonical_name} — {category} | {site}", clamped to 60 characters. The name survives the clamp first;
|
|
7
|
+
// the category and site suffix go before it does.
|
|
8
|
+
export function entityTitle(entity, siteName) {
|
|
9
|
+
const category = entity.definition.category?.trim() || entityTypeLabel(entity.entity_type);
|
|
10
|
+
const full = siteName ? `${entity.canonical_name} — ${category} | ${siteName}` : `${entity.canonical_name} — ${category}`;
|
|
11
|
+
if (full.length <= TITLE_MAX)
|
|
12
|
+
return full;
|
|
13
|
+
const withoutSite = `${entity.canonical_name} — ${category}`;
|
|
14
|
+
if (withoutSite.length <= TITLE_MAX)
|
|
15
|
+
return withoutSite;
|
|
16
|
+
return clamp(entity.canonical_name, TITLE_MAX);
|
|
17
|
+
}
|
|
18
|
+
// The definition lede clamped to 160 characters. A lede under 130 characters stays as it is: the text is not
|
|
19
|
+
// padded, because there is nothing true to pad it with.
|
|
20
|
+
export function entityDescription(entity) {
|
|
21
|
+
return clamp(definitionLede(entity), DESCRIPTION_MAX);
|
|
22
|
+
}
|
|
23
|
+
export function entityMetadata(entity, options) {
|
|
24
|
+
const canonical = entityUrl(entity, options);
|
|
25
|
+
const title = entityTitle(entity, options.siteName);
|
|
26
|
+
const description = entityDescription(entity);
|
|
27
|
+
const metadata = {
|
|
28
|
+
title,
|
|
29
|
+
description,
|
|
30
|
+
alternates: { canonical },
|
|
31
|
+
openGraph: {
|
|
32
|
+
title,
|
|
33
|
+
description,
|
|
34
|
+
type: 'article',
|
|
35
|
+
url: canonical,
|
|
36
|
+
...(options.siteName ? { siteName: options.siteName } : {}),
|
|
37
|
+
...(options.locale ? { locale: options.locale } : {}),
|
|
38
|
+
},
|
|
39
|
+
twitter: { card: 'summary', title, description },
|
|
40
|
+
metadataBase: new URL(new URL(options.siteUrl.includes('://') ? options.siteUrl : `https://${options.siteUrl}`).origin),
|
|
41
|
+
};
|
|
42
|
+
if (entity.author) {
|
|
43
|
+
metadata.authors = [{ name: entity.author.name, ...(entity.author.url ? { url: entity.author.url } : {}) }];
|
|
44
|
+
}
|
|
45
|
+
return metadata;
|
|
46
|
+
}
|
|
47
|
+
export function wikiContentSitemap(entries, options) {
|
|
48
|
+
return entries.map(({ entity, lastReviewed }) => ({
|
|
49
|
+
url: entityUrl(entity, options),
|
|
50
|
+
lastModified: lastReviewed,
|
|
51
|
+
changeFrequency: 'monthly',
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
function clamp(value, max) {
|
|
55
|
+
if (value.length <= max)
|
|
56
|
+
return value;
|
|
57
|
+
const cut = value.slice(0, max - 1);
|
|
58
|
+
const atSpace = cut.lastIndexOf(' ');
|
|
59
|
+
return `${(atSpace > max * 0.6 ? cut.slice(0, atSpace) : cut).replace(/[\s,;:.]+$/, '')}…`;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/wiki-content/metadata.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAwB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAE/E,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC5B,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,yGAAyG;AACzG,kDAAkD;AAClD,MAAM,UAAU,WAAW,CAAC,MAAkB,EAAE,QAA6B;IAC3E,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,eAAe,C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C,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC,OAAO,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IgniteClient } from '../client.js';
|
|
2
|
+
import type { FeedPage } from '../types.js';
|
|
3
|
+
import { type WikiEntityInput } from './schema.js';
|
|
4
|
+
export type PullSummary = {
|
|
5
|
+
published: number;
|
|
6
|
+
written: string[];
|
|
7
|
+
unchanged: string[];
|
|
8
|
+
kept: string[];
|
|
9
|
+
skipped: Array<{
|
|
10
|
+
slug: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
}>;
|
|
13
|
+
unresolvedMarkers: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function feedPageToEntity(page: FeedPage, siteUrl?: string): {
|
|
16
|
+
entity: WikiEntityInput;
|
|
17
|
+
unresolvedMarkers: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function pullWiki(client: IgniteClient, dir: string, options: {
|
|
20
|
+
siteUrl?: string | undefined;
|
|
21
|
+
dryRun?: boolean | undefined;
|
|
22
|
+
log?: ((line: string) => void) | undefined;
|
|
23
|
+
}): Promise<PullSummary>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { entityFile } from './load.js';
|
|
3
|
+
import { parseWikiEntity } from './schema.js';
|
|
4
|
+
const MARKER = /\[(\d+)\]/g;
|
|
5
|
+
// Maps one published Ignite wiki page onto the entity contract. Only what the page states is carried over:
|
|
6
|
+
// its lede, its sections, the paragraphs that cite a source, the source list, its author and its dates.
|
|
7
|
+
// Type and aliases are the reviewer's call, so the file starts as a `concept` with no aliases.
|
|
8
|
+
export function feedPageToEntity(page, siteUrl) {
|
|
9
|
+
const html = page.html;
|
|
10
|
+
const title = firstMatch(html, /<h1\b[^>]*>([\s\S]*?)<\/h1>/i) ?? page.title;
|
|
11
|
+
const body = html.replace(/<h1\b[^>]*>[\s\S]*?<\/h1>/i, '');
|
|
12
|
+
const sourcesIndex = body.search(/<h2\b[^>]*>\s*Sources\s*<\/h2>/i);
|
|
13
|
+
const content = sourcesIndex >= 0 ? body.slice(0, sourcesIndex) : body;
|
|
14
|
+
const sourcesHtml = sourcesIndex >= 0 ? body.slice(sourcesIndex) : '';
|
|
15
|
+
const citations = [...sourcesHtml.matchAll(/<li\b[^>]*>\s*<a\b[^>]*href=["']([^"']+)["'][^>]*>([\s\S]*?)<\/a>/gi)].map((match, i) => ({
|
|
16
|
+
n: i + 1,
|
|
17
|
+
url: decode(match[1] ?? ''),
|
|
18
|
+
title: textOf(match[2] ?? '') || decode(match[1] ?? ''),
|
|
19
|
+
accessed: (page.dateModified ?? page.updatedAt).slice(0, 10),
|
|
20
|
+
}));
|
|
21
|
+
const known = new Set(citations.map((c) => c.n));
|
|
22
|
+
const chunks = content.split(/(?=<h2\b)/i);
|
|
23
|
+
const lead = [];
|
|
24
|
+
const sections = [];
|
|
25
|
+
const crossLinks = [];
|
|
26
|
+
let unresolved = 0;
|
|
27
|
+
for (const chunk of chunks) {
|
|
28
|
+
const heading = firstMatch(chunk, /<h2\b[^>]*>([\s\S]*?)<\/h2>/i);
|
|
29
|
+
const rest = heading === null ? chunk : chunk.replace(/<h2\b[^>]*>[\s\S]*?<\/h2>/i, '');
|
|
30
|
+
for (const link of rest.matchAll(/<ul class="wiki-related">([\s\S]*?)<\/ul>/gi)) {
|
|
31
|
+
for (const anchor of (link[1] ?? '').matchAll(/href=["']([^"']+)["']/gi)) {
|
|
32
|
+
const slug = ownWikiSlug(anchor[1] ?? '', siteUrl);
|
|
33
|
+
if (slug)
|
|
34
|
+
crossLinks.push({ target_slug: slug });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const paragraphs = [...rest.matchAll(/<p\b([^>]*)>([\s\S]*?)<\/p>/gi)]
|
|
38
|
+
.filter((m) => !/wiki-(questions|related)-label/.test(m[1] ?? ''))
|
|
39
|
+
.map((m) => textOf(m[2] ?? ''))
|
|
40
|
+
.filter((t) => t !== '');
|
|
41
|
+
if (heading === null) {
|
|
42
|
+
lead.push(...paragraphs);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const section = { heading: textOf(heading), paragraphs: [], stats: [] };
|
|
46
|
+
for (const paragraph of paragraphs) {
|
|
47
|
+
const markers = [...paragraph.matchAll(MARKER)].map((m) => Number(m[1]));
|
|
48
|
+
const resolvable = markers.filter((n) => known.has(n));
|
|
49
|
+
if (resolvable.length > 0) {
|
|
50
|
+
section.stats.push({ text: paragraph, citation: resolvable[0] });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
if (markers.length > 0)
|
|
54
|
+
unresolved += markers.length;
|
|
55
|
+
section.paragraphs.push(paragraph.replace(/\s*\[\d+\]/g, '').replace(/\s{2,}/g, ' ').trim());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (section.paragraphs.length + section.stats.length > 0)
|
|
59
|
+
sections.push(section);
|
|
60
|
+
}
|
|
61
|
+
const lede = lead[0] ?? sections[0]?.paragraphs[0] ?? '';
|
|
62
|
+
const dateModified = page.dateModified ?? page.updatedAt;
|
|
63
|
+
const entity = {
|
|
64
|
+
entity_type: 'concept',
|
|
65
|
+
canonical_name: textOf(title),
|
|
66
|
+
slug: page.slug,
|
|
67
|
+
aliases: [],
|
|
68
|
+
definition: { lede },
|
|
69
|
+
sections,
|
|
70
|
+
cross_links: dedupe(crossLinks).filter((link) => link.target_slug !== page.slug),
|
|
71
|
+
citations,
|
|
72
|
+
changelog: [{ date: dateModified.slice(0, 10), note: 'Imported from the published Ignite page' }],
|
|
73
|
+
same_as: [],
|
|
74
|
+
imported_from: { source: 'ignite', slug: page.slug, dateModified },
|
|
75
|
+
};
|
|
76
|
+
if (page.author?.name) {
|
|
77
|
+
entity.author = { name: page.author.name, ...(page.author.url ? { url: page.author.url } : {}) };
|
|
78
|
+
}
|
|
79
|
+
return { entity, unresolvedMarkers: unresolved };
|
|
80
|
+
}
|
|
81
|
+
export async function pullWiki(client, dir, options) {
|
|
82
|
+
const { pages } = await client.pages();
|
|
83
|
+
const wiki = pages.filter((page) => page.kind === 'wiki');
|
|
84
|
+
const summary = { published: wiki.length, written: [], unchanged: [], kept: [], skipped: [], unresolvedMarkers: 0 };
|
|
85
|
+
const log = options.log ?? (() => undefined);
|
|
86
|
+
if (!options.dryRun)
|
|
87
|
+
mkdirSync(dir, { recursive: true });
|
|
88
|
+
for (const page of wiki) {
|
|
89
|
+
const { entity, unresolvedMarkers } = feedPageToEntity(page, options.siteUrl);
|
|
90
|
+
summary.unresolvedMarkers += unresolvedMarkers;
|
|
91
|
+
const file = entityFile(dir, page.slug);
|
|
92
|
+
const parsed = parseWikiEntity(file, entity);
|
|
93
|
+
if (!parsed.entity) {
|
|
94
|
+
summary.skipped.push({ slug: page.slug, reason: parsed.issues.map((i) => i.message).join('; ') });
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const existing = readExisting(file);
|
|
98
|
+
if (existing && !existing.imported_from) {
|
|
99
|
+
summary.kept.push(page.slug);
|
|
100
|
+
log(` keep ${file} (authored here; not overwritten)`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (existing?.imported_from?.dateModified === (page.dateModified ?? page.updatedAt)) {
|
|
104
|
+
summary.unchanged.push(page.slug);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!options.dryRun)
|
|
108
|
+
writeFileSync(file, `${JSON.stringify(parsed.entity, null, 2)}\n`);
|
|
109
|
+
summary.written.push(page.slug);
|
|
110
|
+
log(` ${options.dryRun ? 'would write' : 'write'} ${file}`);
|
|
111
|
+
}
|
|
112
|
+
return summary;
|
|
113
|
+
}
|
|
114
|
+
function readExisting(file) {
|
|
115
|
+
if (!existsSync(file))
|
|
116
|
+
return null;
|
|
117
|
+
try {
|
|
118
|
+
const parsed = parseWikiEntity(file, JSON.parse(readFileSync(file, 'utf8')));
|
|
119
|
+
return parsed.entity;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function ownWikiSlug(href, siteUrl) {
|
|
126
|
+
let path = href;
|
|
127
|
+
try {
|
|
128
|
+
const url = new URL(href, siteUrl ?? 'https://placeholder.invalid');
|
|
129
|
+
if (siteUrl && url.host !== new URL(siteUrl).host && url.host !== 'placeholder.invalid')
|
|
130
|
+
return null;
|
|
131
|
+
path = url.pathname;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const match = path.match(/^\/(?:w|wiki)\/([a-z0-9]+(?:-[a-z0-9]+)*)\/?$/);
|
|
137
|
+
return match?.[1] ?? null;
|
|
138
|
+
}
|
|
139
|
+
function dedupe(links) {
|
|
140
|
+
const seen = new Set();
|
|
141
|
+
return links.filter((link) => (seen.has(link.target_slug) ? false : (seen.add(link.target_slug), true)));
|
|
142
|
+
}
|
|
143
|
+
function firstMatch(html, pattern) {
|
|
144
|
+
const match = html.match(pattern);
|
|
145
|
+
return match?.[1] ?? null;
|
|
146
|
+
}
|
|
147
|
+
function textOf(html) {
|
|
148
|
+
return decode(html.replace(/<[^>]+>/g, ' ')).replace(/\s+/g, ' ').trim();
|
|
149
|
+
}
|
|
150
|
+
function decode(value) {
|
|
151
|
+
return value
|
|
152
|
+
.replace(/&/g, '&')
|
|
153
|
+
.replace(/</g, '<')
|
|
154
|
+
.replace(/>/g, '>')
|
|
155
|
+
.replace(/"/g, '"')
|
|
156
|
+
.replace(/'/g, "'")
|
|
157
|
+
.replace(/'/g, "'")
|
|
158
|
+
.repl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C;IAC/B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,OAAe;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,KAAK;SACT,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type IgniteTokens } from '../operator/ui.js';
|
|
2
|
+
import { type WikiSiteOptions } from './jsonld.js';
|
|
3
|
+
import { type EntityType, type WikiEntity } from './schema.js';
|
|
4
|
+
export type WikiRenderOptions = WikiSiteOptions & {
|
|
5
|
+
tokens?: IgniteTokens | undefined;
|
|
6
|
+
injectCss?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare function CitedText({ text, citations }: {
|
|
9
|
+
text: string;
|
|
10
|
+
citations: Set<number>;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export declare function WikiEntityArticle({ entity, entities, lastReviewed, options, }: {
|
|
13
|
+
entity: WikiEntity;
|
|
14
|
+
entities: WikiEntity[];
|
|
15
|
+
lastReviewed: string;
|
|
16
|
+
options: WikiRenderOptions;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
export declare function groupByType(entities: WikiEntity[]): Array<{
|
|
19
|
+
type: EntityType;
|
|
20
|
+
entities: WikiEntity[];
|
|
21
|
+
}>;
|
|
22
|
+
export declare function WikiEntityIndex({ entities, options }: {
|
|
23
|
+
entities: WikiEntity[];
|
|
24
|
+
options: WikiRenderOptions;
|
|
25
|
+
}): import("react").JSX.Element | null;
|
|
26
|
+
export declare function WikiEntitySidebar({ entities, options }: {
|
|
27
|
+
entities: WikiEntity[];
|
|
28
|
+
options: WikiRenderOptions;
|
|
29
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { IGNITE_CSS, tokensToStyle } from '../operator/ui.js';
|
|
3
|
+
import { entityJsonLd, entityPath, jsonLdText } from './jsonld.js';
|
|
4
|
+
import { definitionLede, ENTITY_TYPES, entityTypeLabel } from './schema.js';
|
|
5
|
+
const MARKER = /\[(\d+)\]/g;
|
|
6
|
+
// Same frame the feed pages use, without the context provider, so this file stays importable outside Next.
|
|
7
|
+
function IgniteFrame({ tokens, injectCss = true, children }) {
|
|
8
|
+
const style = tokensToStyle(tokens);
|
|
9
|
+
return (_jsxs("div", { className: "ignite", style: style, children: [injectCss ? _jsx("style", { "data-ignite": "css", children: IGNITE_CSS }) : null, children] }));
|
|
10
|
+
}
|
|
11
|
+
// Text with `[n]` markers becomes text with links to `#cite-n`. A marker whose citation is absent stays plain
|
|
12
|
+
// text; the validator has already failed the build for that case, so this only matters for ad-hoc renders.
|
|
13
|
+
export function CitedText({ text, citations }) {
|
|
14
|
+
const parts = [];
|
|
15
|
+
let last = 0;
|
|
16
|
+
let key = 0;
|
|
17
|
+
for (const match of text.matchAll(MARKER)) {
|
|
18
|
+
const index = match.index ?? 0;
|
|
19
|
+
const n = Number(match[1]);
|
|
20
|
+
if (index > last)
|
|
21
|
+
parts.push(text.slice(last, index));
|
|
22
|
+
if (citations.has(n)) {
|
|
23
|
+
parts.push(_jsxs("a", { className: "ignite-wiki-cite", href: `#cite-${n}`, "aria-label": `Source ${n}`, children: ["[", n, "]"] }, key++));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
parts.push(match[0]);
|
|
27
|
+
}
|
|
28
|
+
last = index + match[0].length;
|
|
29
|
+
}
|
|
30
|
+
if (last < text.length)
|
|
31
|
+
parts.push(text.slice(last));
|
|
32
|
+
return _jsx(_Fragment, { children: parts });
|
|
33
|
+
}
|
|
34
|
+
function statText(text, citation) {
|
|
35
|
+
return new RegExp(`\\[${citation}\\]`).test(text) ? text : `${text} [${citation}]`;
|
|
36
|
+
}
|
|
37
|
+
function hostOf(url) {
|
|
38
|
+
try {
|
|
39
|
+
return new URL(url).host;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return url;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// The six regions, in order, from the payload alone. No freeform body.
|
|
46
|
+
export function WikiEntityArticle({ entity, entities, lastReviewed, options, }) {
|
|
47
|
+
const bySlug = new Map(entities.map((e) => [e.slug, e]));
|
|
48
|
+
const targets = entity.cross_links
|
|
49
|
+
.map((link) => bySlug.get(link.target_slug))
|
|
50
|
+
.filter((target) => target !== undefined);
|
|
51
|
+
const citationIndices = new Set(entity.citations.map((c) => c.n));
|
|
52
|
+
const citations = [...entity.citations].sort((a, b) => a.n - b.n);
|
|
53
|
+
const changelog = [...entity.changelog].sort((a, b) => (a.date < b.date ? 1 : -1));
|
|
54
|
+
const jsonLd = entityJsonLd(entity, { ...options, lastReviewed, crossLinkTargets: targets });
|
|
55
|
+
const base = entityPath({ slug: '' }, options).replace(/\/$/, '');
|
|
56
|
+
return (_jsx(IgniteFrame, { tokens: options.tokens, injectCss: options.injectCss, children: _jsxs("article", { className: "ignite-article ignite-wiki-entity", "data-entity-type": entity.entity_type, children: [_jsxs("nav", { className: "ignite-kicker", "aria-label": "Breadcrumb", children: [_jsx("a", { href: "/", children: "Home" }), _jsx("span", { "aria-hidden": "true", children: " / " }), _jsx("a", { href: base || '/', children: "Wiki" }), _jsx("span", { "aria-hidden": "true", children: " / " }), _jsx("a", { href: `${base}#${entity.entity_type}`, children: entityTypeLabel(entity.entity_type) })] }), _jsx("h1", { className: "ignite-title", children: entity.canonical_name }), _jsx("p", { className: "ignite-wiki-definition", id: "definition", children: definitionLede(entity) }), entity.sections.map((section, i) => (_jsxs("section", { className: "ignite-wiki-section", children: [_jsx("h2", { id: `s-${i + 1}`, children: section.heading }), section.paragraphs.map((paragraph, p) => (_jsx("p", { children: _jsx(CitedText, { text: paragraph, citations: citationIndices }) }, p))), section.stats.map((stat, s) => (_jsx("p", { className: "ignite-wiki-stat", children: _jsx(CitedText, { text: statText(stat.text, stat.citation), citations: citationIndices }) }, `stat-${s}`)))] }, i))), targets.length > 0 ? (_jsxs("section", { className: "ignite-wiki-related", "aria-labelledby": "related", children: [_jsx("h2", { id: "related", children: "Related" }), _jsx("ul", { children: targets.map((target) => (_jsxs("li", { children: [_jsx("a", { href: entityPath(target, options), children: target.canonical_name }), _jsxs("span", { className: "ignite-wiki-related-type", children: [" \u00B7 ", entityTypeLabel(target.entity_type)] })] }, target.slug))) })] })) : null, citations.length > 0 ? (_jsxs("section", { className: "ignite-wiki-citations", "aria-labelledby": "sources", children: [_jsx("h2", { id: "sources", children: "Sources" }), _jsx("ol", { children: citations.map((citation) => (_jsxs("li", { id: `cite-${citation.n}`, value: citation.n, children: [_jsx("a", { href: citation.url, children: citation.title }), _jsxs("span", { className: "ignite-wiki-cite-host", children: [" \u00B7 ", hostOf(citation.url)] }), _jsxs("span", { className: "ignite-wiki-cite-accessed", children: [" \u00B7 accessed ", citation.accessed] })] }, citation.n))) })] })) : null, _jsxs("footer", { className: "ignite-wiki-footer", children: [entity.author ? (_jsxs("p", { className: "ignite-wiki-author", children: ["By ", entity.author.url ? _jsx("a", { href: entity.author.url, children: entity.author.name }) : entity.author.name] })) : null, _jsxs("p", { className: "ignite-wiki-reviewed", children: ["Last reviewed ", _jsx("time", { dateTime: lastReviewed, children: lastReviewed })] }), changelog.length > 0 ? (_jsx("ul", { className: "ignite-wiki-changelog", children: changelog.map((entry, i) => (_jsxs("li", { children: [_jsx("time", { dateTime: entry.date, children: entry.date }), " \u2014 ", entry.note] }, i))) })) : null] }), _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: jsonLdText(jsonLd) } })] }) }));
|
|
57
|
+
}
|
|
58
|
+
export function groupByType(entities) {
|
|
59
|
+
return ENTITY_TYPES.map((type) => ({
|
|
60
|
+
type,
|
|
61
|
+
entities: entities
|
|
62
|
+
.filter((entity) => entity.entity_type === type)
|
|
63
|
+
.sort((a, b) => a.canonical_name.localeCompare(b.canonical_name)),
|
|
64
|
+
})).filter((group) => group.entities.length > 0);
|
|
65
|
+
}
|
|
66
|
+
// The index: one definition lede per entity, grouped by type. Renders nothing for an empty set.
|
|
67
|
+
export function WikiEntityIndex({ entities, options }) {
|
|
68
|
+
const groups = groupByType(entities);
|
|
69
|
+
if (groups.length === 0)
|
|
70
|
+
return null;
|
|
71
|
+
return (_jsxs(IgniteFrame, { tokens: options.tokens, injectCss: options.injectCss, children: [_jsx("h1", { className: "ignite-index-title", children: "Wiki" }), groups.map((group) => (_jsxs("section", { className: "ignite-wiki-group", id: group.type, children: [_jsx("h2", { children: entityTypeLabel(group.type) }), _jsx("ul", { className: "ignite-tree", children: group.entities.map((entity) => (_jsxs("li", { className: "ignite-wiki-entry", children: [_jsx("a", { className: "ignite-wiki-link ignite-wiki-title", href: entityPath(entity, options), children: entity.canonical_name }), _jsx("p", { className: "ignite-wiki-meta", children: definitionLede(entity) })] }, entity.slug))) })] }, group.type)))] }));
|
|
72
|
+
}
|
|
73
|
+
// Sidebar for a wiki layout: every entity grouped by type, canonical names as anchors.
|
|
74
|
+
export function WikiEntitySidebar({ entities, options }) {
|
|
75
|
+
const groups = groupByType(entities);
|
|
76
|
+
if (groups.length === 0)
|
|
77
|
+
return null;
|
|
78
|
+
return (_jsx("nav", { className: "ignite ignite-wiki-sidebar", "aria-label": "Wiki", children: groups.map((group) => (_jsxs("div", { children: [_jsx("p", { className: "ignite-wiki-meta", children: entityTypeLabel(group.type) }), _jsx("ul", { className: "ignite-tree", children: group.entities.map((entity) => (_jsx("li", { children: _jsx("a", { className: "ignite-wiki-link", href: entityPath(entity, options), children: entity.canonical_name }) }, entity.slug))) })] }, group.type))) }));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/wiki-content/render.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAqB,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAoC,MAAM,aAAa,CAAC;AAO9G,MAAM,MAAM,GAAG,YAAY,CAAC;AAE5B,2GAA2G;AAC3G,SAAS,WAAW,CAAC,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,QAAQ,EAA+F;IACtJ,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAA8B,CAAC;IACjE,OAAO,CACL,eAAK,SAAS,EAAC,QAAQ,EAAC,KAAK,EAAE,KAAK,aACjC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AsB,SAAS,EAAC,mBAAmB,aACjD,YAAG,SAAS,EAAC,oCAAoC,EAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,YAChF,MAAM,CAAC,cAAc,GACpB,EACJ,YAAG,SAAS,EAAC,kBAAkB,YAAE,cAAc,CAAC,MAAM,CAAC,GAAK,KAJrD,MAAM,CAAC,IAAI,CAKf,CACN,CAAC,GACC,KAXO,KAAK,CAAC,IAAI,CAYd,CACX,CAAC,IACU,CACf,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAA0D;IAC7G,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,CACL,cAAK,SAAS,EAAC,4BAA4B,gBAAY,MAAM,YAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,0BACE,YAAG,SAAS,EAAC,kBAAkB,YAAE,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,GAAK,EACjE,aAAI,SAAS,EAAC,aAAa,YACxB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC9B,uBACE,YAAG,SAAS,EAAC,kBAAkB,EAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,YAC9D,MAAM,CAAC,cAAc,GACpB,IAHG,MAAM,CAAC,IAAI,CAIf,CACN,CAAC,GACC,KAVG,KAAK,CAAC,IAAI,CAWd,CACP,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ENTITY_TYPES: readonly ["company", "product", "person", "concept", "location", "offering"];
|
|
3
|
+
export type EntityType = (typeof ENTITY_TYPES)[number];
|
|
4
|
+
export declare const wikiEntitySchema: z.ZodObject<{
|
|
5
|
+
entity_type: z.ZodEnum<{
|
|
6
|
+
company: "company";
|
|
7
|
+
product: "product";
|
|
8
|
+
person: "person";
|
|
9
|
+
concept: "concept";
|
|
10
|
+
location: "location";
|
|
11
|
+
offering: "offering";
|
|
12
|
+
}>;
|
|
13
|
+
canonical_name: z.ZodString;
|
|
14
|
+
slug: z.ZodString;
|
|
15
|
+
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
16
|
+
definition: z.ZodObject<{
|
|
17
|
+
lede: z.ZodOptional<z.ZodString>;
|
|
18
|
+
category: z.ZodOptional<z.ZodString>;
|
|
19
|
+
founded: z.ZodOptional<z.ZodString>;
|
|
20
|
+
function: z.ZodOptional<z.ZodString>;
|
|
21
|
+
differentiator: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
sections: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
24
|
+
heading: z.ZodString;
|
|
25
|
+
paragraphs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
26
|
+
stats: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
27
|
+
text: z.ZodString;
|
|
28
|
+
citation: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>>>;
|
|
30
|
+
}, z.core.$strip>>>;
|
|
31
|
+
cross_links: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
32
|
+
target_slug: z.ZodString;
|
|
33
|
+
anchor: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
citations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
36
|
+
n: z.ZodNumber;
|
|
37
|
+
url: z.ZodString;
|
|
38
|
+
title: z.ZodString;
|
|
39
|
+
accessed: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>>;
|
|
41
|
+
author: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
url: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
changelog: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
46
|
+
date: z.ZodString;
|
|
47
|
+
note: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
49
|
+
same_as: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
50
|
+
imported_from: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
source: z.ZodLiteral<"ignite">;
|
|
52
|
+
slug: z.ZodString;
|
|
53
|
+
dateModified: z.ZodString;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type WikiEntity = z.infer<typeof wikiEntitySchema>;
|
|
57
|
+
export type WikiEntityInput = z.input<typeof wikiEntitySchema>;
|
|
58
|
+
export type WikiIssue = {
|
|
59
|
+
file: string;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
export declare function parseWikiEntity(file: string, raw: unknown): {
|
|
63
|
+
entity: WikiEntity | null;
|
|
64
|
+
issues: WikiIssue[];
|
|
65
|
+
};
|
|
66
|
+
export declare function validateWikiSet(entries: Array<{
|
|
67
|
+
file: string;
|
|
68
|
+
entity: WikiEntity;
|
|
69
|
+
}>): WikiIssue[];
|
|
70
|
+
export declare function fileSlug(file: string): string | null;
|
|
71
|
+
export declare function entityTypeLabel(type: EntityType): string;
|
|
72
|
+
export declare function schemaOrgType(type: EntityType): string;
|
|
73
|
+
export declare function definitionLede(entity: WikiEntity): string;
|