Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(skillhub): 冻结活动任务的停用技能物理身份
xd-bobo3f53c141a21b
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex dc594a6b4e..ed7c276ebb 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -42,7 +42,8 @@缺省字段保留旧调用行为,不向 device-link 新开放管理能力。启停偏好仍按物理身份共享;`activation-preferences.json` 的可选 `discoveryPaths` 按物理路径保存已扫描的绝对发现路径数组;缺省兼容旧偏好。启动时复核指向,启用时删除该身份的入口记录,重命名时- 同事务迁移到新入口。插件托管技能只能在所属插件管理,详情禁用开关,Main 拒绝独立启停。+ 同事务迁移到新入口。活动任务在启动时另存规范化物理身份快照,菜单过滤不重新解析+ 停用别名;原始词法入口仅用于原生启动设置。插件托管技能只能在所属插件管理,详情禁用开关,Main 拒绝独立启停。物理卸载的清理快照汇总已扫描 scope 的同源发现链接,外部导入只移除所选 scope 的入口与对应词法注册记录,不追加其它范围的全局候选。斜杠详情路径携带 scope 与工作目录,同源多副本按范围和最近项目匹配;旧路径无法唯一消歧时不任意选择副本。diff --git a/packages/maker-core/src/agents/base-agent.ts b/packages/maker-core/src/agents/base-agent.tsindex b2668bd8e1..61bc53a102 100644--- a/packages/maker-core/src/agents/base-agent.ts+++ b/packages/maker-core/src/agents/base-agent.ts@@ -7,7 +7,7 @@* - 持有依赖注入的 deps,但具体使用由子类决定*/-import { isSkillDisabled } from './shared/skill-activation.js';+import { canonicalSkillPath, isSkillDisabled } from './shared/skill-activation.js';import type {AgentEvent,@@ -1947,7 +1947,7 @@ export interface CodexContextWindowInfo {* 上层 Session 类持有此句柄并对外暴露 UI 友好的 API。*/export interface AgentSessionHandle {- /** Cindy Skill preference snapshot used to configure this native runtime. */+ /** Canonical physical Skill identities frozen at native runtime startup. */readonly disabledSkillPaths?: readonly string[];getCodexContextWindowInfo?(): Promise<CodexContextWindowInfo | null>;/** SDK 内部 sessionId,session.started 后会回填 */@@ -2327,7 +2327,8 @@ export abstract class BaseAgent {filterActiveSkillCommands(result: ListAgentSkillsResult, remoteHostId?: string, snapshot?: readonly string[]): ListAgentSkillsResult {const disabled = remoteHostId ? [] : snapshot ?? this.deps.getDisabledSkillPaths?.() ?? [];if (disabled.length === 0) return result;- return { ...result, skills: result.skills.filter((skill) => !skill.path || !isSkillDisabled(skill.path, disabled)) };+ return { ...result, skills: result.skills.filter((skill) => !skill.path || !(snapshot+ ? disabled.includes(canonicalSkillPath(skill.path)) : isSkillDisabled(skill.path, disabled))) };}diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.tsindex c94e7636ab..db9c546345 100644--- a/packages/maker-core/src/agents/claude-code/index.ts+++ b/packages/maker-core/src/agents/claude-code/index.ts@@ -173,7 +173,7 @@ import type {MemoryResetResult,} from '../../types/memory.js';import type { McpProviderContext } from '../../interfaces/mcp-provider.js';-import { claudeDisabledSkillOverrides } from '../shared/skill-activation.js';+import { claudeDisabledSkillOverrides, snapshotDisabledSkillPaths } from '../shared/skill-activation.js';import { scanClaudeCustomizations, scanClaudeRuntimeSkills } from './customization-scanner.js';import {REVIEW_SENSITIVE_CREDENTIAL_GLOB_PATTERNS,@@ -2369,6 +2369,7 @@ export class ClaudeCodeAgent extends BaseAgent {// 时快照。装配逻辑(含 apiKeyHelper 恒置空的鉴权防线)在 flag-settings.ts。const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];+ const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);const disabledSkillOverrides = disabledSkillPaths.length > 0? claudeDisabledSkillOverrides((await scanClaudeRuntimeSkills(opts.workingDir)).items, disabledSkillPaths): {};@@ -5594,7 +5595,7 @@ export class ClaudeCodeAgent extends BaseAgent {});};const handle: AgentSessionHandle = {- disabledSkillPaths: Object.freeze([...disabledSkillPaths]),+ disabledSkillPaths: disabledSkillSnapshot,reviewAutoPermissionAction: async (action) => {const decision = await reviewAutoAction(action,diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex 71d2b1aecd..e15cadb681 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -41,7 +41,7 @@ import {type SendOptions,type TurnPermissionPolicy,} from '../base-agent.js';-import { skillEntryPath } from '../shared/skill-activation.js';+import { skillEntryPath, snapshotDisabledSkillPaths } from '../shared/skill-activation.js';import type { AgentCredentialMode } from '../../interfaces/auth-adapter.js';import type {Capabilities,@@ -4824,6 +4824,7 @@ export class CodexAgent extends BaseAgent {);const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];+ const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);if (disabledSkillPaths.length > 0) {try {const response = await host.request<{ config?: Record<string, unknown> }>(@@ -11940,7 +11941,7 @@ export class CodexAgent extends BaseAgent {}// ── AgentSessionHandle ──────────────────────────────────────────────────const handle: AgentSessionHandle = {- disabledSkillPaths: Object.freeze([...disabledSkillPaths]),+ disabledSkillPaths: disabledSkillSnapshot,reviewAutoPermissionAction: async (action) => {const decision = await reviewAutoAction(action);if (decision.unavailable) autoReviewUnavailableNotice.notify();diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex 060aeac693..c105b3c1c3 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -1,3 +1,4 @@+import { snapshotDisabledSkillPaths } from '../shared/skill-activation.js';/*** PiAgent —— pi coding agent(earendil-works/pi)接入。*@@ -3047,6 +3048,7 @@ export class PiAgent extends BaseAgent {// approval from permission mode, MCP/plugin state, or caller vendor options.const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];+ const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);let projectResourceAssembly = unavailablePiProjectResourceAssembly(reviewMode ? 'review-mode-project-resources-disabled' : 'approval-resolver-unavailable',);@@ -5812,7 +5814,7 @@ export class PiAgent extends BaseAgent {getRuntimeCapabilities() {return runtimeCapabilityManifest;},- disabledSkillPaths: Object.freeze([...disabledSkillPaths]),+ disabledSkillPaths: disabledSkillSnapshot,onRuntimeCapabilitiesChange(listener) {if (closed) {notifyRuntimeCapabilityListener(listener, undefined);diff --git a/packages/maker-core/src/agents/shared/skill-activation.ts b/packages/maker-core/src/agents/shared/skill-activation.tsindex e7e6db90e0..83f35cba76 100644--- a/packages/maker-core/src/agents/shared/skill-activation.ts+++ b/packages/maker-core/src/agents/shared/skill-activation.ts@@ -10,6 +10,11 @@ export function canonicalSkillPath(value: string): string {return process.platform === 'win32' ? resolved.toLowerCase() : resolved;}+/** Freeze physical identities before asynchronous native runtime startup. */+export function snapshotDisabledSkillPaths(paths: readonly string[]): readonly string[] {+ return Object.freeze([...new Set(paths.map(canonicalSkillPath))]);+}+export function isSkillDisabled(source: string, disabledPaths: readonly string[]): boolean {const key = canonicalSkillPath(source);return disabledPaths.some((candidate) => canonicalSkillPath(candidate) === key);diff --git a/packages/maker-core/src/maker.test.ts b/packages/maker-core/src/maker.test.tsindex 52f9a658ba..60288e26b4 100644--- a/packages/maker-core/src/maker.test.ts+++ b/packages/maker-core/src/maker.test.ts@@ -4,12 +4,15 @@ import {mkdtempSync,promises as fsPromises,realpathSync,+ symlinkSync,+ unlinkSync,rmSync,writeFileSync,} from 'node:fs';import { tmpdir } from 'node:os';import path from 'node:path';+import { snapshotDisabledSkillPaths } from './agents/shared/skill-activation.js';import { Maker, type CreateSessionOptions } from './maker.js';import { Session } from './session.js';import { createAsyncQueue } from './agents/shared/async-queue.js';@@ -137,7 +140,7 @@ describe('Maker Pi managed-package skill boundary', () => {let disabled: string[] = [source];const agent = createAgent(async (opts) => ({...createHandle({ id: opts.sessionId ?? 'fixture', agentKind }),- disabledSkillPaths: Object.freeze([...disabled]),+ disabledSkillPaths: snapshotDisabledSkillPaths(disabled),}), agentKind);agent.listAgentSkills = vi.fn(async () => ({ skills: [{kind: 'agent-skill' as const, name: 'demo', source: 'skill' as const, path: source,@@ -157,6 +160,36 @@ describe('Maker Pi managed-package skill boundary', () => {await maker.shutdown();});+ it.each(['claude-code', 'codex', 'pi'] as const)('keeps %s disabled identities stable after alias retargeting', async (agentKind) => {+ const root = mkdtempSync(path.join(tmpdir(), 'cindy-disabled-snapshot-'));+ const a = path.join(root, 'a');+ const b = path.join(root, 'b');+ const alias = path.join(root, 'alias');+ mkdirSync(a);+ mkdirSync(b);+ symlinkSync(a, alias, process.platform === 'win32' ? 'junction' : 'dir');+ const agent = createAgent(async (opts) => ({+ ...createHandle({ id: opts.sessionId ?? 'fixture', agentKind }),+ disabledSkillPaths: snapshotDisabledSkillPaths([alias]),+ }), agentKind);+ agent.listAgentSkills = vi.fn(async () => ({ skills: [a, b].map((source) => ({+ kind: 'agent-skill' as const, name: path.basename(source), source: 'skill' as const, path: source,+ })) }));+ agent.filterActiveSkillCommands = (result, remoteHostId, snapshot) => BaseAgent.prototype.filterActiveSkillCommands.call(+ { deps: { getDisabledSkillPaths: () => [alias] } } as unknown as BaseAgent, result, remoteHostId, snapshot,+ );+ const maker = new Maker({ agents: { [agentKind]: agent }, storage: createStorage(), logger: createLogger() });+ try {+ await maker.createSession({ id: 'stable-disabled', agentKind, workingDir: root, model: 'm' });+ unlinkSync(alias);+ symlinkSync(b, alias, process.platform === 'win32' ? 'junction' : 'dir');+ const live = await maker.listAgentSkills(agentKind, { workingDir: root, sessionId: 'stable-disabled' });+ expect(live.skills.map((skill) => skill.name)).toEqual(['b']);+ const preview = await maker.listAgentSkills(agentKind, { workingDir: root });+ expect(preview.skills.map((skill) => skill.name)).toEqual(['a']);+ } finally { await maker.shutdown(); rmSync(root, { recursive: true, force: true }); }+ });+it('allows package skills only for previews and ordinary local Pi tasks', async () => {const storage = createStorage();const base = {