@andyqiu/codeforge 0.5.21 → 0.5.24

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/dist/adr-init.js CHANGED
@@ -15,7 +15,24 @@ function resolveAssetsRoot() {
15
15
  break;
16
16
  dir = parent;
17
17
  }
18
- throw new Error(`assets/adr-init/ 未找到(从 ${here} 上溯 6 层);` + `如果是 npm 安装请检查 package.json "files" 字段是否包含 "assets/"`);
18
+ const xdgConfig = process.env["XDG_CONFIG_HOME"];
19
+ const homeDir = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
20
+ const fallbackRoots = [
21
+ xdgConfig ? path.join(xdgConfig, "opencode") : null,
22
+ path.join(homeDir, ".config", "opencode"),
23
+ process.env["APPDATA"] ? path.join(process.env["APPDATA"], "opencode") : null,
24
+ process.env["LOCALAPPDATA"] ? path.join(process.env["LOCALAPPDATA"], "opencode") : null
25
+ ].filter(Boolean);
26
+ for (const root of fallbackRoots) {
27
+ const candidate = path.join(root, "assets", "adr-init");
28
+ if (existsSync(candidate)) {
29
+ return candidate;
30
+ }
31
+ }
32
+ throw new Error(`assets/adr-init/ 未找到。已尝试:
33
+ ` + ` 1. 从 ${here} 上溯 6 层
34
+ ` + ` 2. 全局路径:${fallbackRoots.join(", ")}
35
+ ` + `请重装 codeforge:bash install.sh --global`);
19
36
  }
20
37
  function isGitRepo(cwd) {
21
38
  try {
package/dist/index.js CHANGED
@@ -14353,7 +14353,24 @@ function resolveAssetsRoot() {
14353
14353
  break;
14354
14354
  dir = parent;
14355
14355
  }
14356
- throw new Error(`assets/adr-init/ 未找到(从 ${here} 上溯 6 层);` + `如果是 npm 安装请检查 package.json "files" 字段是否包含 "assets/"`);
14356
+ const xdgConfig = process.env["XDG_CONFIG_HOME"];
14357
+ const homeDir = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "";
14358
+ const fallbackRoots = [
14359
+ xdgConfig ? path16.join(xdgConfig, "opencode") : null,
14360
+ path16.join(homeDir, ".config", "opencode"),
14361
+ process.env["APPDATA"] ? path16.join(process.env["APPDATA"], "opencode") : null,
14362
+ process.env["LOCALAPPDATA"] ? path16.join(process.env["LOCALAPPDATA"], "opencode") : null
14363
+ ].filter(Boolean);
14364
+ for (const root of fallbackRoots) {
14365
+ const candidate = path16.join(root, "assets", "adr-init");
14366
+ if (existsSync4(candidate)) {
14367
+ return candidate;
14368
+ }
14369
+ }
14370
+ throw new Error(`assets/adr-init/ 未找到。已尝试:
14371
+ ` + ` 1. 从 ${here} 上溯 6 层
14372
+ ` + ` 2. 全局路径:${fallbackRoots.join(", ")}
14373
+ ` + `请重装 codeforge:bash install.sh --global`);
14357
14374
  }
14358
14375
  function isGitRepo2(cwd) {
14359
14376
  try {
@@ -14544,8 +14561,10 @@ var description29 = [
14544
14561
  "**何时调用**:",
14545
14562
  "- 用户说「给这个项目加 ADR / 装一下 ADR 检查 / 同步一下 ADR 模板」",
14546
14563
  "- 新项目 init 流程中希望把决策记录体系一起带上",
14547
- "**特点**:零 npm 依赖(用 git config core.hooksPath 而非 husky);跟仓库走(提交 .githooks/ 进 git);幂等(默认 skip 已存在文件,--force 自动 .bak.<ts> 备份)",
14548
- "**何时不需要**:当前项目已有完整的 ADR + hooks(默认 skip 行为会保护,但调用本身浪费一次 IO)"
14564
+ "- 已有 ADR 但文件内容不正确时,传 force=true 覆盖修正",
14565
+ "**特点**:零 npm 依赖(用 git config core.hooksPath 而非 husky);跟仓库走(提交 .githooks/ 进 git);幂等(默认 skip 已存在文件,force=true 自动 .bak.<ts> 备份)",
14566
+ "**何时不需要**:当前项目已有完整的 ADR + hooks(默认 skip 行为会保护)",
14567
+ "**\uD83D\uDEAB 失败时严禁绕过**:如果返回 ok=false reason=assets_not_found,必须停止并告知用户重装 codeforge(bash install.sh --global),**绝对不允许手动创建文件替代**——手动创建会产生格式错误的文件(如错误的数字编号前缀),破坏整个项目的 ADR 体系"
14549
14568
  ].join(`
14550
14569
  `);
14551
14570
  var ArgsSchema29 = z30.object({
@@ -16357,7 +16376,8 @@ var codeforgeToolsServer = async (ctx) => {
16357
16376
  const v = projectValidate("adr_init", ArgsSchema29, args);
16358
16377
  if (!v.ok)
16359
16378
  return wrap(JSON.parse(v.output));
16360
- const result = await execute29(v.data);
16379
+ const dataWithCwd = { ...v.data, cwd: v.data.cwd ?? ctx.directory ?? process.cwd() };
16380
+ const result = await execute29(dataWithCwd);
16361
16381
  return wrap(result, { title: "adr_init" });
16362
16382
  });
16363
16383
  }
@@ -21132,7 +21152,7 @@ import * as zlib from "node:zlib";
21132
21152
  // lib/version-injected.ts
21133
21153
  function getInjectedVersion() {
21134
21154
  try {
21135
- const v = "0.5.21";
21155
+ const v = "0.5.24";
21136
21156
  if (typeof v === "string" && /^\d+\.\d+\.\d+/.test(v)) {
21137
21157
  return v;
21138
21158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andyqiu/codeforge",
3
- "version": "0.5.21",
3
+ "version": "0.5.24",
4
4
  "description": "CodeForge — opencode 的零侵入扩展包",
5
5
  "type": "module",
6
6
  "private": false,