@rowansenne/workflow-run 0.21.2 → 0.22.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.
@@ -68,7 +68,8 @@ export function docnexusConnected(root) {
68
68
 
69
69
  export function resolveTemplate(root, skill, id) {
70
70
  const meta = skillMeta(skill);
71
- const t = meta?.templates.find((x) => x.id === id);
71
+ if (!meta) return { ok: false, error: 'unknown', message: `skill「${skill}」没有安装(${rel(root, SKILLS_DIR)} 下找不到 ${skill}/skill.json);重跑安装并在 --skills 里带上它` };
72
+ const t = meta.templates.find((x) => x.id === id);
72
73
  if (!t) return { ok: false, error: 'unknown', message: `skill「${skill}」没有登记模板「${id}」(见 ${skill}/skill.json 的 templates)` };
73
74
  const lib = path.join(docnexusRoot(root), 'docnexus', 'library', 'templates', skill, id);
74
75
  const project = path.join(root, TEMPLATES_DIR, skill, id);
@@ -195,8 +196,8 @@ export function status(root) {
195
196
  categories: Object.fromEntries(skillMetas().map((m) => [m.name, resolveCategory(root, m.name)]).filter(([, c]) => c.ok).map(([n, c]) => [n, c.category])),
196
197
  how: dn ? '缺模板时运行 npx @rowansenne/workflow-run seed-templates' : '重跑 npx @rowansenne/workflow-run 并加 --with-docnexus',
197
198
  },
198
- // 产物位置:项目里(默认)或独立文档仓库(workflow/references/requirements.md)
199
- artifacts: (() => { const L = layout(root); return { mode: L.mode, ok: L.ok, ...(L.mode === 'repo' ? { repo: L.repo_rel, project: L.project, commit_prompt: L.commit_prompt } : { dir: 'workflow-run/docs/requirements' }), how: L.ok ? null : L.hint }; })(),
199
+ // 产物位置:项目里(默认)或独立文档仓库,两种都是 docs/requirements/<需求>/<项目>/(workflow/references/requirements.md)
200
+ artifacts: (() => { const L = layout(root); return { mode: L.mode, ok: L.ok, dir: 'workflow-run/docs/requirements', project: L.project, ...(L.mode === 'repo' ? { repo: L.repo_rel, commit_prompt: L.commit_prompt } : {}), how: L.ok ? null : L.hint }; })(),
200
201
  // 代码图谱:可用时读代码、查调用链与影响面优先用它(见 workflow/references/codegraph.md)
201
202
  codegraph: codegraphStatus(root),
202
203
  database: {
@@ -12,16 +12,17 @@ import path from 'node:path';
12
12
  import { spawnSync } from 'node:child_process';
13
13
  import { fileURLToPath } from 'node:url';
14
14
  import { collect, KINDS } from './artifacts.mjs';
15
- import { requirements, repoRequirements, layout, parseDocnexus } from './requirement.mjs';
15
+ import { repoRequirements, layout, parseDocnexus, REQ_DIR } from './requirement.mjs';
16
16
  import { parseReview, parseDelivery, captureState, buildReport } from './report.mjs';
17
17
 
18
18
  const DEFAULT_OUT = 'workflow-run/tmp/view/index.html';
19
19
 
20
20
  // 页面数据:按需求分组
21
21
  export function viewData(root) {
22
- // 文档仓库模式:连同其他项目(服务)的产物一起看,一个需求下按项目区分
22
+ // 连同其他项目(服务)的产物一起看,一个需求下按项目区分(文档仓库里常见;两种模式目录结构相同)
23
23
  const L = layout(root);
24
- const metas = new Map(L.mode === 'repo' ? repoRequirements(root, L).map((r) => [r.slug, { name: r.name, dir: null, branches: [...new Set(r.projects.flatMap((p) => p.meta.branches ?? []))], meta: r.projects.find((p) => p.project === L.project)?.meta ?? r.projects[0]?.meta ?? {} }]) : requirements(root, L).map((r) => [r.slug, r]));
24
+ const reqDirOf = (slug) => (L.mode === 'repo' ? `${L.repo_name}:docs/requirements/${slug}` : `${REQ_DIR}/${slug}`);
25
+ const metas = new Map(repoRequirements(root, L).map((r) => [r.slug, { name: r.name, dir: reqDirOf(r.slug), branches: [...new Set(r.projects.flatMap((p) => p.meta.branches ?? []))], meta: r.projects.find((p) => p.project === L.project)?.meta ?? r.projects[0]?.meta ?? {} }]));
25
26
  const groups = new Map();
26
27
  for (const a of collect(root, { allProjects: true })) {
27
28
  const id = a.requirement ? `req:${a.requirement}` : `branch:${a.branch ?? '(无分支)'}`;
@@ -29,7 +30,7 @@ export function viewData(root) {
29
30
  const m = a.requirement ? metas.get(a.requirement) : null;
30
31
  groups.set(id, {
31
32
  id, name: m?.name ?? (a.requirement ?? a.branch ?? '(无分支)'),
32
- dir: m?.dir ?? (a.requirement && L.mode === 'repo' ? `${L.repo_name}:docs/requirements/${a.requirement}` : null), named_by: m?.meta?.named_by ?? null, branches: new Set(m?.branches ?? []), projects: new Set(), artifacts: [],
33
+ dir: m?.dir ?? (a.requirement ? reqDirOf(a.requirement) : null), named_by: m?.meta?.named_by ?? null, branches: new Set(m?.branches ?? []), projects: new Set(), artifacts: [],
33
34
  });
34
35
  }
35
36
  const g = groups.get(id);