plan

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package plan 提供 Plan Mode(计划模式)软引导 + 审批退出。

对齐上游:packages/core/plan-mode

设计要点:

  • plan:policy 是一个 Prompt Section(order 500),仅在 plan mode 开启时注入 system prompt;
  • 进入 plan mode 写入 plan/mode(on) 事件;下一轮请求时 plan:policy section 注入成功;
  • exit_plan_mode 工具触发 UserQuestion 审批(走 M14 UQ 接缝);
  • 审批通过 → 移除 plan:policy section(下轮请求不出现)+ 写 plan/mode(off);
  • 审批拒绝 → plan:policy section 仍保留(继续计划模式)。

Index

Constants

View Source
const PlanPolicySectionName = "plan_policy"

PlanPolicySectionName 是 plan:policy section 的名字。

Variables

This section is empty.

Functions

func Enter

func Enter(sl *session.SessionLog, sys *sysprompt.Assembler) error

Enter 进入 plan mode:写 plan/mode(on) 事件,并注入 plan:policy section。

func Exit

func Exit(sl *session.SessionLog, sys *sysprompt.Assembler) error

Exit 退出 plan mode:写 plan/mode(off) 事件,并移除 plan:policy section。

func IsActive

func IsActive(sl *session.SessionLog) bool

IsActive 判断当前是否处于 plan mode。

Types

type ExitPlanModeResult

type ExitPlanModeResult struct {
	// Approved 审批是否通过。
	Approved bool
	// Exited 是否实际退出(通过才退出)。
	Exited bool
}

ExitPlanModeResult 是 exit_plan_mode 审批的结果。

type ExitPlanModeTool

type ExitPlanModeTool struct {
	// contains filtered or unexported fields
}

ExitPlanModeTool 是 exit_plan_mode 工具:UserQuestion 审批通过才移除 plan:policy。

func NewExitPlanModeTool

func NewExitPlanModeTool(sl *session.SessionLog, sys *sysprompt.Assembler) *ExitPlanModeTool

NewExitPlanModeTool 创建 exit_plan_mode 工具。

func (*ExitPlanModeTool) Description

func (t *ExitPlanModeTool) Description() string

Description 返回工具描述。

func (*ExitPlanModeTool) Execute

func (t *ExitPlanModeTool) Execute(ctx context.Context, input map[string]any) (any, error)

Execute 实现工具:触发审批,通过则移除 plan:policy 并退出,拒绝则保留。

func (*ExitPlanModeTool) Name

func (t *ExitPlanModeTool) Name() string

Name 返回工具名。

func (*ExitPlanModeTool) SetAsker

func (t *ExitPlanModeTool) SetAsker(f func(ctx context.Context, prompt string, choices []string) (int, error))

SetAsker 注入用户提问回调(默认测试用 stub:通过)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL