@neocode-ai/web 1.1.1
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 +54 -0
- package/astro.config.mjs +145 -0
- package/config.mjs +14 -0
- package/package.json +41 -0
- package/public/robots.txt +6 -0
- package/public/theme.json +183 -0
- package/src/assets/lander/check.svg +2 -0
- package/src/assets/lander/copy.svg +2 -0
- package/src/assets/lander/screenshot-github.png +0 -0
- package/src/assets/lander/screenshot-splash.png +0 -0
- package/src/assets/lander/screenshot-vscode.png +0 -0
- package/src/assets/lander/screenshot.png +0 -0
- package/src/assets/logo-dark.svg +20 -0
- package/src/assets/logo-light.svg +20 -0
- package/src/assets/logo-ornate-dark.svg +18 -0
- package/src/assets/logo-ornate-light.svg +18 -0
- package/src/assets/web/web-homepage-active-session.png +0 -0
- package/src/assets/web/web-homepage-new-session.png +0 -0
- package/src/assets/web/web-homepage-see-servers.png +0 -0
- package/src/components/Head.astro +50 -0
- package/src/components/Header.astro +128 -0
- package/src/components/Hero.astro +11 -0
- package/src/components/Lander.astro +713 -0
- package/src/components/Share.tsx +634 -0
- package/src/components/SiteTitle.astro +59 -0
- package/src/components/icons/custom.tsx +87 -0
- package/src/components/icons/index.tsx +4454 -0
- package/src/components/share/common.tsx +77 -0
- package/src/components/share/content-bash.module.css +85 -0
- package/src/components/share/content-bash.tsx +67 -0
- package/src/components/share/content-code.module.css +26 -0
- package/src/components/share/content-code.tsx +32 -0
- package/src/components/share/content-diff.module.css +153 -0
- package/src/components/share/content-diff.tsx +231 -0
- package/src/components/share/content-error.module.css +64 -0
- package/src/components/share/content-error.tsx +24 -0
- package/src/components/share/content-markdown.module.css +154 -0
- package/src/components/share/content-markdown.tsx +75 -0
- package/src/components/share/content-text.module.css +63 -0
- package/src/components/share/content-text.tsx +37 -0
- package/src/components/share/copy-button.module.css +30 -0
- package/src/components/share/copy-button.tsx +28 -0
- package/src/components/share/part.module.css +428 -0
- package/src/components/share/part.tsx +780 -0
- package/src/components/share.module.css +832 -0
- package/src/content/docs/1-0.mdx +67 -0
- package/src/content/docs/acp.mdx +156 -0
- package/src/content/docs/agents.mdx +720 -0
- package/src/content/docs/cli.mdx +597 -0
- package/src/content/docs/commands.mdx +323 -0
- package/src/content/docs/config.mdx +683 -0
- package/src/content/docs/custom-tools.mdx +170 -0
- package/src/content/docs/ecosystem.mdx +76 -0
- package/src/content/docs/enterprise.mdx +170 -0
- package/src/content/docs/formatters.mdx +130 -0
- package/src/content/docs/github.mdx +321 -0
- package/src/content/docs/gitlab.mdx +195 -0
- package/src/content/docs/ide.mdx +48 -0
- package/src/content/docs/index.mdx +359 -0
- package/src/content/docs/keybinds.mdx +191 -0
- package/src/content/docs/lsp.mdx +188 -0
- package/src/content/docs/mcp-servers.mdx +511 -0
- package/src/content/docs/models.mdx +223 -0
- package/src/content/docs/modes.mdx +331 -0
- package/src/content/docs/network.mdx +57 -0
- package/src/content/docs/permissions.mdx +237 -0
- package/src/content/docs/plugins.mdx +362 -0
- package/src/content/docs/providers.mdx +1889 -0
- package/src/content/docs/rules.mdx +180 -0
- package/src/content/docs/sdk.mdx +391 -0
- package/src/content/docs/server.mdx +286 -0
- package/src/content/docs/share.mdx +128 -0
- package/src/content/docs/skills.mdx +220 -0
- package/src/content/docs/themes.mdx +369 -0
- package/src/content/docs/tools.mdx +345 -0
- package/src/content/docs/troubleshooting.mdx +300 -0
- package/src/content/docs/tui.mdx +390 -0
- package/src/content/docs/web.mdx +136 -0
- package/src/content/docs/windows-wsl.mdx +113 -0
- package/src/content/docs/zen.mdx +251 -0
- package/src/content.config.ts +7 -0
- package/src/pages/[...slug].md.ts +18 -0
- package/src/pages/s/[id].astro +113 -0
- package/src/styles/custom.css +405 -0
- package/src/types/lang-map.d.ts +27 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Permissions
|
|
3
|
+
description: Control which actions require approval to run.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
NeoCode uses the `permission` config to decide whether a given action should run automatically, prompt you, or be blocked.
|
|
7
|
+
|
|
8
|
+
As of `v1.1.1`, the legacy `tools` boolean config is deprecated and has been merged into `permission`. The old `tools` config is still supported for backwards compatibility.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Actions
|
|
13
|
+
|
|
14
|
+
Each permission rule resolves to one of:
|
|
15
|
+
|
|
16
|
+
- `"allow"` — run without approval
|
|
17
|
+
- `"ask"` — prompt for approval
|
|
18
|
+
- `"deny"` — block the action
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
You can set permissions globally (with `*`), and override specific tools.
|
|
25
|
+
|
|
26
|
+
```json title="neocode.json"
|
|
27
|
+
{
|
|
28
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
29
|
+
"permission": {
|
|
30
|
+
"*": "ask",
|
|
31
|
+
"bash": "allow",
|
|
32
|
+
"edit": "deny"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You can also set all permissions at once:
|
|
38
|
+
|
|
39
|
+
```json title="neocode.json"
|
|
40
|
+
{
|
|
41
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
42
|
+
"permission": "allow"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Granular Rules (Object Syntax)
|
|
49
|
+
|
|
50
|
+
For most permissions, you can use an object to apply different actions based on the tool input.
|
|
51
|
+
|
|
52
|
+
```json title="neocode.json"
|
|
53
|
+
{
|
|
54
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
55
|
+
"permission": {
|
|
56
|
+
"bash": {
|
|
57
|
+
"*": "ask",
|
|
58
|
+
"git *": "allow",
|
|
59
|
+
"npm *": "allow",
|
|
60
|
+
"rm *": "deny",
|
|
61
|
+
"grep *": "allow"
|
|
62
|
+
},
|
|
63
|
+
"edit": {
|
|
64
|
+
"*": "deny",
|
|
65
|
+
"packages/web/src/content/docs/*.mdx": "allow"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Rules are evaluated by pattern match, with the **last matching rule winning**. A common pattern is to put the catch-all `"*"` rule first, and more specific rules after it.
|
|
72
|
+
|
|
73
|
+
### Wildcards
|
|
74
|
+
|
|
75
|
+
Permission patterns use simple wildcard matching:
|
|
76
|
+
|
|
77
|
+
- `*` matches zero or more of any character
|
|
78
|
+
- `?` matches exactly one character
|
|
79
|
+
- All other characters match literally
|
|
80
|
+
|
|
81
|
+
### Home Directory Expansion
|
|
82
|
+
|
|
83
|
+
You can use `~` or `$HOME` at the start of a pattern to reference your home directory. This is particularly useful for [`external_directory`](#external-directories) rules.
|
|
84
|
+
|
|
85
|
+
- `~/projects/*` -> `/Users/username/projects/*`
|
|
86
|
+
- `$HOME/projects/*` -> `/Users/username/projects/*`
|
|
87
|
+
- `~` -> `/Users/username`
|
|
88
|
+
|
|
89
|
+
### External Directories
|
|
90
|
+
|
|
91
|
+
Use `external_directory` to allow tool calls that touch paths outside the working directory where NeoCode was started. This applies to any tool that takes a path as input (for example `read`, `edit`, `list`, `glob`, `grep`, and many `bash` commands).
|
|
92
|
+
|
|
93
|
+
Home expansion (like `~/...`) only affects how a pattern is written. It does not make an external path part of the current workspace, so paths outside the working directory must still be allowed via `external_directory`.
|
|
94
|
+
|
|
95
|
+
For example, this allows access to everything under `~/projects/personal/`:
|
|
96
|
+
|
|
97
|
+
```json title="neocode.json"
|
|
98
|
+
{
|
|
99
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
100
|
+
"permission": {
|
|
101
|
+
"external_directory": {
|
|
102
|
+
"~/projects/personal/**": "allow"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Any directory allowed here inherits the same defaults as the current workspace. Since [`read` defaults to `allow`](#defaults), reads are also allowed for entries under `external_directory` unless overridden. Add explicit rules when a tool should be restricted in these paths, such as blocking edits while keeping reads:
|
|
109
|
+
|
|
110
|
+
```json title="neocode.json"
|
|
111
|
+
{
|
|
112
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
113
|
+
"permission": {
|
|
114
|
+
"external_directory": {
|
|
115
|
+
"~/projects/personal/**": "allow"
|
|
116
|
+
},
|
|
117
|
+
"edit": {
|
|
118
|
+
"~/projects/personal/**": "deny"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Keep the list focused on trusted paths, and layer extra allow or deny rules as needed for other tools (for example `bash`).
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Available Permissions
|
|
129
|
+
|
|
130
|
+
NeoCode permissions are keyed by tool name, plus a couple of safety guards:
|
|
131
|
+
|
|
132
|
+
- `read` — reading a file (matches the file path)
|
|
133
|
+
- `edit` — all file modifications (covers `edit`, `write`, `patch`, `multiedit`)
|
|
134
|
+
- `glob` — file globbing (matches the glob pattern)
|
|
135
|
+
- `grep` — content search (matches the regex pattern)
|
|
136
|
+
- `list` — listing files in a directory (matches the directory path)
|
|
137
|
+
- `bash` — running shell commands (matches parsed commands like `git status --porcelain`)
|
|
138
|
+
- `task` — launching subagents (matches the subagent type)
|
|
139
|
+
- `skill` — loading a skill (matches the skill name)
|
|
140
|
+
- `lsp` — running LSP queries (currently non-granular)
|
|
141
|
+
- `todoread`, `todowrite` — reading/updating the todo list
|
|
142
|
+
- `webfetch` — fetching a URL (matches the URL)
|
|
143
|
+
- `websearch`, `codesearch` — web/code search (matches the query)
|
|
144
|
+
- `external_directory` — triggered when a tool touches paths outside the project working directory
|
|
145
|
+
- `doom_loop` — triggered when the same tool call repeats 3 times with identical input
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Defaults
|
|
150
|
+
|
|
151
|
+
If you don’t specify anything, NeoCode starts from permissive defaults:
|
|
152
|
+
|
|
153
|
+
- Most permissions default to `"allow"`.
|
|
154
|
+
- `doom_loop` and `external_directory` default to `"ask"`.
|
|
155
|
+
- `read` is `"allow"`, but `.env` files are denied by default:
|
|
156
|
+
|
|
157
|
+
```json title="neocode.json"
|
|
158
|
+
{
|
|
159
|
+
"permission": {
|
|
160
|
+
"read": {
|
|
161
|
+
"*": "allow",
|
|
162
|
+
"*.env": "deny",
|
|
163
|
+
"*.env.*": "deny",
|
|
164
|
+
"*.env.example": "allow"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## What “Ask” Does
|
|
173
|
+
|
|
174
|
+
When NeoCode prompts for approval, the UI offers three outcomes:
|
|
175
|
+
|
|
176
|
+
- `once` — approve just this request
|
|
177
|
+
- `always` — approve future requests matching the suggested patterns (for the rest of the current NeoCode session)
|
|
178
|
+
- `reject` — deny the request
|
|
179
|
+
|
|
180
|
+
The set of patterns that `always` would approve is provided by the tool (for example, bash approvals typically whitelist a safe command prefix like `git status*`).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Agents
|
|
185
|
+
|
|
186
|
+
You can override permissions per agent. Agent permissions are merged with the global config, and agent rules take precedence. [Learn more](/docs/agents#permissions) about agent permissions.
|
|
187
|
+
|
|
188
|
+
:::note
|
|
189
|
+
Refer to the [Granular Rules (Object Syntax)](#granular-rules-object-syntax) section above for more detailed pattern matching examples.
|
|
190
|
+
:::
|
|
191
|
+
|
|
192
|
+
```json title="neocode.json"
|
|
193
|
+
{
|
|
194
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
195
|
+
"permission": {
|
|
196
|
+
"bash": {
|
|
197
|
+
"*": "ask",
|
|
198
|
+
"git *": "allow",
|
|
199
|
+
"git commit *": "deny",
|
|
200
|
+
"git push *": "deny",
|
|
201
|
+
"grep *": "allow"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"agent": {
|
|
205
|
+
"build": {
|
|
206
|
+
"permission": {
|
|
207
|
+
"bash": {
|
|
208
|
+
"*": "ask",
|
|
209
|
+
"git *": "allow",
|
|
210
|
+
"git commit *": "ask",
|
|
211
|
+
"git push *": "deny",
|
|
212
|
+
"grep *": "allow"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
You can also configure agent permissions in Markdown:
|
|
221
|
+
|
|
222
|
+
```markdown title="~/.config/neocode/agents/review.md"
|
|
223
|
+
---
|
|
224
|
+
description: Code review without edits
|
|
225
|
+
mode: subagent
|
|
226
|
+
permission:
|
|
227
|
+
edit: deny
|
|
228
|
+
bash: ask
|
|
229
|
+
webfetch: deny
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
Only analyze code and suggest changes.
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
:::tip
|
|
236
|
+
Use pattern matching for commands with arguments. `"grep *"` allows `grep pattern file.txt`, while `"grep"` alone would block it. Commands like `git status` work for default behavior but require explicit permission (like `"git status *"`) when arguments are passed.
|
|
237
|
+
:::
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Plugins
|
|
3
|
+
description: Write your own plugins to extend NeoCode.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Plugins allow you to extend NeoCode by hooking into various events and customizing behavior. You can create plugins to add new features, integrate with external services, or modify NeoCode's default behavior.
|
|
7
|
+
|
|
8
|
+
For examples, check out the [plugins](/docs/ecosystem#plugins) created by the community.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Use a plugin
|
|
13
|
+
|
|
14
|
+
There are two ways to load plugins.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
### From local files
|
|
19
|
+
|
|
20
|
+
Place JavaScript or TypeScript files in the plugin directory.
|
|
21
|
+
|
|
22
|
+
- `.neocode/plugins/` - Project-level plugins
|
|
23
|
+
- `~/.config/neocode/plugins/` - Global plugins
|
|
24
|
+
|
|
25
|
+
Files in these directories are automatically loaded at startup.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### From npm
|
|
30
|
+
|
|
31
|
+
Specify npm packages in your config file.
|
|
32
|
+
|
|
33
|
+
```json title="neocode.json"
|
|
34
|
+
{
|
|
35
|
+
"$schema": "https://neo.khulnasoft.com/config.json",
|
|
36
|
+
"plugin": ["neocode-helicone-session", "neocode-wakatime", "@my-org/custom-plugin"]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Both regular and scoped npm packages are supported.
|
|
41
|
+
|
|
42
|
+
Browse available plugins in the [ecosystem](/docs/ecosystem#plugins).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### How plugins are installed
|
|
47
|
+
|
|
48
|
+
**npm plugins** are installed automatically using Bun at startup. Packages and their dependencies are cached in `~/.cache/neocode/node_modules/`.
|
|
49
|
+
|
|
50
|
+
**Local plugins** are loaded directly from the plugin directory. To use external packages, you must create a `package.json` within your config directory (see [Dependencies](#dependencies)), or publish the plugin to npm and [add it to your config](/docs/config#plugins).
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Load order
|
|
55
|
+
|
|
56
|
+
Plugins are loaded from all sources and all hooks run in sequence. The load order is:
|
|
57
|
+
|
|
58
|
+
1. Global config (`~/.config/neocode/neocode.json`)
|
|
59
|
+
2. Project config (`neocode.json`)
|
|
60
|
+
3. Global plugin directory (`~/.config/neocode/plugins/`)
|
|
61
|
+
4. Project plugin directory (`.neocode/plugins/`)
|
|
62
|
+
|
|
63
|
+
Duplicate npm packages with the same name and version are loaded once. However, a local plugin and an npm plugin with similar names are both loaded separately.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Create a plugin
|
|
68
|
+
|
|
69
|
+
A plugin is a **JavaScript/TypeScript module** that exports one or more plugin
|
|
70
|
+
functions. Each function receives a context object and returns a hooks object.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### Dependencies
|
|
75
|
+
|
|
76
|
+
Local plugins and custom tools can use external npm packages. Add a `package.json` to your config directory with the dependencies you need.
|
|
77
|
+
|
|
78
|
+
```json title=".neocode/package.json"
|
|
79
|
+
{
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"shescape": "^2.1.0"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
NeoCode runs `bun install` at startup to install these. Your plugins and tools can then import them.
|
|
87
|
+
|
|
88
|
+
```ts title=".neocode/plugins/my-plugin.ts"
|
|
89
|
+
import { escape } from "shescape"
|
|
90
|
+
|
|
91
|
+
export const MyPlugin = async (ctx) => {
|
|
92
|
+
return {
|
|
93
|
+
"tool.execute.before": async (input, output) => {
|
|
94
|
+
if (input.tool === "bash") {
|
|
95
|
+
output.args.command = escape(output.args.command)
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### Basic structure
|
|
105
|
+
|
|
106
|
+
```js title=".neocode/plugins/example.js"
|
|
107
|
+
export const MyPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
108
|
+
console.log("Plugin initialized!")
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
// Hook implementations go here
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The plugin function receives:
|
|
117
|
+
|
|
118
|
+
- `project`: The current project information.
|
|
119
|
+
- `directory`: The current working directory.
|
|
120
|
+
- `worktree`: The git worktree path.
|
|
121
|
+
- `client`: An neocode SDK client for interacting with the AI.
|
|
122
|
+
- `$`: Bun's [shell API](https://bun.com/docs/runtime/shell) for executing commands.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### TypeScript support
|
|
127
|
+
|
|
128
|
+
For TypeScript plugins, you can import types from the plugin package:
|
|
129
|
+
|
|
130
|
+
```ts title="my-plugin.ts" {1}
|
|
131
|
+
import type { Plugin } from "@neocode-ai/plugin"
|
|
132
|
+
|
|
133
|
+
export const MyPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
|
|
134
|
+
return {
|
|
135
|
+
// Type-safe hook implementations
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### Events
|
|
143
|
+
|
|
144
|
+
Plugins can subscribe to events as seen below in the Examples section. Here is a list of the different events available.
|
|
145
|
+
|
|
146
|
+
#### Command Events
|
|
147
|
+
|
|
148
|
+
- `command.executed`
|
|
149
|
+
|
|
150
|
+
#### File Events
|
|
151
|
+
|
|
152
|
+
- `file.edited`
|
|
153
|
+
- `file.watcher.updated`
|
|
154
|
+
|
|
155
|
+
#### Installation Events
|
|
156
|
+
|
|
157
|
+
- `installation.updated`
|
|
158
|
+
|
|
159
|
+
#### LSP Events
|
|
160
|
+
|
|
161
|
+
- `lsp.client.diagnostics`
|
|
162
|
+
- `lsp.updated`
|
|
163
|
+
|
|
164
|
+
#### Message Events
|
|
165
|
+
|
|
166
|
+
- `message.part.removed`
|
|
167
|
+
- `message.part.updated`
|
|
168
|
+
- `message.removed`
|
|
169
|
+
- `message.updated`
|
|
170
|
+
|
|
171
|
+
#### Permission Events
|
|
172
|
+
|
|
173
|
+
- `permission.asked`
|
|
174
|
+
- `permission.replied`
|
|
175
|
+
|
|
176
|
+
#### Server Events
|
|
177
|
+
|
|
178
|
+
- `server.connected`
|
|
179
|
+
|
|
180
|
+
#### Session Events
|
|
181
|
+
|
|
182
|
+
- `session.created`
|
|
183
|
+
- `session.compacted`
|
|
184
|
+
- `session.deleted`
|
|
185
|
+
- `session.diff`
|
|
186
|
+
- `session.error`
|
|
187
|
+
- `session.idle`
|
|
188
|
+
- `session.status`
|
|
189
|
+
- `session.updated`
|
|
190
|
+
|
|
191
|
+
#### Todo Events
|
|
192
|
+
|
|
193
|
+
- `todo.updated`
|
|
194
|
+
|
|
195
|
+
#### Tool Events
|
|
196
|
+
|
|
197
|
+
- `tool.execute.after`
|
|
198
|
+
- `tool.execute.before`
|
|
199
|
+
|
|
200
|
+
#### TUI Events
|
|
201
|
+
|
|
202
|
+
- `tui.prompt.append`
|
|
203
|
+
- `tui.command.execute`
|
|
204
|
+
- `tui.toast.show`
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Examples
|
|
209
|
+
|
|
210
|
+
Here are some examples of plugins you can use to extend neocode.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
### Send notifications
|
|
215
|
+
|
|
216
|
+
Send notifications when certain events occur:
|
|
217
|
+
|
|
218
|
+
```js title=".neocode/plugins/notification.js"
|
|
219
|
+
export const NotificationPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
220
|
+
return {
|
|
221
|
+
event: async ({ event }) => {
|
|
222
|
+
// Send notification on session completion
|
|
223
|
+
if (event.type === "session.idle") {
|
|
224
|
+
await $`osascript -e 'display notification "Session completed!" with title "neocode"'`
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
We are using `osascript` to run AppleScript on macOS. Here we are using it to send notifications.
|
|
232
|
+
|
|
233
|
+
:::note
|
|
234
|
+
If you’re using the NeoCode desktop app, it can send system notifications automatically when a response is ready or when a session errors.
|
|
235
|
+
:::
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### .env protection
|
|
240
|
+
|
|
241
|
+
Prevent neocode from reading `.env` files:
|
|
242
|
+
|
|
243
|
+
```javascript title=".neocode/plugins/env-protection.js"
|
|
244
|
+
export const EnvProtection = async ({ project, client, $, directory, worktree }) => {
|
|
245
|
+
return {
|
|
246
|
+
"tool.execute.before": async (input, output) => {
|
|
247
|
+
if (input.tool === "read" && output.args.filePath.includes(".env")) {
|
|
248
|
+
throw new Error("Do not read .env files")
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### Custom tools
|
|
258
|
+
|
|
259
|
+
Plugins can also add custom tools to neocode:
|
|
260
|
+
|
|
261
|
+
```ts title=".neocode/plugins/custom-tools.ts"
|
|
262
|
+
import { type Plugin, tool } from "@neocode-ai/plugin"
|
|
263
|
+
|
|
264
|
+
export const CustomToolsPlugin: Plugin = async (ctx) => {
|
|
265
|
+
return {
|
|
266
|
+
tool: {
|
|
267
|
+
mytool: tool({
|
|
268
|
+
description: "This is a custom tool",
|
|
269
|
+
args: {
|
|
270
|
+
foo: tool.schema.string(),
|
|
271
|
+
},
|
|
272
|
+
async execute(args, context) {
|
|
273
|
+
const { directory, worktree } = context
|
|
274
|
+
return `Hello ${args.foo} from ${directory} (worktree: ${worktree})`
|
|
275
|
+
},
|
|
276
|
+
}),
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The `tool` helper creates a custom tool that neocode can call. It takes a Zod schema function and returns a tool definition with:
|
|
283
|
+
|
|
284
|
+
- `description`: What the tool does
|
|
285
|
+
- `args`: Zod schema for the tool's arguments
|
|
286
|
+
- `execute`: Function that runs when the tool is called
|
|
287
|
+
|
|
288
|
+
Your custom tools will be available to neocode alongside built-in tools.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
### Logging
|
|
293
|
+
|
|
294
|
+
Use `client.app.log()` instead of `console.log` for structured logging:
|
|
295
|
+
|
|
296
|
+
```ts title=".neocode/plugins/my-plugin.ts"
|
|
297
|
+
export const MyPlugin = async ({ client }) => {
|
|
298
|
+
await client.app.log({
|
|
299
|
+
service: "my-plugin",
|
|
300
|
+
level: "info",
|
|
301
|
+
message: "Plugin initialized",
|
|
302
|
+
extra: { foo: "bar" },
|
|
303
|
+
})
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Levels: `debug`, `info`, `warn`, `error`. See [SDK documentation](https://neo.khulnasoft.com/docs/sdk) for details.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
### Compaction hooks
|
|
312
|
+
|
|
313
|
+
Customize the context included when a session is compacted:
|
|
314
|
+
|
|
315
|
+
```ts title=".neocode/plugins/compaction.ts"
|
|
316
|
+
import type { Plugin } from "@neocode-ai/plugin"
|
|
317
|
+
|
|
318
|
+
export const CompactionPlugin: Plugin = async (ctx) => {
|
|
319
|
+
return {
|
|
320
|
+
"experimental.session.compacting": async (input, output) => {
|
|
321
|
+
// Inject additional context into the compaction prompt
|
|
322
|
+
output.context.push(`
|
|
323
|
+
## Custom Context
|
|
324
|
+
|
|
325
|
+
Include any state that should persist across compaction:
|
|
326
|
+
- Current task status
|
|
327
|
+
- Important decisions made
|
|
328
|
+
- Files being actively worked on
|
|
329
|
+
`)
|
|
330
|
+
},
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
The `experimental.session.compacting` hook fires before the LLM generates a continuation summary. Use it to inject domain-specific context that the default compaction prompt would miss.
|
|
336
|
+
|
|
337
|
+
You can also replace the compaction prompt entirely by setting `output.prompt`:
|
|
338
|
+
|
|
339
|
+
```ts title=".neocode/plugins/custom-compaction.ts"
|
|
340
|
+
import type { Plugin } from "@neocode-ai/plugin"
|
|
341
|
+
|
|
342
|
+
export const CustomCompactionPlugin: Plugin = async (ctx) => {
|
|
343
|
+
return {
|
|
344
|
+
"experimental.session.compacting": async (input, output) => {
|
|
345
|
+
// Replace the entire compaction prompt
|
|
346
|
+
output.prompt = `
|
|
347
|
+
You are generating a continuation prompt for a multi-agent swarm session.
|
|
348
|
+
|
|
349
|
+
Summarize:
|
|
350
|
+
1. The current task and its status
|
|
351
|
+
2. Which files are being modified and by whom
|
|
352
|
+
3. Any blockers or dependencies between agents
|
|
353
|
+
4. The next steps to complete the work
|
|
354
|
+
|
|
355
|
+
Format as a structured prompt that a new agent can use to resume work.
|
|
356
|
+
`
|
|
357
|
+
},
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
When `output.prompt` is set, it completely replaces the default compaction prompt. The `output.context` array is ignored in this case.
|