dsh-lite-memory 0.18.36 → 0.18.37
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.37.md +8 -0
- package/index.js +10 -2
- package/package.json +1 -1
- package/test/recall.test.mjs +34 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# 0.18.37:npm 提醒先看当前项目层
|
|
2
|
+
|
|
3
|
+
- 动作前的 npm 提醒不再只查全局层:先查当前项目层的现行记忆,再查全局层,项目规则优先。
|
|
4
|
+
- 本机流程按记忆分层规矩留在项目层,也能在 `npm whoami` / `npm publish` 前拦一次,而不是因为没进全局层就失效。
|
|
5
|
+
- 同一条提醒仍然每轮最多一次,已交付过的条目不会再提示;项目记忆关闭时行为不变。
|
|
6
|
+
- 补回归:项目层与全局层各放一条 npm 规则,验证项目层优先且正文送达。
|
|
7
|
+
|
|
8
|
+
验证:`npm test` 全绿;`npm run bench` / `npm run bench:evolution` 均 exit 0;`style-lint` 通过。
|
package/index.js
CHANGED
|
@@ -2671,8 +2671,16 @@ export function apply(ctx, config) {
|
|
|
2671
2671
|
const held = prepared.get(agent);
|
|
2672
2672
|
if (!held || held.npmHinted) return undefined;
|
|
2673
2673
|
if (!memoryOnForAgent(agent)) return undefined;
|
|
2674
|
-
|
|
2675
|
-
const
|
|
2674
|
+
/** 本机流程按规矩留在项目层;全局层是兜底,先看当前项目再看全局。 */
|
|
2675
|
+
const scopes = [];
|
|
2676
|
+
try {
|
|
2677
|
+
const project = scopeOf(cwdOf({ agent }));
|
|
2678
|
+
if (project && project.confirmed !== false && project.key !== 'global') scopes.push(project);
|
|
2679
|
+
} catch { /* 项目根还没确认时只看全局 */ }
|
|
2680
|
+
scopes.push(globalScope());
|
|
2681
|
+
const row = scopes.flatMap((scope) => {
|
|
2682
|
+
try { return loadIndex(scope).entries || []; } catch { return []; }
|
|
2683
|
+
}).find((entry) => {
|
|
2676
2684
|
if (!entry || entry.archived || entry.origin === 'project_evolution') return false;
|
|
2677
2685
|
/** 过期/被取代的规则不能再在动作前拦人。 */
|
|
2678
2686
|
if (view.lifecycleStatusOf(entry)) return false;
|
package/package.json
CHANGED
package/test/recall.test.mjs
CHANGED
|
@@ -846,6 +846,40 @@ console.log('recall.test.mjs: ok');
|
|
|
846
846
|
assert.ok(scopeNpm.key, '项目层不受影响');
|
|
847
847
|
}
|
|
848
848
|
|
|
849
|
+
// A27b:npm 提醒先看当前项目层,再看全局层;本机流程留在项目层也能在动作前拦人。
|
|
850
|
+
{
|
|
851
|
+
const cwdNpmProject = mkdir('npm-guard-project');
|
|
852
|
+
const scopeNpmProject = store.scopeOf(cwdNpmProject);
|
|
853
|
+
store.setRecallMode(scopeNpmProject, 'adaptive', { operationId: 'npm-guard-project-mode' });
|
|
854
|
+
assert.ok(store.upsert(global, {
|
|
855
|
+
title: 'npm 全局登录提醒',
|
|
856
|
+
summary: '全局层的 npm 登录说明',
|
|
857
|
+
body: '全局层:npm login 会误导,改用 dsh-npm。',
|
|
858
|
+
tags: ['npm'],
|
|
859
|
+
applicability: 'all_in_scope',
|
|
860
|
+
}).record);
|
|
861
|
+
assert.ok(store.upsert(scopeNpmProject, {
|
|
862
|
+
title: 'npm 项目发布前先看凭据',
|
|
863
|
+
summary: '这个项目的 npm 发布步骤',
|
|
864
|
+
body: '项目层:先读 Keychain 位置,再用 dsh-npm publish,不要 npm whoami。',
|
|
865
|
+
tags: ['npm', '发布'],
|
|
866
|
+
applicability: 'all_in_scope',
|
|
867
|
+
}).record);
|
|
868
|
+
const guards = [];
|
|
869
|
+
const agent = makeAgent('agent-npm-project', cwdNpmProject);
|
|
870
|
+
agent.ctx = {
|
|
871
|
+
tools: { guard: (fn) => { guards.push(fn); return () => {}; } },
|
|
872
|
+
effect: (fn) => fn(),
|
|
873
|
+
};
|
|
874
|
+
const runtime = boot();
|
|
875
|
+
runtime.handlers.get('agent/created').at(-1)({ agent });
|
|
876
|
+
const sig = signal();
|
|
877
|
+
await runtime.preStep({ agent, signal: sig, turn: 'npm-project-1' }, enter(human('先看下环境状态')));
|
|
878
|
+
const blocked = guards[0]({ name: 'bash', callId: 'call-npm-project', arguments: { command: 'npm publish' } });
|
|
879
|
+
assert.match(String(blocked), /项目发布前先看凭据/, '项目层规则优先于全局层');
|
|
880
|
+
assert.match(String(blocked), /Keychain/, '给项目层正文');
|
|
881
|
+
}
|
|
882
|
+
|
|
849
883
|
// A28:零命中的同一轮里,关键动作发生后补查一次;补到后不再重复注入。
|
|
850
884
|
{
|
|
851
885
|
const cwdActionKey = mkdir('action-key');
|