jsharness 1.0.0 → 1.0.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 +14 -4
  2. package/package.json +1 -1
package/lib/index.mjs CHANGED
@@ -769,10 +769,20 @@ function findHarnessSource(projectDir) {
769
769
  const localHarness = path.join(projectDir, '.harness');
770
770
  if (fs.existsSync(localHarness)) return localHarness;
771
771
 
772
- // 2. npm 包内的 harness(当本包被安装后)
773
- // __dirname 指向 lib/,向上两级到包根,再到 .harness/
774
- const packageHarness = path.join(__dirname, '..', '..', '.harness');
775
- if (fs.existsSync(packageHarness)) return packageHarness;
772
+ // 2. npm 包内的 harness — 通过 package.json 定位包根(兼容 npm install / global)
773
+ try {
774
+ const require = createRequire(import.meta.url);
775
+ const pkgPath = require.resolve('jsharness/package.json');
776
+ const pkgRoot = path.dirname(pkgPath);
777
+ const packageHarness = path.join(pkgRoot, '.harness');
778
+ if (fs.existsSync(packageHarness)) return packageHarness;
779
+ } catch {
780
+ // jsharness 未作为依赖安装时跳过
781
+ }
782
+
783
+ // 3. 本地开发模式 fallback(lib/ → 包根 → .harness/)
784
+ const devHarness = path.join(__dirname, '..', '..', '.harness');
785
+ if (fs.existsSync(devHarness)) return devHarness;
776
786
 
777
787
  return null;
778
788
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"jsharness","version":"1.0.0","description":"Harness Engineering - AI 编程行为工程化管控系统。将 rules/skills/gate/agents 一键注入到 CodeBuddy、Cursor、Copilot 等 AI 工具中。","main":"lib/index.mjs","bin":{"jsharness":"./bin/jsharness.js"},"type":"module","scripts":{"jsharness":"node bin/jsharness.js","init":"node bin/jsharness.js init","list-tools":"node bin/jsharness.js list-tools","status":"node bin/jsharness.js status","test":"node bin/jsharness.js status"},"keywords":["harness","ai-coding","codebuddy","cursor","copilot","rules-engineering","ai-assistant","vue3","spring-boot"],"author":"","license":"ISC","engines":{"node":">=18.0.0"},"files":["bin/","lib/",".harness/","README.md"],"dependencies":{"commander":"^12.1.0"},"devDependencies":{"openspec":"^0.0.0","webpack":"^5.107.0","webpack-cli":"^7.0.2"},"repository":{"type":"git","url":""},"homepage":""}
1
+ {"name":"jsharness","version":"1.0.1","description":"Harness Engineering - AI 编程行为工程化管控系统。将 rules/skills/gate/agents 一键注入到 CodeBuddy、Cursor、Copilot 等 AI 工具中。","main":"lib/index.mjs","bin":{"jsharness":"./bin/jsharness.js"},"type":"module","scripts":{"jsharness":"node bin/jsharness.js","init":"node bin/jsharness.js init","list-tools":"node bin/jsharness.js list-tools","status":"node bin/jsharness.js status","test":"node bin/jsharness.js status"},"keywords":["harness","ai-coding","codebuddy","cursor","copilot","rules-engineering","ai-assistant","vue3","spring-boot"],"author":"","license":"ISC","engines":{"node":">=18.0.0"},"files":["bin/","lib/",".harness/","README.md"],"dependencies":{"commander":"^12.1.0"},"devDependencies":{"openspec":"^0.0.0","webpack":"^5.107.0","webpack-cli":"^7.0.2"},"repository":{"type":"git","url":""},"homepage":""}