@unionschool/easy-agents 1.0.27 → 1.0.34

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/bin/tasks.js CHANGED
@@ -223,9 +223,9 @@ export async function execute(content, signal, workCredential, { agentCredential
223
223
  return { status: 'succeeded', reply_text: digest };
224
224
  }
225
225
  if (task && content.prompt) prompt = content.prompt + '\n\n' + prompt;
226
- // Agy 只接对话(2026-11-23),任务运行仍只有 Codex、Claude。
226
+ // Agy、Cursor 只接对话(2026-11-23),任务运行仍只有 Codex、Claude。
227
227
  if (resources && (['codex', 'claude_code'].includes(content.agent?.tool_type) && (task || content.run_kind === 'chat')
228
- || content.agent?.tool_type === 'antigravity' && content.run_kind === 'chat')) {
228
+ || ['antigravity', 'cursor'].includes(content.agent?.tool_type) && content.run_kind === 'chat')) {
229
229
  let credential;
230
230
  // Same rule as the platform: only chat_mode 'chat' is a plain conversation. Workflow notifications to the lead
231
231
  // (merge after deploy, answers, sync handoff) arrive with an empty chat_mode and must be able to act.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unionschool/easy-agents",
3
- "version": "1.0.27",
3
+ "version": "1.0.34",
4
4
  "description": "EasyAgents",
5
5
  "easyAgentsDesktop": 1,
6
6
  "type": "module",
@@ -13,7 +13,7 @@ sys.path.insert(0, str(Path(resources) / "lib"))
13
13
  sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
14
14
  # 工具适配器用 npm 核心包自带的那份(只依赖标准库),不用安装包 lib 里打包时的旧副本:
15
15
  # 这样 /compact、/steer 等适配器修复随核心更新生效,不必重装应用(2026-11-23)。
16
- from runtime.easyagents_core.tools import NO_OUTPUT_TEXT, AntigravityAdapter, ClaudeCodeAdapter, CodexAdapter, SteerError
16
+ from runtime.easyagents_core.tools import NO_OUTPUT_TEXT, AntigravityAdapter, ClaudeCodeAdapter, CodexAdapter, CursorAdapter, SteerError
17
17
  from runtime.platform_prompt import platform_entry
18
18
 
19
19
  # 聊天模式不是限制、是为了快(用户 2026-11-23:“chat 模式是为了减少聊天时间,不用花时间去看项目”“chat 的模式不是限制,是不用 agent 去看项目内容,除非用户有要求看项目”“聊天要使用工具”):
@@ -137,11 +137,16 @@ def run(content, cancelled):
137
137
  # Agy 没有附加系统说明的参数,建议回复格式暂不告知。
138
138
  adapter = AntigravityAdapter()
139
139
  options = {}
140
+ elif tool == "cursor":
141
+ # Cursor 对话(2026-11-23:飞书私聊给 Cursor 发消息,独立客户端连回四次“不支持”):cursor-agent -p,
142
+ # 聊天、工作同一套参数。没有附加系统说明的参数,建议回复格式暂不告知;不支持运行中补充(平台改为排队)。
143
+ adapter = CursorAdapter()
144
+ options = {}
140
145
  else:
141
146
  return failed("unsupported_task", "此工具尚未接入设备文本对话")
142
147
  if not shutil.which(adapter.executable):
143
148
  return failed("tool_missing", "本机未找到 " + adapter.executable_name)
144
- adapter.instructions = instructions_for(tool, tools, command) if tool != "antigravity" else None
149
+ adapter.instructions = instructions_for(tool, tools, command) if tool not in ("antigravity", "cursor") else None
145
150
  if content.get("_on_adapter"):
146
151
  content["_on_adapter"](adapter)
147
152
 
@@ -78,6 +78,53 @@ def _address(value: str) -> str:
78
78
  return value.rstrip("/").removesuffix(".git")
79
79
 
80
80
 
81
+ LOCKFILES = ('pnpm-lock.yaml', 'package-lock.json', 'yarn.lock')
82
+
83
+
84
+ def link_dependencies(root: Path, worktree: Path) -> list[str]:
85
+ """独立工作树复用原目录已装好的 node_modules(2026-11-23 T-176:执行者、审核人每次都在新工作树里重装工作台依赖)。
86
+ 只在锁文件与原目录逐字节相同时建软链接;锁文件不同、原目录没装、工作树里已有的都不动。尽力而为,失败不影响运行。
87
+ node_modules 被 .gitignore 忽略,不算未提交改动;git worktree remove 只删链接,不删原目录的依赖。"""
88
+ linked = []
89
+ try:
90
+ listing = git(worktree, 'ls-files', '-z', '--', 'package.json', '*/package.json')
91
+ except GitError:
92
+ return linked
93
+ for name in filter(None, listing.split('\0')):
94
+ folder = Path(name).parent
95
+ if 'node_modules' in folder.parts:
96
+ continue
97
+ source, target = root / folder / 'node_modules', worktree / folder / 'node_modules'
98
+ if not source.is_dir() or target.exists() or target.is_symlink():
99
+ continue
100
+ same = [lock for lock in LOCKFILES if (root / folder / lock).is_file() and (worktree / folder / lock).is_file()
101
+ and (root / folder / lock).read_bytes() == (worktree / folder / lock).read_bytes()]
102
+ if not same:
103
+ continue
104
+ try:
105
+ target.symlink_to(source, target_is_directory=True)
106
+ linked.append(folder.as_posix())
107
+ except OSError:
108
+ continue
109
+ if linked:
110
+ _exclude_links(worktree)
111
+ return linked
112
+
113
+
114
+ def _exclude_links(worktree: Path) -> None:
115
+ """仓库常写 `node_modules/`,带斜杠只匹配目录,软链接会显示成未跟踪文件,同步就不肯清理这个工作树。
116
+ 在各工作树共用的本地排除文件里补一行不带斜杠的 `node_modules`(不进 Git)。"""
117
+ try:
118
+ exclude = Path(git(worktree, 'rev-parse', '--path-format=absolute', '--git-common-dir')) / 'info' / 'exclude'
119
+ text = exclude.read_text() if exclude.is_file() else ''
120
+ if 'node_modules' not in text.splitlines():
121
+ exclude.parent.mkdir(parents=True, exist_ok=True)
122
+ gap = '' if not text or text.endswith('\n') else '\n'
123
+ exclude.write_text(text + gap + '# EasyAgents 客户端:独立工作树里复用依赖的软链接\nnode_modules\n')
124
+ except (GitError, OSError):
125
+ pass
126
+
127
+
81
128
  class GitWorkspace:
82
129
  def __init__(self, cwd: Path, content: dict, cancel: threading.Event, worktrees: Path | None = None):
83
130
  self.cwd, self.cancel = cwd, cancel
@@ -203,6 +250,7 @@ class GitWorkspace:
203
250
  except OSError:
204
251
  raise GitError('git_worktree', '无法建立隔离工作树目录') from None
205
252
  self.run('worktree', 'add', '--detach', str(path), commit)
253
+ link_dependencies(root, path)
206
254
  self.cwd = path / subdirectory
207
255
  if not self.cwd.is_dir():
208
256
  raise GitError('workspace_missing', '独立工作树缺少已登记的子目录')
@@ -110,6 +110,8 @@ def run(cwd: Path, content: dict, cancel: threading.Event, worktrees: Path | Non
110
110
  return ToolResult(status="failed", failure_code="git_ahead", workspace_sync="sync_diverged",
111
111
  failure_detail=f"本地 {default} 领先远程 {ahead} 个提交,交给智能体核对后推送")
112
112
  notes = [f"已切回 {default} 并快进到远程最新"]
113
+ # 先清工作树再删分支:任务分支检出在部署人等的工作树里时删不掉(2026-11-23 T-177 本地任务分支因此留下)
114
+ removed = _remove_task_worktrees(root, branch or "", worktrees, cancel) if branch else []
113
115
  if branch and _exists(root, f"refs/heads/{branch}", cancel):
114
116
  try:
115
117
  # -d 只删已合并的分支,未合并的保留。
@@ -117,7 +119,6 @@ def run(cwd: Path, content: dict, cancel: threading.Event, worktrees: Path | Non
117
119
  notes.append(f"已删除本地任务分支 {branch}")
118
120
  except GitError:
119
121
  notes.append(f"本地任务分支 {branch} 有未合并提交,已保留")
120
- removed = _remove_task_worktrees(root, branch or "", worktrees, cancel) if branch else []
121
122
  if removed:
122
123
  notes.append("已清理独立工作树 " + "、".join(removed))
123
124
  return ToolResult(status="succeeded", reply_text=";".join(notes) + "。", workspace_sync="synced")