svharness 0.14.8 → 0.14.9
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/commands/init.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -22,7 +55,7 @@ const harness_name_1 = require("../utils/harness-name");
|
|
|
22
55
|
const yaml_safe_path_1 = require("../utils/yaml-safe-path");
|
|
23
56
|
const harness_yaml_baseline_1 = require("../core/harness-yaml-baseline");
|
|
24
57
|
const repomix_apply_hint_1 = require("../core/repomix-apply-hint");
|
|
25
|
-
const
|
|
58
|
+
const repomix_pack_path_1 = require("../core/repomix-pack-path");
|
|
26
59
|
const extra_assets_intake_1 = require("../core/extra-assets-intake");
|
|
27
60
|
const baseline_copy_1 = require("../utils/baseline-copy");
|
|
28
61
|
const doc_intake_paths_1 = require("../core/doc-intake-paths");
|
|
@@ -189,7 +222,7 @@ async function runInit(opts) {
|
|
|
189
222
|
configItems.push({
|
|
190
223
|
label: 'Repomix 基线包',
|
|
191
224
|
value: enableRepomix
|
|
192
|
-
? `启用(${(0,
|
|
225
|
+
? `启用(${(0, repomix_pack_path_1.repomixPackRelFile)()})`
|
|
193
226
|
: '关闭(默认;大基线整库快照/单文件工具/留档时再 --repomix)',
|
|
194
227
|
});
|
|
195
228
|
}
|
|
@@ -384,14 +417,15 @@ async function runInit(opts) {
|
|
|
384
417
|
'请检查基线拷贝结果(黑名单/大小上限可能过滤掉了所有文件)。');
|
|
385
418
|
}
|
|
386
419
|
}
|
|
387
|
-
const
|
|
420
|
+
const { runRepomixPackBaseline } = await Promise.resolve().then(() => __importStar(require('../core/repomix-pack')));
|
|
421
|
+
const outAbs = await runRepomixPackBaseline({
|
|
388
422
|
packRootFs,
|
|
389
423
|
harnessRootFs: targetRoot,
|
|
390
424
|
onLog: (m) => logger_1.logger.info(` ${m}`),
|
|
391
425
|
});
|
|
392
426
|
logger_1.logger.success(`baseline Repomix 已生成:${node_path_1.default.relative(targetRoot, outAbs)}`);
|
|
393
427
|
repomixGenerated = true;
|
|
394
|
-
await (0, harness_yaml_baseline_1.setBaselineRepomixPack)(targetRoot, (0,
|
|
428
|
+
await (0, harness_yaml_baseline_1.setBaselineRepomixPack)(targetRoot, (0, repomix_pack_path_1.repomixPackRelFile)());
|
|
395
429
|
logger_1.logger.info(`已更新 harness.yaml:baseline.repomix_pack`);
|
|
396
430
|
const agentsApplyPath = node_path_1.default.join(targetRoot, 'AGENTS_APPLY.md');
|
|
397
431
|
if (await fs_extra_1.default.pathExists(agentsApplyPath)) {
|
package/dist/core/next-steps.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.printNextSteps = printNextSteps;
|
|
7
7
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
-
const
|
|
8
|
+
const repomix_pack_path_1 = require("./repomix-pack-path");
|
|
9
9
|
/**
|
|
10
10
|
* Print a human-friendly "what to do next" block after init succeeds.
|
|
11
11
|
*/
|
|
@@ -62,7 +62,7 @@ function printNextSteps(input) {
|
|
|
62
62
|
lines.push('');
|
|
63
63
|
if (input.repomixGenerated) {
|
|
64
64
|
lines.push(picocolors_1.default.bold('Baseline Repomix(XML)'));
|
|
65
|
-
lines.push(' 输出文件: ' + picocolors_1.default.cyan((0,
|
|
65
|
+
lines.push(' 输出文件: ' + picocolors_1.default.cyan((0, repomix_pack_path_1.repomixPackRelFile)()));
|
|
66
66
|
lines.push('');
|
|
67
67
|
}
|
|
68
68
|
else if (input.hasSource) {
|
|
@@ -74,7 +74,7 @@ function printNextSteps(input) {
|
|
|
74
74
|
lines.push(' 启用:重新 build 并加 ' +
|
|
75
75
|
picocolors_1.default.cyan('--repomix') +
|
|
76
76
|
'(须保留 --baseline)→ ' +
|
|
77
|
-
picocolors_1.default.cyan((0,
|
|
77
|
+
picocolors_1.default.cyan((0, repomix_pack_path_1.repomixPackRelFile)()));
|
|
78
78
|
lines.push(' 说明:svharnessbuild README「Repomix」');
|
|
79
79
|
lines.push('');
|
|
80
80
|
}
|
|
@@ -11,7 +11,7 @@ exports.applyRepomixHintPlaceholder = applyRepomixHintPlaceholder;
|
|
|
11
11
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
12
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
13
|
const harness_yaml_baseline_1 = require("./harness-yaml-baseline");
|
|
14
|
-
const
|
|
14
|
+
const repomix_pack_path_1 = require("./repomix-pack-path");
|
|
15
15
|
exports.REPOMIX_APPLY_HINT_PLACEHOLDER = '__REPOMIX_APPLY_HINT__';
|
|
16
16
|
/**
|
|
17
17
|
* Resolve Repomix pack path relative to harness root: harness.yaml field first, then file existence.
|
|
@@ -24,7 +24,7 @@ async function resolveRepomixPackRel(harnessRoot) {
|
|
|
24
24
|
if (await fs_extra_1.default.pathExists(abs))
|
|
25
25
|
return fromYaml;
|
|
26
26
|
}
|
|
27
|
-
const defaultRel = (0,
|
|
27
|
+
const defaultRel = (0, repomix_pack_path_1.repomixPackRelFile)();
|
|
28
28
|
const defaultAbs = node_path_1.default.join(harnessRoot, defaultRel);
|
|
29
29
|
if (await fs_extra_1.default.pathExists(defaultAbs))
|
|
30
30
|
return defaultRel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.REPOMIX_PACK_FILENAME = exports.REPOMIX_BASELINE_REL_DIR = void 0;
|
|
7
|
+
exports.repomixPackRelFile = repomixPackRelFile;
|
|
8
|
+
/**
|
|
9
|
+
* Repomix output paths (no dependency on the repomix package).
|
|
10
|
+
* Keeps CLI startup free of ESM-only `repomix` when `--repomix` is not used.
|
|
11
|
+
*/
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
/** Relative to harness root: `baseline/repomix/repomix-pack.xml`. */
|
|
14
|
+
exports.REPOMIX_BASELINE_REL_DIR = node_path_1.default.join('baseline', 'repomix');
|
|
15
|
+
exports.REPOMIX_PACK_FILENAME = 'repomix-pack.xml';
|
|
16
|
+
function repomixPackRelFile() {
|
|
17
|
+
return node_path_1.default.join(exports.REPOMIX_BASELINE_REL_DIR, exports.REPOMIX_PACK_FILENAME).replace(/\\/g, '/');
|
|
18
|
+
}
|
|
@@ -3,22 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.REPOMIX_PACK_FILENAME = exports.REPOMIX_BASELINE_REL_DIR = void 0;
|
|
7
|
-
exports.repomixPackRelFile = repomixPackRelFile;
|
|
6
|
+
exports.repomixPackRelFile = exports.REPOMIX_PACK_FILENAME = exports.REPOMIX_BASELINE_REL_DIR = void 0;
|
|
8
7
|
exports.runRepomixPackBaseline = runRepomixPackBaseline;
|
|
9
8
|
/**
|
|
10
9
|
* Optional baseline snapshot via Repomix (single XML under `baseline/repomix/`).
|
|
11
10
|
* Enabled only when `svharness build --repomix` is passed with `--baseline`.
|
|
12
11
|
* Complements `baseline/code/` (per-file references); see svharnessbuild README § Repomix.
|
|
12
|
+
*
|
|
13
|
+
* Repomix 1.x is ESM-only; load it via dynamic import() so CommonJS svharness works on Node 18/20.
|
|
13
14
|
*/
|
|
14
15
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
15
16
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
exports
|
|
19
|
-
exports
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const repomix_pack_path_1 = require("./repomix-pack-path");
|
|
18
|
+
Object.defineProperty(exports, "REPOMIX_BASELINE_REL_DIR", { enumerable: true, get: function () { return repomix_pack_path_1.REPOMIX_BASELINE_REL_DIR; } });
|
|
19
|
+
Object.defineProperty(exports, "REPOMIX_PACK_FILENAME", { enumerable: true, get: function () { return repomix_pack_path_1.REPOMIX_PACK_FILENAME; } });
|
|
20
|
+
Object.defineProperty(exports, "repomixPackRelFile", { enumerable: true, get: function () { return repomix_pack_path_1.repomixPackRelFile; } });
|
|
21
|
+
/** Native ESM import(); TS "module": "commonjs" would otherwise emit require("repomix"). */
|
|
22
|
+
function importRepomixEsm() {
|
|
23
|
+
return new Function('return import("repomix")')();
|
|
24
|
+
}
|
|
25
|
+
async function loadRepomixRunCli() {
|
|
26
|
+
const mod = await importRepomixEsm();
|
|
27
|
+
return mod.runCli;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Pack `packRootFs` with Repomix (library `runCli`) and write XML to
|
|
@@ -26,9 +32,9 @@ function repomixPackRelFile() {
|
|
|
26
32
|
*/
|
|
27
33
|
async function runRepomixPackBaseline(opts) {
|
|
28
34
|
const { packRootFs, harnessRootFs, onLog } = opts;
|
|
29
|
-
const outDir = node_path_1.default.join(harnessRootFs,
|
|
35
|
+
const outDir = node_path_1.default.join(harnessRootFs, repomix_pack_path_1.REPOMIX_BASELINE_REL_DIR);
|
|
30
36
|
await fs_extra_1.default.ensureDir(outDir);
|
|
31
|
-
const outAbs = node_path_1.default.join(outDir,
|
|
37
|
+
const outAbs = node_path_1.default.join(outDir, repomix_pack_path_1.REPOMIX_PACK_FILENAME);
|
|
32
38
|
await fs_extra_1.default.remove(outAbs).catch(() => undefined);
|
|
33
39
|
const cliOptions = {
|
|
34
40
|
style: 'xml',
|
|
@@ -41,10 +47,12 @@ async function runRepomixPackBaseline(opts) {
|
|
|
41
47
|
};
|
|
42
48
|
onLog?.(`[repomix] cwd=${packRootFs}`);
|
|
43
49
|
onLog?.(`[repomix] output=${outAbs}`);
|
|
50
|
+
const runCli = await loadRepomixRunCli();
|
|
44
51
|
try {
|
|
45
|
-
const result = await
|
|
52
|
+
const result = await runCli(['.'], packRootFs, cliOptions);
|
|
46
53
|
if (result && typeof result === 'object' && 'packResult' in result) {
|
|
47
|
-
const pr = result
|
|
54
|
+
const pr = result
|
|
55
|
+
.packResult;
|
|
48
56
|
onLog?.(`[repomix] done: ${pr.totalFiles} files, ${pr.totalTokens} tokens, ${pr.totalCharacters} chars`);
|
|
49
57
|
}
|
|
50
58
|
}
|