@namewta/skills-hub 0.1.46 → 0.1.48
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 +1 -1
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/package.json +1 -1
- package/scripts/persistence/home.md +1 -0
- package/skills/dev/dev-archive/references/change-closure.md +4 -0
- package/skills/home/home-project-changelog/SKILL.md +4 -3
- package/skills/home/home-project-changelog/assets/project-changelog.md +20 -10
- package/skills/home/home-project-changelog/references/git-ranges.md +19 -5
- package/skills/home/home-project-changelog/references/tools.md +13 -5
- package/skills/home/home-project-changelog/references/workflow.md +11 -2
- package/skills/home/home-project-changelog/references/writing.md +15 -7
- package/skills/home/home-project-changelog/scripts/changelog.mjs +5 -2
- package/skills/home/home-project-changelog/scripts/contract.mjs +6 -2
- package/skills/home/home-project-changelog/scripts/git.mjs +6 -0
- package/skills/home/home-project-changelog/scripts/storage.mjs +8 -2
- package/skills/home/home-project-changelog/scripts/summary.mjs +13 -12
- package/skills/home/home-setup/SKILL.md +1 -1
- package/skills/home/home-setup/references/registry.md +4 -0
- package/skills/home/home-setup/scripts/git.mjs +2 -0
- package/skills/home/home-website/SKILL.md +20 -0
- package/skills/home/home-website/assets/website/gitignore.tmpl +4 -0
- package/skills/home/home-website/assets/website/package-lock.json +2376 -0
- package/skills/home/home-website/assets/website/package.json +11 -0
- package/skills/home/home-website/assets/website/scripts/artifact.mjs +84 -0
- package/skills/home/home-website/assets/website/scripts/inputs.mjs +209 -0
- package/skills/home/home-website/assets/website/scripts/preview.mjs +50 -0
- package/skills/home/home-website/assets/website/scripts/render.mjs +92 -0
- package/skills/home/home-website/assets/website/scripts/site.mjs +173 -0
- package/skills/home/home-website/assets/website/site/.vitepress/theme/index.js +3 -0
- package/skills/home/home-website/assets/website/site/public/home-assets/app.js +292 -0
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +337 -0
- package/skills/home/home-website/assets/website/site/public/home-assets/start.js +7 -0
- package/skills/home/home-website/assets/website/site/templates/layout.mjs +81 -0
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +53 -0
- package/skills/home/home-website/assets/website/site/templates/model.mjs +66 -0
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +93 -0
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +114 -0
- package/skills/home/home-website/assets/website/site.config.json +6 -0
- package/skills/home/home-website/references/website.md +85 -0
- package/skills/home/home-website/scripts/init.mjs +57 -0
- package/skills/home/home-workflow/SKILL.md +1 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { categories, periodsByEnd } from './model.mjs';
|
|
2
|
+
|
|
3
|
+
export const escapeHtml = value => String(value).replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
4
|
+
export const shortDate = date => date.slice(5).replace('-', '.');
|
|
5
|
+
export const projectPath = project => 'projects/' + project.id + '/';
|
|
6
|
+
export const logPath = (project, period) => projectPath(project) + 'changelog/' + (period ? '#range-' + period.key : '');
|
|
7
|
+
export const availableGroups = (projects) => [...new Set(projects.flatMap(project => project.groups))];
|
|
8
|
+
export const arrow = '<span aria-hidden="true" class="arrow">→</span>';
|
|
9
|
+
export const external = '<span aria-hidden="true" class="external-arrow">↗</span>';
|
|
10
|
+
|
|
11
|
+
export function symbol(name) {
|
|
12
|
+
return `<span class="symbol sym-${name}" aria-hidden="true"><i></i></span>`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function mark(project, small = false) {
|
|
16
|
+
return `<span aria-hidden="true" class="project-mark tone-${project.color} ${small ? 'small' : ''}"><span class="motif motif-${project.mark}"><i></i><b></b></span></span>`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function projectChip(project) {
|
|
20
|
+
return `<span class="project-chip tone-${project.color}"><i></i>${escapeHtml(project.name)}</span>`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function header(root, section, siteTitle) {
|
|
24
|
+
const nav = [['home', '总览', ''], ['projects', '项目目录', 'projects/'], ['changelog', '变更时间线', 'changelog/']];
|
|
25
|
+
return `<header class="masthead"><div class="wrap mast-inner">
|
|
26
|
+
<a class="brand" href="${root}" aria-label="${escapeHtml(siteTitle)} 总览"><span class="brand-stamp" aria-hidden="true"><i></i><b></b></span><span>${escapeHtml(siteTitle)}</span></a>
|
|
27
|
+
<nav aria-label="主导航" class="main-nav">${nav.map(([id,label,path]) => `<a href="${root}${path}"${section === id ? ' aria-current="page"' : ''}>${label}</a>`).join('')}</nav>
|
|
28
|
+
<div class="mast-tools"><button type="button" class="search-open enhanced-only" data-open-search aria-label="搜索全站">${symbol('search')}<span>搜索</span><kbd>Ctrl K</kbd></button>
|
|
29
|
+
<button type="button" class="icon-button theme-button enhanced-only" data-theme-toggle aria-label="切换深色模式" title="切换深色模式">${symbol('moon')}${symbol('sun')}</button></div>
|
|
30
|
+
</div></header>`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function searchDialog() {
|
|
34
|
+
return `<dialog closedby="any" id="search-dialog" aria-labelledby="search-title"><h2 id="search-title" class="sr">搜索项目与变更</h2>
|
|
35
|
+
<div class="search-dialog-field">${symbol('search')}<input id="global-query" type="search" placeholder="搜索项目、仓库 ID 或变更内容" aria-label="搜索项目与变更" autocomplete="off">
|
|
36
|
+
<button class="close-search" type="button" data-close-search aria-label="关闭搜索">Esc</button></div>
|
|
37
|
+
<p class="result-summary" aria-live="polite" id="search-summary"></p><div id="search-results"></div>
|
|
38
|
+
<div class="search-help"><span><kbd>↑</kbd> <kbd>↓</kbd> 选择结果</span><span><kbd>Enter</kbd> 打开</span></div>
|
|
39
|
+
</dialog>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function crumbs(root, parts) {
|
|
43
|
+
return `<nav class="crumbs" aria-label="当前位置"><a href="${root}">总览</a>${parts.map(([label, url]) => `<span aria-hidden="true">/</span>${url ? `<a href="${root}${url}">${escapeHtml(label)}</a>` : `<span aria-current="page">${escapeHtml(label)}</span>`}`).join('')}</nav>`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function frame({base, title, section, content}) {
|
|
47
|
+
const html = `<div class="home-site" data-root="${base}"><a class="skip-link" href="#main">跳到正文</a>
|
|
48
|
+
${header(base, section, title)}
|
|
49
|
+
<main class="wrap main-content" id="main" tabindex="-1">${content}</main>
|
|
50
|
+
<footer class="site-footer"><div class="wrap footer-inner"><a class="footer-brand" href="${base}">${escapeHtml(title)}</a></div></footer>
|
|
51
|
+
${searchDialog()}</div>`;
|
|
52
|
+
return html.replace(/<a\b([^>]+)>/gu, (tag, attrs) => attrs.includes(' target=') ? tag : '<a target="_self"'+attrs+'>');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function projectCard(root, project) {
|
|
56
|
+
const recent = periodsByEnd(project)[0];
|
|
57
|
+
return `<a class="project-card tone-${project.color}" data-project="${project.id}" data-groups="${escapeHtml(JSON.stringify(project.groups))}"
|
|
58
|
+
href="${root}${projectPath(project)}" aria-label="查看 ${escapeHtml(project.name)}(${project.id})">
|
|
59
|
+
<div class="card-top">${mark(project)}${project.groups.length ? `<span class="group-tag">${escapeHtml(project.groups.join(" · "))}</span>` : ''}</div>
|
|
60
|
+
<h3>${escapeHtml(project.name)}</h3><span class="repo-id">${project.id}</span>
|
|
61
|
+
<p>${escapeHtml(project.purpose)}</p><div class="card-foot"><span>${recent ? `${symbol('clock')} <time datetime="${recent.to}">${recent.to.replaceAll('-', '.')}</time>` : `${symbol('clock')} 尚无已记录变更`}</span>${arrow}</div>
|
|
62
|
+
</a>`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function statStrip(stats, commitLabel = '提交数') {
|
|
66
|
+
const metrics = [
|
|
67
|
+
['changes','变更总数',stats.changes], ['commits',commitLabel,stats.commits],
|
|
68
|
+
...categories.map(category => [category,category === '功能' ? '功能(含新增能力)' : category,stats.byCategory?.[category]]),
|
|
69
|
+
['added','新增',stats.added],
|
|
70
|
+
];
|
|
71
|
+
return `<dl class="stat-strip">${metrics.map(([key,label,count]) => `<div data-stat="${key}"><dt>${label}</dt><dd>${count == null ? (key === 'added' ? '未单列' : '未核实') : count.toLocaleString('zh-CN')}</dd></div>`).join('')}</dl>`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function statSummary(id, title, stats, scope) {
|
|
75
|
+
return `<section class="stat-summary" id="${id}" aria-labelledby="${id}-title"><h2 id="${id}-title">${title}</h2><p>${scope} 提交数为区间提交数合计。</p>${statStrip(stats)}</section>`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function intervalCount(period) {
|
|
79
|
+
if (period.baseline) return '零项基线';
|
|
80
|
+
return `${period.items.length} 条变更`;
|
|
81
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { categories, distinctRangeLabel, itemId } from './model.mjs';
|
|
2
|
+
import { crumbs, escapeHtml as esc, logPath, projectPath, statStrip, statSummary, symbol } from './layout.mjs';
|
|
3
|
+
|
|
4
|
+
const date = value => `<time datetime="${value}">${value.replaceAll('-','.')}</time>`;
|
|
5
|
+
export const impactLabels = markers => (markers ?? []).map(name=>`<span class="impact-tag">${esc(name)}</span>`).join('');
|
|
6
|
+
|
|
7
|
+
function row(root, project, period, index) {
|
|
8
|
+
const item = period.items[index];
|
|
9
|
+
const [category,text,markers] = item ?? ['区间说明', period.note ||
|
|
10
|
+
(period.baseline ? '建立记录基线,历史变更未回填' : '有 '+period.commits+' 次提交,无单列变更')];
|
|
11
|
+
const target = item ? '#'+itemId(period,index) : '#range-'+period.key;
|
|
12
|
+
return `<li class="ledger-entry" data-kind="${category}"${item ? ' data-entry' : ''}>
|
|
13
|
+
<span class="type-label">${category}</span><a class="change-cell" href="${root}${logPath(project)}${target}">${impactLabels(markers)}${esc(text)}</a>
|
|
14
|
+
</li>`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function segment(root, project, period) {
|
|
18
|
+
const rows = period.items.length ? period.items.map((_,index) => row(root,project,period,index)) : [row(root,project,period,-1)];
|
|
19
|
+
const remaining = rows.slice(2);
|
|
20
|
+
const qualifier = period.baseline ? '零项基线' : period.from ? '' : '仅记录截止日';
|
|
21
|
+
return `<section class="ledger-period">
|
|
22
|
+
<h4><a href="${root}${logPath(project,period)}">${esc(distinctRangeLabel(project,period))}</a>${qualifier ? ` <span>${qualifier}</span>` : ''}</h4>
|
|
23
|
+
<ul class="ledger-lines" role="list">${rows.slice(0,2).join('')}</ul>
|
|
24
|
+
${remaining.length ? `<details class="more-entries"><summary><span class="show-more">展开其余 <span data-more-count>${remaining.length}</span> 条</span><span class="show-less">收起更多变更</span></summary><ul class="ledger-lines" role="list">${remaining.join('')}</ul></details>` : ''}
|
|
25
|
+
</section>`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function windowSection(root, window) {
|
|
29
|
+
const {from,to,groups,rangeCount,stats} = window;
|
|
30
|
+
const title = from ? date(from)+' <span class="date-divider">—</span> '+date(to) : '截至 '+date(to);
|
|
31
|
+
return `<section class="ledger-window" id="window-${to}" aria-labelledby="dates-${to}">
|
|
32
|
+
<header class="window-head"><h2 id="dates-${to}">${title}</h2><span class="window-count">${groups.length} 个项目 · ${rangeCount} 段 · ${stats.changes} 条变更</span></header>
|
|
33
|
+
<details class="window-statistics"><summary>本窗全部记录统计</summary>${statStrip(stats)}</details>
|
|
34
|
+
${groups.map(({project,periods}) => `<section class="ledger-group tone-${project.color}" data-ledger-repo="${project.id}">
|
|
35
|
+
<h3><a class="ledger-project" href="${root}${projectPath(project)}"><i></i>${esc(project.name)}</a>${project.id !== project.name ? ` <span class="repo-id">${project.id}</span>` : ''}</h3>
|
|
36
|
+
${periods.map(period => segment(root,project,period)).join('')}
|
|
37
|
+
</section>`).join('')}
|
|
38
|
+
</section>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function changelog(root, projects, windows, stats) {
|
|
42
|
+
const ranges = windows.reduce((sum,window) => sum + window.rangeCount,0);
|
|
43
|
+
const count = windows.length+' 个窗口 · '+projects.length+' 个项目 · '+ranges+' 段 · '+stats.changes+' 条变更';
|
|
44
|
+
return `${crumbs(root,[['变更时间线']])}<header class="ledger-intro"><h1>变更时间线</h1><p>按日志截止日划分观测窗口。每个窗口内按项目聚合,条目链接到原文。</p></header>
|
|
45
|
+
${statSummary('site-statistics','全部公开变更',stats,'汇总整个站点,筛选命中另行计数。')}
|
|
46
|
+
<section class="ledger" aria-label="跨仓库变更"><div class="ledger-tools"><p class="ledger-count" id="timeline-count" aria-live="polite">${count}</p>
|
|
47
|
+
<search class="ledger-filters enhanced-only" aria-label="筛选时间线"><label class="ledger-search">${symbol('search')}<input id="timeline-query" type="search" aria-label="筛选变更正文" placeholder="筛选变更正文" autocomplete="off"></label>
|
|
48
|
+
<label><span class="sr">筛选项目</span><select id="timeline-project"><option value="">全部项目</option>${projects.map(p=>`<option value="${p.id}">${esc(p.id)}</option>`).join('')}</select></label>
|
|
49
|
+
<label><span class="sr">筛选类别</span><select id="timeline-category"><option value="">全部类别</option>${[...categories,'区间说明'].map(c=>`<option>${c}</option>`).join('')}</select></label>
|
|
50
|
+
<button type="button" class="ledger-toggle" id="expand-ledger" aria-pressed="false">展开全部</button></search></div>
|
|
51
|
+
${windows.map(window => windowSection(root,window)).join('')}
|
|
52
|
+
<div id="timeline-empty" class="empty-panel"${windows.length ? ' hidden' : ''}><h2>没有匹配的变更记录</h2><p>${windows.length ? '可更换项目、类别或关键词。' : '暂无已保存且可公开的日志区间。'}</p><button type="button" id="reset-timeline" class="secondary-button enhanced-only">清除筛选</button></div></section>`;
|
|
53
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const categories = ['功能', '修复', '重构', '优化', '维护'];
|
|
2
|
+
|
|
3
|
+
export function timeline(projects) {
|
|
4
|
+
return projects.flatMap(project => project.periods.map((period, order) => ({project, period, order})))
|
|
5
|
+
.sort((a, b) => b.period.to.localeCompare(a.period.to) || a.project.id.localeCompare(b.project.id, 'en') || a.order - b.order);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function periodsByEnd(project) {
|
|
9
|
+
return [...project.periods].sort((a, b) => b.to.localeCompare(a.to));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function statistics(periods) {
|
|
13
|
+
function sum(value) {
|
|
14
|
+
let total = 0;
|
|
15
|
+
for (const period of periods) {
|
|
16
|
+
const count = value(period);
|
|
17
|
+
if (!Number.isSafeInteger(count) || !Number.isSafeInteger(total + count)) return null;
|
|
18
|
+
total += count;
|
|
19
|
+
}
|
|
20
|
+
return total;
|
|
21
|
+
}
|
|
22
|
+
const changes = sum(period => period.verified === false ? null : period.items.length);
|
|
23
|
+
return {
|
|
24
|
+
changes,
|
|
25
|
+
commits: sum(period => period.commits),
|
|
26
|
+
byCategory: changes === null ? null : Object.fromEntries(categories.map(category => [
|
|
27
|
+
category, sum(period => period.items.filter(([type]) => type === category).length),
|
|
28
|
+
])),
|
|
29
|
+
added: sum(period => period.added),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function observationWindows(projects) {
|
|
34
|
+
const byEnd = new Map();
|
|
35
|
+
for (const {project, period} of timeline(projects)) {
|
|
36
|
+
if (!byEnd.has(period.to)) byEnd.set(period.to, new Map());
|
|
37
|
+
const groups = byEnd.get(period.to);
|
|
38
|
+
if (!groups.has(project.id)) groups.set(project.id, {project, periods:[]});
|
|
39
|
+
groups.get(project.id).periods.push(period);
|
|
40
|
+
}
|
|
41
|
+
const ends = [...byEnd.keys()];
|
|
42
|
+
return ends.map((to, index) => {
|
|
43
|
+
const previous = ends[index + 1];
|
|
44
|
+
const from = previous ? new Date(Date.parse(previous) + 86_400_000).toISOString().slice(0, 10) : null;
|
|
45
|
+
const groups = [...byEnd.get(to).values()];
|
|
46
|
+
const periods = groups.flatMap(group => group.periods);
|
|
47
|
+
return {from, to, groups, rangeCount:periods.length, stats:statistics(periods)};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function periodTitle(period) {
|
|
52
|
+
return period.items[0]?.[1] ?? (period.baseline ? '建立日志记录基线' : '完成本次区间核对');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function rangeLabel(period) {
|
|
56
|
+
return period.from ? period.from + ' 至 ' + period.to : period.to;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function distinctRangeLabel(project, period) {
|
|
60
|
+
const repeated = project.periods.some(p => p !== period && p.from === period.from && p.to === period.to);
|
|
61
|
+
return rangeLabel(period) + (repeated ? ' · 第 ' + period.key.split('-').at(-1) + ' 段' : '');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function itemId(period, index) {
|
|
65
|
+
return 'entry-' + period.key + '-' + (index + 1);
|
|
66
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { categories, distinctRangeLabel, itemId, periodsByEnd, rangeLabel, periodTitle, statistics, timeline } from './model.mjs';
|
|
2
|
+
import { arrow, availableGroups, crumbs, escapeHtml as esc, external, intervalCount, logPath, mark, projectCard, projectChip, projectPath, shortDate, statStrip, statSummary, symbol } from './layout.mjs';
|
|
3
|
+
|
|
4
|
+
import { impactLabels } from './ledger.mjs';
|
|
5
|
+
const endDate = date => `<time datetime="${date}">${date.replaceAll('-', '.')}</time>`;
|
|
6
|
+
const day = 86400000;
|
|
7
|
+
const chartDay = (asOf, offset) => new Date(Date.parse(asOf) + offset * day).toISOString().slice(0,10);
|
|
8
|
+
|
|
9
|
+
function chartLane(root, project, asOf) {
|
|
10
|
+
const periods = project.periods.filter(period => period.to >= chartDay(asOf, -13) && period.to <= asOf);
|
|
11
|
+
if (!periods.length) return '';
|
|
12
|
+
const byDate = new Map();
|
|
13
|
+
for (const period of periods) {
|
|
14
|
+
if (!byDate.has(period.to)) byDate.set(period.to, []);
|
|
15
|
+
byDate.get(period.to).push(period);
|
|
16
|
+
}
|
|
17
|
+
const x = date => 3 + 94 * Math.min(13, Math.max(0, (Date.parse(date) - Date.parse(chartDay(asOf, -13))) / day)) / 13;
|
|
18
|
+
const bars = periods.filter(period => period.from && period.from !== period.to).map(period => `<i class="range-bar" style="--left:${x(period.from).toFixed(2)}%;--width:${(x(period.to) - x(period.from)).toFixed(2)}%"></i>`).join('');
|
|
19
|
+
const dots = [...byDate].map(([date, same]) => {
|
|
20
|
+
const label = `${project.id},${date},${same.length} 个区间。${periodTitle(same[0])}`;
|
|
21
|
+
return `<a class="plot-point${same[0].baseline ? ' baseline-point' : ''}${same.length > 1 ? ' multiple' : ''}" href="${root}${logPath(project, same[0])}" style="--x:${x(date).toFixed(2)}%" aria-label="${esc(label)}" title="${esc(label)}"><i></i></a>`;
|
|
22
|
+
}).join('');
|
|
23
|
+
return `<div class="chart-lane tone-${project.color}"><a href="${root}${projectPath(project)}" class="lane-name">${project.id}</a><div class="lane-track">${bars}${dots}</div></div>`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function activityChart(root, projects, asOf) {
|
|
27
|
+
if (!asOf) return '';
|
|
28
|
+
const dayLabel = offset => shortDate(chartDay(asOf, offset));
|
|
29
|
+
return `<figure class="activity-figure"><figcaption><span class="chart-label">${symbol('activity')}仓库活动</span><span class="chart-window">${dayLabel(-13)} — ${dayLabel(0)}</span></figcaption>
|
|
30
|
+
<div class="lane-list">${projects.map(project => chartLane(root, project, asOf)).join('')}</div>
|
|
31
|
+
<div class="chart-axis"><span>${dayLabel(-13)}</span><span>${dayLabel(-7)}</span><span>${dayLabel(0)}</span></div>
|
|
32
|
+
<div class="chart-key"><span><i class="key-line"></i>记录区间</span><span><i class="key-dot"></i>区间结束</span><span><i class="key-multi"></i>同日多段</span><span><i class="key-ring"></i>基线</span></div></figure>`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sectionHeading(title, url, label) {
|
|
36
|
+
return `<div class="section-heading"><h2>${title}</h2><a class="text-link" href="${url}">${label} ${arrow}</a></div>`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function overview(root, projects, windows, stats) {
|
|
40
|
+
const records = timeline(projects);
|
|
41
|
+
const asOf = records[0]?.period.to;
|
|
42
|
+
const recent = records.slice(0, 5);
|
|
43
|
+
return `<section class="overview-hero" aria-labelledby="hero-title"><div class="hero-copy">
|
|
44
|
+
<div class="hero-date"><i></i>${asOf ? '截至 '+endDate(asOf) : '项目与日志'}</div><h1 id="hero-title">项目总览</h1><p>我维护的项目、公开文档与各仓库的 Git 变更记录。</p>
|
|
45
|
+
<dl class="hero-stats"><div><dt>公开项目</dt><dd>${projects.length}</dd></div><div><dt>观测窗口</dt><dd>${windows.length}</dd></div><div><dt>记录区间</dt><dd>${records.length}</dd></div></dl>
|
|
46
|
+
</div>${activityChart(root, projects, asOf)}</section>
|
|
47
|
+
${statSummary('site-statistics','全部公开变更',stats,'汇总各项目所有公开区间。')}
|
|
48
|
+
<div class="overview-columns"><section class="home-catalog" aria-label="项目目录预览">
|
|
49
|
+
${sectionHeading('项目目录', root + 'projects/', '全部项目')}
|
|
50
|
+
<div class="project-grid home-grid">${projects.length ? projects.slice(0,4).map(p => projectCard(root,p)).join('') : '<p>暂无公开项目</p>'}</div></section>
|
|
51
|
+
<section class="recent-panel" aria-label="最近变更"><div class="recent-heading"><span class="section-accent"></span><h2>最近变更</h2></div>
|
|
52
|
+
<ol class="recent-list">${recent.map(({project,period}) => `<li class="tone-${project.color}"><a href="${root}${logPath(project,period)}"><div class="recent-meta"><time datetime="${period.to}">${shortDate(period.to)}</time>${projectChip(project)}</div><strong>${esc(periodTitle(period))}</strong><span class="recent-sub">${esc(rangeLabel(period))} · ${intervalCount(period)}</span></a></li>`).join('')}</ol>
|
|
53
|
+
<a class="text-link recent-all" href="${root}changelog/">完整时间线 ${arrow}</a></section></div>`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function catalog(root, projects) {
|
|
57
|
+
return `${crumbs(root,[['项目目录']])}<header class="page-head"><h1>项目目录</h1><p>共 ${projects.length} 个公开项目。选择项目查看倒序日志区间。</p></header>
|
|
58
|
+
<section aria-label="项目筛选"><div class="filter-bar enhanced-only"><div class="filter-pills" aria-label="选择项目分组">${['全部',...availableGroups(projects)].map((g,i) => `<button type="button" data-group-filter="${i ? esc(g) : ''}" aria-pressed="${i === 0}">${esc(g)}</button>`).join('')}</div>
|
|
59
|
+
<label class="field search-field">${symbol('search')}<input id="catalog-query" type="search" aria-label="筛选项目" placeholder="名称、ID 或简介" autocomplete="off"></label></div>
|
|
60
|
+
<p id="catalog-count" class="list-count" aria-live="polite">显示 ${projects.length} 个项目</p><div id="project-grid" class="project-grid catalog-grid">${projects.map(project => projectCard(root,project)).join('')}</div>
|
|
61
|
+
<div class="empty-panel" id="catalog-empty"${projects.length ? ' hidden' : ''}><h2>没有匹配的项目</h2><p>${projects.length ? '换个关键词,或清除当前筛选。' : '暂无已保存且可公开的项目日志。'}</p><button type="button" class="secondary-button enhanced-only" id="reset-catalog">清除筛选</button></div></section>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function timelineRow(root, project, period) {
|
|
65
|
+
return `<a class="timeline-row" data-repo="${project.id}" href="${root}${logPath(project,period)}">${mark(project,true)}<div class="row-copy"><h3>${esc(distinctRangeLabel(project,period))}</h3><span class="range-caption">${esc(periodTitle(period))}</span></div><span class="row-count">${intervalCount(period)}</span>${arrow}</a>`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function resourceButtons(project) {
|
|
69
|
+
return [[project.docsUrl, '公开文档'], [project.repoUrl, '源代码']].filter(([url]) => url).map(([url, label]) =>
|
|
70
|
+
`<a class="secondary-button" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${label} ${external}</a>`).join('');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function detail(root, project, stats) {
|
|
74
|
+
const periods = periodsByEnd(project);
|
|
75
|
+
return `${crumbs(root,[['项目目录','projects/'],[project.name]])}<header class="detail-head tone-${project.color}"><div class="detail-intro">${mark(project)}<div>${project.groups.length ? `<span class="detail-group">${esc(project.groups.join(" · "))}</span>` : ''}<h1>${esc(project.name)}</h1><span class="repo-id">${project.id}</span></div></div>
|
|
76
|
+
<p>${esc(project.purpose)}</p><div class="button-row"><a class="primary-button" href="${root}${logPath(project)}">阅读完整日志 ${arrow}</a>${resourceButtons(project)}</div></header>
|
|
77
|
+
${statSummary('project-statistics','本项目统计',stats,`汇总本项目 ${periods.length} 个公开区间。`)}
|
|
78
|
+
<section class="detail-recent"><div class="section-heading"><h2>记录区间</h2><a class="text-link" href="${root}changelog/?repo=${project.id}">在时间线中查看 ${arrow}</a></div>
|
|
79
|
+
${periods.map(period => timelineRow(root,project,period)).join('')}</section>`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function logPeriod(project, period) {
|
|
83
|
+
return `<article id="range-${period.key}" class="log-period tone-${project.color}"><div class="period-heading">${projectChip(project)}<span>${period.baseline ? '基线' : 'Git 区间'}</span></div><h2>${esc(distinctRangeLabel(project,period))}</h2><p class="period-title">${esc(periodTitle(period))}</p>
|
|
84
|
+
${period.note ? `<p class="period-note">${esc(period.note)}</p>` : ''}${statStrip(statistics([period]),'本次提交')}
|
|
85
|
+
${categories.map(category => {const items=period.items.map(([c,text,markers],i)=>({c,text,markers,i})).filter(item=>item.c===category);return items.length ? `<section class="category-block"><h3>${category}</h3><ul>${items.map(({text,markers,i})=>`<li class="log-entry" id="${itemId(period,i)}">${impactLabels(markers)}${esc(text)}</li>`).join('')}</ul></section>` : '';}).join('')}</article>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function repositoryLog(root, project, stats) {
|
|
89
|
+
return `${crumbs(root,[['项目目录','projects/'],[project.name,projectPath(project)],['变更日志']])}<header class="page-head"><span class="detail-group">${project.id}</span><h1>${esc(project.name)} 变更日志</h1><p>${project.periods.length} 个记录区间,按项目日志原序展示。</p></header>
|
|
90
|
+
${statSummary('project-statistics','本项目统计',stats,`汇总本项目 ${project.periods.length} 个公开区间。`)}
|
|
91
|
+
<div class="log-layout"><nav class="log-index" aria-label="本仓区间"><h2>本仓区间</h2>${project.periods.map(p=>`<a href="#range-${p.key}"><time>${p.to}</time><span>${esc(periodTitle(p))}</span></a>`).join('')}${project.legacy ? '<a href="#legacy">历史补记</a>' : ''}</nav>
|
|
92
|
+
<div class="log-content">${project.periods.map(p=>logPeriod(project,p)).join('')}${project.legacy ? `<article id="legacy" class="log-period"><h2>历史补记</h2><p class="legacy-text">${esc(project.legacy)}</p><small>历史原文保留在此页。</small></article>` : ''}</div></div>`;
|
|
93
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { categories, itemId, statistics } from './model.mjs';
|
|
2
|
+
|
|
3
|
+
const tags = ['破坏性', '安全', '弃用', '移除', '回退'];
|
|
4
|
+
const columns = ['变更总数', ...categories, '本次提交'];
|
|
5
|
+
const dateTitle = /^## (\d{4}-\d{2}-\d{2})(?: 至 (\d{4}-\d{2}-\d{2}))?$/u;
|
|
6
|
+
const splitCells = line => line.trim().slice(1,-1).split('|').map(word => word.trim());
|
|
7
|
+
export function validDay(day) {
|
|
8
|
+
if (typeof day !== 'string' || !/^\d{4}-\d{2}-\d{2}$/u.test(day)) return false;
|
|
9
|
+
const ms = Date.parse(day + 'T00:00:00Z');
|
|
10
|
+
return Number.isFinite(ms) && new Date(ms).toISOString().slice(0,10) === day;
|
|
11
|
+
}
|
|
12
|
+
function tableAt(lines, i) {
|
|
13
|
+
if (!lines[i]?.startsWith('|') || !lines[i+1]?.startsWith('|') || !lines[i+2]?.startsWith('|')) return null;
|
|
14
|
+
const headers = splitCells(lines[i]), values = splitCells(lines[i+2]);
|
|
15
|
+
const expected = headers.includes('新增') ? [...columns, '新增'] : columns;
|
|
16
|
+
const separators = splitCells(lines[i+1]);
|
|
17
|
+
if (headers.length !== expected.length || headers.length !== values.length || !expected.every(key=>headers.includes(key))) return null;
|
|
18
|
+
if (separators.length !== headers.length || !separators.every(cell=>/^:?-{3,}:?$/u.test(cell))) return null;
|
|
19
|
+
if (!values.every(val=>/^(?:\d+|\d{1,3}(?:,\d{3})+)$/u.test(val) && Number.isSafeInteger(Number(val.replaceAll(',',''))))) return null;
|
|
20
|
+
return Object.fromEntries(headers.map((key,index)=>[key,Number(values[index].replaceAll(',',''))]));
|
|
21
|
+
}
|
|
22
|
+
function entry(category, body) {
|
|
23
|
+
const markers = [];
|
|
24
|
+
let text = body;
|
|
25
|
+
while (true) {
|
|
26
|
+
const match = /^\*\*\[([^\]]+)\]\*\*\s+/u.exec(text);
|
|
27
|
+
if (!match || !tags.includes(match[1])) break;
|
|
28
|
+
markers.push(match[1]);
|
|
29
|
+
text = text.slice(match[0].length);
|
|
30
|
+
}
|
|
31
|
+
return [category,text.replace(/\\([\[\]])/gu,'$1'),markers];
|
|
32
|
+
}
|
|
33
|
+
function parsePeriod(title, lines) {
|
|
34
|
+
let group = '', totals = null, originalTable = '', fence = '';
|
|
35
|
+
const items = [], notes = [];
|
|
36
|
+
for (let i=0; i<lines.length; i++) {
|
|
37
|
+
const line = lines[i].trim();
|
|
38
|
+
if (!line) continue;
|
|
39
|
+
const delimiter = /^\s*(\x60{3,}|~{3,})/u.exec(line);
|
|
40
|
+
if (delimiter || fence) {
|
|
41
|
+
if (delimiter && !fence) fence=delimiter[1];
|
|
42
|
+
else if (delimiter && delimiter[1][0]===fence[0] && delimiter[1].length>=fence.length) fence='';
|
|
43
|
+
notes.push(line);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const table = tableAt(lines,i);
|
|
47
|
+
if (table) { totals=table; originalTable=lines.slice(i,i+3).join('\n'); i+=2; group=''; continue; }
|
|
48
|
+
if (line.startsWith('### ')) {
|
|
49
|
+
group = line.slice(4);
|
|
50
|
+
if (!categories.includes(group)) notes.push(line);
|
|
51
|
+
} else if (categories.includes(group) && line.startsWith('- ')) {
|
|
52
|
+
items.push(entry(group,line.slice(2)));
|
|
53
|
+
} else notes.push(line);
|
|
54
|
+
}
|
|
55
|
+
const from = title[2] ? title[1] : null, to = title[2] ?? title[1];
|
|
56
|
+
const countsOK = totals && totals['变更总数'] === items.length &&
|
|
57
|
+
(totals['新增'] === undefined || totals['新增'] <= totals['功能']) &&
|
|
58
|
+
categories.every(category=>totals[category] === items.filter(([name])=>name===category).length);
|
|
59
|
+
if (originalTable && !countsOK) notes.push('原文统计待核对\n'+originalTable);
|
|
60
|
+
return {
|
|
61
|
+
from, to, items, notes, note:notes.join('\n'), commits:totals?.['本次提交'] ?? null,
|
|
62
|
+
added:countsOK ? totals['新增'] ?? (totals['功能'] === 0 ? 0 : null) : null,
|
|
63
|
+
verified:Boolean(countsOK), baseline:!items.length && totals?.['本次提交'] === 0 && notes.some(note=>/基线|之前的变更未回填/u.test(note)),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function parseMarkdown(body) {
|
|
68
|
+
const ranges = [], legacy = [];
|
|
69
|
+
let header = null, block = [], fence = '';
|
|
70
|
+
function flush() {
|
|
71
|
+
if (header) ranges.push(parsePeriod(header,block));
|
|
72
|
+
else legacy.push(...block);
|
|
73
|
+
block = [];
|
|
74
|
+
}
|
|
75
|
+
for (const line of body.replace(/^\uFEFF/u,'').split(/\r?\n/u)) {
|
|
76
|
+
const fenceStart = /^\s*(\x60{3,}|~{3,})/u.exec(line);
|
|
77
|
+
if (fenceStart) {
|
|
78
|
+
if (!fence) fence = fenceStart[1];
|
|
79
|
+
else if (fenceStart[1][0] === fence[0] && fenceStart[1].length >= fence.length) fence = '';
|
|
80
|
+
block.push(line);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (!fence && line.startsWith('## ')) {
|
|
84
|
+
flush();
|
|
85
|
+
const match = dateTitle.exec(line.trim());
|
|
86
|
+
header = match && validDay(match[1]) && (!match[2] || validDay(match[2]) && match[2]>=match[1]) ? match : null;
|
|
87
|
+
if (!header) block.push(line);
|
|
88
|
+
} else if (header || block.length || !line.startsWith('# ')) block.push(line);
|
|
89
|
+
}
|
|
90
|
+
flush();
|
|
91
|
+
const occurrences = new Map();
|
|
92
|
+
for (const period of [...ranges].reverse()) {
|
|
93
|
+
const pair = (period.from ?? 'single') + '_' + period.to;
|
|
94
|
+
const number = (occurrences.get(pair) ?? 0) + 1;
|
|
95
|
+
occurrences.set(pair,number);
|
|
96
|
+
period.key = pair+'-'+number;
|
|
97
|
+
}
|
|
98
|
+
return {periods:ranges,legacy:legacy.join('\n').trim()};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function publicProject(project) {
|
|
102
|
+
return {
|
|
103
|
+
schemaVersion:1,id:project.id,name:project.name,purpose:project.purpose,
|
|
104
|
+
groups:project.groups, ...(project.docsUrl ? {docsUrl:project.docsUrl} : {}), ...(project.repoUrl ? {repoUrl:project.repoUrl} : {}),
|
|
105
|
+
stats:statistics(project.periods),
|
|
106
|
+
ranges:project.periods.map(period=>({
|
|
107
|
+
key:period.key,from:period.from,to:period.to,baseline:!!period.baseline,
|
|
108
|
+
stats:statistics([period]),
|
|
109
|
+
notes:period.notes ?? (period.note ? [period.note] : []),
|
|
110
|
+
entries:period.items.map(([category,text,markers=[]],i)=>({key:itemId(period,i),category,text,markers})),
|
|
111
|
+
})),
|
|
112
|
+
...(project.legacy ? {legacy:project.legacy} : {}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Home 网站的初始化、刷新与发布
|
|
2
|
+
|
|
3
|
+
## 打开已构建的网站
|
|
4
|
+
|
|
5
|
+
双击 `.agents/home/website/dist/index.html` 即可离线浏览。浏览器允许本地脚本时,项目导航、筛选、搜索和主题切换都可使用。移动或分享制品时,保留整个 `dist/` 目录。
|
|
6
|
+
|
|
7
|
+
验证托管路径或 HTTP 404 时,从 Home 根运行:
|
|
8
|
+
|
|
9
|
+
~~~powershell
|
|
10
|
+
npm --prefix .agents/home/website run preview
|
|
11
|
+
~~~
|
|
12
|
+
|
|
13
|
+
在浏览器打开终端输出的地址。默认是 `http://127.0.0.1:4173/`,配置了 `base` 的站点会显示对应的路径。终端保持运行,按 `Ctrl+C` 结束预览。
|
|
14
|
+
|
|
15
|
+
端口被占用时,运行 `node .agents/home/website/scripts/site.mjs preview --port 4174` 改用 4174。
|
|
16
|
+
|
|
17
|
+
## 初始化与构建
|
|
18
|
+
|
|
19
|
+
在确认的 Home 根运行以下命令。单装网站技能即可,工程生成后也可以独立构建。记录中的 `repos.json` 由 home-setup 提供。
|
|
20
|
+
|
|
21
|
+
~~~sh
|
|
22
|
+
node .agents/skills/home-website/scripts/init.mjs --home .
|
|
23
|
+
npm --prefix .agents/home/website ci
|
|
24
|
+
npm --prefix .agents/home/website run build
|
|
25
|
+
~~~
|
|
26
|
+
|
|
27
|
+
构建回执包含 `built` 或 `unchanged`、站点前缀、公开项目数、条目数、统计和输入诊断。重新初始化只补缺并报告与模板不同的文件,保留本地内容。
|
|
28
|
+
|
|
29
|
+
## 更新已有模板
|
|
30
|
+
|
|
31
|
+
更新已安装的 `home-website` 技能后,从实际 Home 根在临时目录生成一份新模板。将原网站的脚本和站点源文件备份,再比较两个版本。以下为 PowerShell 示例。
|
|
32
|
+
|
|
33
|
+
~~~powershell
|
|
34
|
+
$atlasSite = (Resolve-Path .agents/home/website).Path
|
|
35
|
+
$atlasScratch = Join-Path ([IO.Path]::GetTempPath()) ('home-atlas-' + [guid]::NewGuid())
|
|
36
|
+
New-Item -ItemType Directory -Path $atlasScratch | Out-Null
|
|
37
|
+
node .agents/skills/home-website/scripts/init.mjs --home $atlasScratch
|
|
38
|
+
$atlasNew = Join-Path $atlasScratch '.agents/home/website'
|
|
39
|
+
$atlasBackup = Join-Path $atlasScratch 'backup'
|
|
40
|
+
New-Item -ItemType Directory -Path $atlasBackup | Out-Null
|
|
41
|
+
Copy-Item -LiteralPath "$atlasSite/scripts","$atlasSite/site" -Destination $atlasBackup -Recurse
|
|
42
|
+
git diff --no-index -- "$atlasSite/scripts" "$atlasNew/scripts"
|
|
43
|
+
git diff --no-index -- "$atlasSite/site" "$atlasNew/site"
|
|
44
|
+
~~~
|
|
45
|
+
|
|
46
|
+
`git diff --no-index` 返回 1 表示找到差异。逐文件应用模板变更,原样使用模板的文件可直接从新版本复制,改过的文件合并差异。`site.config.json` 和 Home 的登记、日志及状态沿用手头版本。此版使用原有依赖锁定,缺依赖时在实际网站目录运行 `npm ci`。执行 `node .agents/home/website/scripts/site.mjs refresh` 并核对排除项、统计与原文链接。需要撤回时,用备份恢复刚合入的文件并重新刷新,上一份成功制品也留在 `.cache/previous-dist/`。
|
|
47
|
+
|
|
48
|
+
## 公开字段与数据来源
|
|
49
|
+
|
|
50
|
+
修改网站工程中的 `site.config.json`。`title` 是网站标题,`base` 为 `/` 或以斜线结尾的部署前缀,例如 `/portfolio/`。`scope` 为 `all`。`publicGroups` 缺省为空。`overrides` 以登记项目 ID 为键,可设置 `displayName`、`summary`、`docsUrl`、`repoUrl`、`hidden` 或 `showChangelog`。
|
|
51
|
+
|
|
52
|
+
- 公开集合取当前登记、`changelogs/state.json` 中成功保存的记录和展示配置。已保存且匹配正文的零项基线有公开区间。排除无状态、仅 Markdown、撤登、`hidden: true` 或 `showChangelog: false` 的项目。目录、详情、日志、搜索、JSON 和统计使用同一集合。
|
|
53
|
+
- 分组仅公开与 `publicGroups` 同名的登记值。源码与文档入口取站主明确提供的 HTTPS 地址。本机路径、内部引用和原始状态留在 Home。
|
|
54
|
+
- `changelogs/<id>.md` 是可编辑的展示原文。以日期、区间提交数和统计核对成功段。正文按文本生成,保留已匹配日期段、区间说明与可公开的无日期补记。缺少对应成功记录的日期段留在 Home。应公开项目有 pending、成功正文缺失或无法核对时,刷新失败并保留上一份完整制品。
|
|
55
|
+
- `dist/data/catalog.json` 提供站点 `stats`、项目清单和 `windows`。`dist/data/projects/<id>.json` 提供项目 `stats` 和各区间 `ranges[].stats`。区间和条目有独立键,单条摘要沿用所属段的日期。人工调整段内顺序可能改变基于条目序号的旧链接。
|
|
56
|
+
|
|
57
|
+
## 时间线与统计
|
|
58
|
+
|
|
59
|
+
连续的观测截止日划分全站窗口。首窗显示“截至”首个截止日,后续窗口从上一个截止日的次日开始。每段只进自己的结束日窗口,保留原始起止日。项目详情按区间结束日倒序,全文保留日志文件的段落顺序。
|
|
60
|
+
|
|
61
|
+
首页和时间线统计全部公开区间,详情和单仓日志统计该项目的所有区间。展开“本窗全部记录统计”可看对应窗口。筛选命中单独计数。提交数为所含原区间的提交数合计,变更总数为五类条目数之和。
|
|
62
|
+
|
|
63
|
+
“功能(含新增能力)”也包含重要的预期行为变化。若已核实某段的独立新增条数,可在该段原统计表添加 `新增` 列。
|
|
64
|
+
|
|
65
|
+
| 变更总数 | 功能 | 修复 | 重构 | 优化 | 维护 | 本次提交 | 新增 |
|
|
66
|
+
| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
|
67
|
+
| 3 | 2 | 1 | 0 | 0 | 0 | 4 | 1 |
|
|
68
|
+
|
|
69
|
+
新增取 0 到该段功能条数之间的整数。没有功能的核实段为 0。有功能且缺少新增列的段显示“未单列”。范围内任一段未单列时,新增合计也显示“未单列”,公开 JSON 的 `added` 为 `null`。现有日志可直接构建,补齐精确新增数据时再按证据修订原段。
|
|
70
|
+
|
|
71
|
+
## 更新和安全切换
|
|
72
|
+
|
|
73
|
+
完成一批登记或 Git 日志保存后,从真实 Home 根调用 `node .agents/home/website/scripts/site.mjs refresh`。手改 Markdown、网站展示设置或模板之后也用该命令。只读查询、同节点无变化和仅清除 pending 回执没有新的展示内容。正常批次更新时独立报告各仓保存结果和网站结果。
|
|
74
|
+
|
|
75
|
+
刷新按网站目录串行。构建候选在 `.cache/`,核对页面、链接和索引后才替换 `dist/`。上一个完整产物保留于 `.cache/previous-dist/`。重新构建可加 `--force`。构建输入仅使用 Home 登记、日志和站点工程,安装完成后无需子仓可用。
|
|
76
|
+
|
|
77
|
+
## 修复本地刷新
|
|
78
|
+
|
|
79
|
+
1. 缺少依赖时在网站工程运行 `npm ci`。`repos.json` 缺失先核对是否指向正确的 Home。日志 pending、损坏或正文缺失先交 home-project-changelog。
|
|
80
|
+
2. 中断后核对 `.refresh.lock/owner.json` 中的主机与 PID。原进程确认结束后运行 `node .agents/home/website/scripts/site.mjs recover`,再从最新输入刷新。恢复会在需要时将上一版完整产物放回 `dist/`。
|
|
81
|
+
3. 若构建或发布前预览出现需隐去的文字,回到登记、源 Markdown 或 `site.config.json` 修订并刷新。构建回执可检查本轮项目增删及日志解析诊断。
|
|
82
|
+
|
|
83
|
+
## 交付静态产物
|
|
84
|
+
|
|
85
|
+
在部署前按目标设置 `base` 并重建。将 `dist/` 作为静态制品,供 GitHub Pages、Nginx 或其他静态主机读取。目标必须能提供目录下的 `index.html` 和真实 404。配置后用匿名访问核对站点首页、跨仓时间线、两个不同仓的深链接和未知路由。保留成功部署版本和上一版本的制品作为回退依据。
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const source = fileURLToPath(new URL('../assets/website/', import.meta.url));
|
|
8
|
+
const info = target => fs.lstatSync(target,{throwIfNoEntry:false});
|
|
9
|
+
function ensureDirectory(target) {
|
|
10
|
+
try { fs.mkdirSync(target); }
|
|
11
|
+
catch (error) { if (error.code !== 'EEXIST') throw error; }
|
|
12
|
+
if (!info(target)?.isDirectory()) throw Error('须使用普通目录:'+target);
|
|
13
|
+
}
|
|
14
|
+
function initialize(home) {
|
|
15
|
+
const requested = path.resolve(home);
|
|
16
|
+
if (!info(requested)?.isDirectory()) throw Error('Home 根须为已有普通目录。');
|
|
17
|
+
const root = fs.realpathSync(requested);
|
|
18
|
+
const website = path.join(root,'.agents','home','website');
|
|
19
|
+
for (const directory of [path.join(root,'.agents'),path.join(root,'.agents','home'),website]) ensureDirectory(directory);
|
|
20
|
+
const created = [], existing = [], conflicts = [];
|
|
21
|
+
function copy(from, to, relative='') {
|
|
22
|
+
for (const entry of fs.readdirSync(from,{withFileTypes:true})) {
|
|
23
|
+
const name = entry.name === 'gitignore.tmpl' ? '.gitignore' : entry.name;
|
|
24
|
+
const original = path.join(from,entry.name);
|
|
25
|
+
const target = path.join(to,name);
|
|
26
|
+
const label = relative+name;
|
|
27
|
+
if (entry.isDirectory()) {
|
|
28
|
+
ensureDirectory(target);
|
|
29
|
+
copy(original,target,label+'/');
|
|
30
|
+
} else if (entry.isFile()) {
|
|
31
|
+
try {
|
|
32
|
+
fs.copyFileSync(original,target,fs.constants.COPYFILE_EXCL);
|
|
33
|
+
created.push(label);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error.code !== 'EEXIST') throw error;
|
|
36
|
+
if (!info(target)?.isFile()) throw Error('须使用普通文件:'+label);
|
|
37
|
+
if (fs.readFileSync(original).equals(fs.readFileSync(target))) existing.push(label);
|
|
38
|
+
else conflicts.push(label);
|
|
39
|
+
}
|
|
40
|
+
} else throw Error('网站模板包含非普通文件:'+label);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
copy(source,website);
|
|
44
|
+
return {status:created.length?'initialized':'existing',website,created,existing,conflicts,
|
|
45
|
+
next:['npm --prefix .agents/home/website ci','npm --prefix .agents/home/website run build','npm --prefix .agents/home/website run preview']};
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const {values} = parseArgs({options:{home:{type:'string'},help:{type:'boolean'}}});
|
|
49
|
+
if (values.help) console.log('用法:node scripts/init.mjs --home <Home 根>');
|
|
50
|
+
else {
|
|
51
|
+
if (!values.home) throw Error('请显式提供 --home <Home 根>。');
|
|
52
|
+
console.log(JSON.stringify(initialize(values.home),null,2));
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(JSON.stringify({status:'failed',message:error.message}));
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
}
|
|
@@ -20,6 +20,7 @@ description: 从 Home 向一个或多个已登记项目派发工作、查询项
|
|
|
20
20
|
| 查当前背景、长期决定,整理入口、知识或合作风格 | home-knowledge |
|
|
21
21
|
| 查过去事件、会话摘要、当时理由或接续线索 | home-history |
|
|
22
22
|
| 查看或按 Git 提交范围更新已登记项目的变更日志 | home-project-changelog |
|
|
23
|
+
| 初始化、刷新或预览 Home 项目与跨仓日志展示站 | home-website |
|
|
23
24
|
| 管理派发消息、回复、占用和状态,查询任务或重建视图 | home-tasks |
|
|
24
25
|
| 确认项目关系、契约 owner 和影响集合 | home-map |
|
|
25
26
|
| 验证多个项目共同工作的版本组合 | home-integrate |
|