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% >

相关推荐
橙子家8 小时前
浏览器缓存之【身份与会话管理】:Cookies 和 Private state tokens
前端
最新资讯动态9 小时前
HDC 2026 | 对话鲸鸿动能:存量时代,品牌如何夺回营销“主动权”?
前端
最新资讯动态9 小时前
游戏出海,从产品走向体系
前端
最新资讯动态9 小时前
20人团队跑出百万DAU、大厂也来抢量:谁在鸿蒙生态跑出加速度
前端
最新资讯动态10 小时前
千万开发者背后,鸿蒙商业化的B面
前端
爱勇宝11 小时前
AI 时代:智商决定起点,情商决定走多远
前端·ai编程
kyriewen12 小时前
用了半年 Claude Code 后,我尝试关掉它写了一周代码——结果比想象中严重
前端·javascript·ai编程
IT_陈寒12 小时前
Vite的静态资源打包让我熬夜到三点,这坑千万别跳
前端·人工智能·后端
徐小夕13 小时前
万字拆解 JitWord:企业级实时协同文档底层架构 + 大模型 AI 融合完整实践
前端·vue.js·github
一份执念13 小时前
uni-app 小程序分包限制处理与主包体积优化实战
前端·微信小程序