jsharness 1.0.1 → 1.0.2
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/bin/jsharness.js +1 -1
- package/lib/index.mjs +44 -8
- package/package.json +1 -1
package/bin/jsharness.js
CHANGED
package/lib/index.mjs
CHANGED
|
@@ -611,7 +611,18 @@ export async function runInit(projectDir, options = {}) {
|
|
|
611
611
|
// 1. 确定 Harness 源路径
|
|
612
612
|
const harnessDir = findHarnessSource(projectDir);
|
|
613
613
|
if (!harnessDir) {
|
|
614
|
-
console.error('❌ 未找到 .harness/
|
|
614
|
+
console.error('❌ 未找到 .harness/ 目录。');
|
|
615
|
+
console.error('');
|
|
616
|
+
console.error(' 请先安装 jsharness:');
|
|
617
|
+
console.error(' npm i -D jsharness');
|
|
618
|
+
console.error('');
|
|
619
|
+
console.error(' 然后重新运行:');
|
|
620
|
+
console.error(' npx jsharness init --verbose');
|
|
621
|
+
console.error('');
|
|
622
|
+
// 输出调试信息
|
|
623
|
+
const nmPath = path.join(projectDir, 'node_modules', 'jsharness', '.harness');
|
|
624
|
+
console.error(` [DEBUG] 项目目录: ${projectDir}`);
|
|
625
|
+
console.error(` [DEBUG] node_modules/jsharness/.harness 存在: ${fs.existsSync(nmPath) ? '是' : '否'}`);
|
|
615
626
|
process.exit(1);
|
|
616
627
|
}
|
|
617
628
|
if (verbose) console.log(` 📂 Harness 源: ${harnessDir}`);
|
|
@@ -769,20 +780,45 @@ function findHarnessSource(projectDir) {
|
|
|
769
780
|
const localHarness = path.join(projectDir, '.harness');
|
|
770
781
|
if (fs.existsSync(localHarness)) return localHarness;
|
|
771
782
|
|
|
772
|
-
// 2.
|
|
783
|
+
// 2. 通过 node_modules 查找(npm i -D jsharness 后)
|
|
784
|
+
const nmCandidates = [
|
|
785
|
+
path.join(projectDir, 'node_modules', 'jsharness', '.harness'),
|
|
786
|
+
path.join(projectDir, 'node_modules', '.pnpm', 'jsharness*', 'node_modules', 'jsharness', '.harness'),
|
|
787
|
+
];
|
|
788
|
+
for (const c of nmCandidates) {
|
|
789
|
+
try {
|
|
790
|
+
const expanded = (c.includes('*') ? fs.readdirSync(path.dirname(c))
|
|
791
|
+
.filter(d => d.startsWith('jsharness')).map(d => path.join(path.dirname(c), d, 'node_modules', 'jsharness', '.harness')) : [c])
|
|
792
|
+
.flat();
|
|
793
|
+
for (const p of expanded) {
|
|
794
|
+
if (fs.existsSync(p)) return p;
|
|
795
|
+
}
|
|
796
|
+
} catch { /* skip */ }
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// 3. 通过 require.resolve 定位 npm 包根
|
|
773
800
|
try {
|
|
774
|
-
const
|
|
775
|
-
const pkgPath =
|
|
776
|
-
const
|
|
777
|
-
const packageHarness = path.join(pkgRoot, '.harness');
|
|
801
|
+
const _require = createRequire(import.meta.url);
|
|
802
|
+
const pkgPath = _require.resolve('jsharness/package.json');
|
|
803
|
+
const packageHarness = path.join(path.dirname(pkgPath), '.harness');
|
|
778
804
|
if (fs.existsSync(packageHarness)) return packageHarness;
|
|
779
805
|
} catch {
|
|
780
|
-
//
|
|
806
|
+
// require 解析失败,继续尝试其他方式
|
|
781
807
|
}
|
|
782
808
|
|
|
783
|
-
//
|
|
809
|
+
// 4. __dirname 相对路径(本地开发模式)
|
|
784
810
|
const devHarness = path.join(__dirname, '..', '..', '.harness');
|
|
785
811
|
if (fs.existsSync(devHarness)) return devHarness;
|
|
786
812
|
|
|
813
|
+
// 5. 最后尝试:沿 __dirname 向上搜索 .harness
|
|
814
|
+
let current = __dirname;
|
|
815
|
+
for (let i = 0; i < 5; i++) {
|
|
816
|
+
const candidate = path.join(current, '.harness');
|
|
817
|
+
if (fs.existsSync(candidate) && current !== projectDir) return candidate;
|
|
818
|
+
const parent = path.dirname(current);
|
|
819
|
+
if (parent === current) break;
|
|
820
|
+
current = parent;
|
|
821
|
+
}
|
|
822
|
+
|
|
787
823
|
return null;
|
|
788
824
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"jsharness","version":"1.0.
|
|
1
|
+
{"name":"jsharness","version":"1.0.2","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":""}
|