@rowansenne/workflow-run 0.31.0 → 0.31.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.31.1] - 2026-11-02
8
+
9
+ ### 修复
10
+ - 模板导入前检查 DocNexus 已登记文件;发现缺失时列出文件路径和记录 ID,停止本轮模板导入/更新,不再误按新建触发 target_changed,也不自动恢复文件或修改记录。
11
+
7
12
  ## [0.31.0] - 2026-10-31
8
13
 
9
14
  ### 文档
@@ -80,7 +80,21 @@ const pick = (skills) => (skills ? TEMPLATES.filter((t) => skills.includes(t.ski
80
80
  export function seedTemplates(root, tplDir, { ok = console.log, warn = console.error, version = '', skills, quietSkip = false } = {}) {
81
81
  requireDocNexus(root);
82
82
  const result = { seeded: [], skipped: [], failed: [], records: {} };
83
- for (const t of pick(skills)) {
83
+ const templates = pick(skills);
84
+ // DocNexus 写入会校验所有已登记正文;缺文件时只报告,不自动恢复或继续写入。
85
+ if (templates.some((t) => !fs.existsSync(libFile(root, t)))) {
86
+ const dir = path.join(docnexusWorkspace(root), 'records');
87
+ for (const entry of fs.existsSync(dir) ? fs.readdirSync(dir, { withFileTypes: true }) : []) {
88
+ if (!entry.isDirectory()) continue;
89
+ const record = JSON.parse(fs.readFileSync(path.join(dir, entry.name, 'record.json'), 'utf8'));
90
+ const file = path.join(docnexusWorkspace(root), 'library', record.file_path);
91
+ if (fs.existsSync(file)) continue;
92
+ const error = `缺少 DocNexus 已登记文件:${file}(记录:${record.id});请核对文件位置后重试`;
93
+ result.failed.push({ file: record.file_path, error }); warn(error);
94
+ }
95
+ if (result.failed.length) return result;
96
+ }
97
+ for (const t of templates) {
84
98
  if (fs.existsSync(libFile(root, t))) {
85
99
  result.skipped.push(t.file);
86
100
  if (!quietSkip) ok(`DocNexus 中已有 ${t.file},保留不覆盖`);
@@ -170,7 +170,7 @@ async function main() {
170
170
  const r = seedTemplates(o.root, TPL_DIR, { ok, warn, version: PKG.version, skills: installedSkills(o.root) });
171
171
  saveTemplateRecords(o.root, r.records);
172
172
  let failed = r.failed.length;
173
- if (o.update) {
173
+ if (o.update && !failed) {
174
174
  step('更新导入后未改动的模板(--update)');
175
175
  const u = updateTemplates(o.root, TPL_DIR, templateRecords(o.root), { ok, warn, version: PKG.version, skills: installedSkills(o.root) });
176
176
  saveTemplateRecords(o.root, u.records);
@@ -161,6 +161,7 @@ npx @rowansenne/workflow-run seed-templates --diff # 团队改过
161
161
  ```
162
162
 
163
163
  * 只导入 DocNexus 里还没有的、有默认版本的模板(技术方案、上线方案不在内),已有的不覆盖;项目已接入但缺模板时,安装结束会列出缺哪几份。
164
+ * 若已有 DocNexus 记录对应的文件缺失,会列出缺失文件路径和记录 ID,并停止本轮模板导入/更新,供用户核对文件位置;不自动恢复文件、不修改记录。
164
165
  * 之后模板随知识库更新:直接编辑 `workflow-run/docnexus/library/templates/...` 后在业务项目根执行 `./.docnexus/node_modules/.bin/docnexus document sync --id <id>` 采纳;或者在生成文档后,skill 发现你做了结构性调整时会提议同步回模板(你确认后才写入)。每次变更都记录在 DocNexus 的 timeline 里,可追溯。
165
166
  * 模板里的 `{{...}}` 是给 agent 的填写提示,DocNexus 原样保存;不要写成单独一行的 `{{fact:...}}`(那是 DocNexus 的事实引用语法)。
166
167
  * 以前放在 `workflow-run/templates/` 下的项目模板:接入 DocNexus 后,缺模板时 skill 会把它作为 `import_from` 提议导入知识库;导入后删除这些文件。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowansenne/workflow-run",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "项目级 Agent Skills 一键初始化:workflow / dev / project-review / code-graph / database-query / nacos-config / md-to-wiki / 需求文档与技术上线方案生成",
5
5
  "keywords": [
6
6
  "agent-skills",