dsh-lite-memory 0.18.31 → 0.18.32
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/docs/RELEASE-0.18.32.md +8 -0
- package/package.json +1 -1
- package/store.js +11 -1
- package/test/store.test.mjs +16 -0
package/package.json
CHANGED
package/store.js
CHANGED
|
@@ -2507,6 +2507,8 @@ export const MEMORY_CLASSES = ['personal_preference', 'project_fact', 'environme
|
|
|
2507
2507
|
export const DURABILITIES = ['durable', 'task'];
|
|
2508
2508
|
|
|
2509
2509
|
const ENVIRONMENT_KEYS = ['machine', 'targetOs', 'runtime', 'shell'];
|
|
2510
|
+
/** 一台机器/一次运行才算收住本机痕迹;只写操作系统名(targetOs)换台机器照样不成立。 */
|
|
2511
|
+
const MACHINE_SCOPE_KEYS = ['machine', 'runtime'];
|
|
2510
2512
|
|
|
2511
2513
|
/**
|
|
2512
2514
|
* 范围路由:用户明确说的范围最高;没有就按记忆类别提案,设备事实必须带设备条件。
|
|
@@ -2568,8 +2570,16 @@ export function routeScope(draft, options = {}) {
|
|
|
2568
2570
|
return false;
|
|
2569
2571
|
}
|
|
2570
2572
|
})();
|
|
2573
|
+
/** 本机痕迹只被「本机/运行时」条件收住;targetOs 是平台,不是这台机器。 */
|
|
2574
|
+
const machineScoped = (() => {
|
|
2575
|
+
try {
|
|
2576
|
+
return (view.normalizeConditions(source.conditions) || []).some((item) => MACHINE_SCOPE_KEYS.includes(item.key));
|
|
2577
|
+
} catch {
|
|
2578
|
+
return false;
|
|
2579
|
+
}
|
|
2580
|
+
})();
|
|
2571
2581
|
/** 真正挡回项目层的只有「本机痕迹 + 没有声明适用环境」;只写命令名不算本机痕迹。 */
|
|
2572
|
-
const machineConflict = machineBound && !
|
|
2582
|
+
const machineConflict = machineBound && !machineScoped;
|
|
2573
2583
|
const base = { chosenScope: '', reasonCode: '', requiredConditions: [], needsScope: false, explicit };
|
|
2574
2584
|
/** 通用层拿不出普适证据时:有项目就留在项目层,没有就问一次运行环境。 */
|
|
2575
2585
|
const fallbackToProject = (reasonCode) => {
|
package/test/store.test.mjs
CHANGED
|
@@ -1089,6 +1089,22 @@ test('归属路由:本机痕迹的「通用流程」留在项目层,干净
|
|
|
1089
1089
|
assert.equal(evidencePath.chosenScope, 'project', '依据本身是本机文件不算普适证据');
|
|
1090
1090
|
assert.equal(evidencePath.reasonCode, 'machine_bound_procedure');
|
|
1091
1091
|
|
|
1092
|
+
const osOnlyProcedure = store.routeScope({
|
|
1093
|
+
title: '本机部署脚本', summary: '本机部署脚本的位置', body: 'bash /tmp/deploy.sh',
|
|
1094
|
+
memoryClass: 'portable_procedure', scope: 'global',
|
|
1095
|
+
conditions: [{ key: 'targetOs', value: 'macos' }],
|
|
1096
|
+
}, { project });
|
|
1097
|
+
assert.equal(osOnlyProcedure.chosenScope, 'project', '只写操作系统名收不住本机路径');
|
|
1098
|
+
assert.equal(osOnlyProcedure.reasonCode, 'machine_bound_scope');
|
|
1099
|
+
|
|
1100
|
+
const osOnlyClass = store.routeScope({
|
|
1101
|
+
title: '本机部署脚本', summary: '本机部署脚本的位置', body: 'bash /tmp/deploy.sh',
|
|
1102
|
+
memoryClass: 'portable_procedure',
|
|
1103
|
+
conditions: [{ key: 'targetOs', value: 'macos' }],
|
|
1104
|
+
}, { project });
|
|
1105
|
+
assert.equal(osOnlyClass.chosenScope, 'project', 'targetOs 不是机器条件,不能凭它搬去全局层');
|
|
1106
|
+
assert.equal(osOnlyClass.reasonCode, 'machine_bound_procedure');
|
|
1107
|
+
|
|
1092
1108
|
const scopedProcedure = store.routeScope({
|
|
1093
1109
|
title: 'npm 操作走 dsh-npm', summary: '本机 npm 命令用包装脚本',
|
|
1094
1110
|
body: '本机 npm 一律用 dsh-npm;裸 npm 报 ENEEDAUTH 不是缺凭据',
|