agentikit 0.0.8 → 0.0.12
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 +135 -117
- package/dist/index.d.ts +13 -3
- package/dist/index.js +7 -1
- package/dist/src/asset-spec.d.ts +2 -0
- package/dist/src/asset-spec.js +22 -3
- package/dist/src/asset-type-handler.d.ts +27 -0
- package/dist/src/asset-type-handler.js +33 -0
- package/dist/src/cli.js +335 -100
- package/dist/src/common.d.ts +6 -1
- package/dist/src/common.js +18 -4
- package/dist/src/config-cli.d.ts +9 -0
- package/dist/src/config-cli.js +473 -0
- package/dist/src/config.d.ts +25 -6
- package/dist/src/config.js +188 -28
- package/dist/src/db.d.ts +46 -0
- package/dist/src/db.js +299 -0
- package/dist/src/embedder.js +12 -7
- package/dist/src/github.d.ts +4 -0
- package/dist/src/github.js +19 -0
- package/dist/src/handlers/agent-handler.d.ts +2 -0
- package/dist/src/handlers/agent-handler.js +26 -0
- package/dist/src/handlers/command-handler.d.ts +2 -0
- package/dist/src/handlers/command-handler.js +23 -0
- package/dist/src/handlers/index.d.ts +6 -0
- package/dist/src/handlers/index.js +23 -0
- package/dist/src/handlers/knowledge-handler.d.ts +2 -0
- package/dist/src/handlers/knowledge-handler.js +56 -0
- package/dist/src/handlers/markdown-helpers.d.ts +7 -0
- package/dist/src/handlers/markdown-helpers.js +15 -0
- package/dist/src/handlers/script-handler.d.ts +2 -0
- package/dist/src/handlers/script-handler.js +78 -0
- package/dist/src/handlers/skill-handler.d.ts +2 -0
- package/dist/src/handlers/skill-handler.js +30 -0
- package/dist/src/handlers/tool-handler.d.ts +2 -0
- package/dist/src/handlers/tool-handler.js +58 -0
- package/dist/src/indexer.d.ts +1 -23
- package/dist/src/indexer.js +162 -155
- package/dist/src/init.d.ts +2 -2
- package/dist/src/init.js +21 -9
- package/dist/src/llm.js +4 -3
- package/dist/src/metadata.d.ts +1 -1
- package/dist/src/metadata.js +22 -64
- package/dist/src/origin-resolve.d.ts +19 -0
- package/dist/src/origin-resolve.js +53 -0
- package/dist/src/registry-install.d.ts +11 -0
- package/dist/src/registry-install.js +315 -0
- package/dist/src/registry-resolve.d.ts +3 -0
- package/dist/src/registry-resolve.js +299 -0
- package/dist/src/registry-search.d.ts +27 -0
- package/dist/src/registry-search.js +263 -0
- package/dist/src/registry-types.d.ts +62 -0
- package/dist/src/registry-types.js +1 -0
- package/dist/src/stash-add.d.ts +4 -0
- package/dist/src/stash-add.js +59 -0
- package/dist/src/stash-clone.d.ts +22 -0
- package/dist/src/stash-clone.js +83 -0
- package/dist/src/stash-ref.d.ts +27 -3
- package/dist/src/stash-ref.js +63 -24
- package/dist/src/stash-registry.d.ts +18 -0
- package/dist/src/stash-registry.js +221 -0
- package/dist/src/stash-resolve.js +3 -0
- package/dist/src/stash-search.d.ts +3 -1
- package/dist/src/stash-search.js +357 -138
- package/dist/src/stash-show.d.ts +1 -1
- package/dist/src/stash-show.js +28 -89
- package/dist/src/stash-source.d.ts +24 -0
- package/dist/src/stash-source.js +81 -0
- package/dist/src/stash-types.d.ts +175 -1
- package/dist/src/stash.d.ts +9 -1
- package/dist/src/stash.js +5 -0
- package/dist/src/tool-runner.d.ts +1 -1
- package/dist/src/tool-runner.js +18 -5
- package/package.json +7 -2
- package/src/asset-spec.ts +20 -4
- package/src/asset-type-handler.ts +77 -0
- package/src/cli.ts +354 -103
- package/src/common.ts +23 -5
- package/src/config-cli.ts +499 -0
- package/src/config.ts +218 -37
- package/src/db.ts +411 -0
- package/src/embedder.ts +22 -11
- package/src/github.ts +21 -0
- package/src/handlers/agent-handler.ts +32 -0
- package/src/handlers/command-handler.ts +29 -0
- package/src/handlers/index.ts +25 -0
- package/src/handlers/knowledge-handler.ts +62 -0
- package/src/handlers/markdown-helpers.ts +19 -0
- package/src/handlers/script-handler.ts +92 -0
- package/src/handlers/skill-handler.ts +37 -0
- package/src/handlers/tool-handler.ts +71 -0
- package/src/indexer.ts +208 -187
- package/src/init.ts +17 -9
- package/src/llm.ts +4 -3
- package/src/metadata.ts +21 -65
- package/src/origin-resolve.ts +67 -0
- package/src/registry-install.ts +361 -0
- package/src/registry-resolve.ts +341 -0
- package/src/registry-search.ts +335 -0
- package/src/registry-types.ts +72 -0
- package/src/stash-add.ts +63 -0
- package/src/stash-clone.ts +127 -0
- package/src/stash-ref.ts +84 -26
- package/src/stash-registry.ts +259 -0
- package/src/stash-resolve.ts +3 -0
- package/src/stash-search.ts +425 -155
- package/src/stash-show.ts +33 -82
- package/src/stash-source.ts +103 -0
- package/src/stash-types.ts +186 -1
- package/src/stash.ts +23 -0
- package/src/tool-runner.ts +18 -5
- package/dist/src/similarity.d.ts +0 -34
- package/src/similarity.ts +0 -271
package/README.md
CHANGED
|
@@ -1,183 +1,201 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent-i-Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Agent-i-Kit gives AI coding agents a shared library of capabilities they can
|
|
4
|
+
search and use. You organize tools, skills, commands, agents, knowledge, and
|
|
5
|
+
scripts into a **stash**, and agents discover what they need through
|
|
6
|
+
`akm` (Agent Kit Manager).
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
## What Is a Kit?
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
A kit is a shareable package of assets. Any directory with asset
|
|
11
|
+
subdirectories is a valid kit:
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
```text
|
|
14
|
+
my-kit/
|
|
15
|
+
tools/ # Executable scripts (.sh, .ts, .js)
|
|
16
|
+
skills/ # Skill definitions (directories with SKILL.md)
|
|
17
|
+
commands/ # Slash commands (.md)
|
|
18
|
+
agents/ # Agent definitions (.md)
|
|
19
|
+
knowledge/ # Reference documents (.md)
|
|
20
|
+
scripts/ # General scripts (.py, .rb, .go, etc.)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Kits can be published to npm or hosted on GitHub. Tag them with `akm` or
|
|
24
|
+
`agentikit` so others can discover them through registry search.
|
|
25
|
+
|
|
26
|
+
## What Is a Stash?
|
|
27
|
+
|
|
28
|
+
The stash is your local library of assets. It combines three sources:
|
|
29
|
+
|
|
30
|
+
1. **Working stash** -- Your personal assets (`AKM_STASH_DIR`). Read-write.
|
|
31
|
+
2. **Mounted dirs** -- Shared team directories. Read-only.
|
|
32
|
+
3. **Installed kits** -- Kits from npm or GitHub via `akm add`. Read-only.
|
|
33
|
+
|
|
34
|
+
When you search or open an asset, the working stash takes priority. This
|
|
35
|
+
means you can install a kit and override individual assets by cloning them
|
|
36
|
+
into your working stash.
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
10
39
|
|
|
11
40
|
```sh
|
|
41
|
+
# Install
|
|
12
42
|
npm install -g agentikit
|
|
13
|
-
# or
|
|
14
|
-
bun add -g agentikit
|
|
15
|
-
```
|
|
16
43
|
|
|
17
|
-
|
|
44
|
+
# Initialize your stash
|
|
45
|
+
akm init
|
|
46
|
+
|
|
47
|
+
# Search for assets
|
|
48
|
+
akm search "deploy"
|
|
49
|
+
|
|
50
|
+
# Show an asset
|
|
51
|
+
akm show tool:deploy.sh
|
|
52
|
+
|
|
53
|
+
# Install a kit from npm
|
|
54
|
+
akm add @scope/my-kit
|
|
18
55
|
|
|
19
|
-
|
|
56
|
+
# Search installed and registry kits
|
|
57
|
+
akm search "lint" --source both
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Standalone Binary
|
|
20
61
|
|
|
21
62
|
```sh
|
|
22
63
|
# macOS / Linux
|
|
23
64
|
curl -fsSL https://raw.githubusercontent.com/itlackey/agentikit/main/install.sh | bash
|
|
24
|
-
# pin a release tag)
|
|
25
|
-
curl -fsSL https://raw.githubusercontent.com/itlackey/agentikit/main/install.sh | bash -s -- v1.2.3
|
|
26
65
|
|
|
27
|
-
#
|
|
66
|
+
# Windows (PowerShell)
|
|
28
67
|
irm https://raw.githubusercontent.com/itlackey/agentikit/main/install.ps1 -OutFile install.ps1; ./install.ps1
|
|
29
68
|
```
|
|
30
69
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Stash model
|
|
70
|
+
## Searching and Showing Assets
|
|
34
71
|
|
|
35
|
-
|
|
72
|
+
Search returns scored results with metadata explaining why each hit matched:
|
|
36
73
|
|
|
37
74
|
```sh
|
|
38
|
-
|
|
75
|
+
akm search "docker" --type tool
|
|
39
76
|
```
|
|
40
77
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"hits": [
|
|
81
|
+
{
|
|
82
|
+
"name": "docker-build",
|
|
83
|
+
"type": "tool",
|
|
84
|
+
"description": "Build and push Docker images",
|
|
85
|
+
"openRef": "tool:docker-build.sh",
|
|
86
|
+
"score": 0.92,
|
|
87
|
+
"whyMatched": "matched name tokens, fts bm25 relevance"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
50
91
|
```
|
|
51
92
|
|
|
52
|
-
|
|
93
|
+
Use `openRef` from search results to show the full asset:
|
|
53
94
|
|
|
54
95
|
```sh
|
|
55
|
-
akm
|
|
56
|
-
akm index [--full] # Build search index (incremental by default)
|
|
57
|
-
akm search [query] # Search the stash
|
|
58
|
-
akm show <type:name> # Read a stash asset by ref
|
|
96
|
+
akm show tool:docker-build.sh
|
|
59
97
|
```
|
|
60
98
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"type": "tool",
|
|
102
|
+
"name": "docker-build.sh",
|
|
103
|
+
"runCmd": "cd \"/path/to/tools\" && bash \"/path/to/tools/docker-build.sh\"",
|
|
104
|
+
"kind": "bash"
|
|
105
|
+
}
|
|
67
106
|
```
|
|
68
107
|
|
|
69
|
-
|
|
70
|
-
- `--type`: `tool | skill | command | agent | knowledge | any` (default: `any`)
|
|
71
|
-
- `--limit`: defaults to `20`
|
|
72
|
-
|
|
73
|
-
Returns typed hits with `openRef`, score/explainability details (`score`, `whyMatched`), and, for tools, execution-ready `runCmd`.
|
|
74
|
-
|
|
75
|
-
### show
|
|
76
|
-
|
|
77
|
-
Show a hit using `openRef` from search results.
|
|
108
|
+
For knowledge assets, views let you navigate large documents:
|
|
78
109
|
|
|
79
110
|
```sh
|
|
80
|
-
akm show
|
|
81
|
-
akm show knowledge:guide.md --view
|
|
82
|
-
akm show knowledge:guide.md --view section --heading "Getting Started"
|
|
83
|
-
akm show knowledge:guide.md --view lines --start 10 --end 30
|
|
111
|
+
akm show knowledge:api-guide.md --view toc
|
|
112
|
+
akm show knowledge:api-guide.md --view section --heading "Authentication"
|
|
84
113
|
```
|
|
85
114
|
|
|
86
|
-
|
|
115
|
+
## Using With AI Agents
|
|
87
116
|
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
- `agent` — full markdown body as `prompt` (+ best-effort `description`, `toolPolicy`, `modelHint`)
|
|
91
|
-
- `tool` — `runCmd`/`kind` (the agent uses the host's shell to execute `runCmd`)
|
|
92
|
-
- `knowledge` — content with optional view modes (`full`, `toc`, `frontmatter`, `section`, `lines`)
|
|
117
|
+
Agent-i-Kit is designed to be called by AI coding agents. The agent searches
|
|
118
|
+
for capabilities, reads the results, and acts on them.
|
|
93
119
|
|
|
94
|
-
|
|
120
|
+
### OpenCode
|
|
95
121
|
|
|
96
|
-
|
|
122
|
+
In an OpenCode project, add akm as a tool in your configuration. The agent
|
|
123
|
+
can then search the stash and run tools directly:
|
|
97
124
|
|
|
98
|
-
```
|
|
99
|
-
|
|
125
|
+
```text
|
|
126
|
+
Search the stash for deployment tools, then run the best match.
|
|
100
127
|
```
|
|
101
128
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- `agentikitInit()` — initialize stash directory
|
|
105
|
-
- `agentikitIndex()` — build/rebuild search index
|
|
129
|
+
The agent calls `akm search "deploy" --type tool`, picks the top result,
|
|
130
|
+
reads its `runCmd` from `akm show`, and executes it.
|
|
106
131
|
|
|
107
|
-
|
|
132
|
+
### Claude Code
|
|
108
133
|
|
|
109
|
-
|
|
134
|
+
Add akm commands as tools or reference them from your CLAUDE.md:
|
|
110
135
|
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
akm config --set key=value # Update a config key
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Embedding connection
|
|
136
|
+
```markdown
|
|
137
|
+
## Available Tools
|
|
117
138
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
```sh
|
|
121
|
-
akm config --set 'embedding={"endpoint":"http://localhost:11434/v1/embeddings","model":"nomic-embed-text"}'
|
|
139
|
+
Use `akm search <query>` to find tools, skills, and commands in the stash.
|
|
140
|
+
Use `akm show <ref>` to read asset details before using them.
|
|
122
141
|
```
|
|
123
142
|
|
|
124
|
-
|
|
143
|
+
### Any Agent
|
|
125
144
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### LLM connection
|
|
145
|
+
The JSON output from `akm search` and `akm show` is designed for machine
|
|
146
|
+
consumption. Any agent that can run shell commands can use akm:
|
|
131
147
|
|
|
132
|
-
|
|
148
|
+
1. `akm search "what you need"` -- Find relevant assets
|
|
149
|
+
2. `akm show <openRef>` -- Get the details
|
|
150
|
+
3. Use the asset (run the `runCmd`, follow the skill instructions, etc.)
|
|
133
151
|
|
|
134
|
-
|
|
135
|
-
akm config --set 'llm={"endpoint":"http://localhost:11434/v1/chat/completions","model":"llama3.2"}'
|
|
136
|
-
```
|
|
152
|
+
## Installing Kits
|
|
137
153
|
|
|
138
|
-
|
|
154
|
+
Install kits from npm, GitHub, or local directories:
|
|
139
155
|
|
|
140
156
|
```sh
|
|
141
|
-
akm
|
|
157
|
+
akm add @scope/my-kit # npm package
|
|
158
|
+
akm add github:owner/repo # GitHub repo
|
|
159
|
+
akm add ./path/to/local/kit # Local git directory
|
|
142
160
|
```
|
|
143
161
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
[Ollama](https://ollama.com) provides local models with an OpenAI-compatible API. After installing Ollama and pulling your models:
|
|
162
|
+
Search the registry to discover kits:
|
|
147
163
|
|
|
148
164
|
```sh
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
ollama pull llama3.2
|
|
165
|
+
akm search "code review" --source registry
|
|
166
|
+
```
|
|
152
167
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
akm config --set 'llm={"endpoint":"http://localhost:11434/v1/chat/completions","model":"llama3.2"}'
|
|
168
|
+
Only packages tagged with `akm` or `agentikit` appear in registry results.
|
|
169
|
+
See [docs/registry.md](docs/registry.md) for details.
|
|
156
170
|
|
|
157
|
-
|
|
158
|
-
akm index --full
|
|
159
|
-
```
|
|
171
|
+
## Publishing a Kit
|
|
160
172
|
|
|
161
|
-
|
|
173
|
+
1. Organize your assets into the standard directory structure
|
|
174
|
+
2. Add `"akm"` to `keywords` in `package.json` (for npm) or add the `akm`
|
|
175
|
+
topic to your GitHub repo
|
|
176
|
+
3. Optionally add an `agentikit.include` array in `package.json` to control
|
|
177
|
+
which paths are included when installed
|
|
162
178
|
|
|
163
179
|
```json
|
|
164
180
|
{
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"
|
|
181
|
+
"name": "@scope/my-kit",
|
|
182
|
+
"keywords": ["akm"],
|
|
183
|
+
"agentikit": {
|
|
184
|
+
"include": ["tools", "skills", "commands"]
|
|
185
|
+
}
|
|
168
186
|
}
|
|
169
187
|
```
|
|
170
188
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
| Key | Type | Default | Description |
|
|
174
|
-
|-----|------|---------|-------------|
|
|
175
|
-
| `semanticSearch` | `boolean` | `true` | Enable semantic search ranking |
|
|
176
|
-
| `additionalStashDirs` | `string[]` | `[]` | Extra stash directories to search |
|
|
177
|
-
| `embedding` | `object` | not set | OpenAI-compatible embedding endpoint (`endpoint`, `model`, `apiKey?`) |
|
|
178
|
-
| `llm` | `object` | not set | OpenAI-compatible LLM endpoint (`endpoint`, `model`, `apiKey?`) |
|
|
179
|
-
|
|
180
|
-
## Notes
|
|
189
|
+
## Documentation
|
|
181
190
|
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
| Doc | Description |
|
|
192
|
+
| --- | --- |
|
|
193
|
+
| [Concepts](docs/concepts.md) | Asset types, stash sources, metadata, tool execution |
|
|
194
|
+
| [CLI Reference](docs/cli.md) | All akm commands and flags |
|
|
195
|
+
| [Kit Maker's Guide](docs/kit-makers.md) | How to build and share a kit |
|
|
196
|
+
| [Registry](docs/registry.md) | Finding, installing, and publishing kits |
|
|
197
|
+
| [Search](docs/search.md) | Hybrid search architecture and scoring |
|
|
198
|
+
| [Indexing](docs/indexing.md) | How the search index is built |
|
|
199
|
+
| [Filesystem](docs/filesystem.md) | Directory layout and `.stash.json` schema |
|
|
200
|
+
| [Configuration](docs/configuration.md) | Providers, settings, and Ollama setup |
|
|
201
|
+
| [Library API](docs/api.md) | Using agentikit as a TypeScript/JS library |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { agentikitSearch, agentikitShow } from "./src/stash";
|
|
1
|
+
export { agentikitAdd, agentikitClone, agentikitList, agentikitRemove, agentikitReinstall, agentikitSearch, agentikitShow, agentikitUpdate, resolveStashSources, resolveAllStashDirs, findSourceForPath, } from "./src/stash";
|
|
2
2
|
export { agentikitInit } from "./src/init";
|
|
3
3
|
export type { InitResponse } from "./src/init";
|
|
4
|
-
export type { AgentikitAssetType, AgentikitSearchType, SearchHit, SearchResponse, ShowResponse, KnowledgeView, } from "./src/stash";
|
|
4
|
+
export type { AgentikitAssetType, AgentikitSearchType, AddResponse, LocalSearchHit, RegistrySearchResultHit, SearchSource, SearchHit, SearchResponse, ShowResponse, KnowledgeView, ListResponse, RemoveResponse, ReinstallResponse, UpdateResponse, RegistryListEntry, RegistryInstallStatus, ReinstallResultItem, UpdateResultItem, StashSource, StashSourceKind, CloneOptions, CloneResponse, } from "./src/stash";
|
|
5
5
|
export type { ToolKind } from "./src/tool-runner";
|
|
6
6
|
export { agentikitIndex } from "./src/indexer";
|
|
7
7
|
export type { IndexResponse } from "./src/indexer";
|
|
@@ -12,7 +12,17 @@ export { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterO
|
|
|
12
12
|
export type { TocHeading, KnowledgeToc } from "./src/markdown";
|
|
13
13
|
export { parseFrontmatter } from "./src/frontmatter";
|
|
14
14
|
export { loadConfig, saveConfig, updateConfig } from "./src/config";
|
|
15
|
-
export type { AgentikitConfig, EmbeddingConnectionConfig, LlmConnectionConfig } from "./src/config";
|
|
15
|
+
export type { AgentikitConfig, EmbeddingConnectionConfig, LlmConnectionConfig, RegistryConfig } from "./src/config";
|
|
16
|
+
export { parseRegistryRef, resolveRegistryArtifact } from "./src/registry-resolve";
|
|
17
|
+
export { searchRegistry } from "./src/registry-search";
|
|
18
|
+
export { installRegistryRef, upsertInstalledRegistryEntry, removeInstalledRegistryEntry, getRegistryCacheRootDir, detectStashRoot, } from "./src/registry-install";
|
|
19
|
+
export type { RegistrySource, ParsedRegistryRef, ParsedNpmRef, ParsedGithubRef, ResolvedRegistryArtifact, RegistryInstalledEntry, RegistryInstallResult, RegistrySearchHit, RegistrySearchResponse, } from "./src/registry-types";
|
|
16
20
|
export { enhanceMetadata, isLlmAvailable } from "./src/llm";
|
|
17
21
|
export { embed, cosineSimilarity, isEmbeddingAvailable } from "./src/embedder";
|
|
18
22
|
export type { EmbeddingVector } from "./src/embedder";
|
|
23
|
+
export type { SearchUsageMode } from "./src/stash-types";
|
|
24
|
+
export type { AssetTypeHandler, ShowInput } from "./src/asset-type-handler";
|
|
25
|
+
export { registerAssetType, getHandler, tryGetHandler, getAllHandlers, getRegisteredTypeNames } from "./src/asset-type-handler";
|
|
26
|
+
export { parseAssetRef, makeAssetRef } from "./src/stash-ref";
|
|
27
|
+
export type { AssetRef } from "./src/stash-ref";
|
|
28
|
+
export { resolveSourcesForOrigin, isRemoteOrigin } from "./src/origin-resolve";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export { agentikitSearch, agentikitShow } from "./src/stash";
|
|
1
|
+
export { agentikitAdd, agentikitClone, agentikitList, agentikitRemove, agentikitReinstall, agentikitSearch, agentikitShow, agentikitUpdate, resolveStashSources, resolveAllStashDirs, findSourceForPath, } from "./src/stash";
|
|
2
2
|
export { agentikitInit } from "./src/init";
|
|
3
3
|
export { agentikitIndex } from "./src/indexer";
|
|
4
4
|
export { resolveRg, isRgAvailable, ensureRg } from "./src/ripgrep";
|
|
5
5
|
export { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterOnly, formatToc } from "./src/markdown";
|
|
6
6
|
export { parseFrontmatter } from "./src/frontmatter";
|
|
7
7
|
export { loadConfig, saveConfig, updateConfig } from "./src/config";
|
|
8
|
+
export { parseRegistryRef, resolveRegistryArtifact } from "./src/registry-resolve";
|
|
9
|
+
export { searchRegistry } from "./src/registry-search";
|
|
10
|
+
export { installRegistryRef, upsertInstalledRegistryEntry, removeInstalledRegistryEntry, getRegistryCacheRootDir, detectStashRoot, } from "./src/registry-install";
|
|
8
11
|
export { enhanceMetadata, isLlmAvailable } from "./src/llm";
|
|
9
12
|
export { embed, cosineSimilarity, isEmbeddingAvailable } from "./src/embedder";
|
|
13
|
+
export { registerAssetType, getHandler, tryGetHandler, getAllHandlers, getRegisteredTypeNames } from "./src/asset-type-handler";
|
|
14
|
+
export { parseAssetRef, makeAssetRef } from "./src/stash-ref";
|
|
15
|
+
export { resolveSourcesForOrigin, isRemoteOrigin } from "./src/origin-resolve";
|
package/dist/src/asset-spec.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface AssetSpec {
|
|
|
6
6
|
toCanonicalName: (typeRoot: string, filePath: string) => string | undefined;
|
|
7
7
|
toAssetPath: (typeRoot: string, name: string) => string;
|
|
8
8
|
}
|
|
9
|
+
/** Extended set of script extensions for the script asset type */
|
|
10
|
+
export declare const SCRIPT_EXTENSIONS_BROAD: Set<string>;
|
|
9
11
|
export declare const ASSET_SPECS: Record<AgentikitAssetType, AssetSpec>;
|
|
10
12
|
export declare const ASSET_TYPES: AgentikitAssetType[];
|
|
11
13
|
export declare const TYPE_DIRS: Record<AgentikitAssetType, string>;
|
package/dist/src/asset-spec.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { toPosix } from "./common";
|
|
3
|
+
import { tryGetHandler } from "./asset-type-handler";
|
|
2
4
|
export const SCRIPT_EXTENSIONS = new Set([".sh", ".ts", ".js", ".ps1", ".cmd", ".bat"]);
|
|
3
5
|
const markdownSpec = {
|
|
4
6
|
isRelevantFile: (fileName) => path.extname(fileName).toLowerCase() === ".md",
|
|
5
7
|
toCanonicalName: (typeRoot, filePath) => toPosix(path.relative(typeRoot, filePath)),
|
|
6
8
|
toAssetPath: (typeRoot, name) => path.join(typeRoot, name),
|
|
7
9
|
};
|
|
10
|
+
/** Extended set of script extensions for the script asset type */
|
|
11
|
+
export const SCRIPT_EXTENSIONS_BROAD = new Set([
|
|
12
|
+
...SCRIPT_EXTENSIONS,
|
|
13
|
+
".py", ".rb", ".go", ".pl", ".php", ".lua", ".r", ".swift", ".kt", ".kts",
|
|
14
|
+
]);
|
|
8
15
|
export const ASSET_SPECS = {
|
|
9
16
|
tool: {
|
|
10
17
|
stashDir: "tools",
|
|
@@ -26,6 +33,12 @@ export const ASSET_SPECS = {
|
|
|
26
33
|
command: { stashDir: "commands", ...markdownSpec },
|
|
27
34
|
agent: { stashDir: "agents", ...markdownSpec },
|
|
28
35
|
knowledge: { stashDir: "knowledge", ...markdownSpec },
|
|
36
|
+
script: {
|
|
37
|
+
stashDir: "scripts",
|
|
38
|
+
isRelevantFile: (fileName) => SCRIPT_EXTENSIONS_BROAD.has(path.extname(fileName).toLowerCase()),
|
|
39
|
+
toCanonicalName: (typeRoot, filePath) => toPosix(path.relative(typeRoot, filePath)),
|
|
40
|
+
toAssetPath: (typeRoot, name) => path.join(typeRoot, name),
|
|
41
|
+
},
|
|
29
42
|
};
|
|
30
43
|
export const ASSET_TYPES = Object.keys(ASSET_SPECS);
|
|
31
44
|
export const TYPE_DIRS = ASSET_TYPES.reduce((acc, type) => {
|
|
@@ -33,14 +46,20 @@ export const TYPE_DIRS = ASSET_TYPES.reduce((acc, type) => {
|
|
|
33
46
|
return acc;
|
|
34
47
|
}, {});
|
|
35
48
|
export function isRelevantAssetFile(assetType, fileName) {
|
|
49
|
+
const handler = tryGetHandler(assetType);
|
|
50
|
+
if (handler)
|
|
51
|
+
return handler.isRelevantFile(fileName);
|
|
36
52
|
return ASSET_SPECS[assetType].isRelevantFile(fileName);
|
|
37
53
|
}
|
|
38
54
|
export function deriveCanonicalAssetName(assetType, typeRoot, filePath) {
|
|
55
|
+
const handler = tryGetHandler(assetType);
|
|
56
|
+
if (handler)
|
|
57
|
+
return handler.toCanonicalName(typeRoot, filePath);
|
|
39
58
|
return ASSET_SPECS[assetType].toCanonicalName(typeRoot, filePath);
|
|
40
59
|
}
|
|
41
60
|
export function resolveAssetPathFromName(assetType, typeRoot, name) {
|
|
61
|
+
const handler = tryGetHandler(assetType);
|
|
62
|
+
if (handler)
|
|
63
|
+
return handler.toAssetPath(typeRoot, name);
|
|
42
64
|
return ASSET_SPECS[assetType].toAssetPath(typeRoot, name);
|
|
43
65
|
}
|
|
44
|
-
function toPosix(input) {
|
|
45
|
-
return input.replace(/\\/g, "/");
|
|
46
|
-
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StashEntry } from "./metadata";
|
|
2
|
+
import type { LocalSearchHit, ShowResponse, KnowledgeView } from "./stash-types";
|
|
3
|
+
export interface ShowInput {
|
|
4
|
+
name: string;
|
|
5
|
+
path: string;
|
|
6
|
+
content: string;
|
|
7
|
+
view?: KnowledgeView;
|
|
8
|
+
stashDirs?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface AssetTypeHandler {
|
|
11
|
+
/** The type name, e.g. "tool", "script" */
|
|
12
|
+
readonly typeName: string;
|
|
13
|
+
/** Directory inside the stash root, e.g. "tools", "scripts" */
|
|
14
|
+
readonly stashDir: string;
|
|
15
|
+
isRelevantFile(fileName: string): boolean;
|
|
16
|
+
toCanonicalName(typeRoot: string, filePath: string): string | undefined;
|
|
17
|
+
toAssetPath(typeRoot: string, name: string): string;
|
|
18
|
+
buildShowResponse(input: ShowInput): ShowResponse;
|
|
19
|
+
enrichSearchHit?(hit: LocalSearchHit, stashDir: string): void;
|
|
20
|
+
readonly defaultUsageGuide: string[];
|
|
21
|
+
extractTypeMetadata?(entry: StashEntry, file: string, ext: string): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function registerAssetType(handler: AssetTypeHandler): void;
|
|
24
|
+
export declare function getHandler(type: string): AssetTypeHandler;
|
|
25
|
+
export declare function tryGetHandler(type: string): AssetTypeHandler | undefined;
|
|
26
|
+
export declare function getAllHandlers(): AssetTypeHandler[];
|
|
27
|
+
export declare function getRegisteredTypeNames(): string[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// ── Registry ─────────────────────────────────────────────────────────────────
|
|
2
|
+
const handlers = new Map();
|
|
3
|
+
let handlersInitialized = false;
|
|
4
|
+
function ensureHandlersRegistered() {
|
|
5
|
+
if (handlersInitialized)
|
|
6
|
+
return;
|
|
7
|
+
handlersInitialized = true;
|
|
8
|
+
// Import handler registrations
|
|
9
|
+
require("./handlers/index");
|
|
10
|
+
}
|
|
11
|
+
export function registerAssetType(handler) {
|
|
12
|
+
handlers.set(handler.typeName, handler);
|
|
13
|
+
}
|
|
14
|
+
export function getHandler(type) {
|
|
15
|
+
ensureHandlersRegistered();
|
|
16
|
+
const handler = handlers.get(type);
|
|
17
|
+
if (!handler) {
|
|
18
|
+
throw new Error(`Unknown asset type: "${type}"`);
|
|
19
|
+
}
|
|
20
|
+
return handler;
|
|
21
|
+
}
|
|
22
|
+
export function tryGetHandler(type) {
|
|
23
|
+
ensureHandlersRegistered();
|
|
24
|
+
return handlers.get(type);
|
|
25
|
+
}
|
|
26
|
+
export function getAllHandlers() {
|
|
27
|
+
ensureHandlersRegistered();
|
|
28
|
+
return Array.from(handlers.values());
|
|
29
|
+
}
|
|
30
|
+
export function getRegisteredTypeNames() {
|
|
31
|
+
ensureHandlersRegistered();
|
|
32
|
+
return Array.from(handlers.keys());
|
|
33
|
+
}
|