@mstar-harness/cli 3.8.0 → 3.8.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/dist/mstar-harness.js +284 -236
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -2432,9 +2432,9 @@ var require_picocolors2 = __commonJS(function(exports, module) {
|
|
|
2432
2432
|
// src/index.ts
|
|
2433
2433
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
2434
2434
|
import { createHash, randomUUID as randomUUID3 } from "crypto";
|
|
2435
|
-
import
|
|
2435
|
+
import fs10 from "fs";
|
|
2436
2436
|
import path14 from "path";
|
|
2437
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2437
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/key.js
|
|
2438
2438
|
var keybindings = ["emacs", "vim"];
|
|
2439
2439
|
var keybindingLookup = new Set(keybindings);
|
|
2440
2440
|
function isKeybinding(value) {
|
|
@@ -2451,7 +2451,7 @@ var isDownKey = (key, keybindings2 = []) => key.name === "down" || keybindings2.
|
|
|
2451
2451
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
2452
2452
|
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
2453
2453
|
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
2454
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2454
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/errors.js
|
|
2455
2455
|
class AbortPromptError extends Error {
|
|
2456
2456
|
name = "AbortPromptError";
|
|
2457
2457
|
message = "Prompt was aborted";
|
|
@@ -2477,10 +2477,10 @@ class HookError extends Error {
|
|
|
2477
2477
|
class ValidationError extends Error {
|
|
2478
2478
|
name = "ValidationError";
|
|
2479
2479
|
}
|
|
2480
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2480
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
2481
2481
|
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
2482
2482
|
|
|
2483
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2483
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
2484
2484
|
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
2485
2485
|
var hookStorage = new AsyncLocalStorage;
|
|
2486
2486
|
function createStore(rl) {
|
|
@@ -2585,7 +2585,7 @@ var effectScheduler = {
|
|
|
2585
2585
|
}
|
|
2586
2586
|
};
|
|
2587
2587
|
|
|
2588
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2588
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
2589
2589
|
function isFactory(value) {
|
|
2590
2590
|
return typeof value === "function";
|
|
2591
2591
|
}
|
|
@@ -2611,7 +2611,7 @@ function useState(defaultValue) {
|
|
|
2611
2611
|
});
|
|
2612
2612
|
}
|
|
2613
2613
|
|
|
2614
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2614
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
2615
2615
|
function useEffect(cb, depArray) {
|
|
2616
2616
|
withPointer((pointer) => {
|
|
2617
2617
|
const oldDeps = pointer.get();
|
|
@@ -2623,7 +2623,7 @@ function useEffect(cb, depArray) {
|
|
|
2623
2623
|
});
|
|
2624
2624
|
}
|
|
2625
2625
|
|
|
2626
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2626
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/theme.js
|
|
2627
2627
|
import { styleText } from "node:util";
|
|
2628
2628
|
|
|
2629
2629
|
// ../../node_modules/.bun/@inquirer+figures@2.0.9/node_modules/@inquirer/figures/dist/index.js
|
|
@@ -2915,7 +2915,7 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
|
2915
2915
|
var dist_default = figures;
|
|
2916
2916
|
var replacements = Object.entries(specialMainSymbols);
|
|
2917
2917
|
|
|
2918
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2918
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/theme.js
|
|
2919
2919
|
var defaultTheme = {
|
|
2920
2920
|
prefix: {
|
|
2921
2921
|
idle: styleText("blue", "?"),
|
|
@@ -2943,7 +2943,7 @@ function getDefaultTheme() {
|
|
|
2943
2943
|
};
|
|
2944
2944
|
}
|
|
2945
2945
|
|
|
2946
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2946
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
2947
2947
|
function isPlainObject(value) {
|
|
2948
2948
|
if (typeof value !== "object" || value === null)
|
|
2949
2949
|
return false;
|
|
@@ -2971,7 +2971,7 @@ function makeTheme(...themes) {
|
|
|
2971
2971
|
return deepMerge(...themesToMerge);
|
|
2972
2972
|
}
|
|
2973
2973
|
|
|
2974
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
2974
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
2975
2975
|
function usePrefix({ status = "idle", theme }) {
|
|
2976
2976
|
const [showLoader, setShowLoader] = useState(false);
|
|
2977
2977
|
const [tick, setTick] = useState(0);
|
|
@@ -3001,7 +3001,7 @@ function usePrefix({ status = "idle", theme }) {
|
|
|
3001
3001
|
const iconName = status === "loading" ? "idle" : status;
|
|
3002
3002
|
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
3003
3003
|
}
|
|
3004
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3004
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
3005
3005
|
function useMemo(fn, dependencies) {
|
|
3006
3006
|
return withPointer((pointer) => {
|
|
3007
3007
|
const prev = pointer.get();
|
|
@@ -3013,11 +3013,11 @@ function useMemo(fn, dependencies) {
|
|
|
3013
3013
|
return prev.value;
|
|
3014
3014
|
});
|
|
3015
3015
|
}
|
|
3016
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3016
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
3017
3017
|
function useRef(val) {
|
|
3018
3018
|
return useState({ current: val })[0];
|
|
3019
3019
|
}
|
|
3020
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3020
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
3021
3021
|
function useKeypress(userHandler) {
|
|
3022
3022
|
const signal = useRef(userHandler);
|
|
3023
3023
|
signal.current = userHandler;
|
|
@@ -3035,7 +3035,7 @@ function useKeypress(userHandler) {
|
|
|
3035
3035
|
};
|
|
3036
3036
|
}, []);
|
|
3037
3037
|
}
|
|
3038
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3038
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/utils.js
|
|
3039
3039
|
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
3040
3040
|
|
|
3041
3041
|
// ../../node_modules/.bun/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
@@ -3379,7 +3379,7 @@ function wrapAnsi(string, columns, options) {
|
|
|
3379
3379
|
`);
|
|
3380
3380
|
}
|
|
3381
3381
|
|
|
3382
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3382
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/utils.js
|
|
3383
3383
|
function breakLines(content, width) {
|
|
3384
3384
|
return content.split(`
|
|
3385
3385
|
`).flatMap((line) => wrapAnsi(line, width, { trim: false, wordWrap: false }).split(`
|
|
@@ -3390,7 +3390,7 @@ function readlineWidth() {
|
|
|
3390
3390
|
return import_cli_width.default({ defaultWidth: 80, output: readline().output });
|
|
3391
3391
|
}
|
|
3392
3392
|
|
|
3393
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3393
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
3394
3394
|
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
3395
3395
|
const state = useRef({
|
|
3396
3396
|
lastPointer: active,
|
|
@@ -3456,7 +3456,7 @@ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
|
3456
3456
|
return pageBuffer.filter((line) => typeof line === "string").join(`
|
|
3457
3457
|
`);
|
|
3458
3458
|
}
|
|
3459
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3459
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
3460
3460
|
var import_mute_stream = __toESM(require_lib(), 1);
|
|
3461
3461
|
import * as readline2 from "node:readline";
|
|
3462
3462
|
import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
@@ -3669,7 +3669,7 @@ var {
|
|
|
3669
3669
|
unload
|
|
3670
3670
|
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
3671
3671
|
|
|
3672
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3672
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
3673
3673
|
import { stripVTControlCharacters } from "node:util";
|
|
3674
3674
|
|
|
3675
3675
|
// ../../node_modules/.bun/@inquirer+ansi@2.0.8/node_modules/@inquirer/ansi/dist/index.js
|
|
@@ -3688,7 +3688,7 @@ var cursorTo = (x, y) => {
|
|
|
3688
3688
|
var eraseLine = ESC2 + "2K";
|
|
3689
3689
|
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
3690
3690
|
|
|
3691
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3691
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
3692
3692
|
var height = (content) => content.split(`
|
|
3693
3693
|
`).length;
|
|
3694
3694
|
var lastLine = (content) => content.split(`
|
|
@@ -3754,7 +3754,7 @@ class ScreenManager {
|
|
|
3754
3754
|
}
|
|
3755
3755
|
}
|
|
3756
3756
|
|
|
3757
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3757
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
3758
3758
|
class PromisePolyfill extends Promise {
|
|
3759
3759
|
static withResolver() {
|
|
3760
3760
|
let resolve;
|
|
@@ -3767,9 +3767,17 @@ class PromisePolyfill extends Promise {
|
|
|
3767
3767
|
}
|
|
3768
3768
|
}
|
|
3769
3769
|
|
|
3770
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3770
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
3771
3771
|
import path from "node:path";
|
|
3772
3772
|
var nativeSetImmediate = globalThis.setImmediate;
|
|
3773
|
+
function listenTo(target, event, listener) {
|
|
3774
|
+
if ("on" in target) {
|
|
3775
|
+
target.on(event, listener);
|
|
3776
|
+
return () => target.removeListener(event, listener);
|
|
3777
|
+
}
|
|
3778
|
+
target.addEventListener(event, listener);
|
|
3779
|
+
return () => target.removeEventListener(event, listener);
|
|
3780
|
+
}
|
|
3773
3781
|
function getCallSites() {
|
|
3774
3782
|
const savedPrepareStackTrace = Error.prepareStackTrace;
|
|
3775
3783
|
let result = [];
|
|
@@ -3801,37 +3809,45 @@ function createPrompt(view) {
|
|
|
3801
3809
|
output.mute();
|
|
3802
3810
|
const screen = new ScreenManager(rl);
|
|
3803
3811
|
const { promise, resolve, reject } = PromisePolyfill.withResolver();
|
|
3804
|
-
const cancel = () => reject(new CancelPromptError);
|
|
3805
|
-
if (signal) {
|
|
3806
|
-
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
3807
|
-
if (signal.aborted) {
|
|
3808
|
-
abort();
|
|
3809
|
-
return Object.assign(promise, { cancel });
|
|
3810
|
-
}
|
|
3811
|
-
signal.addEventListener("abort", abort);
|
|
3812
|
-
cleanups.add(() => signal.removeEventListener("abort", abort));
|
|
3813
|
-
}
|
|
3814
|
-
cleanups.add(onExit((code, signal2) => {
|
|
3815
|
-
reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
|
|
3816
|
-
}));
|
|
3817
|
-
const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
|
|
3818
|
-
rl.on("SIGINT", sigint);
|
|
3819
|
-
cleanups.add(() => rl.removeListener("SIGINT", sigint));
|
|
3820
3812
|
return withHooks(rl, (cycle) => {
|
|
3821
|
-
const
|
|
3822
|
-
|
|
3823
|
-
|
|
3813
|
+
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
3814
|
+
const settlePrompt = (settle) => {
|
|
3815
|
+
try {
|
|
3816
|
+
clearEffects();
|
|
3817
|
+
settle();
|
|
3818
|
+
} catch (error) {
|
|
3819
|
+
reject(error);
|
|
3820
|
+
}
|
|
3821
|
+
};
|
|
3822
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve(value));
|
|
3823
|
+
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
3824
|
+
const promptPromise = Object.assign(promise.finally(() => {
|
|
3825
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
3826
|
+
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
3827
|
+
output.end();
|
|
3828
|
+
}).then(() => promise), { cancel: () => rejectPrompt(new CancelPromptError) });
|
|
3829
|
+
if (signal) {
|
|
3830
|
+
const abort = () => rejectPrompt(new AbortPromptError({ cause: signal.reason }));
|
|
3831
|
+
if (signal.aborted) {
|
|
3832
|
+
abort();
|
|
3833
|
+
return promptPromise;
|
|
3834
|
+
}
|
|
3835
|
+
cleanups.add(listenTo(signal, "abort", abort));
|
|
3836
|
+
}
|
|
3837
|
+
cleanups.add(onExit((code, signal2) => {
|
|
3838
|
+
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
|
|
3839
|
+
}));
|
|
3840
|
+
cleanups.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
|
|
3841
|
+
cleanups.add(listenTo(rl, "close", clearEffects));
|
|
3824
3842
|
const startCycle = () => {
|
|
3825
|
-
|
|
3826
|
-
rl.input.on("keypress", checkCursorPos);
|
|
3827
|
-
cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
|
|
3843
|
+
cleanups.add(listenTo(rl.input, "keypress", () => screen.checkCursorPos()));
|
|
3828
3844
|
let pendingDone = null;
|
|
3829
3845
|
cycle(() => {
|
|
3830
3846
|
let effectsSettled = false;
|
|
3831
3847
|
try {
|
|
3832
3848
|
const nextView = view(config, (value) => {
|
|
3833
3849
|
if (effectsSettled) {
|
|
3834
|
-
|
|
3850
|
+
resolvePrompt(value);
|
|
3835
3851
|
} else {
|
|
3836
3852
|
pendingDone = { value };
|
|
3837
3853
|
}
|
|
@@ -3848,13 +3864,13 @@ function createPrompt(view) {
|
|
|
3848
3864
|
screen.render(content, bottomContent);
|
|
3849
3865
|
effectScheduler.run();
|
|
3850
3866
|
} catch (error) {
|
|
3851
|
-
|
|
3867
|
+
rejectPrompt(error);
|
|
3852
3868
|
}
|
|
3853
3869
|
effectsSettled = true;
|
|
3854
3870
|
if (pendingDone !== null) {
|
|
3855
3871
|
const { value } = pendingDone;
|
|
3856
3872
|
pendingDone = null;
|
|
3857
|
-
|
|
3873
|
+
resolvePrompt(value);
|
|
3858
3874
|
}
|
|
3859
3875
|
});
|
|
3860
3876
|
};
|
|
@@ -3863,22 +3879,12 @@ function createPrompt(view) {
|
|
|
3863
3879
|
} else {
|
|
3864
3880
|
startCycle();
|
|
3865
3881
|
}
|
|
3866
|
-
return
|
|
3867
|
-
effectScheduler.clearAll();
|
|
3868
|
-
return answer;
|
|
3869
|
-
}, (error) => {
|
|
3870
|
-
effectScheduler.clearAll();
|
|
3871
|
-
throw error;
|
|
3872
|
-
}).finally(() => {
|
|
3873
|
-
cleanups.forEach((cleanup) => cleanup());
|
|
3874
|
-
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
3875
|
-
output.end();
|
|
3876
|
-
}).then(() => promise), { cancel });
|
|
3882
|
+
return promptPromise;
|
|
3877
3883
|
});
|
|
3878
3884
|
};
|
|
3879
3885
|
return prompt;
|
|
3880
3886
|
}
|
|
3881
|
-
// ../../node_modules/.bun/@inquirer+core@12.0.
|
|
3887
|
+
// ../../node_modules/.bun/@inquirer+core@12.0.3+72cd8510778f549e/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
3882
3888
|
import { styleText as styleText2 } from "node:util";
|
|
3883
3889
|
class Separator {
|
|
3884
3890
|
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
@@ -3892,7 +3898,7 @@ class Separator {
|
|
|
3892
3898
|
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
3893
3899
|
}
|
|
3894
3900
|
}
|
|
3895
|
-
// ../../node_modules/.bun/@inquirer+select@5.2.
|
|
3901
|
+
// ../../node_modules/.bun/@inquirer+select@5.2.5+72cd8510778f549e/node_modules/@inquirer/select/dist/index.js
|
|
3896
3902
|
import { styleText as styleText3 } from "node:util";
|
|
3897
3903
|
var selectTheme = {
|
|
3898
3904
|
icon: { cursor: dist_default.pointer },
|
|
@@ -9481,6 +9487,7 @@ function harnessVersionFrom(moduleDir) {
|
|
|
9481
9487
|
function readHarnessVersion() {
|
|
9482
9488
|
return harnessVersionFrom(dirname7(fileURLToPath(import.meta.url)));
|
|
9483
9489
|
}
|
|
9490
|
+
var DSH_LLM_FALLBACKS_VERSION = "0.5.2";
|
|
9484
9491
|
var MSTARC_FILE2 = ".mstarc";
|
|
9485
9492
|
var MSTARC_SECTION2 = "config";
|
|
9486
9493
|
var MSTARC_HARNESS_DIR_KEY2 = "harness_dir";
|
|
@@ -12115,7 +12122,67 @@ var cursorAdapter = {
|
|
|
12115
12122
|
};
|
|
12116
12123
|
|
|
12117
12124
|
// src/adapters/dsh.ts
|
|
12125
|
+
import fs5 from "node:fs";
|
|
12118
12126
|
import os4 from "node:os";
|
|
12127
|
+
|
|
12128
|
+
// src/version-compare.ts
|
|
12129
|
+
function splitVersion(v) {
|
|
12130
|
+
const dash = v.indexOf("-");
|
|
12131
|
+
if (dash === -1)
|
|
12132
|
+
return [v, undefined];
|
|
12133
|
+
return [v.slice(0, dash), v.slice(dash + 1)];
|
|
12134
|
+
}
|
|
12135
|
+
function compareCore(a, b) {
|
|
12136
|
+
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
12137
|
+
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
12138
|
+
for (let i = 0;i < 3; i++) {
|
|
12139
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
12140
|
+
if (d !== 0)
|
|
12141
|
+
return d;
|
|
12142
|
+
}
|
|
12143
|
+
return 0;
|
|
12144
|
+
}
|
|
12145
|
+
function comparePrerelease(a, b) {
|
|
12146
|
+
if (a === undefined && b === undefined)
|
|
12147
|
+
return 0;
|
|
12148
|
+
if (a === undefined)
|
|
12149
|
+
return 1;
|
|
12150
|
+
if (b === undefined)
|
|
12151
|
+
return -1;
|
|
12152
|
+
const ia = a.split(".");
|
|
12153
|
+
const ib = b.split(".");
|
|
12154
|
+
const n = Math.min(ia.length, ib.length);
|
|
12155
|
+
for (let i = 0;i < n; i++) {
|
|
12156
|
+
const d = compareIdentifier(ia[i], ib[i]);
|
|
12157
|
+
if (d !== 0)
|
|
12158
|
+
return d;
|
|
12159
|
+
}
|
|
12160
|
+
return ia.length - ib.length;
|
|
12161
|
+
}
|
|
12162
|
+
function compareIdentifier(a, b) {
|
|
12163
|
+
const aNum = /^\d+$/.test(a);
|
|
12164
|
+
const bNum = /^\d+$/.test(b);
|
|
12165
|
+
if (aNum && bNum) {
|
|
12166
|
+
const na = BigInt(a);
|
|
12167
|
+
const nb = BigInt(b);
|
|
12168
|
+
return na < nb ? -1 : na > nb ? 1 : 0;
|
|
12169
|
+
}
|
|
12170
|
+
if (aNum)
|
|
12171
|
+
return -1;
|
|
12172
|
+
if (bNum)
|
|
12173
|
+
return 1;
|
|
12174
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
12175
|
+
}
|
|
12176
|
+
function compareSemver(a, b) {
|
|
12177
|
+
const [coreA, preA] = splitVersion(a);
|
|
12178
|
+
const [coreB, preB] = splitVersion(b);
|
|
12179
|
+
const coreDiff = compareCore(coreA, coreB);
|
|
12180
|
+
if (coreDiff !== 0)
|
|
12181
|
+
return coreDiff;
|
|
12182
|
+
return comparePrerelease(preA, preB);
|
|
12183
|
+
}
|
|
12184
|
+
|
|
12185
|
+
// src/adapters/dsh.ts
|
|
12119
12186
|
import path7 from "node:path";
|
|
12120
12187
|
var DSH_BIN = "dsh";
|
|
12121
12188
|
var DSH_PROFILE = "web";
|
|
@@ -12134,13 +12201,35 @@ function addTimeoutMs() {
|
|
|
12134
12201
|
const parsed = Number(raw);
|
|
12135
12202
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : DSH_ADD_TIMEOUT_MS;
|
|
12136
12203
|
}
|
|
12137
|
-
var
|
|
12138
|
-
var DSH_PLUGIN_SPECS = ["@mstar-harness/dsh", `dsh-llm-fallbacks@${DSH_FALLBACKS_VERSION}`];
|
|
12204
|
+
var DSH_PLUGIN_SPECS = ["@mstar-harness/dsh", `dsh-llm-fallbacks@${DSH_LLM_FALLBACKS_VERSION}`];
|
|
12139
12205
|
var DSH_FALLBACKS_SPEC = DSH_PLUGIN_SPECS[1];
|
|
12140
12206
|
function dshLoaderName(spec) {
|
|
12141
12207
|
const at = spec.lastIndexOf("@");
|
|
12142
12208
|
return at > 0 ? spec.slice(0, at) : spec;
|
|
12143
12209
|
}
|
|
12210
|
+
var DSH_FALLBACKS_LOADER_NAME = dshLoaderName(DSH_FALLBACKS_SPEC);
|
|
12211
|
+
var FALLBACKS_VERSION_SHAPE_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
12212
|
+
function readInstalledFallbacksVersion(profileDir) {
|
|
12213
|
+
const pkgJson = path7.join(profileDir, "node_modules", DSH_FALLBACKS_LOADER_NAME, "package.json");
|
|
12214
|
+
try {
|
|
12215
|
+
const raw = fs5.readFileSync(pkgJson, "utf8");
|
|
12216
|
+
const version = JSON.parse(raw).version;
|
|
12217
|
+
if (typeof version === "string") {
|
|
12218
|
+
const trimmed = version.trim();
|
|
12219
|
+
if (FALLBACKS_VERSION_SHAPE_RE.test(trimmed))
|
|
12220
|
+
return trimmed;
|
|
12221
|
+
}
|
|
12222
|
+
} catch {}
|
|
12223
|
+
return null;
|
|
12224
|
+
}
|
|
12225
|
+
function fallbacksVersionDrifted(profileDir) {
|
|
12226
|
+
if (!FALLBACKS_VERSION_SHAPE_RE.test(DSH_LLM_FALLBACKS_VERSION))
|
|
12227
|
+
return false;
|
|
12228
|
+
const installedVersion = readInstalledFallbacksVersion(profileDir);
|
|
12229
|
+
if (installedVersion === null)
|
|
12230
|
+
return true;
|
|
12231
|
+
return compareSemver(installedVersion, DSH_LLM_FALLBACKS_VERSION) !== 0;
|
|
12232
|
+
}
|
|
12144
12233
|
var DSH_INSTALL_HINT = "Install the DeepSeek Harness CLI (@deepseek-ai/dsh), e.g. `pnpm add -g @deepseek-ai/dsh` or `npm install -g @deepseek-ai/dsh`, then re-run init.";
|
|
12145
12234
|
function runDsh(args, dryRun, timeoutMs) {
|
|
12146
12235
|
return runCliCommand([DSH_BIN, ...args], { dryRun, timeoutMs, env: process.env });
|
|
@@ -12198,14 +12287,18 @@ function runInit2(scope, dryRun, initFlags) {
|
|
|
12198
12287
|
throw new Error(`${DSH_BIN} CLI not found on PATH. ${DSH_INSTALL_HINT}`);
|
|
12199
12288
|
}
|
|
12200
12289
|
const installed = new Set;
|
|
12290
|
+
const disabledLoaderNames = new Set;
|
|
12201
12291
|
if (!dryRun) {
|
|
12202
12292
|
try {
|
|
12203
12293
|
const entries = parseLoaderEntries(runDsh([DSH_PROFILE_FLAG, DSH_PROFILE, DSH_DUMP_FLAG], dryRun, DSH_LOCAL_TIMEOUT_MS));
|
|
12204
12294
|
if (entries === null) {
|
|
12205
12295
|
notes.push("Warning: could not parse installed plugins from dump (unexpected format); proceeding with add (idempotent).");
|
|
12206
12296
|
} else {
|
|
12207
|
-
for (const entry of entries)
|
|
12297
|
+
for (const entry of entries) {
|
|
12208
12298
|
installed.add(entry.name);
|
|
12299
|
+
if (!entry.enabled)
|
|
12300
|
+
disabledLoaderNames.add(entry.name);
|
|
12301
|
+
}
|
|
12209
12302
|
}
|
|
12210
12303
|
} catch (error) {
|
|
12211
12304
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -12218,8 +12311,13 @@ function runInit2(scope, dryRun, initFlags) {
|
|
|
12218
12311
|
continue;
|
|
12219
12312
|
}
|
|
12220
12313
|
if (!dryRun && (installed.has(spec) || installed.has(dshLoaderName(spec)))) {
|
|
12221
|
-
|
|
12222
|
-
|
|
12314
|
+
const isFallbacks = spec === DSH_FALLBACKS_SPEC;
|
|
12315
|
+
const disabledRow = disabledLoaderNames.has(spec) || disabledLoaderNames.has(dshLoaderName(spec));
|
|
12316
|
+
const needsVersionAlign = isFallbacks && fallbacksVersionDrifted(profileDir) && !disabledRow;
|
|
12317
|
+
if (!needsVersionAlign) {
|
|
12318
|
+
notes.push(`skipped-existing: ${spec} (already installed in profile ${DSH_PROFILE})`);
|
|
12319
|
+
continue;
|
|
12320
|
+
}
|
|
12223
12321
|
}
|
|
12224
12322
|
const addArgs = ["plugin", DSH_PROFILE_FLAG, DSH_PROFILE, "add", spec];
|
|
12225
12323
|
if (dryRun) {
|
|
@@ -12263,7 +12361,14 @@ function runDoctor2(scope) {
|
|
|
12263
12361
|
const byName = new Map(entries.map((entry) => [entry.name, entry]));
|
|
12264
12362
|
for (const spec of DSH_PLUGIN_SPECS) {
|
|
12265
12363
|
const entry = byName.get(spec) ?? byName.get(dshLoaderName(spec));
|
|
12266
|
-
|
|
12364
|
+
let state = !entry ? "uninstalled" : entry.enabled ? "mounted" : "disabled";
|
|
12365
|
+
if (spec === DSH_FALLBACKS_SPEC && state === "mounted" && fallbacksVersionDrifted(profileDir)) {
|
|
12366
|
+
const installedVersion = readInstalledFallbacksVersion(profileDir);
|
|
12367
|
+
const installedLabel = installedVersion ?? "unknown";
|
|
12368
|
+
notes.push(`${spec}: drifted (installed ${installedLabel}, pinned ${DSH_LLM_FALLBACKS_VERSION})`);
|
|
12369
|
+
errors2.push(`${spec} is drifted (profile has ${installedLabel}, harness pins ${DSH_LLM_FALLBACKS_VERSION}). Run: mstar-harness init --target dsh`);
|
|
12370
|
+
continue;
|
|
12371
|
+
}
|
|
12267
12372
|
notes.push(`${spec}: ${state}`);
|
|
12268
12373
|
if (state === "mounted")
|
|
12269
12374
|
continue;
|
|
@@ -12283,65 +12388,8 @@ var dshAdapter = {
|
|
|
12283
12388
|
import os5 from "node:os";
|
|
12284
12389
|
import path9 from "node:path";
|
|
12285
12390
|
|
|
12286
|
-
// src/version-compare.ts
|
|
12287
|
-
function splitVersion(v) {
|
|
12288
|
-
const dash = v.indexOf("-");
|
|
12289
|
-
if (dash === -1)
|
|
12290
|
-
return [v, undefined];
|
|
12291
|
-
return [v.slice(0, dash), v.slice(dash + 1)];
|
|
12292
|
-
}
|
|
12293
|
-
function compareCore(a, b) {
|
|
12294
|
-
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
12295
|
-
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
12296
|
-
for (let i = 0;i < 3; i++) {
|
|
12297
|
-
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
12298
|
-
if (d !== 0)
|
|
12299
|
-
return d;
|
|
12300
|
-
}
|
|
12301
|
-
return 0;
|
|
12302
|
-
}
|
|
12303
|
-
function comparePrerelease(a, b) {
|
|
12304
|
-
if (a === undefined && b === undefined)
|
|
12305
|
-
return 0;
|
|
12306
|
-
if (a === undefined)
|
|
12307
|
-
return 1;
|
|
12308
|
-
if (b === undefined)
|
|
12309
|
-
return -1;
|
|
12310
|
-
const ia = a.split(".");
|
|
12311
|
-
const ib = b.split(".");
|
|
12312
|
-
const n = Math.min(ia.length, ib.length);
|
|
12313
|
-
for (let i = 0;i < n; i++) {
|
|
12314
|
-
const d = compareIdentifier(ia[i], ib[i]);
|
|
12315
|
-
if (d !== 0)
|
|
12316
|
-
return d;
|
|
12317
|
-
}
|
|
12318
|
-
return ia.length - ib.length;
|
|
12319
|
-
}
|
|
12320
|
-
function compareIdentifier(a, b) {
|
|
12321
|
-
const aNum = /^\d+$/.test(a);
|
|
12322
|
-
const bNum = /^\d+$/.test(b);
|
|
12323
|
-
if (aNum && bNum) {
|
|
12324
|
-
const na = BigInt(a);
|
|
12325
|
-
const nb = BigInt(b);
|
|
12326
|
-
return na < nb ? -1 : na > nb ? 1 : 0;
|
|
12327
|
-
}
|
|
12328
|
-
if (aNum)
|
|
12329
|
-
return -1;
|
|
12330
|
-
if (bNum)
|
|
12331
|
-
return 1;
|
|
12332
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
12333
|
-
}
|
|
12334
|
-
function compareSemver(a, b) {
|
|
12335
|
-
const [coreA, preA] = splitVersion(a);
|
|
12336
|
-
const [coreB, preB] = splitVersion(b);
|
|
12337
|
-
const coreDiff = compareCore(coreA, coreB);
|
|
12338
|
-
if (coreDiff !== 0)
|
|
12339
|
-
return coreDiff;
|
|
12340
|
-
return comparePrerelease(preA, preB);
|
|
12341
|
-
}
|
|
12342
|
-
|
|
12343
12391
|
// src/adapters/omp.ts
|
|
12344
|
-
import
|
|
12392
|
+
import fs6 from "node:fs";
|
|
12345
12393
|
import path8 from "node:path";
|
|
12346
12394
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
12347
12395
|
var OMP_PACKAGE_REL = path8.join("packages", "omp");
|
|
@@ -12414,28 +12462,28 @@ function findInstalledPlugin(plugins) {
|
|
|
12414
12462
|
function validatePluginTree(pluginRoot) {
|
|
12415
12463
|
const errors2 = [];
|
|
12416
12464
|
const markerPath = path8.join(pluginRoot, "plugin.json");
|
|
12417
|
-
if (!
|
|
12465
|
+
if (!fs6.existsSync(markerPath)) {
|
|
12418
12466
|
errors2.push(`Missing omp plugin marker: ${markerPath}`);
|
|
12419
12467
|
}
|
|
12420
12468
|
for (const skill of SKILL_SMOKE) {
|
|
12421
12469
|
const skillPath = path8.join(pluginRoot, "skills", skill, "SKILL.md");
|
|
12422
|
-
if (!
|
|
12470
|
+
if (!fs6.existsSync(skillPath))
|
|
12423
12471
|
errors2.push(`Missing skill: ${skillPath}`);
|
|
12424
12472
|
}
|
|
12425
12473
|
for (const command of COMMAND_SMOKE) {
|
|
12426
12474
|
const commandPath = path8.join(pluginRoot, "commands", `${command}.md`);
|
|
12427
|
-
if (!
|
|
12475
|
+
if (!fs6.existsSync(commandPath))
|
|
12428
12476
|
errors2.push(`Missing command: ${commandPath}`);
|
|
12429
12477
|
}
|
|
12430
12478
|
const hostRef = path8.join(pluginRoot, "skills", "mstar-host", "references", "omp.md");
|
|
12431
|
-
if (!
|
|
12479
|
+
if (!fs6.existsSync(hostRef))
|
|
12432
12480
|
errors2.push(`Missing omp host reference: ${hostRef}`);
|
|
12433
12481
|
return errors2;
|
|
12434
12482
|
}
|
|
12435
12483
|
function runInit3(scope, dryRun) {
|
|
12436
12484
|
const notes = ensureLocalHarnessRepo(dryRun);
|
|
12437
12485
|
const projectRoot = resolveProjectRoot2();
|
|
12438
|
-
if (
|
|
12486
|
+
if (fs6.existsSync(path8.join(HARNESS_REPO_PATH, ".git"))) {
|
|
12439
12487
|
if (dryRun) {
|
|
12440
12488
|
notes.push(`Would update local harness repo: git -C ${HARNESS_REPO_PATH} pull --ff-only`);
|
|
12441
12489
|
} else {
|
|
@@ -12455,7 +12503,7 @@ function runInit3(scope, dryRun) {
|
|
|
12455
12503
|
notes.push("omp CLI not found on PATH. Install Oh My Pi (`omp`), then re-run init or manually: omp plugin install @mstar-harness/omp");
|
|
12456
12504
|
} else {
|
|
12457
12505
|
const ompPackagePath = path8.join(HARNESS_REPO_PATH, OMP_PACKAGE_REL);
|
|
12458
|
-
if (!dryRun && !
|
|
12506
|
+
if (!dryRun && !fs6.existsSync(path8.join(ompPackagePath, "plugin.json"))) {
|
|
12459
12507
|
try {
|
|
12460
12508
|
runCliCommand(["bun", "install"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
12461
12509
|
runCliCommand(["bun", "run", "engine:build"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
@@ -12546,7 +12594,7 @@ function runDoctor3(scope) {
|
|
|
12546
12594
|
if (scope === "project") {
|
|
12547
12595
|
const projectRoot = resolveProjectRoot2();
|
|
12548
12596
|
const gitignorePath = path8.join(projectRoot, ".gitignore");
|
|
12549
|
-
const gitignore =
|
|
12597
|
+
const gitignore = fs6.existsSync(gitignorePath) ? fs6.readFileSync(gitignorePath, "utf8") : "";
|
|
12550
12598
|
for (const entry of missingHarnessProcessGitignoreEntries(gitignore)) {
|
|
12551
12599
|
errors2.push(`Missing .gitignore entry: ${entry}`);
|
|
12552
12600
|
}
|
|
@@ -12723,7 +12771,7 @@ var opencodeAdapter = {
|
|
|
12723
12771
|
};
|
|
12724
12772
|
|
|
12725
12773
|
// src/adapters/zcode.ts
|
|
12726
|
-
import
|
|
12774
|
+
import fs7 from "node:fs";
|
|
12727
12775
|
import os7 from "node:os";
|
|
12728
12776
|
import path11 from "node:path";
|
|
12729
12777
|
var MARKETPLACE_ID = "mstar-local";
|
|
@@ -12799,7 +12847,7 @@ function findMarketplacePlugin(raw) {
|
|
|
12799
12847
|
}
|
|
12800
12848
|
function validateMarketplaceJson() {
|
|
12801
12849
|
const errors2 = [];
|
|
12802
|
-
if (!
|
|
12850
|
+
if (!fs7.existsSync(MARKETPLACE_JSON_PATH)) {
|
|
12803
12851
|
errors2.push(`Missing ZCode marketplace: ${MARKETPLACE_JSON_PATH}`);
|
|
12804
12852
|
return errors2;
|
|
12805
12853
|
}
|
|
@@ -12824,7 +12872,7 @@ function validateMarketplaceJson() {
|
|
|
12824
12872
|
}
|
|
12825
12873
|
function validateKnownMarketplaces() {
|
|
12826
12874
|
const errors2 = [];
|
|
12827
|
-
if (!
|
|
12875
|
+
if (!fs7.existsSync(KNOWN_MARKETPLACES_PATH)) {
|
|
12828
12876
|
errors2.push(`Missing ZCode known_marketplaces.json: ${KNOWN_MARKETPLACES_PATH}`);
|
|
12829
12877
|
return errors2;
|
|
12830
12878
|
}
|
|
@@ -12848,13 +12896,13 @@ function validateKnownMarketplaces() {
|
|
|
12848
12896
|
function validatePluginAgents2(pluginRoot) {
|
|
12849
12897
|
const errors2 = [];
|
|
12850
12898
|
const agentsDir = path11.join(pluginRoot, "agents");
|
|
12851
|
-
if (!
|
|
12899
|
+
if (!fs7.existsSync(agentsDir)) {
|
|
12852
12900
|
errors2.push(`Missing plugin agents directory: ${agentsDir}`);
|
|
12853
12901
|
return errors2;
|
|
12854
12902
|
}
|
|
12855
12903
|
for (const agentName of ZCODE_AGENT_SMOKE_NAMES) {
|
|
12856
12904
|
const agentPath = path11.join(agentsDir, `${agentName}.md`);
|
|
12857
|
-
if (!
|
|
12905
|
+
if (!fs7.existsSync(agentPath)) {
|
|
12858
12906
|
errors2.push(`Missing plugin agent file: ${agentPath}`);
|
|
12859
12907
|
}
|
|
12860
12908
|
}
|
|
@@ -12878,8 +12926,8 @@ function runInit5(scope, dryRun) {
|
|
|
12878
12926
|
notes.push(`Materialized local ZCode plugin checkout at ${ZCODE_PLUGIN_CHECKOUT_PROJECT} for smoke checks (the registered marketplace still points at the github repo).`);
|
|
12879
12927
|
}
|
|
12880
12928
|
if (!dryRun) {
|
|
12881
|
-
if (!
|
|
12882
|
-
|
|
12929
|
+
if (!fs7.existsSync(MARKETPLACE_DIR))
|
|
12930
|
+
fs7.mkdirSync(MARKETPLACE_DIR, { recursive: true });
|
|
12883
12931
|
writeJson2(MARKETPLACE_JSON_PATH, buildMarketplaceJson());
|
|
12884
12932
|
}
|
|
12885
12933
|
notes.push(`Wrote ZCode marketplace: ${MARKETPLACE_JSON_PATH}`);
|
|
@@ -12902,7 +12950,7 @@ function runDoctor5(scope) {
|
|
|
12902
12950
|
const checkoutPath = path11.join(projectRoot, ZCODE_PLUGIN_CHECKOUT_PROJECT);
|
|
12903
12951
|
errors2.push(...validateGitCheckout(checkoutPath, ZCODE_PLUGIN_MARKER));
|
|
12904
12952
|
const gitignorePath = path11.join(projectRoot, ".gitignore");
|
|
12905
|
-
const gitignore =
|
|
12953
|
+
const gitignore = fs7.existsSync(gitignorePath) ? fs7.readFileSync(gitignorePath, "utf8") : "";
|
|
12906
12954
|
if (!gitignore.split(/\r?\n/).includes(ZCODE_PLUGIN_CHECKOUT_PROJECT)) {
|
|
12907
12955
|
errors2.push(`Missing .gitignore entry: ${ZCODE_PLUGIN_CHECKOUT_PROJECT}`);
|
|
12908
12956
|
}
|
|
@@ -13004,7 +13052,7 @@ function formatCliDoctorNote(detected, expected) {
|
|
|
13004
13052
|
}
|
|
13005
13053
|
|
|
13006
13054
|
// src/plugin-version-alignment.ts
|
|
13007
|
-
import
|
|
13055
|
+
import fs8 from "node:fs";
|
|
13008
13056
|
import os8 from "node:os";
|
|
13009
13057
|
import path12 from "node:path";
|
|
13010
13058
|
var PLUGIN_VERSION_SHAPE_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
@@ -13018,7 +13066,7 @@ function highestVersion(current, candidate) {
|
|
|
13018
13066
|
function versionFromJsonFile(filePath) {
|
|
13019
13067
|
let raw;
|
|
13020
13068
|
try {
|
|
13021
|
-
raw =
|
|
13069
|
+
raw = fs8.readFileSync(filePath, "utf8");
|
|
13022
13070
|
} catch {
|
|
13023
13071
|
return null;
|
|
13024
13072
|
}
|
|
@@ -13043,7 +13091,7 @@ function defaultOpencodePackagesRoot() {
|
|
|
13043
13091
|
function detectOpencodePluginVersion(packagesRoot = defaultOpencodePackagesRoot()) {
|
|
13044
13092
|
let specs;
|
|
13045
13093
|
try {
|
|
13046
|
-
specs =
|
|
13094
|
+
specs = fs8.readdirSync(path12.join(packagesRoot, "@mstar-harness"), { withFileTypes: true });
|
|
13047
13095
|
} catch {
|
|
13048
13096
|
return null;
|
|
13049
13097
|
}
|
|
@@ -13076,7 +13124,7 @@ function readZcodeManifestVersion(versionDir) {
|
|
|
13076
13124
|
function detectZcodePluginVersion(cacheRoot = ZCODE_PLUGINS_CACHE_ROOT2) {
|
|
13077
13125
|
let marketplaceEntries;
|
|
13078
13126
|
try {
|
|
13079
|
-
marketplaceEntries =
|
|
13127
|
+
marketplaceEntries = fs8.readdirSync(cacheRoot, { withFileTypes: true });
|
|
13080
13128
|
} catch {
|
|
13081
13129
|
return null;
|
|
13082
13130
|
}
|
|
@@ -13087,7 +13135,7 @@ function detectZcodePluginVersion(cacheRoot = ZCODE_PLUGINS_CACHE_ROOT2) {
|
|
|
13087
13135
|
const pluginRoot = path12.join(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
13088
13136
|
let versionEntries;
|
|
13089
13137
|
try {
|
|
13090
|
-
versionEntries =
|
|
13138
|
+
versionEntries = fs8.readdirSync(pluginRoot, { withFileTypes: true });
|
|
13091
13139
|
} catch {
|
|
13092
13140
|
continue;
|
|
13093
13141
|
}
|
|
@@ -13123,7 +13171,7 @@ function listDirsToDepth(root, maxDepth) {
|
|
|
13123
13171
|
const visit = (dir, depth) => {
|
|
13124
13172
|
let entries;
|
|
13125
13173
|
try {
|
|
13126
|
-
entries =
|
|
13174
|
+
entries = fs8.readdirSync(dir, { withFileTypes: true });
|
|
13127
13175
|
} catch {
|
|
13128
13176
|
return;
|
|
13129
13177
|
}
|
|
@@ -13236,7 +13284,7 @@ function formatPluginVersionDoctorNote(target, cliVersion, installed) {
|
|
|
13236
13284
|
var SUPPORTED_TARGETS = ["opencode", "cursor", "codex", "zcode", "omp", "dsh", "kimi"];
|
|
13237
13285
|
|
|
13238
13286
|
// src/utils.ts
|
|
13239
|
-
import
|
|
13287
|
+
import fs9 from "node:fs";
|
|
13240
13288
|
import path13 from "node:path";
|
|
13241
13289
|
function parseCsv(raw) {
|
|
13242
13290
|
if (!raw)
|
|
@@ -13262,7 +13310,7 @@ function findUpPackageRoot(startDir, predicate) {
|
|
|
13262
13310
|
let dir = path13.resolve(startDir);
|
|
13263
13311
|
for (;; ) {
|
|
13264
13312
|
try {
|
|
13265
|
-
const manifest = JSON.parse(
|
|
13313
|
+
const manifest = JSON.parse(fs9.readFileSync(joinWithinRoot(dir, "package.json"), "utf8"));
|
|
13266
13314
|
if (predicate(manifest))
|
|
13267
13315
|
return dir;
|
|
13268
13316
|
} catch {}
|
|
@@ -13445,7 +13493,7 @@ function resolvePluginRoot(options) {
|
|
|
13445
13493
|
if (options.root)
|
|
13446
13494
|
return path14.resolve(options.root);
|
|
13447
13495
|
let candidate = resolveProjectRoot3();
|
|
13448
|
-
while (!
|
|
13496
|
+
while (!fs10.existsSync(path14.join(candidate, "plugin.json"))) {
|
|
13449
13497
|
const parent = path14.dirname(candidate);
|
|
13450
13498
|
if (parent === candidate)
|
|
13451
13499
|
break;
|
|
@@ -13515,7 +13563,7 @@ function runScaffold(pathArg) {
|
|
|
13515
13563
|
if (harnessKind === "mstar" && path14.resolve(harnessDir) === mstarDirAtWorkspaceRoot) {
|
|
13516
13564
|
const gitignorePath = workspaceRoot.endsWith(path14.sep) ? `${workspaceRoot}.gitignore` : `${workspaceRoot}${path14.sep}.gitignore`;
|
|
13517
13565
|
const snippet = emitGitignoreSnippet("mstar");
|
|
13518
|
-
const current =
|
|
13566
|
+
const current = fs10.existsSync(gitignorePath) ? fs10.readFileSync(gitignorePath, "utf8") : "";
|
|
13519
13567
|
const lines = new Set(current.split(/\r?\n/).map((line) => line.trim()));
|
|
13520
13568
|
const snippetLines = snippet.split(`
|
|
13521
13569
|
`).map((line) => line.trim());
|
|
@@ -13537,18 +13585,18 @@ function runScaffold(pathArg) {
|
|
|
13537
13585
|
`) ? "" : `
|
|
13538
13586
|
`}.mstarc
|
|
13539
13587
|
`;
|
|
13540
|
-
|
|
13588
|
+
fs10.writeFileSync(gitignorePath, next, "utf8");
|
|
13541
13589
|
} else {
|
|
13542
13590
|
const prefix = current && !current.endsWith(`
|
|
13543
13591
|
`) ? `
|
|
13544
13592
|
` : "";
|
|
13545
|
-
|
|
13593
|
+
fs10.appendFileSync(gitignorePath, `${prefix}${[...missingComments, ...missing].join(`
|
|
13546
13594
|
`)}
|
|
13547
13595
|
`, "utf8");
|
|
13548
13596
|
}
|
|
13549
13597
|
created.push(".gitignore (canonical harness snippet)");
|
|
13550
13598
|
}
|
|
13551
|
-
const finalLines =
|
|
13599
|
+
const finalLines = fs10.readFileSync(gitignorePath, "utf8").split(/\r?\n/);
|
|
13552
13600
|
const broadIndexes = finalLines.map((line, index) => line.trim() === ".mstar/**" ? index : -1).filter((index) => index !== -1);
|
|
13553
13601
|
const canonicalNegationIndexes = finalLines.map((line, index) => CANONICAL_NEGATIONS[line.trim()] === true ? index : -1).filter((index) => index !== -1);
|
|
13554
13602
|
const firstCanonicalNegationIndex = canonicalNegationIndexes[0] ?? -1;
|
|
@@ -13710,7 +13758,7 @@ function runScaffold(pathArg) {
|
|
|
13710
13758
|
finalLines.push("");
|
|
13711
13759
|
}
|
|
13712
13760
|
if (normalized) {
|
|
13713
|
-
|
|
13761
|
+
fs10.writeFileSync(gitignorePath, finalLines.join(`
|
|
13714
13762
|
`), "utf8");
|
|
13715
13763
|
created.push(".gitignore (canonical harness snippet reordered)");
|
|
13716
13764
|
} else if (missing.length === 0) {
|
|
@@ -13721,8 +13769,8 @@ function runScaffold(pathArg) {
|
|
|
13721
13769
|
}
|
|
13722
13770
|
const agentsPath = path14.join(harnessDir, "AGENTS.md");
|
|
13723
13771
|
const agentsLabel = `${path14.basename(harnessDir)}/AGENTS.md`;
|
|
13724
|
-
if (!
|
|
13725
|
-
|
|
13772
|
+
if (!fs10.existsSync(agentsPath)) {
|
|
13773
|
+
fs10.writeFileSync(agentsPath, HARNESS_AGENTS_TEMPLATE, "utf8");
|
|
13726
13774
|
created.push(agentsLabel);
|
|
13727
13775
|
} else {
|
|
13728
13776
|
skipped.push(`${agentsLabel} (already present)`);
|
|
@@ -13796,7 +13844,7 @@ statusCommand.command("validate").description("Validate a v2 status.json root or
|
|
|
13796
13844
|
let statusPath;
|
|
13797
13845
|
try {
|
|
13798
13846
|
statusPath = resolveStatusFilePath(pathArg);
|
|
13799
|
-
if (!
|
|
13847
|
+
if (!fs10.existsSync(statusPath)) {
|
|
13800
13848
|
throw new Error(`status file not found: ${statusPath}`);
|
|
13801
13849
|
}
|
|
13802
13850
|
const gate2 = path14.basename(statusPath) === WORKFLOW_SNAPSHOT_FILE ? validateWorkflowSnapshot(readJson2(statusPath)) : validateStatus(statusPath);
|
|
@@ -13820,7 +13868,7 @@ statusCommand.command("validate").description("Validate a v2 status.json root or
|
|
|
13820
13868
|
statusCommand.command("tech-debt").description("Print the residual tech-debt rollup aggregated over every {PROJECT_DIR}/<id>/residuals.json register " + "(total_open / by_severity / by_target / by_plan; the project register is the source of truth \u2014 " + "no stored-summary drift check, informational exit 0)").argument("[path]", "Project dir (default: resolved {PROJECT_DIR})").action((pathArg) => {
|
|
13821
13869
|
try {
|
|
13822
13870
|
const projectDir = pathArg ? path14.resolve(pathArg) : resolveProjectDir();
|
|
13823
|
-
if (!
|
|
13871
|
+
if (!fs10.existsSync(projectDir)) {
|
|
13824
13872
|
throw new Error(`project dir not found: ${projectDir}`);
|
|
13825
13873
|
}
|
|
13826
13874
|
const rollup = techDebtRollup(projectDir);
|
|
@@ -13839,7 +13887,7 @@ statusCommand.command("findings-cleanup").description("Enforce a plan's findings
|
|
|
13839
13887
|
try {
|
|
13840
13888
|
const projectDir = resolveProjectDir(process.cwd(), options.harness ? { harnessDir: options.harness } : {});
|
|
13841
13889
|
const registerPath = path14.join(projectDir, options.project ?? _DEFAULT_PROJECT, PROJECT_REGISTER_FILE);
|
|
13842
|
-
if (!
|
|
13890
|
+
if (!fs10.existsSync(registerPath)) {
|
|
13843
13891
|
throw new Error(`project register not found: ${registerPath}`);
|
|
13844
13892
|
}
|
|
13845
13893
|
const mode = options.mode === "zero-residual" || options.mode === "allow-residual" ? options.mode : undefined;
|
|
@@ -13959,12 +14007,12 @@ function readPersistPayload(options) {
|
|
|
13959
14007
|
}
|
|
13960
14008
|
if (options.file !== undefined) {
|
|
13961
14009
|
const requested = path14.isAbsolute(options.file) ? options.file : `${process.cwd()}${path14.sep}${options.file}`;
|
|
13962
|
-
if (!
|
|
14010
|
+
if (!fs10.existsSync(requested)) {
|
|
13963
14011
|
throw new Error(`persist payload file not found: ${requested}`);
|
|
13964
14012
|
}
|
|
13965
|
-
return
|
|
14013
|
+
return fs10.readFileSync(requested, "utf8");
|
|
13966
14014
|
}
|
|
13967
|
-
return
|
|
14015
|
+
return fs10.readFileSync(0, "utf8");
|
|
13968
14016
|
}
|
|
13969
14017
|
function validatePersistPayload(kind, payload) {
|
|
13970
14018
|
let gate2;
|
|
@@ -14122,7 +14170,7 @@ leaseCommand.command("verify").description("Verify a plan's execution_lease on t
|
|
|
14122
14170
|
throw new SddScriptError("usage: lease verify --workflow <id> [--plan <plan-id>] [--harness <path>]", 2);
|
|
14123
14171
|
}
|
|
14124
14172
|
const snapshotPath = resolveSnapshotPath(options.workflow, options.harness);
|
|
14125
|
-
if (!
|
|
14173
|
+
if (!fs10.existsSync(snapshotPath)) {
|
|
14126
14174
|
throw new Error(`workflow snapshot not found: ${snapshotPath}`);
|
|
14127
14175
|
}
|
|
14128
14176
|
const doc = readJson2(snapshotPath);
|
|
@@ -14160,7 +14208,7 @@ leaseCommand.command("verify-integration").description("Verify the workflow snap
|
|
|
14160
14208
|
throw new SddScriptError("usage: lease verify-integration --workflow <id> [--harness <path>]", 2);
|
|
14161
14209
|
}
|
|
14162
14210
|
const snapshotPath = resolveSnapshotPath(options.workflow, options.harness);
|
|
14163
|
-
if (!
|
|
14211
|
+
if (!fs10.existsSync(snapshotPath)) {
|
|
14164
14212
|
throw new Error(`workflow snapshot not found: ${snapshotPath}`);
|
|
14165
14213
|
}
|
|
14166
14214
|
const doc = readJson2(snapshotPath);
|
|
@@ -14195,7 +14243,7 @@ function loadSddContextFile(pathValue) {
|
|
|
14195
14243
|
}
|
|
14196
14244
|
let raw;
|
|
14197
14245
|
try {
|
|
14198
|
-
raw =
|
|
14246
|
+
raw = fs10.readFileSync(pathValue, "utf8");
|
|
14199
14247
|
} catch {
|
|
14200
14248
|
throw new SddScriptError(`no such context file: ${pathValue}`, 2);
|
|
14201
14249
|
}
|
|
@@ -14303,9 +14351,9 @@ iterationCommand.command("gate").description("Evaluate the phase-transition gate
|
|
|
14303
14351
|
try {
|
|
14304
14352
|
const snapshotPath = resolveSnapshotPath(options.workflow, options.harness);
|
|
14305
14353
|
const compassPath = path14.resolve(options.compass);
|
|
14306
|
-
if (!
|
|
14354
|
+
if (!fs10.existsSync(snapshotPath))
|
|
14307
14355
|
throw new Error(`workflow snapshot not found: ${snapshotPath}`);
|
|
14308
|
-
if (!
|
|
14356
|
+
if (!fs10.existsSync(compassPath))
|
|
14309
14357
|
throw new Error(`compass file not found: ${compassPath}`);
|
|
14310
14358
|
const result = evaluatePhaseGate(readJson2(snapshotPath), parseCompassFrontmatter(compassPath), {
|
|
14311
14359
|
currentBranch: options.branch,
|
|
@@ -14344,11 +14392,11 @@ dispatchCommand.command("validate").description("Validate an Assignment markdown
|
|
|
14344
14392
|
throw new SddScriptError("usage: dispatch validate <assignment-file> [--branch <branch>]", 2);
|
|
14345
14393
|
}
|
|
14346
14394
|
const fromCwd = path14.isAbsolute(assignmentFile) ? assignmentFile : path14.resolve(process.cwd(), assignmentFile);
|
|
14347
|
-
const file =
|
|
14348
|
-
if (!
|
|
14395
|
+
const file = fs10.existsSync(fromCwd) ? fromCwd : resolveCliPath(assignmentFile);
|
|
14396
|
+
if (!fs10.existsSync(file)) {
|
|
14349
14397
|
throw new Error(`assignment file not found: ${assignmentFile} (tried ${fromCwd} and ${resolveCliPath(assignmentFile)})`);
|
|
14350
14398
|
}
|
|
14351
|
-
const text =
|
|
14399
|
+
const text = fs10.readFileSync(file, "utf8");
|
|
14352
14400
|
const readOnly = isReadOnlyAssignmentRole(parseAssignmentFields(text).executeAs ?? "");
|
|
14353
14401
|
const violations = [...validateAssignmentFields(text, { writable: readOnly ? false : undefined }).violations];
|
|
14354
14402
|
if (!readOnly) {
|
|
@@ -14407,7 +14455,7 @@ worktreeCommand.command("check").description("L1: verify the plan's execution_le
|
|
|
14407
14455
|
throw new SddScriptError("usage: worktree check <plan-id> --workflow <id> [--harness <path>] [--control <path>] (or --plan <plan-id>)", 2);
|
|
14408
14456
|
}
|
|
14409
14457
|
const snapshotPath = resolveSnapshotPath(options.workflow, options.harness);
|
|
14410
|
-
if (!
|
|
14458
|
+
if (!fs10.existsSync(snapshotPath)) {
|
|
14411
14459
|
throw new Error(`workflow snapshot not found: ${snapshotPath}`);
|
|
14412
14460
|
}
|
|
14413
14461
|
const doc = readJson2(snapshotPath);
|
|
@@ -14465,10 +14513,10 @@ worktreeCommand.command("qc-alignment").description("Assert the QC/QA alignment
|
|
|
14465
14513
|
const assignments = [];
|
|
14466
14514
|
for (const fileArg of files) {
|
|
14467
14515
|
const file = path14.isAbsolute(fileArg) ? fileArg : `${process.cwd()}${path14.sep}${fileArg}`;
|
|
14468
|
-
if (!
|
|
14516
|
+
if (!fs10.existsSync(file)) {
|
|
14469
14517
|
throw new Error(`assignment file not found: ${file}`);
|
|
14470
14518
|
}
|
|
14471
|
-
const text =
|
|
14519
|
+
const text = fs10.readFileSync(file, "utf8");
|
|
14472
14520
|
const combinedRange = parseAssignmentHeaderField(text, "Review range / Diff basis");
|
|
14473
14521
|
const planId = parseAssignmentHeaderField(text, "plan_id");
|
|
14474
14522
|
const reviewRange = parseAssignmentHeaderField(text, "Review range") || combinedRange;
|
|
@@ -14511,10 +14559,10 @@ reviewCommand.command("seats").description("Map an Assignment's execution mode t
|
|
|
14511
14559
|
throw new SddScriptError("usage: review seats <assignment-file> [--mode sdd|inline|targeted] [--reviewers <role1,role2,...>]", 2);
|
|
14512
14560
|
}
|
|
14513
14561
|
const file = path14.isAbsolute(assignmentFile) ? assignmentFile : `${process.cwd()}${path14.sep}${assignmentFile}`;
|
|
14514
|
-
if (!
|
|
14562
|
+
if (!fs10.existsSync(file)) {
|
|
14515
14563
|
throw new Error(`assignment file not found: ${file}`);
|
|
14516
14564
|
}
|
|
14517
|
-
const text =
|
|
14565
|
+
const text = fs10.readFileSync(file, "utf8");
|
|
14518
14566
|
const mode = options.mode ?? parseAssignmentExecutionMode(text);
|
|
14519
14567
|
const reviewers = (options.reviewers ?? "").split(",").map((role) => role.trim()).filter((role) => role !== "");
|
|
14520
14568
|
const result = executionModeToN(mode, { seats: reviewers });
|
|
@@ -14590,7 +14638,7 @@ function lintTargetType(filePath) {
|
|
|
14590
14638
|
function collectLintTargets(dir) {
|
|
14591
14639
|
const targets = [];
|
|
14592
14640
|
const visit = (current) => {
|
|
14593
|
-
for (const entry of
|
|
14641
|
+
for (const entry of fs10.readdirSync(current, { withFileTypes: true })) {
|
|
14594
14642
|
if (entry.name.includes(path14.sep))
|
|
14595
14643
|
continue;
|
|
14596
14644
|
const child = current + entry.name;
|
|
@@ -14607,7 +14655,7 @@ function collectLintTargets(dir) {
|
|
|
14607
14655
|
return targets;
|
|
14608
14656
|
}
|
|
14609
14657
|
var lintIo = {
|
|
14610
|
-
readText: async (resolvedPath) =>
|
|
14658
|
+
readText: async (resolvedPath) => fs10.promises.readFile(resolvedPath, "utf8")
|
|
14611
14659
|
};
|
|
14612
14660
|
async function lintOneFile(filePath, forcedType, prVariant) {
|
|
14613
14661
|
const text = await lintIo.readText(filePath);
|
|
@@ -14662,9 +14710,9 @@ lintCommand.description("Lint <target> (file or dir) \u2014 exit 1 on violations
|
|
|
14662
14710
|
forcedType = forced;
|
|
14663
14711
|
}
|
|
14664
14712
|
const abs = resolveCliPath(target);
|
|
14665
|
-
if (!
|
|
14713
|
+
if (!fs10.existsSync(abs))
|
|
14666
14714
|
throw new Error(`lint target not found: ${abs}`);
|
|
14667
|
-
const targets =
|
|
14715
|
+
const targets = fs10.statSync(abs).isDirectory() ? collectLintTargets(abs) : [abs];
|
|
14668
14716
|
if (targets.length === 0) {
|
|
14669
14717
|
console.log(import_picocolors2.default.yellow(`lint: no lintable files under ${target}`));
|
|
14670
14718
|
return;
|
|
@@ -14710,16 +14758,16 @@ designMdCommand.command("validate").description("Validate DESIGN.md in <dir>: to
|
|
|
14710
14758
|
throw new SddScriptError("usage: design-md validate <dir>", 2);
|
|
14711
14759
|
const abs = resolveCliPath(dir);
|
|
14712
14760
|
const lightPath = `${abs}${path14.sep}DESIGN.md`;
|
|
14713
|
-
if (!
|
|
14761
|
+
if (!fs10.existsSync(lightPath))
|
|
14714
14762
|
throw new Error(`design file not found: ${lightPath}`);
|
|
14715
|
-
const light =
|
|
14763
|
+
const light = fs10.readFileSync(lightPath, "utf8");
|
|
14716
14764
|
const violations = [];
|
|
14717
14765
|
const tokens = validateDesignTokenFrontmatter(light);
|
|
14718
14766
|
printChecklist("design-md validate (tokens)", tokens);
|
|
14719
14767
|
violations.push(...tokens.violations);
|
|
14720
14768
|
const darkPath = `${abs}${path14.sep}DESIGN.dark.md`;
|
|
14721
|
-
if (
|
|
14722
|
-
const parity = assertLightDarkParity(light,
|
|
14769
|
+
if (fs10.existsSync(darkPath)) {
|
|
14770
|
+
const parity = assertLightDarkParity(light, fs10.readFileSync(darkPath, "utf8"));
|
|
14723
14771
|
printChecklist("design-md validate (light/dark parity)", parity);
|
|
14724
14772
|
violations.push(...parity.violations);
|
|
14725
14773
|
}
|
|
@@ -14867,7 +14915,7 @@ auditCommand.command("scaffold").description("Scaffold an audit-<date>/ plan dir
|
|
|
14867
14915
|
if (!findingsFile)
|
|
14868
14916
|
throw new SddScriptError("usage: audit scaffold <findings-file> [--dir <out-dir>]", 2);
|
|
14869
14917
|
const abs = resolveCliPath(findingsFile);
|
|
14870
|
-
if (!
|
|
14918
|
+
if (!fs10.existsSync(abs))
|
|
14871
14919
|
throw new Error(`findings file not found: ${abs}`);
|
|
14872
14920
|
if (options.date !== undefined && !/^\d{4}-\d{2}-\d{2}$/.test(options.date)) {
|
|
14873
14921
|
throw new SddScriptError("usage: audit scaffold \u2014 --date must be YYYY-MM-DD", 2);
|
|
@@ -14877,7 +14925,7 @@ auditCommand.command("scaffold").description("Scaffold an audit-<date>/ plan dir
|
|
|
14877
14925
|
}
|
|
14878
14926
|
const date = options.date ?? new Date().toISOString().slice(0, 10);
|
|
14879
14927
|
const outDir = options.dir !== undefined ? resolveCliPath(options.dir) : resolveCliPath(`audit-${date}`);
|
|
14880
|
-
const input = parseAuditScaffoldInput(
|
|
14928
|
+
const input = parseAuditScaffoldInput(fs10.readFileSync(abs, "utf8"));
|
|
14881
14929
|
const sha = resolveAuditShortSha(process.cwd(), options.sha);
|
|
14882
14930
|
const result = scaffoldAuditPlan(outDir, input.findings, {
|
|
14883
14931
|
date,
|
|
@@ -14904,7 +14952,7 @@ auditCommand.command("promote").description("Promote selected audit plans into t
|
|
|
14904
14952
|
throw new SddScriptError("usage: audit promote <audit-dir> --plans <ids> [--workflow <id>] [--harness <dir>]", 2);
|
|
14905
14953
|
}
|
|
14906
14954
|
const outDir = resolveCliPath(auditDir);
|
|
14907
|
-
if (!
|
|
14955
|
+
if (!fs10.existsSync(outDir)) {
|
|
14908
14956
|
throw new Error(`audit dir not found: ${outDir}`);
|
|
14909
14957
|
}
|
|
14910
14958
|
const harnessDir = resolveLeaseHarnessDir(options.harness);
|
|
@@ -14935,7 +14983,7 @@ function listTrackedFiles(root) {
|
|
|
14935
14983
|
auditCommand.command("secret-scan").description("Read-only credential-pattern scan over git-tracked files under [path] " + "(default cwd): prints {file, line, type} findings; never prints values. " + "Exit 1 on findings, 0 when clean, 2 when the tracked-file walk or reads fail").argument("[path]", "Directory to scan (default: cwd)").action((scanPath) => {
|
|
14936
14984
|
try {
|
|
14937
14985
|
const root = scanPath !== undefined ? resolveCliPath(scanPath) : process.cwd();
|
|
14938
|
-
if (!
|
|
14986
|
+
if (!fs10.existsSync(root) || !fs10.statSync(root).isDirectory()) {
|
|
14939
14987
|
throw new SddScriptError(`usage: audit secret-scan [path] \u2014 not a directory: ${root}`, 2);
|
|
14940
14988
|
}
|
|
14941
14989
|
const files = listTrackedFiles(root);
|
|
@@ -14962,7 +15010,7 @@ auditCommand.command("secret-scan").description("Read-only credential-pattern sc
|
|
|
14962
15010
|
auditCommand.command("supply-chain").description("Supply-chain checks over a repo root (read-only): root lockfile presence/duplication, " + "unpinned GitHub Actions refs, pull_request_target PR-head checkout. " + "Exit 1 on findings, 0 when clean").argument("[path]", "Repository root (default: cwd)").action((repoPath) => {
|
|
14963
15011
|
try {
|
|
14964
15012
|
const root = repoPath !== undefined ? resolveCliPath(repoPath) : process.cwd();
|
|
14965
|
-
if (!
|
|
15013
|
+
if (!fs10.existsSync(root) || !fs10.statSync(root).isDirectory()) {
|
|
14966
15014
|
throw new SddScriptError(`usage: audit supply-chain [path] \u2014 not a directory: ${root}`, 2);
|
|
14967
15015
|
}
|
|
14968
15016
|
const result = supplyChainChecks(root);
|
|
@@ -14989,9 +15037,9 @@ compoundCommand.command("validate").description("Validate a knowledge doc frontm
|
|
|
14989
15037
|
if (!docPath)
|
|
14990
15038
|
throw new SddScriptError("usage: compound validate <doc-path> [--knowledge-dir <dir>]", 2);
|
|
14991
15039
|
const abs = resolveCliPath(docPath);
|
|
14992
|
-
if (!
|
|
15040
|
+
if (!fs10.existsSync(abs))
|
|
14993
15041
|
throw new Error(`knowledge doc not found: ${abs}`);
|
|
14994
|
-
const text =
|
|
15042
|
+
const text = fs10.readFileSync(abs, "utf8");
|
|
14995
15043
|
const violations = [];
|
|
14996
15044
|
const schema = validateSchemaYaml(text);
|
|
14997
15045
|
printChecklist("compound validate (schema)", schema);
|
|
@@ -15082,9 +15130,9 @@ skillCommand.command("lint").description("Lint <skill-dir>/SKILL.md: frontmatter
|
|
|
15082
15130
|
if (!skillDir)
|
|
15083
15131
|
throw new SddScriptError("usage: skill lint <skill-dir>", 2);
|
|
15084
15132
|
const skillFile = path14.join(resolveCliPath(skillDir), "SKILL.md");
|
|
15085
|
-
if (!
|
|
15133
|
+
if (!fs10.existsSync(skillFile))
|
|
15086
15134
|
throw new Error(`SKILL.md not found: ${skillFile}`);
|
|
15087
|
-
const text =
|
|
15135
|
+
const text = fs10.readFileSync(skillFile, "utf8");
|
|
15088
15136
|
const violations = [];
|
|
15089
15137
|
const frontmatter = lintSkillFrontmatter(text);
|
|
15090
15138
|
printChecklist("skill lint (frontmatter)", frontmatter);
|
|
@@ -15126,14 +15174,14 @@ rolesCommand.command("validate").description("Validate the mstar-roles skill-dir
|
|
|
15126
15174
|
printChecklist("roles validate (mapping)", mapping);
|
|
15127
15175
|
violations.push(...mapping.violations);
|
|
15128
15176
|
const skillTexts = {};
|
|
15129
|
-
for (const entry of
|
|
15177
|
+
for (const entry of fs10.readdirSync(skillsRoot, { withFileTypes: true })) {
|
|
15130
15178
|
if (!entry.isDirectory() || !entry.name.startsWith("mstar-"))
|
|
15131
15179
|
continue;
|
|
15132
15180
|
const skillFile = path14.join(skillsRoot, entry.name, "SKILL.md");
|
|
15133
|
-
if (!
|
|
15181
|
+
if (!fs10.existsSync(skillFile))
|
|
15134
15182
|
continue;
|
|
15135
15183
|
try {
|
|
15136
|
-
skillTexts[entry.name] =
|
|
15184
|
+
skillTexts[entry.name] = fs10.readFileSync(skillFile, "utf8");
|
|
15137
15185
|
} catch {}
|
|
15138
15186
|
}
|
|
15139
15187
|
const loadOrder = lintLoadOrder(skillTexts);
|
|
@@ -15175,11 +15223,11 @@ function parsePrReviewTarget(raw) {
|
|
|
15175
15223
|
prReviewCommand.command("tally").description("Compute the locked-formula tally, verdict and score from accepted findings JSON ([{mergeClass}]) plus the " + "leftover unmet-AC / unverified counts; prints the two-line chat header + structured result (pr-review.md \xA7 Tally)").requiredOption("--findings <file.json>", "Accepted findings JSON \u2014 array of {mergeClass: must-fix|should-fix|nit}").option("--unverified <n>", "Count of residual - unverified: items (default 0)").option("--unmet-ac-unsafe <n>", "Leftover unmet ACs that are unsafe-to-ship (each \u2192 must_fix + 1)").option("--unmet-ac-safe <n>", "Leftover unmet ACs that are ship-safe (each \u2192 should_fix + 1)").action((options) => {
|
|
15176
15224
|
try {
|
|
15177
15225
|
const findingsPath = resolveCliPath(options.findings);
|
|
15178
|
-
if (!
|
|
15226
|
+
if (!fs10.existsSync(findingsPath))
|
|
15179
15227
|
throw new Error(`findings file not found: ${findingsPath}`);
|
|
15180
15228
|
let parsed;
|
|
15181
15229
|
try {
|
|
15182
|
-
parsed = JSON.parse(
|
|
15230
|
+
parsed = JSON.parse(fs10.readFileSync(findingsPath, "utf8"));
|
|
15183
15231
|
} catch (error) {
|
|
15184
15232
|
throw new Error(`--findings is not valid JSON: ${error.message}`);
|
|
15185
15233
|
}
|
|
@@ -15257,9 +15305,9 @@ prReviewCommand.command("report-path").description("Resolve the local-report (or
|
|
|
15257
15305
|
prReviewCommand.command("validate-report").description("Validate a saved local PR-review report against the machine-readable contract (frontmatter fields, verdict-from-tally, " + "locked-formula score recompute, comments tri-state; exit 1 with violations printed)").argument("<file.md>", "Saved report markdown file").action((reportFile) => {
|
|
15258
15306
|
try {
|
|
15259
15307
|
const abs = resolveCliPath(reportFile);
|
|
15260
|
-
if (!
|
|
15308
|
+
if (!fs10.existsSync(abs))
|
|
15261
15309
|
throw new Error(`report file not found: ${abs}`);
|
|
15262
|
-
const gate2 = validatePrReviewReport(
|
|
15310
|
+
const gate2 = validatePrReviewReport(fs10.readFileSync(abs, "utf8"));
|
|
15263
15311
|
printChecklist(abs, gate2);
|
|
15264
15312
|
if (!gate2.ok)
|
|
15265
15313
|
process.exitCode = 1;
|
|
@@ -15367,17 +15415,17 @@ prReviewCommand.command("post").description("Build and POST the GitHub Review pe
|
|
|
15367
15415
|
}
|
|
15368
15416
|
const prNumber = Number(options.pr);
|
|
15369
15417
|
const bodyPath = resolveCliPath(options.bodyFile);
|
|
15370
|
-
if (!
|
|
15418
|
+
if (!fs10.existsSync(bodyPath))
|
|
15371
15419
|
throw new Error(`body file not found: ${bodyPath}`);
|
|
15372
|
-
const body =
|
|
15420
|
+
const body = fs10.readFileSync(bodyPath, "utf8");
|
|
15373
15421
|
let comments = [];
|
|
15374
15422
|
if (options.findings !== undefined) {
|
|
15375
15423
|
const findingsPath = resolveCliPath(options.findings);
|
|
15376
|
-
if (!
|
|
15424
|
+
if (!fs10.existsSync(findingsPath))
|
|
15377
15425
|
throw new Error(`findings file not found: ${findingsPath}`);
|
|
15378
15426
|
let parsed;
|
|
15379
15427
|
try {
|
|
15380
|
-
parsed = JSON.parse(
|
|
15428
|
+
parsed = JSON.parse(fs10.readFileSync(findingsPath, "utf8"));
|
|
15381
15429
|
} catch (error) {
|
|
15382
15430
|
throw new Error(`--findings is not valid JSON: ${error.message}`);
|
|
15383
15431
|
}
|
|
@@ -15481,7 +15529,7 @@ prReviewCommand.command("worktree-setup").description("Create the isolated revie
|
|
|
15481
15529
|
throw new SddScriptError("usage: pr-review worktree-setup \u2014 the five input modes are mutually exclusive", 2);
|
|
15482
15530
|
}
|
|
15483
15531
|
const startDir = process.cwd();
|
|
15484
|
-
if (!
|
|
15532
|
+
if (!fs10.existsSync(path14.join(startDir, ".git")) && gitIf(["rev-parse", "--git-dir"], startDir) === "") {
|
|
15485
15533
|
throw new Error(`not a git repository: ${startDir}`);
|
|
15486
15534
|
}
|
|
15487
15535
|
const repoRoot = gitSync(["rev-parse", "--show-toplevel"], startDir);
|
|
@@ -15557,13 +15605,13 @@ prReviewCommand.command("worktree-setup").description("Create the isolated revie
|
|
|
15557
15605
|
const branchSuffix = mode === "pr" ? "" : `-${headSpec.slice(0, 8)}`;
|
|
15558
15606
|
const worktreePath = path14.resolve(options.path ?? path14.join(repoRoot, ".worktrees", `review-${reviewBranch}${branchSuffix}`));
|
|
15559
15607
|
if (options.path === undefined) {
|
|
15560
|
-
|
|
15608
|
+
fs10.mkdirSync(path14.join(repoRoot, ".worktrees"), { recursive: true });
|
|
15561
15609
|
if (gitIf(["check-ignore", ".worktrees/"], repoRoot) === "") {
|
|
15562
15610
|
const excludePath = path14.join(repoRoot, ".git", "info", "exclude");
|
|
15563
|
-
const existing2 =
|
|
15611
|
+
const existing2 = fs10.existsSync(excludePath) ? fs10.readFileSync(excludePath, "utf8") : "";
|
|
15564
15612
|
if (!existing2.split(`
|
|
15565
15613
|
`).some((line) => line.trim() === ".worktrees/")) {
|
|
15566
|
-
|
|
15614
|
+
fs10.appendFileSync(excludePath, `${existing2 === "" || existing2.endsWith(`
|
|
15567
15615
|
`) ? "" : `
|
|
15568
15616
|
`}.worktrees/
|
|
15569
15617
|
`);
|
|
@@ -15591,7 +15639,7 @@ prReviewCommand.command("worktree-setup").description("Create the isolated revie
|
|
|
15591
15639
|
let sidecarFd;
|
|
15592
15640
|
const cleanupOnFailure = (branchToDelete) => {
|
|
15593
15641
|
try {
|
|
15594
|
-
if (
|
|
15642
|
+
if (fs10.existsSync(worktreePath))
|
|
15595
15643
|
gitSync(["worktree", "remove", "--force", worktreePath], repoRoot);
|
|
15596
15644
|
gitSync(["worktree", "prune"], repoRoot);
|
|
15597
15645
|
if (branchToDelete !== "" && !existing.has(branchToDelete)) {
|
|
@@ -15682,7 +15730,7 @@ prReviewCommand.command("worktree-setup").description("Create the isolated revie
|
|
|
15682
15730
|
diffFileSha256: createHash("sha256").update(snapshot).digest("hex")
|
|
15683
15731
|
};
|
|
15684
15732
|
try {
|
|
15685
|
-
sidecarFd =
|
|
15733
|
+
sidecarFd = fs10.openSync(sidecarPath, "wx+");
|
|
15686
15734
|
} catch (error) {
|
|
15687
15735
|
if (error.code !== "EEXIST" && error.code !== "EISDIR")
|
|
15688
15736
|
throw error;
|
|
@@ -15691,21 +15739,21 @@ prReviewCommand.command("worktree-setup").description("Create the isolated revie
|
|
|
15691
15739
|
writeFdSync(sidecarFd, Buffer.from(JSON.stringify(sidecar2, null, 2), "utf8"));
|
|
15692
15740
|
wroteSidecar = true;
|
|
15693
15741
|
try {
|
|
15694
|
-
|
|
15742
|
+
fs10.writeFileSync(diffFile, snapshot, { flag: "wx" });
|
|
15695
15743
|
} catch (error) {
|
|
15696
15744
|
if (error.code !== "EEXIST" && error.code !== "EISDIR")
|
|
15697
15745
|
throw error;
|
|
15698
15746
|
throw new Error(`refusing to overwrite pre-existing non-snapshot path ${diffFile}`);
|
|
15699
15747
|
}
|
|
15700
15748
|
wroteSnapshot = true;
|
|
15701
|
-
const snapshotStat =
|
|
15749
|
+
const snapshotStat = fs10.lstatSync(diffFile);
|
|
15702
15750
|
sidecar2.diffFileDev = snapshotStat.dev;
|
|
15703
15751
|
sidecar2.diffFileIno = String(snapshotStat.ino);
|
|
15704
15752
|
sidecar2.diffFileMtimeMs = snapshotStat.mtimeMs;
|
|
15705
15753
|
pendingSidecar = sidecar2;
|
|
15706
|
-
|
|
15754
|
+
fs10.ftruncateSync(sidecarFd, 0);
|
|
15707
15755
|
writeFdSync(sidecarFd, Buffer.from(JSON.stringify(sidecar2, null, 2), "utf8"));
|
|
15708
|
-
|
|
15756
|
+
fs10.closeSync(sidecarFd);
|
|
15709
15757
|
sidecarFd = undefined;
|
|
15710
15758
|
return sidecar2;
|
|
15711
15759
|
};
|
|
@@ -15737,13 +15785,13 @@ function prReviewArtifactPathFor(worktreePath, suffix) {
|
|
|
15737
15785
|
function writeFdSync(fd, buf) {
|
|
15738
15786
|
let written = 0;
|
|
15739
15787
|
while (written < buf.length)
|
|
15740
|
-
written +=
|
|
15788
|
+
written += fs10.writeSync(fd, buf, written, buf.length - written, written);
|
|
15741
15789
|
}
|
|
15742
15790
|
function removeOwnedSnapshotFile(worktreePath, sidecar) {
|
|
15743
15791
|
const snapshotPath = prReviewArtifactPathFor(worktreePath, "diff");
|
|
15744
15792
|
let fd;
|
|
15745
15793
|
try {
|
|
15746
|
-
fd =
|
|
15794
|
+
fd = fs10.openSync(snapshotPath, "r");
|
|
15747
15795
|
} catch (error) {
|
|
15748
15796
|
if (error.code === "ENOENT")
|
|
15749
15797
|
return;
|
|
@@ -15751,7 +15799,7 @@ function removeOwnedSnapshotFile(worktreePath, sidecar) {
|
|
|
15751
15799
|
return;
|
|
15752
15800
|
}
|
|
15753
15801
|
try {
|
|
15754
|
-
const st =
|
|
15802
|
+
const st = fs10.fstatSync(fd);
|
|
15755
15803
|
if (!st.isFile())
|
|
15756
15804
|
return;
|
|
15757
15805
|
const recordedIno = sidecar.diffFileIno;
|
|
@@ -15768,28 +15816,28 @@ function removeOwnedSnapshotFile(worktreePath, sidecar) {
|
|
|
15768
15816
|
}
|
|
15769
15817
|
const tmp = `${snapshotPath}.cleanup.${process.pid}.${randomUUID3()}`;
|
|
15770
15818
|
try {
|
|
15771
|
-
|
|
15819
|
+
fs10.renameSync(snapshotPath, tmp);
|
|
15772
15820
|
} catch (error) {
|
|
15773
15821
|
console.error(import_picocolors2.default.yellow(`worktree-cleanup: snapshot at ${snapshotPath} left in place (cannot detach: ${error.message})`));
|
|
15774
15822
|
return;
|
|
15775
15823
|
}
|
|
15776
|
-
const st2 =
|
|
15824
|
+
const st2 = fs10.fstatSync(fd);
|
|
15777
15825
|
let tmpStat;
|
|
15778
15826
|
try {
|
|
15779
|
-
tmpStat =
|
|
15827
|
+
tmpStat = fs10.lstatSync(tmp);
|
|
15780
15828
|
} catch {
|
|
15781
15829
|
tmpStat = undefined;
|
|
15782
15830
|
}
|
|
15783
15831
|
if (tmpStat !== undefined && tmpStat.ino === st2.ino && tmpStat.dev === st2.dev && st2.nlink === 1 && tmpStat.nlink === 1) {
|
|
15784
|
-
|
|
15785
|
-
const st3 =
|
|
15832
|
+
fs10.unlinkSync(tmp);
|
|
15833
|
+
const st3 = fs10.fstatSync(fd);
|
|
15786
15834
|
if (st3.nlink !== 0) {
|
|
15787
15835
|
console.error(import_picocolors2.default.yellow(`worktree-cleanup: unlink at ${tmp} detached a pathname replacement, not the verified snapshot inode (${snapshotPath} still holds ${st3.nlink} link(s)) - the replacement is gone, the verified snapshot was NOT deleted`));
|
|
15788
15836
|
}
|
|
15789
15837
|
} else {
|
|
15790
15838
|
try {
|
|
15791
|
-
|
|
15792
|
-
|
|
15839
|
+
fs10.linkSync(tmp, snapshotPath);
|
|
15840
|
+
fs10.unlinkSync(tmp);
|
|
15793
15841
|
} catch (error) {
|
|
15794
15842
|
if (error.code === "EEXIST") {
|
|
15795
15843
|
console.error(import_picocolors2.default.yellow(`worktree-cleanup: snapshot replacement left at ${tmp} (snapshot path was recreated concurrently)`));
|
|
@@ -15799,41 +15847,41 @@ function removeOwnedSnapshotFile(worktreePath, sidecar) {
|
|
|
15799
15847
|
}
|
|
15800
15848
|
}
|
|
15801
15849
|
} finally {
|
|
15802
|
-
|
|
15850
|
+
fs10.closeSync(fd);
|
|
15803
15851
|
}
|
|
15804
15852
|
}
|
|
15805
15853
|
function removeOwnedFreshSidecarFile(sidecarFd, worktreePath) {
|
|
15806
15854
|
const sidecarPath = prReviewArtifactPathFor(worktreePath, "json");
|
|
15807
15855
|
try {
|
|
15808
|
-
const st =
|
|
15856
|
+
const st = fs10.fstatSync(sidecarFd);
|
|
15809
15857
|
if (!st.isFile() || st.nlink !== 1) {
|
|
15810
15858
|
console.error(import_picocolors2.default.yellow(`worktree-setup rollback: sidecar at ${sidecarPath} left in place (identity no longer held)`));
|
|
15811
15859
|
return;
|
|
15812
15860
|
}
|
|
15813
15861
|
const tmp = `${sidecarPath}.cleanup.${process.pid}.${randomUUID3()}`;
|
|
15814
15862
|
try {
|
|
15815
|
-
|
|
15863
|
+
fs10.renameSync(sidecarPath, tmp);
|
|
15816
15864
|
} catch (error) {
|
|
15817
15865
|
console.error(import_picocolors2.default.yellow(`worktree-setup rollback: sidecar at ${sidecarPath} left in place (cannot detach: ${error.message})`));
|
|
15818
15866
|
return;
|
|
15819
15867
|
}
|
|
15820
|
-
const st2 =
|
|
15868
|
+
const st2 = fs10.fstatSync(sidecarFd);
|
|
15821
15869
|
let tmpStat;
|
|
15822
15870
|
try {
|
|
15823
|
-
tmpStat =
|
|
15871
|
+
tmpStat = fs10.lstatSync(tmp);
|
|
15824
15872
|
} catch {
|
|
15825
15873
|
tmpStat = undefined;
|
|
15826
15874
|
}
|
|
15827
15875
|
if (tmpStat !== undefined && tmpStat.ino === st2.ino && tmpStat.dev === st2.dev) {
|
|
15828
|
-
|
|
15829
|
-
const st3 =
|
|
15876
|
+
fs10.unlinkSync(tmp);
|
|
15877
|
+
const st3 = fs10.fstatSync(sidecarFd);
|
|
15830
15878
|
if (st3.nlink !== 0) {
|
|
15831
15879
|
console.error(import_picocolors2.default.yellow(`worktree-setup rollback: unlink at ${tmp} detached a pathname replacement, not the verified sidecar inode (${sidecarPath} still holds ${st3.nlink} link(s)) - the replacement is gone, the verified sidecar was NOT deleted`));
|
|
15832
15880
|
}
|
|
15833
15881
|
} else {
|
|
15834
15882
|
try {
|
|
15835
|
-
|
|
15836
|
-
|
|
15883
|
+
fs10.linkSync(tmp, sidecarPath);
|
|
15884
|
+
fs10.unlinkSync(tmp);
|
|
15837
15885
|
} catch (error) {
|
|
15838
15886
|
if (error.code === "EEXIST") {
|
|
15839
15887
|
console.error(import_picocolors2.default.yellow(`worktree-setup rollback: sidecar replacement left at ${tmp} (sidecar path was recreated concurrently)`));
|
|
@@ -15844,7 +15892,7 @@ function removeOwnedFreshSidecarFile(sidecarFd, worktreePath) {
|
|
|
15844
15892
|
}
|
|
15845
15893
|
} finally {
|
|
15846
15894
|
try {
|
|
15847
|
-
|
|
15895
|
+
fs10.closeSync(sidecarFd);
|
|
15848
15896
|
} catch {}
|
|
15849
15897
|
}
|
|
15850
15898
|
}
|
|
@@ -15852,12 +15900,12 @@ prReviewCommand.command("worktree-cleanup").description("Remove the review workt
|
|
|
15852
15900
|
try {
|
|
15853
15901
|
const worktreePath = path14.resolve(resolveCliPath(options.path));
|
|
15854
15902
|
const sidecarPath = prReviewArtifactPathFor(worktreePath, "json");
|
|
15855
|
-
if (!
|
|
15903
|
+
if (!fs10.existsSync(sidecarPath)) {
|
|
15856
15904
|
throw new Error(`no setup sidecar found at ${sidecarPath} - run pr-review worktree-setup first (foreign worktrees are never cleaned here)`);
|
|
15857
15905
|
}
|
|
15858
15906
|
let sidecar;
|
|
15859
15907
|
try {
|
|
15860
|
-
sidecar = JSON.parse(
|
|
15908
|
+
sidecar = JSON.parse(fs10.readFileSync(sidecarPath, "utf8"));
|
|
15861
15909
|
} catch (error) {
|
|
15862
15910
|
throw new Error(`setup sidecar at ${sidecarPath} is not valid JSON: ${error.message}`);
|
|
15863
15911
|
}
|
|
@@ -15873,7 +15921,7 @@ prReviewCommand.command("worktree-cleanup").description("Remove the review workt
|
|
|
15873
15921
|
if (!savedOk) {
|
|
15874
15922
|
throw new Error("refusing cleanup: the local report is not saved yet - save it first or pass --report-saved (\xA7 Local report archive)");
|
|
15875
15923
|
}
|
|
15876
|
-
if (
|
|
15924
|
+
if (fs10.existsSync(worktreePath)) {
|
|
15877
15925
|
gitSync(["worktree", "remove", worktreePath], gitRoot);
|
|
15878
15926
|
}
|
|
15879
15927
|
gitSync(["worktree", "prune"], gitRoot);
|
|
@@ -15884,7 +15932,7 @@ prReviewCommand.command("worktree-cleanup").description("Remove the review workt
|
|
|
15884
15932
|
gitSync(["branch", "-D", sidecar.reviewBranch], gitRoot);
|
|
15885
15933
|
}
|
|
15886
15934
|
removeOwnedSnapshotFile(worktreePath, sidecar);
|
|
15887
|
-
|
|
15935
|
+
fs10.rmSync(sidecarPath, { force: true });
|
|
15888
15936
|
console.log(import_picocolors2.default.green(`worktree-cleanup: removed ${worktreePath}${sidecar.reviewBranch !== "" ? ` + deleted ${sidecar.reviewBranch}` : " (no local branch to delete)"}`));
|
|
15889
15937
|
} catch (error) {
|
|
15890
15938
|
failScript(error, "pr-review worktree-cleanup");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mstar-harness/cli",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.2",
|
|
4
4
|
"description": "Morning Star harness CLI — installer bootstrap + mstar workflow verbs (path/status/lease/sdd/iteration/dispatch/worktree/lint/design-md/audit/compound/host/skill).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|