geo-ai-search-optimization 1.2.8 → 1.2.10
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/README.md +72 -1
- package/package.json +1 -1
- package/resources/geo-ai-search-optimization/references/skill-bundle-map.md +20 -0
- package/resources/geo-ai-search-optimization-agent-executor/SKILL.md +24 -0
- package/resources/geo-ai-search-optimization-agent-executor/agents/openai.yaml +4 -0
- package/resources/geo-ai-search-optimization-agent-runbook/SKILL.md +24 -0
- package/resources/geo-ai-search-optimization-agent-runbook/agents/openai.yaml +4 -0
- package/resources/geo-ai-search-optimization-usage/SKILL.md +24 -14
- package/src/agent-executor.js +319 -0
- package/src/agent-runbook.js +438 -0
- package/src/agent-session.js +20 -0
- package/src/auto-flow.js +68 -11
- package/src/cli.js +68 -0
- package/src/index.js +2 -0
- package/src/skills.js +7 -0
package/README.md
CHANGED
|
@@ -81,6 +81,49 @@ geo-ai-search-optimization agent-session ./reports/apply-plan.json --json
|
|
|
81
81
|
- 每一步的目的与预期产物
|
|
82
82
|
- 可直接复制给 agent 的 session prompt
|
|
83
83
|
|
|
84
|
+
## Agent Runbook 命令
|
|
85
|
+
|
|
86
|
+
如果你希望 agent 拿到的不只是会话步骤,而是一份更稳定的执行手册和检查清单,可以直接用 `agent-runbook`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
geo-ai-search-optimization agent-runbook "我想把这份 GEO 结果交给下一个 agent 继续修"
|
|
90
|
+
geo-ai-search-optimization agent-runbook https://example.com
|
|
91
|
+
geo-ai-search-optimization agent-runbook ./your-site
|
|
92
|
+
geo-ai-search-optimization agent-runbook ./reports/apply-plan.json --json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
它会输出:
|
|
96
|
+
|
|
97
|
+
- 开始前检查
|
|
98
|
+
- 工作规则
|
|
99
|
+
- 需要停下来的情况
|
|
100
|
+
- 命令执行清单
|
|
101
|
+
- 重点执行包
|
|
102
|
+
- 验证清单
|
|
103
|
+
- 回报清单
|
|
104
|
+
- 可直接复制给 agent 的 runbook prompt
|
|
105
|
+
|
|
106
|
+
## Agent Executor 命令
|
|
107
|
+
|
|
108
|
+
如果你希望 agent 不只是拿到 runbook,而是直接得到“这一轮先执行哪 1 个任务”的入口,可以直接用 `agent-executor`:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
geo-ai-search-optimization agent-executor ./your-site
|
|
112
|
+
geo-ai-search-optimization agent-executor ./reports/apply-plan.json
|
|
113
|
+
geo-ai-search-optimization agent-executor ./reports/apply-plan.json --task fix-02 --json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
它会输出:
|
|
117
|
+
|
|
118
|
+
- 当前先做哪一包
|
|
119
|
+
- 为什么先做这一包
|
|
120
|
+
- do-now checklist
|
|
121
|
+
- stop checklist
|
|
122
|
+
- success checklist
|
|
123
|
+
- 验证命令
|
|
124
|
+
- 给用户的回报模板
|
|
125
|
+
- 可直接复制给 agent 的 executor prompt
|
|
126
|
+
|
|
84
127
|
## Quick Start
|
|
85
128
|
|
|
86
129
|
如果你要从 0 到 1 启动一个 GEO 项目,建议照这个顺序做。
|
|
@@ -476,6 +519,8 @@ geo-ai-search-optimization install
|
|
|
476
519
|
geo-ai-search-optimization install --target ./tmp/custom-skills --json
|
|
477
520
|
geo-ai-search-optimization auto-flow "audit this site and tell me the next skill"
|
|
478
521
|
geo-ai-search-optimization agent-session ./your-site
|
|
522
|
+
geo-ai-search-optimization agent-runbook ./your-site
|
|
523
|
+
geo-ai-search-optimization agent-executor ./your-site
|
|
479
524
|
geo-ai-search-optimization skills
|
|
480
525
|
geo-ai-search-optimization where
|
|
481
526
|
geo-ai-search-optimization doctor
|
|
@@ -532,6 +577,20 @@ geo-ai-search-optimization help
|
|
|
532
577
|
- 新增 `geo-ai-search-optimization-agent-session` skill
|
|
533
578
|
- 更适合把 GEO 任务直接交给下一个 agent 连续推进
|
|
534
579
|
|
|
580
|
+
## New in 1.2.9
|
|
581
|
+
|
|
582
|
+
- 新增 `agent-runbook` 命令
|
|
583
|
+
- 把 `agent-session` 继续推进成给 agent 使用的执行手册和检查清单
|
|
584
|
+
- 输出开始前检查、工作规则、停止条件、验证清单、回报清单
|
|
585
|
+
- 新增 `geo-ai-search-optimization-agent-runbook` skill
|
|
586
|
+
|
|
587
|
+
## New in 1.2.10
|
|
588
|
+
|
|
589
|
+
- 新增 `agent-executor` 命令
|
|
590
|
+
- 把 runbook 再收敛成“这一轮先做哪 1 包”的单任务入口
|
|
591
|
+
- 输出 do-now checklist、stop checklist、success checklist、验证命令和回报模板
|
|
592
|
+
- 新增 `geo-ai-search-optimization-agent-executor` skill
|
|
593
|
+
|
|
535
594
|
## New in 1.2.5
|
|
536
595
|
|
|
537
596
|
- 新增 `publish-pack`
|
|
@@ -715,10 +774,22 @@ Override with:
|
|
|
715
774
|
|
|
716
775
|
## Resource contents
|
|
717
776
|
|
|
718
|
-
The installed package now includes
|
|
777
|
+
The installed package now includes a bundled GEO skill pack, including:
|
|
719
778
|
|
|
720
779
|
- `geo-ai-search-optimization`
|
|
780
|
+
- `geo-ai-search-optimization-auto-flow`
|
|
781
|
+
- `geo-ai-search-optimization-agent-session`
|
|
782
|
+
- `geo-ai-search-optimization-agent-runbook`
|
|
783
|
+
- `geo-ai-search-optimization-agent-executor`
|
|
721
784
|
- `geo-ai-search-optimization-usage`
|
|
785
|
+
- `geo-ai-search-optimization-agent-handoff`
|
|
786
|
+
- `geo-ai-search-optimization-repair-loop`
|
|
787
|
+
- `geo-ai-search-optimization-completion-report`
|
|
788
|
+
- `geo-ai-search-optimization-handoff-bundle`
|
|
789
|
+
- `geo-ai-search-optimization-share-pack`
|
|
790
|
+
- `geo-ai-search-optimization-export-pack`
|
|
791
|
+
- `geo-ai-search-optimization-html-pack`
|
|
792
|
+
- `geo-ai-search-optimization-publish-pack`
|
|
722
793
|
|
|
723
794
|
## License
|
|
724
795
|
|
package/package.json
CHANGED
|
@@ -42,6 +42,26 @@ Best for:
|
|
|
42
42
|
- giving the next agent a first command, second command, and expected artifact list
|
|
43
43
|
- reducing ambiguity at handoff time
|
|
44
44
|
|
|
45
|
+
### `geo-ai-search-optimization-agent-runbook`
|
|
46
|
+
|
|
47
|
+
Use this when the next agent needs an execution manual, not just a session sequence.
|
|
48
|
+
|
|
49
|
+
Best for:
|
|
50
|
+
|
|
51
|
+
- turning a GEO session into a checklist-driven runbook
|
|
52
|
+
- telling the next agent what to check before acting
|
|
53
|
+
- defining stop conditions, validation checklist, and reporting checklist
|
|
54
|
+
|
|
55
|
+
### `geo-ai-search-optimization-agent-executor`
|
|
56
|
+
|
|
57
|
+
Use this when the next agent should stop planning and start one concrete execution packet.
|
|
58
|
+
|
|
59
|
+
Best for:
|
|
60
|
+
|
|
61
|
+
- selecting the first packet to execute now
|
|
62
|
+
- reducing a runbook into one actionable task
|
|
63
|
+
- giving the next agent a single-task prompt, validation commands, and reply template
|
|
64
|
+
|
|
45
65
|
## Usage guide
|
|
46
66
|
|
|
47
67
|
### `geo-ai-search-optimization-usage`
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: geo-ai-search-optimization-agent-executor
|
|
3
|
+
description: Turn a GEO input into a single-task execution entrypoint for the next agent. Use when an agent should stop planning and start one concrete GEO packet now, with a selected task, do-now checklist, validation commands, success criteria, and a reply template.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GEO Agent Executor
|
|
7
|
+
|
|
8
|
+
Use this skill when the next agent should execute one packet now, not keep expanding the plan.
|
|
9
|
+
|
|
10
|
+
`GEO = Generative Engine Optimization`
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- select the first or requested execution packet
|
|
15
|
+
- compress the runbook into one task entrypoint
|
|
16
|
+
- define do-now, stop, and success checklists
|
|
17
|
+
- provide validation commands and a reply template
|
|
18
|
+
- make the next agent focus on one packet at a time
|
|
19
|
+
|
|
20
|
+
## Best use
|
|
21
|
+
|
|
22
|
+
- when `agent-runbook` is still too broad
|
|
23
|
+
- when a PM or another agent asks “this round, what should we do first?”
|
|
24
|
+
- when execution should start from one concrete packet
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "GEO Agent Executor"
|
|
3
|
+
short_description: "Start one GEO execution packet right now"
|
|
4
|
+
default_prompt: "Use $geo-ai-search-optimization-agent-executor to choose the first GEO packet to execute now, with a do-now checklist, validation commands, and a reply template."
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: geo-ai-search-optimization-agent-runbook
|
|
3
|
+
description: Turn a GEO input into an execution runbook for the next agent. Use when an agent needs more than routing or a session plan, and should receive a checklist-driven manual with preflight checks, stop conditions, validation steps, reporting expectations, and optional execution packets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GEO Agent Runbook
|
|
7
|
+
|
|
8
|
+
Use this skill when the next agent should receive a practical runbook, not just a list of commands.
|
|
9
|
+
|
|
10
|
+
`GEO = Generative Engine Optimization`
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- turn a GEO input into a checklist-driven execution manual
|
|
15
|
+
- define what to check before acting
|
|
16
|
+
- define what should stop execution
|
|
17
|
+
- define how validation and reporting should work
|
|
18
|
+
- carry the next agent from session planning into disciplined execution
|
|
19
|
+
|
|
20
|
+
## Best use
|
|
21
|
+
|
|
22
|
+
- when `agent-session` is still too light and the next agent needs a more operational checklist
|
|
23
|
+
- when a PM or another agent wants a stable “follow this runbook” artifact
|
|
24
|
+
- when execution needs preflight, validation, and reporting rules
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "GEO Agent Runbook"
|
|
3
|
+
short_description: "Build a checklist-driven GEO execution manual"
|
|
4
|
+
default_prompt: "Use $geo-ai-search-optimization-agent-runbook to turn this input into a GEO runbook with preflight checks, execution checklist, validation steps, and reporting guidance."
|
|
@@ -13,23 +13,25 @@ Treat this tool as a PM-friendly GEO workflow for websites.
|
|
|
13
13
|
|
|
14
14
|
`GEO = Generative Engine Optimization`
|
|
15
15
|
|
|
16
|
-
The package is best explained as
|
|
16
|
+
The package is best explained as seventeen layers:
|
|
17
17
|
|
|
18
18
|
1. `auto-flow`: auto-select the next skill and command chain
|
|
19
19
|
2. `agent-session`: build a runnable session for the next agent
|
|
20
|
-
3. `
|
|
21
|
-
4. `
|
|
22
|
-
5. `
|
|
23
|
-
6. `
|
|
24
|
-
7. `
|
|
25
|
-
8. `
|
|
26
|
-
9. `
|
|
27
|
-
10. `
|
|
28
|
-
11. `
|
|
29
|
-
12. `
|
|
30
|
-
13. `
|
|
31
|
-
14. `
|
|
32
|
-
15. `
|
|
20
|
+
3. `agent-runbook`: execution manual and checklist for the next agent
|
|
21
|
+
4. `agent-executor`: choose one packet to execute right now
|
|
22
|
+
5. `skills`: inspect the bundled skill package
|
|
23
|
+
6. `onboard-url` / `onboard`: first look
|
|
24
|
+
7. `scan`: raw signal check
|
|
25
|
+
8. `audit` / `report`: diagnosis
|
|
26
|
+
9. `fix-plan` / `owner-board`: execution planning
|
|
27
|
+
10. `agent-handoff`: agent takeover package
|
|
28
|
+
11. `apply-plan`: execution loop
|
|
29
|
+
12. `completion-report`: closeout
|
|
30
|
+
13. `handoff-bundle`: all-in-one package
|
|
31
|
+
14. `share-pack`: audience-ready delivery
|
|
32
|
+
15. `export-pack`: folder export
|
|
33
|
+
16. `html-pack` / `publish-pack`: browsable and final delivery output
|
|
34
|
+
17. `pm-brief` / `roadmap`: stakeholder alignment
|
|
33
35
|
|
|
34
36
|
## Recommended command order
|
|
35
37
|
|
|
@@ -38,6 +40,8 @@ If the user only has a website URL:
|
|
|
38
40
|
```bash
|
|
39
41
|
npx geo-ai-search-optimization auto-flow https://example.com
|
|
40
42
|
npx geo-ai-search-optimization agent-session https://example.com
|
|
43
|
+
npx geo-ai-search-optimization agent-runbook https://example.com
|
|
44
|
+
npx geo-ai-search-optimization agent-executor https://example.com
|
|
41
45
|
npx geo-ai-search-optimization onboard-url https://example.com
|
|
42
46
|
npx geo-ai-search-optimization pm-brief https://example.com
|
|
43
47
|
npx geo-ai-search-optimization roadmap https://example.com
|
|
@@ -48,6 +52,8 @@ If the user has the website codebase:
|
|
|
48
52
|
```bash
|
|
49
53
|
npx geo-ai-search-optimization auto-flow ./your-site
|
|
50
54
|
npx geo-ai-search-optimization agent-session ./your-site
|
|
55
|
+
npx geo-ai-search-optimization agent-runbook ./your-site
|
|
56
|
+
npx geo-ai-search-optimization agent-executor ./your-site
|
|
51
57
|
npx geo-ai-search-optimization scan ./your-site
|
|
52
58
|
npx geo-ai-search-optimization audit ./your-site
|
|
53
59
|
npx geo-ai-search-optimization fix-plan ./your-site
|
|
@@ -67,6 +73,8 @@ npx geo-ai-search-optimization roadmap ./your-site
|
|
|
67
73
|
|
|
68
74
|
- `auto-flow`: auto-select the next skill and command order from a task brief, URL, project path, or GEO artifact
|
|
69
75
|
- `agent-session`: build a step-by-step session packet for the next agent from the same kinds of inputs
|
|
76
|
+
- `agent-runbook`: build a checklist-driven runbook with preflight, validation, and reporting rules
|
|
77
|
+
- `agent-executor`: select one packet to execute now and package it into a single-task entrypoint
|
|
70
78
|
- `onboard-url`: first-time website check from a live URL
|
|
71
79
|
- `onboard`: interactive first-time onboarding
|
|
72
80
|
- `skills`: list the bundled skills and decide which skill or command chain fits the task
|
|
@@ -93,6 +101,8 @@ When explaining the tool to a user:
|
|
|
93
101
|
- prefer telling them which command to run next, not listing every command
|
|
94
102
|
- if the user or the next agent is unsure where to start, move them to `auto-flow` first
|
|
95
103
|
- if the user wants something the next agent can follow step by step, move them to `agent-session`
|
|
104
|
+
- if the user wants the next agent to follow a checklist and execution manual, move them to `agent-runbook`
|
|
105
|
+
- if the user wants the next agent to start one concrete task now, move them to `agent-executor`
|
|
96
106
|
- explain the result in PM language, not implementation jargon
|
|
97
107
|
- if the user sounds new, start with `onboard-url` or `quick-start`
|
|
98
108
|
- if the user wants another agent to take over, move them to `agent-handoff`
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createApplyPlan } from "./apply-plan.js";
|
|
3
|
+
import { createAgentRunbook } from "./agent-runbook.js";
|
|
4
|
+
import { writeScanOutput } from "./scan.js";
|
|
5
|
+
|
|
6
|
+
const VALID_FORMATS = new Set(["markdown", "json"]);
|
|
7
|
+
|
|
8
|
+
function normalizeFormat(format) {
|
|
9
|
+
const resolved = (format || "markdown").toLowerCase();
|
|
10
|
+
if (!VALID_FORMATS.has(resolved)) {
|
|
11
|
+
throw new Error(`不支持的 agent-executor 格式:${format}。可选值:${Array.from(VALID_FORMATS).join(", ")}`);
|
|
12
|
+
}
|
|
13
|
+
return resolved;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function loadJsonArtifact(input) {
|
|
17
|
+
const raw = await readFile(input, "utf8");
|
|
18
|
+
return JSON.parse(raw);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function resolveRunbookAndPlan(input, options = {}) {
|
|
22
|
+
const runbook = await createAgentRunbook(input, {
|
|
23
|
+
format: "json",
|
|
24
|
+
intent: options.intent,
|
|
25
|
+
taskId: options.taskId
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (runbook.applyPlan?.kind === "geo-apply-plan") {
|
|
29
|
+
return {
|
|
30
|
+
runbook,
|
|
31
|
+
applyPlan: runbook.applyPlan
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (runbook.sourceType === "json") {
|
|
36
|
+
const parsed = await loadJsonArtifact(input).catch(() => null);
|
|
37
|
+
if (parsed?.kind === "geo-apply-plan") {
|
|
38
|
+
return {
|
|
39
|
+
runbook,
|
|
40
|
+
applyPlan: parsed
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (parsed?.kind === "geo-agent-runbook" && parsed.applyPlan?.kind === "geo-apply-plan") {
|
|
44
|
+
return {
|
|
45
|
+
runbook,
|
|
46
|
+
applyPlan: parsed.applyPlan
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const applyPlan = await createApplyPlan(input, {
|
|
53
|
+
format: "json",
|
|
54
|
+
taskId: options.taskId
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
runbook,
|
|
58
|
+
applyPlan
|
|
59
|
+
};
|
|
60
|
+
} catch {
|
|
61
|
+
return {
|
|
62
|
+
runbook,
|
|
63
|
+
applyPlan: null
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function inferExecutorMode(runbook, applyPlan) {
|
|
69
|
+
if (!applyPlan?.packets?.length) {
|
|
70
|
+
if (runbook.contextNeeded?.length) {
|
|
71
|
+
return "needs-context";
|
|
72
|
+
}
|
|
73
|
+
return "planning-only";
|
|
74
|
+
}
|
|
75
|
+
return applyPlan.executionType || "guided-planning";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function selectPacket(applyPlan, taskId) {
|
|
79
|
+
if (!applyPlan?.packets?.length) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (taskId) {
|
|
84
|
+
const selected = applyPlan.packets.find((packet) => packet.id === taskId);
|
|
85
|
+
if (!selected) {
|
|
86
|
+
throw new Error(`找不到执行包:${taskId}`);
|
|
87
|
+
}
|
|
88
|
+
return selected;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return applyPlan.packets[0];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function buildSelectionReason(packet, applyPlan, taskId) {
|
|
95
|
+
if (!packet) {
|
|
96
|
+
return "当前还没有可执行任务包,说明需要先补上下文或先生成 apply-plan。";
|
|
97
|
+
}
|
|
98
|
+
if (taskId) {
|
|
99
|
+
return `已按指定任务 ID 选中:${taskId}。`;
|
|
100
|
+
}
|
|
101
|
+
if (applyPlan?.selectedTaskCount > 1) {
|
|
102
|
+
return "默认选择第一包,代表当前优先级最高、最适合立刻开始的一项任务。";
|
|
103
|
+
}
|
|
104
|
+
return "当前只有一个任务包,因此直接将它作为本轮执行入口。";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function buildDoNowChecklist(packet, executorMode) {
|
|
108
|
+
if (!packet) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const items = [
|
|
113
|
+
`先锁定任务范围:${packet.title}`,
|
|
114
|
+
...packet.inspectTargets.slice(0, 3).map((item) => `先检查:${item}`),
|
|
115
|
+
...packet.editPlan.slice(0, 3).map((item) => `执行动作:${item}`)
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
if (executorMode === "direct-fix") {
|
|
119
|
+
items.push("开始修改前先确认会影响整类页面的复用层,而不是只 patch 单页。");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return items;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function buildStopChecklist(runbook, packet, executorMode) {
|
|
126
|
+
const items = [...(runbook.stopConditions || [])];
|
|
127
|
+
|
|
128
|
+
if (!packet) {
|
|
129
|
+
items.push("还没有拿到执行包时,不要假装已经进入真正修复阶段。");
|
|
130
|
+
return items;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (executorMode === "recommendation-only") {
|
|
134
|
+
items.push("如果当前只有网址或建议上下文,不要输出伪造的代码修改结果。");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
items.push("如果执行中发现这不是最高优先级任务,应先说明原因,再决定是否切换。");
|
|
138
|
+
return items;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function buildSuccessChecklist(packet) {
|
|
142
|
+
if (!packet) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return [
|
|
147
|
+
...packet.doneWhen,
|
|
148
|
+
"你已经能用 PM 可读的方式说明:改了什么、为什么改、验证结果是什么。"
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function buildNextCommands(runbook, packet, input) {
|
|
153
|
+
if (!packet) {
|
|
154
|
+
return runbook.nextCommands || [`geo-ai-search-optimization agent-runbook ${input}`];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const source = runbook.source;
|
|
158
|
+
return [
|
|
159
|
+
`geo-ai-search-optimization completion-report ${source}`,
|
|
160
|
+
`geo-ai-search-optimization handoff-bundle ${source}`
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function buildUserReplyTemplate(packet, executorMode) {
|
|
165
|
+
if (!packet) {
|
|
166
|
+
return [
|
|
167
|
+
"结论:我还不能直接执行,因为当前缺少足够上下文。",
|
|
168
|
+
"我目前确认到的情况:",
|
|
169
|
+
"- ",
|
|
170
|
+
"我还需要你补充:",
|
|
171
|
+
"- ",
|
|
172
|
+
"拿到这些之后,我会先执行:",
|
|
173
|
+
"- "
|
|
174
|
+
].join("\n");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const closingLine =
|
|
178
|
+
executorMode === "direct-fix"
|
|
179
|
+
? "我已经完成这一包可直接落地的部分,并附上复测结果。"
|
|
180
|
+
: executorMode === "recommendation-only"
|
|
181
|
+
? "我已经完成这一包的建议版执行,但还需要更多上下文才能继续实际修改。"
|
|
182
|
+
: "我已经把这一包的执行顺序和阻塞项整理好,下一步可以继续推进。";
|
|
183
|
+
|
|
184
|
+
return [
|
|
185
|
+
`任务:${packet.title}`,
|
|
186
|
+
`结论:${closingLine}`,
|
|
187
|
+
"这次我先做了什么:",
|
|
188
|
+
"- ",
|
|
189
|
+
"我检查了哪些文件 / 页面 / 模板:",
|
|
190
|
+
"- ",
|
|
191
|
+
"我实际修改或建议了什么:",
|
|
192
|
+
"- ",
|
|
193
|
+
"验证结果:",
|
|
194
|
+
"- ",
|
|
195
|
+
"剩余风险或下一步:",
|
|
196
|
+
"- "
|
|
197
|
+
].join("\n");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function buildExecutorPrompt(runbook, packet, executorMode, selectionReason) {
|
|
201
|
+
const lines = [
|
|
202
|
+
"你现在进入 GEO 单任务执行模式。",
|
|
203
|
+
`当前输入:${runbook.source}`,
|
|
204
|
+
`当前阶段:${runbook.stage}`,
|
|
205
|
+
`执行模式:${executorMode}`,
|
|
206
|
+
`任务选择原因:${selectionReason}`
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
if (packet) {
|
|
210
|
+
lines.push(`本轮只做这一包:${packet.title}`);
|
|
211
|
+
lines.push("请你按这个顺序输出:");
|
|
212
|
+
lines.push("1. 先检查什么");
|
|
213
|
+
lines.push("2. 你准备如何执行这一包");
|
|
214
|
+
lines.push("3. 你会如何验证");
|
|
215
|
+
lines.push("4. 完成后如何向用户回报");
|
|
216
|
+
} else {
|
|
217
|
+
lines.push("当前还不能执行具体任务。请先明确缺什么上下文,再告诉用户下一步要补什么。");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
lines.push("一次只推进一包,不要在同一轮同时展开多个任务。");
|
|
221
|
+
return lines.join("\n");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export async function createAgentExecutor(input, options = {}) {
|
|
225
|
+
const format = normalizeFormat(options.format);
|
|
226
|
+
const { runbook, applyPlan } = await resolveRunbookAndPlan(input, options);
|
|
227
|
+
const executorMode = inferExecutorMode(runbook, applyPlan);
|
|
228
|
+
const packet = selectPacket(applyPlan, options.taskId);
|
|
229
|
+
const selectionReason = buildSelectionReason(packet, applyPlan, options.taskId);
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
kind: "geo-agent-executor",
|
|
233
|
+
input,
|
|
234
|
+
source: runbook.source,
|
|
235
|
+
sourceType: runbook.sourceType,
|
|
236
|
+
artifactKind: runbook.artifactKind,
|
|
237
|
+
format,
|
|
238
|
+
intent: runbook.intent,
|
|
239
|
+
stage: runbook.stage,
|
|
240
|
+
executorMode,
|
|
241
|
+
goal: packet ? `先完成这一包:${packet.title}` : runbook.goal,
|
|
242
|
+
selectionReason,
|
|
243
|
+
selectedSkill: {
|
|
244
|
+
name: "geo-ai-search-optimization-agent-executor",
|
|
245
|
+
displayName: "GEO Agent Executor",
|
|
246
|
+
shortDescription: "Start one GEO execution packet right now"
|
|
247
|
+
},
|
|
248
|
+
selectedPacket: packet,
|
|
249
|
+
doNowChecklist: buildDoNowChecklist(packet, executorMode),
|
|
250
|
+
stopChecklist: buildStopChecklist(runbook, packet, executorMode),
|
|
251
|
+
successChecklist: buildSuccessChecklist(packet),
|
|
252
|
+
validationCommands: packet?.validationCommands || runbook.validationChecklist || [],
|
|
253
|
+
userReplyTemplate: buildUserReplyTemplate(packet, executorMode),
|
|
254
|
+
nextCommands: buildNextCommands(runbook, packet, input),
|
|
255
|
+
executorPrompt: buildExecutorPrompt(runbook, packet, executorMode, selectionReason),
|
|
256
|
+
agentRunbook: runbook,
|
|
257
|
+
applyPlan
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function renderAgentExecutorMarkdown(executor) {
|
|
262
|
+
const lines = [
|
|
263
|
+
"# GEO Agent Executor",
|
|
264
|
+
"",
|
|
265
|
+
`- 输入:\`${executor.source}\``,
|
|
266
|
+
`- 输入类型:\`${executor.sourceType}\``,
|
|
267
|
+
`- 工件类型:\`${executor.artifactKind}\``,
|
|
268
|
+
`- 当前阶段:${executor.stage}`,
|
|
269
|
+
`- 执行模式:\`${executor.executorMode}\``,
|
|
270
|
+
`- 本轮目标:${executor.goal}`,
|
|
271
|
+
`- 任务选择原因:${executor.selectionReason}`,
|
|
272
|
+
"",
|
|
273
|
+
"## 现在先做什么",
|
|
274
|
+
""
|
|
275
|
+
];
|
|
276
|
+
|
|
277
|
+
for (const item of executor.doNowChecklist) {
|
|
278
|
+
lines.push(`- [ ] ${item}`);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (executor.selectedPacket) {
|
|
282
|
+
lines.push("", "## 当前任务包", "");
|
|
283
|
+
lines.push(`- ID:\`${executor.selectedPacket.id}\``);
|
|
284
|
+
lines.push(`- 标题:${executor.selectedPacket.title}`);
|
|
285
|
+
lines.push(`- 优先级:${executor.selectedPacket.priority}`);
|
|
286
|
+
lines.push(`- Owner:${executor.selectedPacket.owner}`);
|
|
287
|
+
lines.push(`- 执行类型:\`${executor.selectedPacket.executionType}\``);
|
|
288
|
+
lines.push("");
|
|
289
|
+
lines.push("### 验证命令", "");
|
|
290
|
+
for (const command of executor.validationCommands) {
|
|
291
|
+
lines.push(`- \`${command}\``);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
lines.push("", "## 需要停下来的情况", "");
|
|
296
|
+
for (const item of executor.stopChecklist) {
|
|
297
|
+
lines.push(`- [ ] ${item}`);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
lines.push("", "## 完成标准", "");
|
|
301
|
+
for (const item of executor.successChecklist) {
|
|
302
|
+
lines.push(`- [ ] ${item}`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
lines.push("", "## 完成后怎么回报用户", "", "```text", executor.userReplyTemplate, "```");
|
|
306
|
+
|
|
307
|
+
lines.push("", "## 下一步推荐命令", "");
|
|
308
|
+
for (const command of executor.nextCommands) {
|
|
309
|
+
lines.push(`- \`${command}\``);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
lines.push("", "## 可直接复制给 Agent 的 Executor Prompt", "", "```text", executor.executorPrompt, "```");
|
|
313
|
+
|
|
314
|
+
return `${lines.join("\n")}\n`;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export async function writeAgentExecutorOutput(outputPath, content) {
|
|
318
|
+
return writeScanOutput(outputPath, content);
|
|
319
|
+
}
|