geo-ai-search-optimization 1.2.7 → 1.2.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/README.md +28 -0
- package/package.json +1 -1
- package/resources/geo-ai-search-optimization/references/skill-bundle-map.md +10 -0
- package/resources/geo-ai-search-optimization-agent-session/SKILL.md +24 -0
- package/resources/geo-ai-search-optimization-agent-session/agents/openai.yaml +4 -0
- package/resources/geo-ai-search-optimization-usage/SKILL.md +19 -14
- package/src/agent-session.js +297 -0
- package/src/cli.js +31 -0
- package/src/index.js +1 -0
- package/src/skills.js +2 -0
package/README.md
CHANGED
|
@@ -61,6 +61,26 @@ geo-ai-search-optimization auto-flow ./reports/apply-plan.json --json
|
|
|
61
61
|
- 建议命令顺序
|
|
62
62
|
- 可直接复制给 agent 的 prompt
|
|
63
63
|
|
|
64
|
+
## Agent Session 命令
|
|
65
|
+
|
|
66
|
+
如果你希望不只是“选 skill”,而是直接产出一份给 agent 跟着执行的会话包,可以用 `agent-session`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
geo-ai-search-optimization agent-session "我想把这份 GEO 结果交给下一个 agent 继续修"
|
|
70
|
+
geo-ai-search-optimization agent-session https://example.com
|
|
71
|
+
geo-ai-search-optimization agent-session ./your-site
|
|
72
|
+
geo-ai-search-optimization agent-session ./reports/apply-plan.json --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
它会输出:
|
|
76
|
+
|
|
77
|
+
- 当前阶段与会话状态
|
|
78
|
+
- 会话目标
|
|
79
|
+
- 自动选择的 skill
|
|
80
|
+
- 一步步该跑什么命令
|
|
81
|
+
- 每一步的目的与预期产物
|
|
82
|
+
- 可直接复制给 agent 的 session prompt
|
|
83
|
+
|
|
64
84
|
## Quick Start
|
|
65
85
|
|
|
66
86
|
如果你要从 0 到 1 启动一个 GEO 项目,建议照这个顺序做。
|
|
@@ -455,6 +475,7 @@ geo-ai-search-optimization
|
|
|
455
475
|
geo-ai-search-optimization install
|
|
456
476
|
geo-ai-search-optimization install --target ./tmp/custom-skills --json
|
|
457
477
|
geo-ai-search-optimization auto-flow "audit this site and tell me the next skill"
|
|
478
|
+
geo-ai-search-optimization agent-session ./your-site
|
|
458
479
|
geo-ai-search-optimization skills
|
|
459
480
|
geo-ai-search-optimization where
|
|
460
481
|
geo-ai-search-optimization doctor
|
|
@@ -504,6 +525,13 @@ geo-ai-search-optimization help
|
|
|
504
525
|
- 输出推荐 skill、命令顺序与可直接复制给 agent 的 prompt
|
|
505
526
|
- 新增 `geo-ai-search-optimization-auto-flow` skill,作为 agent 的自动路由入口
|
|
506
527
|
|
|
528
|
+
## New in 1.2.8
|
|
529
|
+
|
|
530
|
+
- 新增 `agent-session` 命令,生成给 agent 跟着执行的会话包
|
|
531
|
+
- 在 `auto-flow` 之上补上步骤级说明、预期产物和 session prompt
|
|
532
|
+
- 新增 `geo-ai-search-optimization-agent-session` skill
|
|
533
|
+
- 更适合把 GEO 任务直接交给下一个 agent 连续推进
|
|
534
|
+
|
|
507
535
|
## New in 1.2.5
|
|
508
536
|
|
|
509
537
|
- 新增 `publish-pack`
|
package/package.json
CHANGED
|
@@ -32,6 +32,16 @@ Best for:
|
|
|
32
32
|
- turning one-line task briefs into a concrete command sequence
|
|
33
33
|
- deciding whether the work should move into diagnosis, execution, closeout, or delivery
|
|
34
34
|
|
|
35
|
+
### `geo-ai-search-optimization-agent-session`
|
|
36
|
+
|
|
37
|
+
Use this when the next agent needs a runnable session plan, not just a routing answer.
|
|
38
|
+
|
|
39
|
+
Best for:
|
|
40
|
+
|
|
41
|
+
- turning `auto-flow` output into a step-by-step execution sequence
|
|
42
|
+
- giving the next agent a first command, second command, and expected artifact list
|
|
43
|
+
- reducing ambiguity at handoff time
|
|
44
|
+
|
|
35
45
|
## Usage guide
|
|
36
46
|
|
|
37
47
|
### `geo-ai-search-optimization-usage`
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: geo-ai-search-optimization-agent-session
|
|
3
|
+
description: Turn a GEO input into a step-by-step agent session plan. Use when an agent should not only pick the next GEO skill, but also receive a runnable session sequence with step goals, expected artifacts, and a copyable session prompt.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GEO Agent Session
|
|
7
|
+
|
|
8
|
+
Use this skill when the next agent should receive a full GEO session plan instead of only a routing recommendation.
|
|
9
|
+
|
|
10
|
+
`GEO = Generative Engine Optimization`
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- choose the current GEO stage
|
|
15
|
+
- choose the right next skill
|
|
16
|
+
- build a step-by-step command sequence
|
|
17
|
+
- explain what each step should produce
|
|
18
|
+
- generate a copyable session prompt
|
|
19
|
+
|
|
20
|
+
## Best use
|
|
21
|
+
|
|
22
|
+
- start a new agent run from a URL, project directory, or GEO artifact
|
|
23
|
+
- turn `auto-flow` output into an execution-ready session
|
|
24
|
+
- hand another agent a clear “do this first, then this” sequence
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "GEO Agent Session"
|
|
3
|
+
short_description: "Build a runnable GEO session for the next agent"
|
|
4
|
+
default_prompt: "Use $geo-ai-search-optimization-agent-session to turn this input into a runnable GEO agent session with step order, expected outputs, and a session prompt."
|
|
@@ -13,22 +13,23 @@ 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 fifteen layers:
|
|
17
17
|
|
|
18
18
|
1. `auto-flow`: auto-select the next skill and command chain
|
|
19
|
-
2. `
|
|
20
|
-
3. `
|
|
21
|
-
4. `
|
|
22
|
-
5. `
|
|
23
|
-
6. `
|
|
24
|
-
7. `
|
|
25
|
-
8. `
|
|
26
|
-
9. `
|
|
27
|
-
10. `
|
|
28
|
-
11. `
|
|
29
|
-
12. `
|
|
30
|
-
13. `
|
|
31
|
-
14. `
|
|
19
|
+
2. `agent-session`: build a runnable session for the next agent
|
|
20
|
+
3. `skills`: inspect the bundled skill package
|
|
21
|
+
4. `onboard-url` / `onboard`: first look
|
|
22
|
+
5. `scan`: raw signal check
|
|
23
|
+
6. `audit` / `report`: diagnosis
|
|
24
|
+
7. `fix-plan` / `owner-board`: execution planning
|
|
25
|
+
8. `agent-handoff`: agent takeover package
|
|
26
|
+
9. `apply-plan`: execution loop
|
|
27
|
+
10. `completion-report`: closeout
|
|
28
|
+
11. `handoff-bundle`: all-in-one package
|
|
29
|
+
12. `share-pack`: audience-ready delivery
|
|
30
|
+
13. `export-pack`: folder export
|
|
31
|
+
14. `html-pack` / `publish-pack`: browsable and final delivery output
|
|
32
|
+
15. `pm-brief` / `roadmap`: stakeholder alignment
|
|
32
33
|
|
|
33
34
|
## Recommended command order
|
|
34
35
|
|
|
@@ -36,6 +37,7 @@ If the user only has a website URL:
|
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
39
|
npx geo-ai-search-optimization auto-flow https://example.com
|
|
40
|
+
npx geo-ai-search-optimization agent-session https://example.com
|
|
39
41
|
npx geo-ai-search-optimization onboard-url https://example.com
|
|
40
42
|
npx geo-ai-search-optimization pm-brief https://example.com
|
|
41
43
|
npx geo-ai-search-optimization roadmap https://example.com
|
|
@@ -45,6 +47,7 @@ If the user has the website codebase:
|
|
|
45
47
|
|
|
46
48
|
```bash
|
|
47
49
|
npx geo-ai-search-optimization auto-flow ./your-site
|
|
50
|
+
npx geo-ai-search-optimization agent-session ./your-site
|
|
48
51
|
npx geo-ai-search-optimization scan ./your-site
|
|
49
52
|
npx geo-ai-search-optimization audit ./your-site
|
|
50
53
|
npx geo-ai-search-optimization fix-plan ./your-site
|
|
@@ -63,6 +66,7 @@ npx geo-ai-search-optimization roadmap ./your-site
|
|
|
63
66
|
## When to recommend each command
|
|
64
67
|
|
|
65
68
|
- `auto-flow`: auto-select the next skill and command order from a task brief, URL, project path, or GEO artifact
|
|
69
|
+
- `agent-session`: build a step-by-step session packet for the next agent from the same kinds of inputs
|
|
66
70
|
- `onboard-url`: first-time website check from a live URL
|
|
67
71
|
- `onboard`: interactive first-time onboarding
|
|
68
72
|
- `skills`: list the bundled skills and decide which skill or command chain fits the task
|
|
@@ -88,6 +92,7 @@ When explaining the tool to a user:
|
|
|
88
92
|
|
|
89
93
|
- prefer telling them which command to run next, not listing every command
|
|
90
94
|
- if the user or the next agent is unsure where to start, move them to `auto-flow` first
|
|
95
|
+
- if the user wants something the next agent can follow step by step, move them to `agent-session`
|
|
91
96
|
- explain the result in PM language, not implementation jargon
|
|
92
97
|
- if the user sounds new, start with `onboard-url` or `quick-start`
|
|
93
98
|
- if the user wants another agent to take over, move them to `agent-handoff`
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { createAutoFlow } from "./auto-flow.js";
|
|
2
|
+
import { writeScanOutput } from "./scan.js";
|
|
3
|
+
|
|
4
|
+
function inferSessionStatus(flow) {
|
|
5
|
+
if (flow.contextNeeded.length > 0) {
|
|
6
|
+
return "needs-context";
|
|
7
|
+
}
|
|
8
|
+
if (flow.intent === "share") {
|
|
9
|
+
return "delivery-ready";
|
|
10
|
+
}
|
|
11
|
+
if (flow.intent === "closeout") {
|
|
12
|
+
return "closeout-ready";
|
|
13
|
+
}
|
|
14
|
+
if (flow.intent === "execute") {
|
|
15
|
+
return "execution-ready";
|
|
16
|
+
}
|
|
17
|
+
return "analysis-ready";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function inferSessionGoal(flow) {
|
|
21
|
+
if (flow.intent === "share") {
|
|
22
|
+
return "把当前 GEO 结果整理成适合分享、外发或交接的产物。";
|
|
23
|
+
}
|
|
24
|
+
if (flow.intent === "closeout") {
|
|
25
|
+
return "整理本轮 GEO 执行结果、剩余风险和下一轮任务。";
|
|
26
|
+
}
|
|
27
|
+
if (flow.intent === "execute") {
|
|
28
|
+
return "把当前输入推进到 agent 可接手、可执行、可验证的 GEO 修复链。";
|
|
29
|
+
}
|
|
30
|
+
if (flow.intent === "guide") {
|
|
31
|
+
return "明确现在该用哪个 skill、该跑哪些命令,以及先后顺序。";
|
|
32
|
+
}
|
|
33
|
+
return "建立当前 GEO 状态、优先级和下一步执行方向。";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseCommand(command) {
|
|
37
|
+
const parts = String(command).trim().split(/\s+/);
|
|
38
|
+
const commandName = parts[1] || parts[0] || "";
|
|
39
|
+
return {
|
|
40
|
+
raw: command,
|
|
41
|
+
commandName
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function inferSkillForCommand(commandName, flow) {
|
|
46
|
+
if (commandName === "auto-flow") {
|
|
47
|
+
return "geo-ai-search-optimization-auto-flow";
|
|
48
|
+
}
|
|
49
|
+
if (commandName === "skills" || commandName === "quick-start") {
|
|
50
|
+
return "geo-ai-search-optimization-usage";
|
|
51
|
+
}
|
|
52
|
+
if (["share-pack"].includes(commandName)) {
|
|
53
|
+
return "geo-ai-search-optimization-share-pack";
|
|
54
|
+
}
|
|
55
|
+
if (["export-pack"].includes(commandName)) {
|
|
56
|
+
return "geo-ai-search-optimization-export-pack";
|
|
57
|
+
}
|
|
58
|
+
if (["html-pack"].includes(commandName)) {
|
|
59
|
+
return "geo-ai-search-optimization-html-pack";
|
|
60
|
+
}
|
|
61
|
+
if (["publish-pack"].includes(commandName)) {
|
|
62
|
+
return "geo-ai-search-optimization-publish-pack";
|
|
63
|
+
}
|
|
64
|
+
if (["agent-handoff"].includes(commandName)) {
|
|
65
|
+
return "geo-ai-search-optimization-agent-handoff";
|
|
66
|
+
}
|
|
67
|
+
if (["apply-plan"].includes(commandName)) {
|
|
68
|
+
return "geo-ai-search-optimization-repair-loop";
|
|
69
|
+
}
|
|
70
|
+
if (["completion-report"].includes(commandName)) {
|
|
71
|
+
return "geo-ai-search-optimization-completion-report";
|
|
72
|
+
}
|
|
73
|
+
if (["handoff-bundle"].includes(commandName)) {
|
|
74
|
+
return "geo-ai-search-optimization-handoff-bundle";
|
|
75
|
+
}
|
|
76
|
+
if (["onboard", "onboard-url", "scan", "audit", "report", "fix-plan", "owner-board", "pm-brief", "roadmap", "meeting-pack", "exec-summary"].includes(commandName)) {
|
|
77
|
+
return flow.selectedSkill.name === "geo-ai-search-optimization-usage"
|
|
78
|
+
? "geo-ai-search-optimization"
|
|
79
|
+
: flow.selectedSkill.name;
|
|
80
|
+
}
|
|
81
|
+
return flow.selectedSkill.name;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function inferStepPurpose(commandName, flow) {
|
|
85
|
+
switch (commandName) {
|
|
86
|
+
case "skills":
|
|
87
|
+
return "先理解当前技能包结构,避免 agent 选错链路。";
|
|
88
|
+
case "quick-start":
|
|
89
|
+
return "快速建立从 0 到 1 的执行顺序。";
|
|
90
|
+
case "onboard":
|
|
91
|
+
case "onboard-url":
|
|
92
|
+
return "先从网址或引导流程拿到首轮 GEO 判断。";
|
|
93
|
+
case "scan":
|
|
94
|
+
return "先做原始信号扫描,确认基础缺口。";
|
|
95
|
+
case "audit":
|
|
96
|
+
return "拿到分数、问题区域和优先级。";
|
|
97
|
+
case "report":
|
|
98
|
+
return "把当前结果整理成可读报告。";
|
|
99
|
+
case "fix-plan":
|
|
100
|
+
return "把诊断结果转成待办和优先级。";
|
|
101
|
+
case "owner-board":
|
|
102
|
+
return "把任务按角色拆开,方便 PM 与执行团队分工。";
|
|
103
|
+
case "pm-brief":
|
|
104
|
+
return "先给 PM 一个可快速理解的摘要。";
|
|
105
|
+
case "roadmap":
|
|
106
|
+
return "把修复顺序转成阶段计划。";
|
|
107
|
+
case "agent-handoff":
|
|
108
|
+
return "把当前结果交接成 agent 可继续执行的工件。";
|
|
109
|
+
case "apply-plan":
|
|
110
|
+
return "把交接结果推进到具体执行包。";
|
|
111
|
+
case "completion-report":
|
|
112
|
+
return "整理本轮完成项、剩余风险和下一轮动作。";
|
|
113
|
+
case "handoff-bundle":
|
|
114
|
+
return "把交接、执行与复盘整成一个总包。";
|
|
115
|
+
case "share-pack":
|
|
116
|
+
return "给不同角色生成可直接分享的视图。";
|
|
117
|
+
case "export-pack":
|
|
118
|
+
return "把分享结果导出成目录文件。";
|
|
119
|
+
case "html-pack":
|
|
120
|
+
return "把产物转成可浏览页面。";
|
|
121
|
+
case "publish-pack":
|
|
122
|
+
return "形成最终可交付包。";
|
|
123
|
+
default:
|
|
124
|
+
return "推进当前 GEO 会话到下一阶段。";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function inferExpectedArtifact(commandName) {
|
|
129
|
+
switch (commandName) {
|
|
130
|
+
case "onboard":
|
|
131
|
+
case "onboard-url":
|
|
132
|
+
return "网址级 onboarding 结果";
|
|
133
|
+
case "scan":
|
|
134
|
+
return "基础信号扫描结果";
|
|
135
|
+
case "audit":
|
|
136
|
+
return "GEO 审计结果";
|
|
137
|
+
case "report":
|
|
138
|
+
return "可读报告";
|
|
139
|
+
case "fix-plan":
|
|
140
|
+
return "待办清单与优先级";
|
|
141
|
+
case "owner-board":
|
|
142
|
+
return "角色分栏任务板";
|
|
143
|
+
case "pm-brief":
|
|
144
|
+
return "PM 摘要";
|
|
145
|
+
case "roadmap":
|
|
146
|
+
return "阶段路线图";
|
|
147
|
+
case "agent-handoff":
|
|
148
|
+
return "agent 交接工件";
|
|
149
|
+
case "apply-plan":
|
|
150
|
+
return "执行包";
|
|
151
|
+
case "completion-report":
|
|
152
|
+
return "复盘工件";
|
|
153
|
+
case "handoff-bundle":
|
|
154
|
+
return "执行总包";
|
|
155
|
+
case "share-pack":
|
|
156
|
+
return "角色化分享包";
|
|
157
|
+
case "export-pack":
|
|
158
|
+
return "导出目录";
|
|
159
|
+
case "html-pack":
|
|
160
|
+
return "HTML 页面包";
|
|
161
|
+
case "publish-pack":
|
|
162
|
+
return "最终可交付包";
|
|
163
|
+
default:
|
|
164
|
+
return "阶段性 GEO 输出";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function buildStepInstructions(parsedCommand, flow) {
|
|
169
|
+
const lines = [
|
|
170
|
+
`运行 \`${parsedCommand.raw}\`。`,
|
|
171
|
+
inferStepPurpose(parsedCommand.commandName, flow),
|
|
172
|
+
`预期得到:${inferExpectedArtifact(parsedCommand.commandName)}。`
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
if (parsedCommand.commandName === "publish-pack") {
|
|
176
|
+
lines.push("完成后把 `START-HERE.md` 和 `AGENT-START.md` 当作最终入口。");
|
|
177
|
+
}
|
|
178
|
+
if (parsedCommand.commandName === "apply-plan") {
|
|
179
|
+
lines.push("执行包出来后,优先从第一包开始,不要同时展开太多任务。");
|
|
180
|
+
}
|
|
181
|
+
if (parsedCommand.commandName === "agent-handoff" && flow.intent === "execute") {
|
|
182
|
+
lines.push("如果还是 advice-only,说明还缺仓库或本地项目上下文。");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return lines;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function buildSessionPrompt(flow, steps) {
|
|
189
|
+
const lines = [
|
|
190
|
+
`Use $${flow.selectedSkill.name} to continue this GEO session.`,
|
|
191
|
+
`当前输入:${flow.source}`,
|
|
192
|
+
`当前阶段:${flow.stage}`,
|
|
193
|
+
`当前意图:${flow.intent}`,
|
|
194
|
+
`会话目标:${inferSessionGoal(flow)}`,
|
|
195
|
+
"请按下面顺序推进,不要跳步骤:"
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
for (const step of steps) {
|
|
199
|
+
lines.push(`${step.id}. ${step.command}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (flow.contextNeeded.length > 0) {
|
|
203
|
+
lines.push("如果当前缺上下文,请先明确缺什么,不要假装已经完成执行。");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
lines.push("每一步都要说明:你为什么做、得到什么、下一步是什么。");
|
|
207
|
+
return lines.join("\n");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function createAgentSession(input, options = {}) {
|
|
211
|
+
const flow = await createAutoFlow(input, { intent: options.intent });
|
|
212
|
+
const steps = flow.commandChain.map((command, index) => {
|
|
213
|
+
const parsedCommand = parseCommand(command);
|
|
214
|
+
return {
|
|
215
|
+
id: `step-${String(index + 1).padStart(2, "0")}`,
|
|
216
|
+
command,
|
|
217
|
+
commandName: parsedCommand.commandName,
|
|
218
|
+
suggestedSkill: inferSkillForCommand(parsedCommand.commandName, flow),
|
|
219
|
+
purpose: inferStepPurpose(parsedCommand.commandName, flow),
|
|
220
|
+
expectedArtifact: inferExpectedArtifact(parsedCommand.commandName),
|
|
221
|
+
instructions: buildStepInstructions(parsedCommand, flow)
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
kind: "geo-agent-session",
|
|
227
|
+
input,
|
|
228
|
+
source: flow.source,
|
|
229
|
+
sourceType: flow.sourceType,
|
|
230
|
+
artifactKind: flow.artifactKind,
|
|
231
|
+
intent: flow.intent,
|
|
232
|
+
stage: flow.stage,
|
|
233
|
+
status: inferSessionStatus(flow),
|
|
234
|
+
goal: inferSessionGoal(flow),
|
|
235
|
+
selectedSkill: flow.selectedSkill,
|
|
236
|
+
secondarySkills: flow.secondarySkills,
|
|
237
|
+
whyThisSkill: flow.whyThisSkill,
|
|
238
|
+
contextNeeded: flow.contextNeeded,
|
|
239
|
+
nextAction: flow.nextAction,
|
|
240
|
+
steps,
|
|
241
|
+
sessionPrompt: buildSessionPrompt(flow, steps),
|
|
242
|
+
autoFlow: flow
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function renderAgentSessionMarkdown(session) {
|
|
247
|
+
const lines = [
|
|
248
|
+
"# GEO Agent Session",
|
|
249
|
+
"",
|
|
250
|
+
`- 输入:\`${session.source}\``,
|
|
251
|
+
`- 输入类型:\`${session.sourceType}\``,
|
|
252
|
+
`- 工件类型:\`${session.artifactKind}\``,
|
|
253
|
+
`- 当前阶段:${session.stage}`,
|
|
254
|
+
`- 会话状态:${session.status}`,
|
|
255
|
+
`- 当前意图:${session.intent}`,
|
|
256
|
+
`- 目标:${session.goal}`,
|
|
257
|
+
`- 自动选择的 skill:\`${session.selectedSkill.name}\``,
|
|
258
|
+
"",
|
|
259
|
+
"## 为什么这样安排",
|
|
260
|
+
"",
|
|
261
|
+
`- ${session.whyThisSkill}`,
|
|
262
|
+
"",
|
|
263
|
+
"## 下一步",
|
|
264
|
+
"",
|
|
265
|
+
`- ${session.nextAction}`
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
if (session.contextNeeded.length > 0) {
|
|
269
|
+
lines.push("", "## 还缺什么", "");
|
|
270
|
+
for (const item of session.contextNeeded) {
|
|
271
|
+
lines.push(`- ${item}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
lines.push("", "## 会话步骤", "");
|
|
276
|
+
for (const step of session.steps) {
|
|
277
|
+
lines.push(`### ${step.id}|${step.commandName}`);
|
|
278
|
+
lines.push("");
|
|
279
|
+
lines.push(`- 命令:\`${step.command}\``);
|
|
280
|
+
lines.push(`- 建议 skill:\`${step.suggestedSkill}\``);
|
|
281
|
+
lines.push(`- 目的:${step.purpose}`);
|
|
282
|
+
lines.push(`- 预期产物:${step.expectedArtifact}`);
|
|
283
|
+
lines.push("- 操作说明:");
|
|
284
|
+
for (const instruction of step.instructions) {
|
|
285
|
+
lines.push(` - ${instruction}`);
|
|
286
|
+
}
|
|
287
|
+
lines.push("");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
lines.push("", "## 可直接复制给 Agent 的 Session Prompt", "", "```text", session.sessionPrompt, "```");
|
|
291
|
+
|
|
292
|
+
return `${lines.join("\n")}\n`;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export async function writeAgentSessionOutput(outputPath, content) {
|
|
296
|
+
return writeScanOutput(outputPath, content);
|
|
297
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createApplyPlan, renderApplyPlanMarkdown, writeApplyPlanOutput } from "./apply-plan.js";
|
|
5
5
|
import { createAgentHandoff, renderAgentHandoffMarkdown, writeAgentHandoffOutput } from "./agent-handoff.js";
|
|
6
|
+
import { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
|
|
6
7
|
import { createAutoFlow, renderAutoFlowMarkdown, writeAutoFlowOutput } from "./auto-flow.js";
|
|
7
8
|
import {
|
|
8
9
|
createCompletionReport,
|
|
@@ -59,6 +60,7 @@ function printHelp() {
|
|
|
59
60
|
" geo-ai-search-optimization",
|
|
60
61
|
" geo-ai-search-optimization install [--target <dir>] [--json]",
|
|
61
62
|
" geo-ai-search-optimization auto-flow <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
|
|
63
|
+
" geo-ai-search-optimization agent-session <input> [--intent <auto|diagnose|guide|execute|share|closeout>] [--json] [--out <file>]",
|
|
62
64
|
" geo-ai-search-optimization skills [--json]",
|
|
63
65
|
" geo-ai-search-optimization where",
|
|
64
66
|
" geo-ai-search-optimization doctor [--json]",
|
|
@@ -151,6 +153,30 @@ async function handleAutoFlow(args) {
|
|
|
151
153
|
process.stdout.write(renderedOutput);
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
async function handleAgentSession(args) {
|
|
157
|
+
const input = args.find((value) => !value.startsWith("-"));
|
|
158
|
+
if (!input) {
|
|
159
|
+
throw new Error("agent-session 需要一个输入值,可以是任务描述、项目路径、网站网址或已导出的工件");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const session = await createAgentSession(input, {
|
|
163
|
+
intent: getFlagValue(args, "--intent")
|
|
164
|
+
});
|
|
165
|
+
const outputJson = hasFlag(args, "--json");
|
|
166
|
+
const renderedOutput = outputJson
|
|
167
|
+
? `${JSON.stringify(session, null, 2)}\n`
|
|
168
|
+
: renderAgentSessionMarkdown(session);
|
|
169
|
+
|
|
170
|
+
const outputPath = getFlagValue(args, "--out");
|
|
171
|
+
if (outputPath) {
|
|
172
|
+
const resolvedOutputPath = await writeAgentSessionOutput(outputPath, renderedOutput);
|
|
173
|
+
process.stdout.write(`已保存 agent-session 结果:${resolvedOutputPath}\n`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
process.stdout.write(renderedOutput);
|
|
178
|
+
}
|
|
179
|
+
|
|
154
180
|
function handleWhere() {
|
|
155
181
|
process.stdout.write(
|
|
156
182
|
[
|
|
@@ -696,6 +722,11 @@ export async function runCli(args = []) {
|
|
|
696
722
|
return;
|
|
697
723
|
}
|
|
698
724
|
|
|
725
|
+
if (command === "agent-session") {
|
|
726
|
+
await handleAgentSession(rest);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
|
|
699
730
|
if (command === "skills") {
|
|
700
731
|
await handleSkills(rest);
|
|
701
732
|
return;
|
package/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
export { createAutoFlow, renderAutoFlowMarkdown, writeAutoFlowOutput } from "./auto-flow.js";
|
|
9
9
|
export { createApplyPlan, renderApplyPlanMarkdown, writeApplyPlanOutput } from "./apply-plan.js";
|
|
10
10
|
export { createAgentHandoff, renderAgentHandoffMarkdown, writeAgentHandoffOutput } from "./agent-handoff.js";
|
|
11
|
+
export { createAgentSession, renderAgentSessionMarkdown, writeAgentSessionOutput } from "./agent-session.js";
|
|
11
12
|
export { createCompletionReport, renderCompletionReportMarkdown, writeCompletionReportOutput } from "./completion-report.js";
|
|
12
13
|
export { createFixPlan, renderFixPlanMarkdown, writeFixPlanOutput } from "./fix-plan.js";
|
|
13
14
|
export { createHandoffBundle, renderHandoffBundleMarkdown, writeHandoffBundleOutput } from "./handoff-bundle.js";
|
package/src/skills.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getPackageRoot } from "./paths.js";
|
|
|
5
5
|
const SKILL_ORDER = [
|
|
6
6
|
"geo-ai-search-optimization",
|
|
7
7
|
"geo-ai-search-optimization-auto-flow",
|
|
8
|
+
"geo-ai-search-optimization-agent-session",
|
|
8
9
|
"geo-ai-search-optimization-usage",
|
|
9
10
|
"geo-ai-search-optimization-agent-handoff",
|
|
10
11
|
"geo-ai-search-optimization-repair-loop",
|
|
@@ -19,6 +20,7 @@ const SKILL_ORDER = [
|
|
|
19
20
|
const SKILL_CATEGORY = {
|
|
20
21
|
"geo-ai-search-optimization": "core",
|
|
21
22
|
"geo-ai-search-optimization-auto-flow": "routing",
|
|
23
|
+
"geo-ai-search-optimization-agent-session": "routing",
|
|
22
24
|
"geo-ai-search-optimization-usage": "guidance",
|
|
23
25
|
"geo-ai-search-optimization-agent-handoff": "execution",
|
|
24
26
|
"geo-ai-search-optimization-repair-loop": "execution",
|