@arcships/morula-runtime 0.1.0-alpha.7 → 0.1.0-alpha.8
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/index.js +2042 -528
- package/dist/morula.js +1584 -109
- package/dist/plugin/plugin.json +1 -1
- package/dist/plugin/skills/morula-cli/SKILL.md +0 -1
- package/dist/plugin/skills/morula-cli/references/commands.md +1533 -254
- package/dist/plugin/skills/morula-working-on-issues/SKILL.md +11 -9
- package/dist/plugin/skills/morula-working-on-issues/references/working-on-issues-source-map.md +1 -1
- package/package.json +3 -2
|
@@ -17,11 +17,13 @@ allowed-tools: Bash(morula *), Bash(git *), Bash(gh *)
|
|
|
17
17
|
|
|
18
18
|
## 0. 运行时上下文与任务详情获取(对应任务系统提示词,必须一一对应)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
任务系统提示词(发给你的首条消息)只承载四样:**你的身份与边界**(阶段职责)、**你的目标**(「你的目标」段)、
|
|
21
|
+
**钥匙**(「基本信息」段的任务 ID / 空间 ID——只是命令入参,不是任务信息)、**工作区与工具入口**(本 skill 与
|
|
22
|
+
`morula task get` / `morula repo list` 的用法指引)。**其余上下文与任务详情一律不进提示词**,用 CLI 获取:
|
|
22
23
|
|
|
23
24
|
- **当前任务详情**:`morula task get`(无参)——taskId 由执行环境提供(`MORULA_TASK_ID` env / `.morula/checkout.json`),无需也不应从别处猜。返回:`id`(本任务 AgentTask ID,UUID)、`code`(任务编号,如 `SPW299-59`)、`objectId`(关联业务任务对象)、`taskPrompt`(本次目标原文)、`contextSnapshot`、`status`。
|
|
24
25
|
- **业务任务详情**(标题/描述):`morula task get <objectId>`;**关键评论**(用户原始诉求/分析结论):`morula comment list --object <objectId>`。
|
|
26
|
+
- **空间仓库清单**(多仓库任务判断依据):`morula repo list --space <spaceId>`——提示词不列仓库,需要时自己查。
|
|
25
27
|
- **「你的目标」**:系统提示「你的目标」段 = 本次任务的原始诉求,据此判断要做什么。
|
|
26
28
|
|
|
27
29
|
> **工作目录 = 任务工作区根**:根下放 `AGENTS.md`(空间项目说明,已作为 project.instructions 自动加载)、
|
|
@@ -55,7 +57,7 @@ allowed-tools: Bash(morula *), Bash(git *), Bash(gh *)
|
|
|
55
57
|
|
|
56
58
|
## 0.3 分支命名:由你(Agent)取名并上报
|
|
57
59
|
|
|
58
|
-
- **任务 ID 获取**:本任务的 AgentTask ID(UUID
|
|
60
|
+
- **任务 ID 获取**:本任务的 AgentTask ID(UUID)在系统提示「基本信息」段(也是 `morula task get`(无参)返回的 `id`,`.agent_context/task-context.md` 开头亦有)。需要调用 `morula task branch` 时用它作为 taskId。
|
|
59
61
|
- **重要区分**:`morula task branch <taskId>` 的 taskId 用**本任务 UUID**(机器协议);但 **MR / 分支 / PR 里的任务编号用对外编号 code**(如 `AGENT-958201`,用于服务端关联/关单)——**不要用 UUID 标记 MR**(UUID 关单只认业务对象,AgentTask 不会被识别,会导致 MR 关联失败)。
|
|
60
62
|
- **只有需要改代码并推分支的任务才取名**;纯问答/只读调研/本地起服务不建分支(见第 3 条决策树)。
|
|
61
63
|
- **先检查当前分支**:若仓库已有 feature 分支(同任务/同一改动闭环的后续轮次复用),**直接继续用当前分支,不要新建**(在仓库目录内执行):
|
|
@@ -108,13 +110,13 @@ allowed-tools: Bash(morula *), Bash(git *), Bash(gh *)
|
|
|
108
110
|
├── .agents/skills/ ← 协作契约 + 本任务自定义 skill
|
|
109
111
|
├── .agent_context/task-context.md ← 任务上下文(见 0 节)
|
|
110
112
|
├── .morula/checkout.json ← daemon 凭据(CLI 内部使用,不要手动读)
|
|
111
|
-
├── <owner>-<repo>/ ←
|
|
113
|
+
├── <owner>-<repo>/ ← 主仓库(已按平台解析结果物化;本地没有的仓库按需 checkout)
|
|
112
114
|
└── <owner>-<repo2>/ ← 次仓库 / 只读检出(按需物化,与主仓库同级)
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
- **git / gh 命令一律在对应仓库目录内执行**(`cd <工作区根>/<仓库目录>`,或 `git -C <仓库目录> ...`):
|
|
116
118
|
工作区根不是 git 仓库,在根目录跑 git 命令必然失败。`morula` CLI 可在工作区根或其任意子目录执行(见 0.4)。
|
|
117
|
-
-
|
|
119
|
+
- **主仓库**:平台已解析出的仓库在**工作区根下就绪**(目录名 = 仓库全名把 `/` 换成 `-`,如 `human-resources/xxx` → `human-resources-xxx`);`ls` 工作区根即可看到,直接在该目录内建分支/提交/推分支/提 PR。**需要空间绑定了哪些仓库时自己查**:`morula repo list --space <spaceId>`(spaceId 见系统提示「基本信息」段)。
|
|
118
120
|
- **若任务需要了解仓库内容/代码/提交状态(读场景,含纯问答)**:用 `morula repo checkout <taskId> <repoFullName>`(本地 daemon 端点,**本轮立即物化**并返回路径,通常是工作区根下的 `<仓库目录>-readonly`),然后在该路径内只读查证:
|
|
119
121
|
- 读代码/提交/分支:`git -C <路径> log --oneline -20`、`git -C <路径> show <sha>`、`git -C <路径> branch -a`、`rg "关键词" <路径>`、读文件等(**只读**,不建分支、不改代码、不提 PR);
|
|
120
122
|
- 刷新远端最新:`git -C <路径> fetch origin --prune`(remote 已配置 SSH,免密)。
|
|
@@ -122,7 +124,7 @@ allowed-tools: Bash(morula *), Bash(git *), Bash(gh *)
|
|
|
122
124
|
- **若任务需要改代码**:用 `morula repo checkout <taskId> <repoFullName>` 拉取/切换仓库(认证已由执行环境注入),
|
|
123
125
|
拿到返回的仓库路径后**chdir 进该仓库目录**,再按第 0.3 条建分支、第 3 条提 PR。可选 `--ref <branch|sha>` 指定检出分支。
|
|
124
126
|
- **若任务纯问答、或空间无可用仓库**:直接回答用户问题,不构建分支/PR(见第 3 条决策树)。
|
|
125
|
-
-
|
|
127
|
+
- **若任务涉及多个仓库(多仓库任务)**:涉及哪些仓库由**你**结合任务描述判断(任务描述里的「涉及仓库」是管家的初始判断;空间绑定了哪些仓库用 `morula repo list --space <spaceId>` 查;执行中发现还需改动其他仓库时,自行 prepare 拉取),**不需要向用户逐个确认**:
|
|
126
128
|
1. 主仓库:在它的子目录内直接 git 操作(工作区根不是仓库);
|
|
127
129
|
2. 其他仓库用 `morula repo prepare <taskId> <repoFullName>` 物化到任务工作区根下(**与主仓库同级的子目录**,本地 daemon 端点,本轮立即物化并返回路径;git 协议拉取,不走平台 API);
|
|
128
130
|
3. 在哪个仓库改动,就在哪个仓库内建分支(第 0.3 条命名规范)、推分支并建 PR/MR(title/description 带任务编号);每个仓库的 PR 服务端都会自动关联到本任务。**分支名逐仓上报**:主仓库(其子目录)用 `morula task branch <taskId> --name <分支名>`;次仓库(同级子目录)用 `morula task branch <taskId> --name <分支名> --repo <owner/name>` —— 服务端据此把分支名写到该仓库的工作上下文(平台侧逐仓建 MR 兜底、交付清单都依赖它;不报则一直停在占位分支名 `morula/tmp-*`,平台找不到你的分支);
|
|
@@ -144,8 +146,8 @@ allowed-tools: Bash(morula *), Bash(git *), Bash(gh *)
|
|
|
144
146
|
morula task inbox [--peek] # 运行中检查点:取本线程未消费消息,纳入本回合(见 1.3)
|
|
145
147
|
# 注:最终总结评论由服务端统一发送(作者=智能体),不要调用 comment add 自行置评。
|
|
146
148
|
```
|
|
147
|
-
-
|
|
148
|
-
`morula repo list --space <spaceId>`(`<spaceId>`
|
|
149
|
+
- **可用仓库清单**:系统提示**不再列出**仓库——需要枚举空间绑定的仓库时用
|
|
150
|
+
`morula repo list --space <spaceId>`(`<spaceId>` 见系统提示「基本信息」段,或 `morula task get` 返回的 `contextSnapshot.spaceId`)。
|
|
149
151
|
- **每个命令的完整参数以 `morula <resource> --help` 为准**(如 `morula repo --help` 只列 repo 的用法);不确定某命令支持哪些旗标时先查它,不要凭记忆拼参数。
|
|
150
152
|
- **禁止** `curl` / `wget` 直连平台 REST API;禁止读取 `~/.morula-cli/config.yaml`、token 文件或环境变量中的密钥。
|
|
151
153
|
- **本地 `.morula/checkout.json` 是 daemon 管理文件**(`morula repo checkout` 内部读取端口与任务凭据),**不要手动读取/复制其中的字段**;凭据由 CLI 处理,你不需要也不应当看到它。
|
|
@@ -332,7 +334,7 @@ morula task inbox --peek # 只看不取(确认有没有新意见,不标
|
|
|
332
334
|
|
|
333
335
|
- **何时发评论**:**最终总结评论由服务端统一以智能体身份发送**(任务完成时自动发布到任务对象,作者=当前智能体)。**你不需要、也不应调用 `morula comment add`**——只要在最终输出里给出用户关心的结论即可,服务端会作为该智能体的完成评论发布。chat 会话无 objectId 的任务(纯对话派发)不回评论——最终交付由 daemon 回填 assistant 消息。
|
|
334
336
|
- **终端输出、思考过程、工具日志用户都看不到**——用户看到的只有服务端整合后发布的最终总结评论。
|
|
335
|
-
- **评论
|
|
337
|
+
- **评论 @触发任务(本任务由评论触发)**:服务端会把最终总结自动作为**该触发评论的回复**发出(挂在被 @ 的评论下)。你无需、也不要自己调用 `morula comment add`/add_comment。
|
|
336
338
|
- **防重复(服务端保证)**:服务端对「同一个任务只发一条完成评论」做幂等,不会重复刷屏。你不需要、也不要去查/发多条。
|
|
337
339
|
- **最终输出 = 只留结论**(不设字数上限、不要求固定格式,自然组织即可):
|
|
338
340
|
- 必答:**做了什么、结果如何、用户需要知道的后续**。
|
package/dist/plugin/skills/morula-working-on-issues/references/working-on-issues-source-map.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
| CLI 写评论(**契约禁止 agent 自行调用**:完成评论由服务端统一发送,见本文件第 5 条) | `morula comment add`(命令存在,但本契约要求不调用) | `packages/morula-cli/src/commands/comment.ts` |
|
|
19
19
|
| CLI 任务详情(**无参**取本任务;带参取业务对象) | `morula task get` → `GET /agent-tasks/:id`;`morula task get <objectId>` → `GET /objects/:id` | `packages/morula-cli/src/commands/task.ts` |
|
|
20
20
|
| daemon 注入凭据(agent 无需自行登录) | runner 注入 `env` 给 Provider 子进程 | `packages/runtime/src/daemon/runner.ts` |
|
|
21
|
-
|
|
|
21
|
+
| 系统提示注入(身份与边界 = 阶段职责 / 目标 / 钥匙 taskId+spaceId / 工具入口指引);任务详情与仓库清单由 `morula task get`(无参)、`morula repo list --space` 获取 | `buildTaskPromptWithContract`(`runner.ts`,唯一进 dim 的 messages[0]);CLI `packages/morula-cli/src/commands/task.ts`(resolveTaskId → `GET /agent-tasks/:id`) | `packages/runtime/src/daemon/runner.ts` |
|
|
22
22
|
| 运行中检查点(本回合内取用户意见) | CLI `morula task inbox [--peek]` → `GET /agent-tasks/:id/thread/inbox`(机器协议;默认取走即消费,落 `consumed` + 当回合号);契约时机见本 SKILL 1.3 | `packages/morula-cli/src/commands/task.ts`、`src/modules/agent-task/chat/object-agent-chat.controller.ts`、`object-agent-message.service.ts`(`getThreadInbox`) |
|
|
23
23
|
| 运行中打断(同一会话重开一轮) | daemon 在安全点(`inFlightTools === 0`)`session/cancel` → `session/resume` → 用新意见重开 prompt;回合号与中断点上报为 `turn_started` / `turn_interrupted` 事件 | `packages/runtime/src/daemon/acp/dim-acp-executor.ts`(回合循环)、`runner.ts`(`buildSteerPort`)、`src/modules/agent-task/chat/object-agent-message.service.ts`(`steerDeliveryStrategy`) |
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcships/morula-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.8",
|
|
5
5
|
"description": "Device-level CLI for the Morula local agent runtime (daemon/portal/models/auth) and the Morula business CLI (morula), distributed via npm",
|
|
6
6
|
"bin": {
|
|
7
7
|
"morula-runtime": "./bin/morula-runtime.js",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
"build:env": "node scripts/gen-build-env.mjs",
|
|
21
21
|
"build:dist": "node scripts/build-dist.mjs",
|
|
22
22
|
"gen:plugin-skill": "tsx scripts/gen-plugin-skill.mts",
|
|
23
|
+
"gen:cli-skill": "tsx scripts/gen-cli-skill.mts",
|
|
23
24
|
"prepublishOnly": "pnpm run gen-build-env && pnpm run build:dist",
|
|
24
25
|
"postinstall": "node scripts/postinstall.mjs",
|
|
25
26
|
"dev": "tsx src/index.ts",
|
|
26
27
|
"dev:morula": "pnpm --filter @morula/morula-cli run dev",
|
|
27
28
|
"lint:type": "tsc --noEmit -p tsconfig.json",
|
|
28
|
-
"test": "tsx --test --test-concurrency=1 test/*.test.ts",
|
|
29
|
+
"test": "tsx --test --test-concurrency=1 test/*.test.ts src/**/*.spec.ts",
|
|
29
30
|
"smoke": "tsx src/index.ts --help"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|