Kiro CLI的context详解

Kiro CLI提供3种类型的context

  • Agent Resources,常用的文件或skills
  • Session Context,临时用的文件或skills
  • Knowledge Bases,比较大(>10MB)的文件或大量的文件

1. 查看当前的context

在Kiro CLI chat中,执行命令**/context show**

1% > /context show

Agent (kiro_default)

(no matches)

  • ~/.kiro/skills/*/SKILL.md

(no matches)

Session (temporary)

<none>

No files in the current directory matched the rules above.

1% >

2. 定义Agent时,通过resources设置context

{

"name": "my-agent",

"description": "My agent",

"resources ": [

"file://README.md",

"file://docs/**/*.md",

"skill://~/.kiro/skills/*/SKILL.md"

]

}

在建立Kiro CLI chat会话时,Agent的resources设置将被加载到会话的context。

3. 设置临时的Session context

在Kiro CLI chat中,执行**/context** add命令添加文件或目录到context

2% > /context add .

Added 1 path(s) to context.

Note: Context modifications via slash command is temporary.

2% >

执行**/context** remove命令从context中删除文件或目录

2% > /context remove .

Removed 1 path(s) from context.

Note: Context modifications via slash command is temporary.

2% >

执行**/context** clear命令从清除所有Session context

2% > /context clear

Cleared context

Note: Context modifications via slash command is temporary.

2% >

4. 设置Knowledge Bases context

Knowledge Bases默认没有开启。

2% > /knowledge show

Knowledge tool is disabled. Enable it with: kiro-cli settings chat.enableKnowledge true

💡 Your knowledge base data is preserved and will be available when re-enabled.

2% >

执行如下命令,开启Knowledge Bases

$ kiro-cli settings chat.enableKnowledge true

$ kiro-cli settings list

chat.enableKnowledge = true (global)

再次打开一个Kiro CLI chat会话,Knowledge Bases已经可用了。

1% > /knowledge show

Agent (kiro_default):

<none>

1% >

1% > /knowledge add -n mypom -p ./pom.xml

Started indexing 'mypom'

Path: ./pom.xml

Operation ID: dfdad1fc

1% > /knowledge show

Agent (kiro_default):

📂 mypom (a79b545c)

./pom.xml

1 items • Best • 04/23 08:43

1% > /knowledge remove mypom

Removed agent knowledge base entry with name 'mypom'

1% > /knowledge show

Agent (kiro_default):

<none>

1% >

相关推荐
朱涛的自习室5 小时前
逃离“古法测试”:AI 测试的“三大定律”
android·前端·人工智能
糖果店的幽灵5 小时前
Claude Code 完全实战指南 - 第二章:CLI 命令大全
前端·chrome
ZC跨境爬虫6 小时前
跟着 MDN 学CSS day_45:媒体查询入门指南——从语法到移动优先实践
前端·css·ui·html·tensorflow·媒体
Hoey6 小时前
虚拟 DOM 和 DIFF 算法
前端·vue.js
bkspiderx6 小时前
HTTP协议:Web通信的“通用语言”解析
前端·网络协议·http
云水一下6 小时前
模块系统与 npm——万物皆模块
前端·npm·node.js
ZC跨境爬虫6 小时前
跟着 MDN 学CSS day_47:(移动优先实战——从手机到宽屏的响应式进化)
前端·css·html·tensorflow·媒体
小新1107 小时前
vue实战项目 计算器
前端·javascript·vue.js
秋田君7 小时前
2026 前端新出路:掌握 C++ 核心语法,无缝衔接 QT 桌面开发
前端·c++·qt
老毛肚7 小时前
jeecgboot vue 路由 拆分01
前端·javascript·typescript