@namewta/skills-hub 0.1.47 → 0.1.49
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 +5 -5
- package/skills/home/home-project-changelog/assets/project-changelog.md +7 -7
- package/skills/home/home-project-changelog/assets/worker-brief.md +1 -1
- package/skills/home/home-project-changelog/references/git-ranges.md +3 -0
- package/skills/home/home-project-changelog/references/tools.md +20 -2
- package/skills/home/home-project-changelog/references/workflow.md +5 -2
- package/skills/home/home-project-changelog/references/writing.md +20 -2
- package/skills/home/home-project-changelog/scripts/changelog.mjs +47 -5
- package/skills/home/home-project-changelog/scripts/contract.mjs +46 -2
- package/skills/home/home-project-changelog/scripts/git.mjs +15 -0
- package/skills/home/home-project-changelog/scripts/revision.mjs +231 -0
- package/skills/home/home-project-changelog/scripts/storage.mjs +32 -8
- package/skills/home/home-project-changelog/scripts/summary.mjs +17 -3
- package/skills/home/home-project-changelog/scripts/tasks.mjs +40 -0
- 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 +251 -0
- package/skills/home/home-website/assets/website/scripts/preview.mjs +50 -0
- package/skills/home/home-website/assets/website/scripts/render.mjs +97 -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 +262 -0
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +330 -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 +93 -0
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +69 -0
- package/skills/home/home-website/assets/website/site/templates/model.mjs +104 -0
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +75 -0
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +130 -0
- package/skills/home/home-website/assets/website/site.config.json +6 -0
- package/skills/home/home-website/references/website.md +82 -0
- package/skills/home/home-website/scripts/init.mjs +57 -0
- package/skills/home/home-workflow/SKILL.md +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { activityMonths, categories, distinctRangeLabel, itemId, periodTitle, statistics, timeline } from './model.mjs';
|
|
2
|
+
import { arrow, availableGroups, categoryBreakdown, crumbs, escapeHtml as esc, external, formatCount, logPath, mark, projectCard, projectChip, projectMetrics, projectPath, statStrip, statSummary, symbol } from './layout.mjs';
|
|
3
|
+
import { impactLabels, monthlyLedger, monthLabel } from './ledger.mjs';
|
|
4
|
+
|
|
5
|
+
function activitySummary(root, projects) {
|
|
6
|
+
const months = activityMonths(projects).filter(({key}) => key !== 'undated').slice(0, 4);
|
|
7
|
+
if (!months.length) return projects.some(project => project.periods.length || project.legacy)
|
|
8
|
+
? `<div class="activity-figure"><p>已有记录保留在变更明细中。</p><a class="text-link" href="${root}changelog/#month-undated">查看变更明细 ${arrow}</a></div>`
|
|
9
|
+
: '';
|
|
10
|
+
const maximum = Math.max(1,...months.map(month => month.changes));
|
|
11
|
+
return `<figure class="activity-figure"><figcaption class="chart-label">近期项目活动</figcaption>
|
|
12
|
+
<table class="activity-table"><thead><tr><th scope="col">月份</th><th scope="col">任务</th><th scope="col">Git 提交</th></tr></thead>
|
|
13
|
+
<tbody>${months.map(({key, changes, commits}) => `<tr><th scope="row"><a href="${root}changelog/#month-${key}">${monthLabel(key)}</a></th><td><span class="activity-value"><i aria-hidden="true" style="--share:${(100*changes/maximum).toFixed(1)}%"></i>${formatCount(changes)}</span></td><td>${formatCount(commits)}</td></tr>`).join('')}</tbody></table>
|
|
14
|
+
<a class="text-link" href="${root}changelog/">查看全部月份 ${arrow}</a></figure>`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function sectionHeading(title, url, label) {
|
|
18
|
+
return `<div class="section-heading"><h2>${title}</h2><a class="text-link" href="${url}">${label} ${arrow}</a></div>`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function overview(root, projects, windows, stats) {
|
|
22
|
+
const asOf = timeline(projects)[0]?.period.to;
|
|
23
|
+
const activity = activitySummary(root, projects);
|
|
24
|
+
return `<section class="overview-hero${activity ? '' : ' hero-no-activity'}" aria-labelledby="hero-title"><div class="hero-copy">
|
|
25
|
+
${asOf ? `<div class="hero-date"><i></i>记录截至 <time datetime="${asOf}">${asOf.replaceAll('-', '.')}</time></div>` : ''}
|
|
26
|
+
<h1 id="hero-title">项目进展总览</h1>
|
|
27
|
+
<dl class="hero-stats"><div><dt>公开项目</dt><dd>${formatCount(projects.length)}</dd></div><div><dt>记录区间提交</dt><dd>${formatCount(stats.commits)}</dd></div><div><dt>已记录任务</dt><dd>${formatCount(stats.changes)}</dd></div></dl>
|
|
28
|
+
</div>${activity}</section>
|
|
29
|
+
<section class="home-catalog" aria-label="项目进展">
|
|
30
|
+
${sectionHeading('项目进展', root + 'projects/', '查找项目')}
|
|
31
|
+
<div class="project-grid home-grid">${projects.length ? projects.map(project => projectCard(root, project)).join('') : '<p>暂无公开项目</p>'}</div>
|
|
32
|
+
</section>`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function catalog(root, projects) {
|
|
36
|
+
return `${crumbs(root,[['项目目录']])}<header class="page-head"><h1>项目目录</h1><p>共 ${projects.length} 个公开项目。打开项目可按月份查看任务和提交。</p></header>
|
|
37
|
+
<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>
|
|
38
|
+
<label class="field search-field">${symbol('search')}<input id="catalog-query" type="search" aria-label="筛选项目" placeholder="名称、ID 或简介" autocomplete="off"></label></div>
|
|
39
|
+
<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>
|
|
40
|
+
<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>`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resourceButtons(project) {
|
|
44
|
+
return [[project.docsUrl, '公开文档'], [project.repoUrl, '源代码']].filter(([url]) => url).map(([url, label]) =>
|
|
45
|
+
`<a class="secondary-button" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${label} ${external}</a>`).join('');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function detail(root, project, stats) {
|
|
49
|
+
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>${project.id !== project.name ? `<span class="repo-id">${esc(project.id)}</span>` : ''}</div></div>
|
|
50
|
+
<p>${esc(project.purpose)}</p>${projectMetrics(project, 'detail-stats', stats)}${categoryBreakdown(stats)}
|
|
51
|
+
<div class="button-row"><a class="secondary-button" href="${root}${logPath(project)}">项目日志原文 ${arrow}</a>${resourceButtons(project)}</div></header>
|
|
52
|
+
${monthlyLedger(root, [project], {showProject:false})}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function logPeriod(project, period) {
|
|
56
|
+
const groups = categories.map(category => {
|
|
57
|
+
const entries = period.items.map(([type, text, markers, meta], index) => {
|
|
58
|
+
if (type !== category) return '';
|
|
59
|
+
const date = meta?.date ? `<time datetime="${esc(meta.date)}">${esc(meta.date)}</time>` : '';
|
|
60
|
+
const area = meta?.area ? `<span>${esc(meta.area)}</span>` : '';
|
|
61
|
+
return `<li class="log-entry" id="${esc(itemId(period, index))}">${impactLabels(markers)}${esc(text)}${date || area ? `<div class="entry-context">${date}${area}</div>` : ''}</li>`;
|
|
62
|
+
}).join('');
|
|
63
|
+
return entries ? `<section class="category-block"><h3>${category}</h3><ul>${entries}</ul></section>` : '';
|
|
64
|
+
}).join('');
|
|
65
|
+
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>
|
|
66
|
+
${period.note ? `<p class="period-note">${esc(period.note)}</p>` : ''}${statStrip(statistics([period]),'本次提交')}
|
|
67
|
+
${groups}</article>`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function repositoryLog(root, project, stats) {
|
|
71
|
+
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>
|
|
72
|
+
${statSummary('project-statistics','本项目统计',stats,`汇总本项目 ${project.periods.length} 个公开区间。`)}
|
|
73
|
+
<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>
|
|
74
|
+
<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>`;
|
|
75
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
const dated = /^(\d{4}-\d{2}-\d{2}) · (.+?) · (.+)$/u.exec(body);
|
|
25
|
+
const unescape = value => value.replace(/\\([\[\]])/gu,'$1');
|
|
26
|
+
const meta = dated && validDay(dated[1]) ? {date:dated[1],area:dated[2] === '—' ? null : unescape(dated[2])} : null;
|
|
27
|
+
let text = meta ? dated[3] : body;
|
|
28
|
+
while (true) {
|
|
29
|
+
const match = /^\*\*\[([^\]]+)\]\*\*\s+/u.exec(text);
|
|
30
|
+
if (!match || !tags.includes(match[1])) break;
|
|
31
|
+
markers.push(match[1]);
|
|
32
|
+
text = text.slice(match[0].length);
|
|
33
|
+
}
|
|
34
|
+
return meta ? [category,unescape(text),markers,meta] : [category,unescape(text),markers];
|
|
35
|
+
}
|
|
36
|
+
function parsePeriod(title, lines, datedOnly) {
|
|
37
|
+
let group = '', totals = null, originalTable = '', fence = '';
|
|
38
|
+
const items = [], notes = [];
|
|
39
|
+
for (let i=0; i<lines.length; i++) {
|
|
40
|
+
const line = lines[i].trim();
|
|
41
|
+
if (!line) continue;
|
|
42
|
+
const delimiter = /^\s*(\x60{3,}|~{3,})/u.exec(line);
|
|
43
|
+
if (delimiter || fence) {
|
|
44
|
+
if (delimiter && !fence) fence=delimiter[1];
|
|
45
|
+
else if (delimiter && delimiter[1][0]===fence[0] && delimiter[1].length>=fence.length) fence='';
|
|
46
|
+
notes.push(line);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const table = tableAt(lines,i);
|
|
50
|
+
if (table) { totals=table; originalTable=lines.slice(i,i+3).join('\n'); i+=2; group=''; continue; }
|
|
51
|
+
if (line.startsWith('### ')) {
|
|
52
|
+
group = line.slice(4);
|
|
53
|
+
if (!categories.includes(group)) notes.push(line);
|
|
54
|
+
} else if (categories.includes(group) && line.startsWith('- ')) {
|
|
55
|
+
const task = entry(group,line.slice(2));
|
|
56
|
+
if (datedOnly && !task[3]) notes.push(line);
|
|
57
|
+
else items.push(task);
|
|
58
|
+
} else notes.push(line);
|
|
59
|
+
}
|
|
60
|
+
const from = title[2] ? title[1] : null, to = title[2] ?? title[1];
|
|
61
|
+
const countsOK = totals && totals['变更总数'] === items.length &&
|
|
62
|
+
(totals['新增'] === undefined || totals['新增'] <= totals['功能']) &&
|
|
63
|
+
categories.every(category=>totals[category] === items.filter(([name])=>name===category).length);
|
|
64
|
+
if (originalTable && !countsOK) notes.push('原文统计待核对\n'+originalTable);
|
|
65
|
+
return {
|
|
66
|
+
from, to, items, notes, note:notes.join('\n'), commits:totals?.['本次提交'] ?? null,
|
|
67
|
+
added:countsOK ? totals['新增'] ?? (totals['功能'] === 0 ? 0 : null) : null,
|
|
68
|
+
verified:Boolean(countsOK), baseline:!items.length && totals?.['本次提交'] === 0 && notes.some(note=>/基线|之前的变更未回填/u.test(note)),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function parseMarkdown(body, {datedOnly = false} = {}) {
|
|
73
|
+
const ranges = [], legacy = [];
|
|
74
|
+
let header = null, block = [], fence = '', comment = false;
|
|
75
|
+
function flush() {
|
|
76
|
+
if (header) ranges.push(parsePeriod(header,block,datedOnly));
|
|
77
|
+
else legacy.push(...block);
|
|
78
|
+
block = [];
|
|
79
|
+
}
|
|
80
|
+
const visibleBody = body.replace(/^\uFEFF/u,'').replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/u,'');
|
|
81
|
+
for (let line of visibleBody.split(/\r?\n/u)) {
|
|
82
|
+
if (!fence && (comment || /^ {0,3}<!--/u.test(line))) {
|
|
83
|
+
const end = line.indexOf('-->');
|
|
84
|
+
comment = end < 0;
|
|
85
|
+
if (comment) continue;
|
|
86
|
+
line = line.slice(end + 3);
|
|
87
|
+
if (!line.trim()) continue;
|
|
88
|
+
}
|
|
89
|
+
const fenceStart = /^\s*(\x60{3,}|~{3,})/u.exec(line);
|
|
90
|
+
if (fenceStart) {
|
|
91
|
+
if (!fence) fence = fenceStart[1];
|
|
92
|
+
else if (fenceStart[1][0] === fence[0] && fenceStart[1].length >= fence.length) fence = '';
|
|
93
|
+
block.push(line);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (!fence && line.startsWith('## ')) {
|
|
97
|
+
flush();
|
|
98
|
+
const match = dateTitle.exec(line.trim());
|
|
99
|
+
header = match && validDay(match[1]) && (!match[2] || validDay(match[2]) && match[2]>=match[1]) ? match : null;
|
|
100
|
+
if (!header) block.push(line);
|
|
101
|
+
} else if (header || block.length || !line.startsWith('# ')) block.push(line);
|
|
102
|
+
}
|
|
103
|
+
flush();
|
|
104
|
+
const occurrences = new Map();
|
|
105
|
+
for (const period of [...ranges].reverse()) {
|
|
106
|
+
const pair = (period.from ?? 'single') + '_' + period.to;
|
|
107
|
+
const number = (occurrences.get(pair) ?? 0) + 1;
|
|
108
|
+
occurrences.set(pair,number);
|
|
109
|
+
period.key = pair+'-'+number;
|
|
110
|
+
}
|
|
111
|
+
return {periods:ranges,legacy:legacy.join('\n').trim()};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function publicProject(project) {
|
|
115
|
+
return {
|
|
116
|
+
schemaVersion:2,id:project.id,name:project.name,purpose:project.purpose,headCommits:project.headCommits,
|
|
117
|
+
groups:project.groups, ...(project.docsUrl ? {docsUrl:project.docsUrl} : {}), ...(project.repoUrl ? {repoUrl:project.repoUrl} : {}),
|
|
118
|
+
stats:statistics(project.periods),
|
|
119
|
+
ranges:project.periods.map(period=>({
|
|
120
|
+
key:period.key,from:period.from,to:period.to,baseline:!!period.baseline,
|
|
121
|
+
stats:statistics([period]),
|
|
122
|
+
notes:period.notes ?? (period.note ? [period.note] : []),
|
|
123
|
+
commitMonths:period.commitMonths ?? null,
|
|
124
|
+
entries:period.items.map(([category,text,markers=[],meta],i)=>({
|
|
125
|
+
key:itemId(period,i),category,text,markers,date:meta?.date ?? null,area:meta?.area ?? null,
|
|
126
|
+
})),
|
|
127
|
+
})),
|
|
128
|
+
...(project.legacy ? {legacy:project.legacy} : {}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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` 的成功段。新日志再逐项核对区间 `ledger.tasks` 的日期、模块、类别、标记和正文。正式数据只从成功记录和相符的 Markdown 构建。成功段有 pending、正文缺失或任务不一致时,刷新报错并保留上次制品。历史补记保留在原文页。
|
|
55
|
+
- `dist/data/catalog.json` 提供 `schemaVersion: 2`、全站统计、各项目的任务量、区间提交数和 `headCommits`,以及按任务与提交月份聚合的 `months` 和按采集截止日聚合的 `windows`。月份未知的旧记录使用 `month: null`。
|
|
56
|
+
- `dist/data/projects/<id>.json` 提供 `headCommits`、项目统计及 `ranges[]`。每段有日期、`stats` 和 `commitMonths`。公开 `entries[]` 含 `key/category/area/date/text/markers`,旧条目的日期与模块可为 `null`。新任务的键在排序后保持稳定。更改模块、类别或正文会改变键。项目私有提交 OID、证据和游标只保存在 Home。
|
|
57
|
+
|
|
58
|
+
## 时间线与统计
|
|
59
|
+
|
|
60
|
+
首页可直接看到公开项目数、已记录的独立任务和区间 Git 提交数。项目卡片在进入详情前就显示已记录任务和仓库累计提交。累计取最新成功节点的可达历史数,未能核实时显示未知;从某个起点开始记录时,累计提交可以大于区间提交数。
|
|
61
|
+
|
|
62
|
+
跨项目页与项目详情按任务完成提交的月份倒序列出全部明细。每月 Git 提交按该月实际提交计数,包含没有单列任务的提交。一个提交完成多个任务时,任务数可以大于提交数。项目、月份、类别和关键词可组合筛选,关键词也能匹配模块。筛选显示命中任务数,月度提交保留所示项目在该月的完整提交量。
|
|
63
|
+
|
|
64
|
+
旧日志缺少逐条日期时,页面单列“日期未记录”并链接到可核实的原区间。全站原有观测窗口仍可从公开 JSON 读取。首窗截至最早的截止日,后续窗口从上一次截止日的次日开始。窗口统计和任务月统计分别服务于采集回顾与实际变更查询。
|
|
65
|
+
|
|
66
|
+
功能可含新增和预期行为变更。新日志用功能任务的 `added` 标志计算精确新增数;旧日志继续支持统计表尾部的 `新增` 列,取 0 至该段功能条数。范围含未单列新增的功能时,公开 JSON 中的 `added` 为 `null`。
|
|
67
|
+
|
|
68
|
+
## 更新和安全切换
|
|
69
|
+
|
|
70
|
+
完成一批登记或 Git 日志保存后,从真实 Home 根调用 `node .agents/home/website/scripts/site.mjs refresh`。修订成功区间、补记、网站展示设置或模板后也用该命令。只读查询、同节点无变化和仅清除 pending 回执没有新的展示内容。正常批次更新时独立报告各仓保存结果和网站结果。
|
|
71
|
+
|
|
72
|
+
刷新按网站目录串行。构建候选在 `.cache/`,核对页面、链接和索引后才替换 `dist/`。上一个完整产物保留于 `.cache/previous-dist/`。重新构建可加 `--force`。构建输入仅使用 Home 登记、日志和站点工程,安装完成后无需子仓可用。
|
|
73
|
+
|
|
74
|
+
## 修复本地刷新
|
|
75
|
+
|
|
76
|
+
1. 缺少依赖时在网站工程运行 `npm ci`。`repos.json` 缺失先核对是否指向正确的 Home。日志 pending、损坏或正文缺失先交 home-project-changelog。
|
|
77
|
+
2. 中断后核对 `.refresh.lock/owner.json` 中的主机与 PID。原进程确认结束后运行 `node .agents/home/website/scripts/site.mjs recover`,再从最新输入刷新。恢复会在需要时将上一版完整产物放回 `dist/`。
|
|
78
|
+
3. 若构建或发布前预览出现需隐去的文字,回到登记、源 Markdown 或 `site.config.json` 修订并刷新。构建回执可检查本轮项目增删及日志解析诊断。
|
|
79
|
+
|
|
80
|
+
## 交付静态产物
|
|
81
|
+
|
|
82
|
+
在部署前按目标设置 `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 |
|