jsharness 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/lib/index.mjs +8 -6
  2. package/package.json +1 -1
package/lib/index.mjs CHANGED
@@ -1095,7 +1095,13 @@ function findHarnessSource(projectDir) {
1095
1095
  const localHarness = path.join(projectDir, '.harness');
1096
1096
  if (fs.existsSync(localHarness)) return localHarness;
1097
1097
 
1098
- // 2. 通过 node_modules 查找(npm i -D jsharness 后)
1098
+ // 2. 本包自身的 .harness/(最可靠:基于 lib/index.mjs 的位置定位)
1099
+ // lib/index.mjs 所在目录 = <pkg_root>/lib/
1100
+ // 所以 .harness/ 在 <pkg_root>/.harness/ 即 __dirname/../.harness
1101
+ const selfHarness = path.join(__dirname, '..', '.harness');
1102
+ if (fs.existsSync(selfHarness)) return selfHarness;
1103
+
1104
+ // 3. 通过 node_modules 查找(npm i -D jsharness 后)
1099
1105
  const nmCandidates = [
1100
1106
  path.join(projectDir, 'node_modules', 'jsharness', '.harness'),
1101
1107
  path.join(projectDir, 'node_modules', '.pnpm', 'jsharness*', 'node_modules', 'jsharness', '.harness'),
@@ -1111,7 +1117,7 @@ function findHarnessSource(projectDir) {
1111
1117
  } catch { /* skip */ }
1112
1118
  }
1113
1119
 
1114
- // 3. 通过 require.resolve 定位 npm 包根
1120
+ // 4. 通过 require.resolve 定位 npm 包根
1115
1121
  try {
1116
1122
  const _require = createRequire(import.meta.url);
1117
1123
  const pkgPath = _require.resolve('jsharness/package.json');
@@ -1121,10 +1127,6 @@ function findHarnessSource(projectDir) {
1121
1127
  // require 解析失败,继续尝试其他方式
1122
1128
  }
1123
1129
 
1124
- // 4. __dirname 相对路径(本地开发模式)
1125
- const devHarness = path.join(__dirname, '..', '..', '.harness');
1126
- if (fs.existsSync(devHarness)) return devHarness;
1127
-
1128
1130
  // 5. 最后尝试:沿 __dirname 向上搜索 .harness
1129
1131
  let current = __dirname;
1130
1132
  for (let i = 0; i < 5; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsharness",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Harness Engineering - AI 编程行为工程化管控系统。将 rules/skills/gate/agents 一键注入到 CodeBuddy、Cursor、Copilot 等 AI 工具中。",
5
5
  "main": "lib/index.mjs",
6
6
  "bin": {