@falkenslab/agent-kit 0.17.0 → 0.19.0
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/assets/extension-launcher.mjs +24 -0
- package/dist/chat/chatController.d.ts +264 -0
- package/dist/chat/chatController.js +510 -0
- package/dist/chat/extensions.d.ts +14 -0
- package/dist/chat/extensions.js +41 -0
- package/dist/chat/history.d.ts +17 -0
- package/dist/chat/history.js +39 -0
- package/dist/{tui → chat}/runs.d.ts +8 -1
- package/dist/{tui → chat}/runs.js +1 -1
- package/dist/core/agentSpec.d.ts +41 -27
- package/dist/core/extensions.d.ts +119 -0
- package/dist/core/extensions.js +97 -0
- package/dist/core/externalExtensions.d.ts +131 -0
- package/dist/core/externalExtensions.js +340 -0
- package/dist/core/hooks/fileScopeGate.d.ts +17 -2
- package/dist/core/hooks/fileScopeGate.js +45 -10
- package/dist/core/hooks/planGate.d.ts +2 -0
- package/dist/core/hooks/planGate.js +1 -10
- package/dist/core/hooks/stepGate.d.ts +1 -1
- package/dist/core/hooks/stepGate.js +3 -3
- package/dist/core/language.js +1 -1
- package/dist/core/messages/de.js +12 -33
- package/dist/core/messages/en.d.ts +13 -16
- package/dist/core/messages/en.js +12 -33
- package/dist/core/messages/es.js +12 -33
- package/dist/core/messages/fr.js +12 -33
- package/dist/core/messages/index.d.ts +6 -0
- package/dist/core/messages/index.js +12 -1
- package/dist/core/packaged.d.ts +10 -0
- package/dist/core/packaged.js +38 -0
- package/dist/core/pluginAgents.d.ts +20 -0
- package/dist/core/pluginAgents.js +76 -0
- package/dist/core/runner.js +16 -9
- package/dist/core/session.d.ts +42 -5
- package/dist/core/session.js +203 -99
- package/dist/core/sessionFacts.d.ts +80 -0
- package/dist/core/sessionFacts.js +48 -0
- package/dist/core/toolLabels.d.ts +24 -6
- package/dist/core/toolLabels.js +24 -39
- package/dist/core/tools/humanApproval.js +3 -3
- package/dist/extensions/awareness/index.d.ts +13 -0
- package/dist/extensions/awareness/index.js +39 -0
- package/dist/extensions/awareness/labels.d.ts +3 -0
- package/dist/extensions/awareness/labels.js +12 -0
- package/dist/extensions/awareness/tools.d.ts +5 -0
- package/dist/extensions/awareness/tools.js +54 -0
- package/dist/{core → extensions/knowledge}/fileKnowledgeStore.d.ts +1 -3
- package/dist/{core → extensions/knowledge}/fileKnowledgeStore.js +23 -29
- package/dist/extensions/knowledge/index.d.ts +8 -0
- package/dist/extensions/knowledge/index.js +35 -0
- package/dist/{core → extensions/knowledge}/knowledgeStore.d.ts +5 -9
- package/dist/{core → extensions/knowledge}/knowledgeStore.js +16 -2
- package/dist/extensions/knowledge/labels.d.ts +3 -0
- package/dist/extensions/knowledge/labels.js +119 -0
- package/dist/extensions/knowledge/prompt.d.ts +28 -0
- package/dist/extensions/knowledge/prompt.js +59 -0
- package/dist/{core/tools/knowledgeTools.d.ts → extensions/knowledge/tools.d.ts} +7 -7
- package/dist/{core/tools/knowledgeTools.js → extensions/knowledge/tools.js} +20 -55
- package/dist/extensions/memory/index.d.ts +12 -0
- package/dist/extensions/memory/index.js +56 -0
- package/dist/extensions/memory/labels.d.ts +3 -0
- package/dist/extensions/memory/labels.js +58 -0
- package/dist/extensions/memory/memoryStore.d.ts +53 -0
- package/dist/extensions/memory/memoryStore.js +88 -0
- package/dist/extensions/memory/tools.d.ts +9 -0
- package/dist/extensions/memory/tools.js +82 -0
- package/dist/extensions/sources/index.d.ts +9 -0
- package/dist/extensions/sources/index.js +40 -0
- package/dist/extensions/sources/labels.d.ts +3 -0
- package/dist/extensions/sources/labels.js +82 -0
- package/dist/{core → extensions/sources}/sources.d.ts +24 -31
- package/dist/{core → extensions/sources}/sources.js +45 -108
- package/dist/{core/tools/saveToSources.d.ts → extensions/sources/tools.d.ts} +7 -3
- package/dist/{core/tools/saveToSources.js → extensions/sources/tools.js} +22 -17
- package/dist/index.d.ts +14 -9
- package/dist/index.js +11 -7
- package/dist/tui/chatTui.d.ts +11 -20
- package/dist/tui/chatTui.js +75 -230
- package/dist/tui/extensionCommand.d.ts +21 -0
- package/dist/tui/extensionCommand.js +133 -0
- package/dist/tui/ink/runChatInk.d.ts +4 -3
- package/dist/tui/ink/runChatInk.js +101 -217
- package/extensions/awareness/.claude-plugin/plugin.json +10 -0
- package/{assets/agent-help → extensions/awareness/skills/help}/SKILL.md +4 -3
- package/{assets/knowledge-plugin → extensions/knowledge}/.claude-plugin/plugin.json +7 -1
- package/extensions/knowledge/commands/ingest.md +7 -0
- package/{assets/knowledge-plugin → extensions/knowledge}/skills/knowledge-ingest/SKILL.md +8 -3
- package/{assets/knowledge-plugin → extensions/knowledge}/skills/knowledge-lint/SKILL.md +12 -5
- package/extensions/memory/.claude-plugin/plugin.json +10 -0
- package/extensions/memory/commands/forget.md +8 -0
- package/extensions/memory/commands/list.md +5 -0
- package/extensions/sources/.claude-plugin/plugin.json +10 -0
- package/package.json +3 -2
- package/assets/knowledge-plugin/commands/ingest.md +0 -7
- package/assets/knowledge-plugin/commands/query.md +0 -5
- package/assets/knowledge-plugin-files/.claude-plugin/plugin.json +0 -4
- package/assets/knowledge-plugin-files/commands/ingest.md +0 -7
- package/assets/knowledge-plugin-files/commands/lint.md +0 -5
- package/assets/knowledge-plugin-files/skills/knowledge-ingest/SKILL.md +0 -46
- package/assets/knowledge-plugin-files/skills/knowledge-lint/SKILL.md +0 -26
- package/assets/knowledge-plugin-files/skills/knowledge-pages/SKILL.md +0 -137
- package/assets/knowledge-plugin-files/skills/knowledge-query/SKILL.md +0 -14
- package/dist/core/agentHelp.d.ts +0 -30
- package/dist/core/agentHelp.js +0 -55
- package/dist/core/knowledge.d.ts +0 -25
- package/dist/core/knowledge.js +0 -84
- /package/dist/{core → extensions/sources}/extractText.d.ts +0 -0
- /package/dist/{core → extensions/sources}/extractText.js +0 -0
- /package/{assets/knowledge-plugin → extensions/knowledge}/commands/lint.md +0 -0
- /package/{assets/knowledge-plugin-files → extensions/knowledge}/commands/query.md +0 -0
- /package/{assets/knowledge-plugin → extensions/knowledge}/skills/knowledge-query/SKILL.md +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Ingest material into the knowledge base right now - the files or topic given, or everything in sources/ not ingested yet
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Apply the `knowledge-ingest` skill right now to: $ARGUMENTS
|
|
6
|
-
|
|
7
|
-
If nothing is given above, ingest every original `list_sources` reports as new, and update the summaries of the ones it reports as changed. When you're done, summarize which pages you created and updated, and anything you couldn't read.
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Health-check the knowledge base right now - broken links, orphans, duplicates, contradictions, gaps
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Apply the `knowledge-lint` skill right now over the whole knowledge base. Fix what's mechanical (links, index, missing back-links) and report the rest: what needs the human's decision, and the gaps worth filling next.
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: knowledge-ingest
|
|
3
|
-
description: Ingest one source into the knowledge base - a file in sources/, a document, a page - creating its summary page, creating or updating the concept and entity pages it touches, linking everything both ways, and updating index.md and log.md.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Ingesting a source into the knowledge base
|
|
7
|
-
|
|
8
|
-
A source is ingested once, and from then on the knowledge base holds what it taught: later sessions read the pages, not the original again. Ingesting is not summarizing a file in isolation - its value is in how it connects to what the knowledge base already knows. Load the `knowledge-pages` skill first for the page templates.
|
|
9
|
-
|
|
10
|
-
## 1. Check it isn't already ingested
|
|
11
|
-
|
|
12
|
-
`list_sources` gives each original's status and summary pages: *new* needs ingesting; *ingested* has a page; *changed* changed after its ingest. For a document from elsewhere, look for it in `index.md` (Summaries) or `Grep` its URL inside the knowledge base. If it already has a page:
|
|
13
|
-
- unchanged source: nothing to do;
|
|
14
|
-
- the source changed or the page is thin: update that page instead of creating another.
|
|
15
|
-
|
|
16
|
-
## 2. Read it for real
|
|
17
|
-
|
|
18
|
-
Read the whole source, not its first page (a long PDF in parts: `list_sources` gives its pages). If it exists only outside the sources folder, keep the original first: `download_to_sources` for a URL (a web page is kept as markdown too: read that one), `save_to_sources` for a file in the run's folder, `request_file` to ask the person for one. `Read` reads PDFs and images; read DOCX, PPTX (with its speaker notes) and XLSX with `extract_text`.
|
|
19
|
-
|
|
20
|
-
## 3. Write the summary page
|
|
21
|
-
|
|
22
|
-
Create `summaries/<slug>.md` with the template: summary, key points (literal wording where exactness matters), frontmatter `file`/`url` pointing to the original.
|
|
23
|
-
|
|
24
|
-
## 4. Update concepts and entities
|
|
25
|
-
|
|
26
|
-
For every concept or entity the source explains or relies on:
|
|
27
|
-
- no page yet: create it;
|
|
28
|
-
- page exists: add what is new (a better definition, an example, a nuance, a fact) with `Edit`, and link the summary under "Sources".
|
|
29
|
-
|
|
30
|
-
Check first whether it exists under another name (`Grep` the knowledge base for the term and look at `aliases`): a duplicate page is worse than none.
|
|
31
|
-
|
|
32
|
-
## 5. Link both ways and look for conflicts
|
|
33
|
-
|
|
34
|
-
Every link you added from page A to page B needs its counterpart in B. If the source contradicts an existing page, record both versions with attribution in both pages - don't overwrite.
|
|
35
|
-
|
|
36
|
-
## 6. Close
|
|
37
|
-
|
|
38
|
-
- `index.md`: new pages, and one-line descriptions that changed.
|
|
39
|
-
- `log.md`: `## [date] ingest | <source title>` with the pages created and updated.
|
|
40
|
-
- `overview.md`: only if the source changes the big picture.
|
|
41
|
-
|
|
42
|
-
When ingesting several sources in a row, do steps 1-5 for each and close once at the end.
|
|
43
|
-
|
|
44
|
-
## An original that was wrong or replaced
|
|
45
|
-
|
|
46
|
-
`retire_source` (the person approves it) moves it aside and marks its summary retired (wrong) or superseded (replaced by a better one). Then update `index.md`, and fix the pages that cite it (`Grep` its file name): after a wrong one, correct or remove what it taught; after a replaced one, ingest the new original and re-ground those passages on it.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: knowledge-lint
|
|
3
|
-
description: Health-check the knowledge base - broken links, pages missing from index.md, orphan pages, one-way links, duplicated concepts, mentioned-but-missing concepts, contradictions, gaps - fix what's mechanical and report the rest.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Linting the knowledge base
|
|
7
|
-
|
|
8
|
-
A knowledge base maintained across sessions drifts: links break, pages go unlisted, the same concept appears under two names. Lint it when asked and after a large ingest. Load `knowledge-pages` first for the templates.
|
|
9
|
-
|
|
10
|
-
## Checks
|
|
11
|
-
|
|
12
|
-
Use `Glob` to list pages and `Grep` (always with `path` inside the knowledge base) to find links, instead of reading every page in full.
|
|
13
|
-
|
|
14
|
-
1. **Broken links**: a relative link whose target file doesn't exist. Fix it if the right target is obvious (a typo, a page under a close name); otherwise report it.
|
|
15
|
-
2. **Index**: every page is listed in `index.md` and every entry there points to an existing page. Fix it.
|
|
16
|
-
3. **Orphans**: pages nothing links to (`Grep` for the file name). Link them from where they belong, or report why they don't belong anywhere.
|
|
17
|
-
4. **One-way links**: a summary that feeds a concept which doesn't list it back... Add the missing side.
|
|
18
|
-
5. **Duplicates**: two pages for the same idea under different names. Merge the content into one, mark the other as superseded (never delete it) and repoint links.
|
|
19
|
-
6. **Missing pages**: terms that several pages treat as concepts or entities but have no page. Create them if the material is there; otherwise list them.
|
|
20
|
-
7. **Contradictions**: claims that disagree across pages without being recorded as such. Record both sides, attributed.
|
|
21
|
-
8. **Provenance**: claims with no traceable source. Add the link, or mark them as unsourced.
|
|
22
|
-
9. **Gaps**: originals `list_sources` reports as new (no summary yet), changed (their summary may be stale) or missing (deleted by hand: their summaries point nowhere), and concepts mentioned but never explained by any source. Report them - they are what to ingest, update or find next.
|
|
23
|
-
|
|
24
|
-
## Close
|
|
25
|
-
|
|
26
|
-
Append `## [date] lint | <summary>` to `log.md` listing what was fixed. Then report to the human: what you fixed, and what needs their decision or more material. Don't make judgement calls silently - merging pages that are only similar, or choosing between contradictory sources, goes in the report.
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: knowledge-pages
|
|
3
|
-
description: Exact templates and conventions for every page of the knowledge base (index, log, overview, summary, concept, entity and synthesis pages) - load it before creating a knowledge base page or restructuring one, so every page keeps the same shape and links.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Knowledge base page templates
|
|
7
|
-
|
|
8
|
-
The knowledge base's layout and rules are in the system prompt ("Knowledge base"). This skill only adds the exact shape of each page. Headings and frontmatter keys stay in English (they are structure); the text under them is in the human's language. Dates are `YYYY-MM-DD`. Links are relative markdown links (from `concepts/x.md`, a summary is `../summaries/y.md`; an original file is `../../sources/...`, adjusted to where the folders really are).
|
|
9
|
-
|
|
10
|
-
Every page starts with YAML frontmatter; `updated` changes whenever you edit the page.
|
|
11
|
-
|
|
12
|
-
## index.md
|
|
13
|
-
|
|
14
|
-
The catalog and entry point. One line per page, grouped by section: Summaries, Concepts, Entities, Syntheses (plus any section the domain adds).
|
|
15
|
-
|
|
16
|
-
```markdown
|
|
17
|
-
# Index
|
|
18
|
-
|
|
19
|
-
## Summaries
|
|
20
|
-
- [Q3 architecture review](summaries/q3-architecture-review.md) - decisions taken on the billing service
|
|
21
|
-
## Concepts
|
|
22
|
-
- [Idempotency](concepts/idempotency.md) - safe retries of a request
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## log.md
|
|
26
|
-
|
|
27
|
-
Append-only; never edit past entries. Newest at the bottom.
|
|
28
|
-
|
|
29
|
-
```markdown
|
|
30
|
-
## [2026-10-03] ingest | Q3 architecture review
|
|
31
|
-
- created: summaries/q3-architecture-review.md, concepts/idempotency.md
|
|
32
|
-
- updated: entities/billing-service.md, index.md
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## overview.md
|
|
36
|
-
|
|
37
|
-
A living synthesis of the whole knowledge base, rewritten (not appended) as understanding grows: what it covers, its main blocks and how they connect (with links), what is still unknown.
|
|
38
|
-
|
|
39
|
-
## Summary page (`summaries/<slug>.md`)
|
|
40
|
-
|
|
41
|
-
One per ingested source.
|
|
42
|
-
|
|
43
|
-
```markdown
|
|
44
|
-
---
|
|
45
|
-
type: summary
|
|
46
|
-
title: "<Title>"
|
|
47
|
-
file: <relative link to the original in sources/, if any>
|
|
48
|
-
url: <original URL, if any>
|
|
49
|
-
ingested: YYYY-MM-DD
|
|
50
|
-
updated: YYYY-MM-DD
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
# <Title>
|
|
54
|
-
|
|
55
|
-
## Summary
|
|
56
|
-
<Two to four paragraphs: what it actually says.>
|
|
57
|
-
|
|
58
|
-
## Key points
|
|
59
|
-
- Claims, definitions or figures likely to be needed later, quoted literally when exact wording matters.
|
|
60
|
-
|
|
61
|
-
## Pages it feeds
|
|
62
|
-
- [Concept or entity](../concepts/<slug>.md)
|
|
63
|
-
|
|
64
|
-
## New or surprising
|
|
65
|
-
- What this source adds to what the knowledge base already had.
|
|
66
|
-
|
|
67
|
-
## Contradictions
|
|
68
|
-
- Conflicts with other pages, linked.
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Concept page (`concepts/<slug>.md`)
|
|
72
|
-
|
|
73
|
-
One idea per page.
|
|
74
|
-
|
|
75
|
-
```markdown
|
|
76
|
-
---
|
|
77
|
-
type: concept
|
|
78
|
-
aliases: []
|
|
79
|
-
updated: YYYY-MM-DD
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
# <Concept>
|
|
83
|
-
|
|
84
|
-
<Definition in one or two sentences.>
|
|
85
|
-
|
|
86
|
-
## Explanation
|
|
87
|
-
<How it works, at the depth the sources give.>
|
|
88
|
-
|
|
89
|
-
## Connections
|
|
90
|
-
- Requires: [Concept](<slug>.md)
|
|
91
|
-
- Related: [Concept](<slug>.md) - how
|
|
92
|
-
|
|
93
|
-
## Sources
|
|
94
|
-
- [Summary](../summaries/<slug>.md) - what it says about this
|
|
95
|
-
|
|
96
|
-
## Contradictions and open questions
|
|
97
|
-
- "<Source A> says X; <source B> says Y" - both attributed.
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Entity page (`entities/<slug>.md`)
|
|
101
|
-
|
|
102
|
-
A concrete thing: a system, a component, an organization, a document, a person only when they are a public role rather than private individual details.
|
|
103
|
-
|
|
104
|
-
```markdown
|
|
105
|
-
---
|
|
106
|
-
type: entity
|
|
107
|
-
kind: <system | component | organization | document | other>
|
|
108
|
-
aliases: []
|
|
109
|
-
updated: YYYY-MM-DD
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
# <Name>
|
|
113
|
-
|
|
114
|
-
<What it is, one or two sentences.>
|
|
115
|
-
|
|
116
|
-
## Facts
|
|
117
|
-
- Attributed facts, each linking the summary or source it comes from.
|
|
118
|
-
|
|
119
|
-
## Connections
|
|
120
|
-
- [Concept or entity](../concepts/<slug>.md) - how
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Synthesis page (`syntheses/<slug>.md`)
|
|
124
|
-
|
|
125
|
-
An answer worth keeping: a comparison, an analysis, a report.
|
|
126
|
-
|
|
127
|
-
```markdown
|
|
128
|
-
---
|
|
129
|
-
type: synthesis
|
|
130
|
-
question: "<The question it answers>"
|
|
131
|
-
updated: YYYY-MM-DD
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
# <Title>
|
|
135
|
-
|
|
136
|
-
<The answer, with links to every page it draws on.>
|
|
137
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: knowledge-query
|
|
3
|
-
description: Answer a question from the knowledge base - find the relevant pages through the index, read them, answer with links to them, and file the answer back as a synthesis page when it is worth keeping.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Querying the knowledge base
|
|
7
|
-
|
|
8
|
-
The knowledge base exists so a question doesn't start from zero. Answer from it first; go back to the originals or the web only for what it doesn't hold.
|
|
9
|
-
|
|
10
|
-
1. **Start from the index.** Read `index.md`, pick the pages that can matter, read those (not the whole knowledge base). `Grep` inside the knowledge base for terms and aliases the index doesn't reveal.
|
|
11
|
-
2. **Answer from the pages**, linking each one you drew on. Say what comes from the knowledge base, what comes from an original in the sources folder (read it if the knowledge base is thin or contradictory) and what comes from outside (label it as such).
|
|
12
|
-
3. **Say what is missing.** If the knowledge base can't answer part of the question, say so and name the source that would fill it, instead of filling the gap from memory silently.
|
|
13
|
-
4. **File it back.** If the answer is a comparison, an analysis or a report that will be asked again, save it as `syntheses/<slug>.md` (template in `knowledge-pages`) with links to its inputs, add it to `index.md`, and log it: `## [date] query | <question>`. A quick factual answer needs no page.
|
|
14
|
-
5. **Feed the knowledge base.** If answering revealed a concept or fact that has no page, or a contradiction, fix that in the knowledge base too and log it.
|
package/dist/core/agentHelp.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { AgentIdentity, Mode } from "./agentSpec.js";
|
|
2
|
-
/**
|
|
3
|
-
* The agent's self-knowledge: who it is (a section of the system prompt) and how it is used
|
|
4
|
-
* (the `agent-help` skill). The chat's part of the skill is the kit's, the same for every
|
|
5
|
-
* agent and kept next to the chat's code (`assets/agent-help/SKILL.md`, checked against the
|
|
6
|
-
* chat's commands and keys by a test); the agent's part is its own guide (`AgentSpec.helpGuide`).
|
|
7
|
-
*/
|
|
8
|
-
/** The plugin the skill is loaded from, as the SDK names its skills ("agent-kit:agent-help"). */
|
|
9
|
-
export declare const AGENT_HELP_SKILL = "agent-kit:agent-help";
|
|
10
|
-
/** Absolute path of the kit's part of the skill, next to `dist/` (or `src/` under tsx). */
|
|
11
|
-
export declare function agentHelpSkillPath(): string;
|
|
12
|
-
/** The "Who you are" section appended to the system prompt: name, version, what it is, the kit's version. */
|
|
13
|
-
export declare function identityPromptSection(identity: AgentIdentity): string;
|
|
14
|
-
/** What the generated skill says about this session. */
|
|
15
|
-
export interface AgentHelpSession {
|
|
16
|
-
mode: Mode;
|
|
17
|
-
/** The modes Shift+Tab goes through (`ModeControl.switchable`). */
|
|
18
|
-
switchable: readonly Mode[];
|
|
19
|
-
/** The built-in knowledge base is on: its slash commands exist. */
|
|
20
|
-
knowledgeBase: boolean;
|
|
21
|
-
/** The sources folder, as shown to the model (e.g. "sources/"). */
|
|
22
|
-
sourcesFolder?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Writes the `agent-help` plugin into `dir` (a folder of this run's), with the kit's part of
|
|
26
|
-
* the skill, this session's facts and the agent's own guide, and returns its root. Generated
|
|
27
|
-
* rather than shipped as it is: the guide goes inside the skill, so the agent needs no file
|
|
28
|
-
* tools to read it, and nothing about it reaches the context until the skill is loaded.
|
|
29
|
-
*/
|
|
30
|
-
export declare function writeAgentHelpPlugin(dir: string, session: AgentHelpSession, helpGuide?: string): Promise<string>;
|
package/dist/core/agentHelp.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { agentKitVersion } from "./version.js";
|
|
5
|
-
/**
|
|
6
|
-
* The agent's self-knowledge: who it is (a section of the system prompt) and how it is used
|
|
7
|
-
* (the `agent-help` skill). The chat's part of the skill is the kit's, the same for every
|
|
8
|
-
* agent and kept next to the chat's code (`assets/agent-help/SKILL.md`, checked against the
|
|
9
|
-
* chat's commands and keys by a test); the agent's part is its own guide (`AgentSpec.helpGuide`).
|
|
10
|
-
*/
|
|
11
|
-
/** The plugin the skill is loaded from, as the SDK names its skills ("agent-kit:agent-help"). */
|
|
12
|
-
export const AGENT_HELP_SKILL = "agent-kit:agent-help";
|
|
13
|
-
/** Absolute path of the kit's part of the skill, next to `dist/` (or `src/` under tsx). */
|
|
14
|
-
export function agentHelpSkillPath() {
|
|
15
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "assets", "agent-help", "SKILL.md");
|
|
16
|
-
}
|
|
17
|
-
/** The "Who you are" section appended to the system prompt: name, version, what it is, the kit's version. */
|
|
18
|
-
export function identityPromptSection(identity) {
|
|
19
|
-
const who = `${identity.name}${identity.version ? ` ${identity.version}` : ""}${identity.description ? `: ${identity.description}` : ""}`;
|
|
20
|
-
return `## Who you are
|
|
21
|
-
You are ${who}. You are built on agent-kit ${agentKitVersion()}, which provides your chat (its modes, keys and slash commands) and your built-in tools.
|
|
22
|
-
When the person asks how to use you (your modes, keys or commands, resuming an earlier conversation, your configuration, what you can do), load the \`agent-help\` skill and answer from it; don't invent options it doesn't list.`;
|
|
23
|
-
}
|
|
24
|
-
/** The skill's "This session" section. */
|
|
25
|
-
function sessionSection(session) {
|
|
26
|
-
const lines = [
|
|
27
|
-
`- This session started in **${session.mode}** mode.`,
|
|
28
|
-
session.switchable.length > 1
|
|
29
|
-
? `- \`Shift+Tab\` goes through: ${session.switchable.join(", ")}.`
|
|
30
|
-
: "- The mode can't be switched during this session.",
|
|
31
|
-
];
|
|
32
|
-
if (session.knowledgeBase)
|
|
33
|
-
lines.push("- You keep a knowledge base (your memory across sessions). Its commands: `/knowledge:ingest` (learn the new or changed files of the sources folder), `/knowledge:query <question>` (answer from it), `/knowledge:lint` (check it and fix what's mechanical).");
|
|
34
|
-
if (session.sourcesFolder)
|
|
35
|
-
lines.push(`- Originals go in \`${session.sourcesFolder}\`: the person drops files there (or you ask for one, or download it), and you never change them.`);
|
|
36
|
-
return `## This session\n\n${lines.join("\n")}`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Writes the `agent-help` plugin into `dir` (a folder of this run's), with the kit's part of
|
|
40
|
-
* the skill, this session's facts and the agent's own guide, and returns its root. Generated
|
|
41
|
-
* rather than shipped as it is: the guide goes inside the skill, so the agent needs no file
|
|
42
|
-
* tools to read it, and nothing about it reaches the context until the skill is loaded.
|
|
43
|
-
*/
|
|
44
|
-
export async function writeAgentHelpPlugin(dir, session, helpGuide) {
|
|
45
|
-
const kitPart = (await readFile(agentHelpSkillPath(), "utf8")).trimEnd();
|
|
46
|
-
const guide = helpGuide ? (await readFile(helpGuide, "utf8")).trim() : "";
|
|
47
|
-
const agentPart = guide
|
|
48
|
-
? `## This agent\n\nThe agent's own guide, for everything about its domain (its commands, configuration, folders):\n\n${guide}`
|
|
49
|
-
: "## This agent\n\nThis agent has no guide of its own: for its domain, say only what your instructions tell you, and that the rest isn't documented.";
|
|
50
|
-
await mkdir(path.join(dir, ".claude-plugin"), { recursive: true });
|
|
51
|
-
await mkdir(path.join(dir, "skills", "agent-help"), { recursive: true });
|
|
52
|
-
await writeFile(path.join(dir, ".claude-plugin", "plugin.json"), `${JSON.stringify({ name: "agent-kit", description: "How to use this agent: the kit's chat and the agent's own guide." }, null, 2)}\n`);
|
|
53
|
-
await writeFile(path.join(dir, "skills", "agent-help", "SKILL.md"), `${kitPart}\n\n${sessionSection(session)}\n\n${agentPart}\n`);
|
|
54
|
-
return dir;
|
|
55
|
-
}
|
package/dist/core/knowledge.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { PageType } from "./knowledgeStore.js";
|
|
2
|
-
/**
|
|
3
|
-
* The built-in knowledge base (an "LLM wiki"): `sourcesDir` holds the originals, `knowledgeDir`
|
|
4
|
-
* is the wiki the agent writes and maintains, and the rules below plus the plugin's skills
|
|
5
|
-
* (knowledge-pages, knowledge-ingest, knowledge-query, knowledge-lint) and commands (/knowledge:ingest, /knowledge:query,
|
|
6
|
-
* /knowledge:lint) are the schema that tells the agent how. Domain-agnostic on purpose: an agent
|
|
7
|
-
* with its own page types (topics, activities...) opts out with `AgentSpec.knowledgeBase: false` and
|
|
8
|
-
* writes its own rules, or extends these.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Absolute path of the plugin shipped with the kit, next to `dist/` (or `src/` under tsx):
|
|
12
|
-
* `assets/knowledge-plugin`, whose skills work through the `knowledge_*` tools, or with
|
|
13
|
-
* `"files"` `assets/knowledge-plugin-files`, whose skills work on the files (ADR-024).
|
|
14
|
-
*/
|
|
15
|
-
export declare function knowledgePluginRoot(variant?: "tools" | "files"): string;
|
|
16
|
-
/**
|
|
17
|
-
* The "Knowledge base" section appended to the system prompt: the layout and the working
|
|
18
|
-
* rules. With `tools` (the kit's default since ADR-024), for a knowledge base reached through
|
|
19
|
-
* the `knowledge_*` tools, listing `pageTypes`; otherwise for one kept with the file tools,
|
|
20
|
-
* whose page templates live in the `knowledge-pages` skill.
|
|
21
|
-
*/
|
|
22
|
-
export declare function knowledgePromptSection(projectDir: string, knowledgeDir: string, sourcesDir?: string, options?: {
|
|
23
|
-
tools?: boolean;
|
|
24
|
-
pageTypes?: readonly PageType[];
|
|
25
|
-
}): string;
|
package/dist/core/knowledge.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
/**
|
|
4
|
-
* The built-in knowledge base (an "LLM wiki"): `sourcesDir` holds the originals, `knowledgeDir`
|
|
5
|
-
* is the wiki the agent writes and maintains, and the rules below plus the plugin's skills
|
|
6
|
-
* (knowledge-pages, knowledge-ingest, knowledge-query, knowledge-lint) and commands (/knowledge:ingest, /knowledge:query,
|
|
7
|
-
* /knowledge:lint) are the schema that tells the agent how. Domain-agnostic on purpose: an agent
|
|
8
|
-
* with its own page types (topics, activities...) opts out with `AgentSpec.knowledgeBase: false` and
|
|
9
|
-
* writes its own rules, or extends these.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Absolute path of the plugin shipped with the kit, next to `dist/` (or `src/` under tsx):
|
|
13
|
-
* `assets/knowledge-plugin`, whose skills work through the `knowledge_*` tools, or with
|
|
14
|
-
* `"files"` `assets/knowledge-plugin-files`, whose skills work on the files (ADR-024).
|
|
15
|
-
*/
|
|
16
|
-
export function knowledgePluginRoot(variant = "tools") {
|
|
17
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "assets", variant === "files" ? "knowledge-plugin-files" : "knowledge-plugin");
|
|
18
|
-
}
|
|
19
|
-
/** A path as shown to the model: relative to the project, forward slashes, with a trailing slash. */
|
|
20
|
-
function shown(projectDir, dir) {
|
|
21
|
-
return `${path.relative(projectDir, dir).split(path.sep).join("/")}/`;
|
|
22
|
-
}
|
|
23
|
-
/** The originals' line of the prompt section, the same in both variants. */
|
|
24
|
-
function originalsLine(originals) {
|
|
25
|
-
return `- **Originals (read-only for you)**: \`${originals}\`. Never rewrite one; build pages *about* them. \`list_sources\` says which are new (not ingested yet), changed since their ingest or missing; add a file only with \`save_to_sources\`, \`download_to_sources\` or by asking the person (\`request_file\`), and take out a wrong or superseded one only with \`retire_source\`. \`Read\` reads PDFs and images; \`extract_text\` reads DOCX, PPTX (with speaker notes) and XLSX.\n`;
|
|
26
|
-
}
|
|
27
|
-
/** The section for a knowledge base reached through the `knowledge_*` tools (ADR-024). */
|
|
28
|
-
function toolsSection(originals, pageTypes) {
|
|
29
|
-
return `## Knowledge base
|
|
30
|
-
Your memory across sessions is an interlinked knowledge base of pages that you write and maintain yourself — a wiki, not a pile of notes. A future session only knows what is written there, so anything worth remembering must end up in a page, not just in this turn's reply. You reach it only through the \`knowledge_*\` tools. Write page content in the language you are using with the human.
|
|
31
|
-
|
|
32
|
-
### Layers
|
|
33
|
-
${originals ? originalsLine(originals) : ""}- **The knowledge base**: pages identified by type and slug (\`concept/spring-tides\`), plus the \`overview\`, a living synthesis of the whole, and the \`log\` of what was done to it (\`knowledge_read\` reads both). Page types: ${pageTypes.map((type) => `\`${type.type}\` (${type.description})`).join("; ")}.
|
|
34
|
-
- **The schema**: these rules plus the \`knowledge-ingest\`, \`knowledge-query\` and \`knowledge-lint\` skills. \`knowledge_create\` without content gives a type's template.
|
|
35
|
-
|
|
36
|
-
### Working rules
|
|
37
|
-
- Start from \`knowledge_search\` or \`knowledge_index\`, then \`knowledge_read\` only the pages the task needs.
|
|
38
|
-
- Link pages by id, \`[Spring tides](concept/spring-tides)\`; links must point to existing pages. The index and the backlinks ("linked from") are kept for you.
|
|
39
|
-
- Change a page with \`knowledge_edit\` (a fragment); \`knowledge_rewrite\` only to redo it whole. Pages are never deleted or renamed: \`knowledge_supersede\` one replaced by another; \`knowledge_retire\` one that was wrong.
|
|
40
|
-
- When an operation is done, \`knowledge_log\` it: \`ingest\`, \`query\`, \`lint\` or \`update\`, with the pages touched.
|
|
41
|
-
- Every claim must be traceable to a summary page, an original, or — clearly labelled as outside the knowledge base — the web.
|
|
42
|
-
- Contradictions are kept, not overwritten: record both versions with attribution in the affected pages.
|
|
43
|
-
- Short, focused, well-linked pages beat long ones: when a page mixes two things, split it.`;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The "Knowledge base" section appended to the system prompt: the layout and the working
|
|
47
|
-
* rules. With `tools` (the kit's default since ADR-024), for a knowledge base reached through
|
|
48
|
-
* the `knowledge_*` tools, listing `pageTypes`; otherwise for one kept with the file tools,
|
|
49
|
-
* whose page templates live in the `knowledge-pages` skill.
|
|
50
|
-
*/
|
|
51
|
-
export function knowledgePromptSection(projectDir, knowledgeDir, sourcesDir, options = {}) {
|
|
52
|
-
const notes = shown(projectDir, knowledgeDir);
|
|
53
|
-
const originals = sourcesDir ? shown(projectDir, sourcesDir) : undefined;
|
|
54
|
-
if (options.tools)
|
|
55
|
-
return toolsSection(originals, options.pageTypes ?? []);
|
|
56
|
-
return `## Knowledge base (${notes})
|
|
57
|
-
\`${notes}\` is your memory across sessions, kept as an interlinked knowledge base of markdown pages that you write and maintain yourself — a wiki, not a pile of notes. A future session only knows what is written there, so anything worth remembering must end up in a page, not just in this turn's reply. Write page content in the language you are using with the human; file names stay lowercase ASCII with hyphens.
|
|
58
|
-
|
|
59
|
-
### Layers
|
|
60
|
-
${originals ? originalsLine(originals) : ""}- **The knowledge base**: \`${notes}\`, entirely yours to write.
|
|
61
|
-
- **The schema**: these rules plus the \`knowledge-pages\` skill (exact template of every page type — load it before creating a page) and the \`knowledge-ingest\`, \`knowledge-query\` and \`knowledge-lint\` skills.
|
|
62
|
-
|
|
63
|
-
### Layout
|
|
64
|
-
\`\`\`
|
|
65
|
-
${notes}
|
|
66
|
-
index.md catalog of every page, one line each: read it FIRST, always
|
|
67
|
-
log.md append-only log of what you did to the knowledge base
|
|
68
|
-
overview.md living synthesis of the whole knowledge base
|
|
69
|
-
summaries/<slug>.md one page per ingested source
|
|
70
|
-
concepts/<slug>.md one page per idea
|
|
71
|
-
entities/<slug>.md one page per concrete thing (system, component, organization, document)
|
|
72
|
-
syntheses/<slug>.md answers worth keeping: comparisons, analyses, reports
|
|
73
|
-
\`\`\`
|
|
74
|
-
|
|
75
|
-
### Working rules
|
|
76
|
-
- Start by reading \`index.md\`, then only the pages the task needs — don't read the whole knowledge base.
|
|
77
|
-
- Links are standard markdown links relative to the page, and go both ways: when A links to B, add the link back in B. To find who links to a page, \`Grep\` for its file name inside the knowledge base.
|
|
78
|
-
- Never rename, move or delete a page (every link to it would break): if it is superseded, say so at its top and link to the new one.
|
|
79
|
-
- Prefer \`Edit\` for changes to an existing page; \`Write\` only for new pages.
|
|
80
|
-
- After any change, update \`index.md\` and append \`## [YYYY-MM-DD] <operation> | <what>\` to \`log.md\`, followed by the pages created/updated. Operations: \`ingest\`, \`query\`, \`lint\`, \`update\`.
|
|
81
|
-
- Every claim must be traceable to a summary page, an original, or — clearly labelled as outside the knowledge base — the web.
|
|
82
|
-
- Contradictions are kept, not overwritten: record both versions with attribution in the affected pages.
|
|
83
|
-
- Short, focused, well-linked pages beat long ones: when a page mixes two things, split it.`;
|
|
84
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|