@knightcodeai/cli-linux-x64 0.9.1 → 0.9.3

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.
Files changed (45) hide show
  1. package/bin/CHANGELOG.md +60 -0
  2. package/bin/README.md +52 -19
  3. package/bin/docs/cli-integration.md +106 -0
  4. package/bin/docs/cli.md +270 -0
  5. package/bin/docs/compaction.md +56 -37
  6. package/bin/docs/configuration.md +46 -0
  7. package/bin/docs/containerization.md +86 -54
  8. package/bin/docs/custom-provider.md +132 -785
  9. package/bin/docs/docs.json +143 -103
  10. package/bin/docs/environment-variables.md +5 -4
  11. package/bin/docs/extensions.md +134 -2956
  12. package/bin/docs/how-knightcode-works.md +49 -0
  13. package/bin/docs/index.md +24 -69
  14. package/bin/docs/json.md +193 -65
  15. package/bin/docs/keybindings.md +56 -101
  16. package/bin/docs/llama-cpp.md +3 -3
  17. package/bin/docs/message-types.md +261 -0
  18. package/bin/docs/models.md +64 -547
  19. package/bin/docs/packages.md +66 -167
  20. package/bin/docs/prompt-templates.md +31 -68
  21. package/bin/docs/providers.md +103 -241
  22. package/bin/docs/quickstart.md +61 -106
  23. package/bin/docs/rpc-commands.md +854 -0
  24. package/bin/docs/rpc-extension-ui.md +200 -0
  25. package/bin/docs/rpc.md +129 -1556
  26. package/bin/docs/sdk.md +76 -1160
  27. package/bin/docs/security.md +70 -32
  28. package/bin/docs/session-format.md +25 -216
  29. package/bin/docs/sessions.md +38 -143
  30. package/bin/docs/settings.md +111 -389
  31. package/bin/docs/shell-aliases.md +85 -5
  32. package/bin/docs/skills.md +51 -189
  33. package/bin/docs/slash-commands.md +63 -0
  34. package/bin/docs/terminal-setup.md +107 -79
  35. package/bin/docs/termux.md +74 -83
  36. package/bin/docs/themes.md +68 -280
  37. package/bin/docs/tmux.md +31 -39
  38. package/bin/docs/tui.md +69 -923
  39. package/bin/docs/usage.md +79 -286
  40. package/bin/docs/windows.md +43 -17
  41. package/bin/export-html/template.js +6 -1
  42. package/bin/knightcode +2 -2
  43. package/bin/package.json +6 -6
  44. package/package.json +1 -1
  45. package/bin/docs/development.md +0 -71
@@ -1,228 +1,127 @@
1
- > knightcode can help you create knightcode packages. Ask it to bundle your extensions, skills, prompt templates, or themes.
2
-
3
1
  # KnightCode Packages
4
2
 
5
- KnightCode packages bundle extensions, skills, prompt templates, and themes so you can share them through npm or git. A package can declare resources in `package.json` under the `knightcode` key, or use conventional directories.
6
-
7
- ## Table of Contents
3
+ KnightCode packages install and distribute extensions, skills, prompt templates, and themes as one unit. Use a package when a customization should be shared through npm or git, or when several resources belong together.
8
4
 
9
- - [Install and Manage](#install-and-manage)
10
- - [Package Sources](#package-sources)
11
- - [Creating a KnightCode Package](#creating-a-knightcode-package)
12
- - [Package Structure](#package-structure)
13
- - [Dependencies](#dependencies)
14
- - [Package Filtering](#package-filtering)
15
- - [Enable and Disable Resources](#enable-and-disable-resources)
16
- - [Scope and Deduplication](#scope-and-deduplication)
5
+ A package is an ordinary directory or npm package. It can expose conventional resource directories, declare explicit paths under the `knightcode` key in `package.json`, and carry its own runtime dependencies.
17
6
 
18
- ## Install and Manage
7
+ ## Install and manage packages
19
8
 
20
- > **Security:** KnightCode packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action including running executables. Review source code before installing third-party packages.
9
+ Install from npm, git, or a local path:
21
10
 
22
11
  ```bash
23
- knightcode install npm:@foo/bar@1.0.0
24
- knightcode install git:github.com/user/repo@v1
25
- knightcode install https://github.com/user/repo # raw URLs work too
26
- knightcode install /absolute/path/to/package
27
- knightcode install ./relative/path/to/package
28
-
29
- knightcode remove npm:@foo/bar
30
- knightcode list # show installed packages from settings
31
- knightcode update # update knightcode only
32
- knightcode update --all # update knightcode, update packages, and reconcile pinned git refs
33
- knightcode update --extensions # update packages and reconcile pinned git refs only
34
- knightcode update --models # refresh model catalogs only
35
- knightcode update --self # update knightcode only
36
- knightcode update --self --force # reinstall knightcode even if current
37
- knightcode update npm:@foo/bar # update one package
38
- knightcode update --extension npm:@foo/bar
39
- ```
40
-
41
- These commands manage knightcode packages and `knightcode update` can update the knightcode CLI installation. For experimental installer-managed installations, `knightcode update` installs the exact checked version into a staged, lockfile-backed release and activates it only after verification, leaving the current release intact if the update fails. Managed installations do not support `--force`; rerun the installer to repair one. To uninstall knightcode itself, see [Quickstart](quickstart.md#uninstall).
42
-
43
- By default, `install` and `remove` write to user settings (`~/.knightcode/agent/settings.json`). Use `-l` to write to project settings (`.knightcode/settings.json`) instead. Project settings can be shared with your team, and knightcode installs any missing packages automatically on startup after the project is trusted.
44
-
45
- To try a package without installing it, use `--extension` or `-e`. This installs to a temporary directory for the current run only:
46
-
47
- ```bash
48
- knightcode -e npm:@foo/bar
49
- knightcode -e git:github.com/user/repo
50
- ```
51
-
52
- ## Package Sources
53
-
54
- KnightCode accepts three source types in settings and `knightcode install`.
55
-
56
- ### npm
57
-
58
- ```
59
- npm:@scope/pkg@1.2.3
60
- npm:pkg
12
+ knightcode install npm:@example/knightcode-tools@1.0.0
13
+ knightcode install git:github.com/example/knightcode-tools@v1
14
+ knightcode install ./local-package
61
15
  ```
62
16
 
63
- - Versioned specs are pinned and skipped by package updates (`knightcode update --extensions`, `knightcode update --all`).
64
- - User installs go under `~/.knightcode/agent/npm/`.
65
- - Project installs go under `.knightcode/npm/`.
66
- - Set `npmCommand` in `settings.json` to pin npm package lookup and install operations to a specific wrapper command such as `mise` or `asdf`.
17
+ `knightcode list` shows configured packages. Use `knightcode remove <source>` to remove one and `knightcode update --extensions` to reconcile package installations. See [Command Line](cli.md#package-commands) for every package command and option.
67
18
 
68
- Example:
19
+ Personal installs are written to `~/.knightcode/agent/settings.json`. Add `--local` or `-l` to write the package declaration to `.knightcode/settings.json`. KnightCode reads declarations from that file only after project trust is granted.
69
20
 
70
- ```json
71
- {
72
- "npmCommand": ["mise", "exec", "node@20", "--", "npm"]
73
- }
74
- ```
21
+ Project packages are installed and loaded only after project trust is resolved. Packages can execute extension code and can include skills that instruct the model to run programs. Review third-party package source before installing it. Review project package declarations before granting project trust.
75
22
 
76
- ### git
23
+ Use `--extension` or `-e` to try a package for one invocation without adding it to settings:
77
24
 
78
- ```
79
- git:github.com/user/repo@v1
80
- git:git@github.com:user/repo@v1
81
- https://github.com/user/repo@v1
82
- ssh://git@github.com/user/repo@v1
83
- ```
84
-
85
- - Without `git:` prefix, only protocol URLs are accepted (`https://`, `http://`, `ssh://`, `git://`).
86
- - With `git:` prefix, shorthand formats are accepted, including `github.com/user/repo` and `git@github.com:user/repo`.
87
- - HTTPS and SSH URLs are both supported.
88
- - SSH URLs use your configured SSH keys automatically (respects `~/.ssh/config`).
89
- - For non-interactive runs (for example CI), you can set `GIT_TERMINAL_PROMPT=0` to disable credential prompts and set `GIT_SSH_COMMAND` (for example `ssh -o BatchMode=yes -o ConnectTimeout=5`) to fail fast.
90
- - Refs are pinned tags or commits. `knightcode update --extensions` and `knightcode update --all` do not move them to newer refs, but they do reconcile an existing clone to the configured ref.
91
- - Use `knightcode install git:host/user/repo@new-ref` to update settings and move an existing package to a new pinned ref.
92
- - Cloned to `~/.knightcode/agent/git/<host>/<path>` (global) or `.knightcode/git/<host>/<path>` (project).
93
- - When reconciliation changes the checkout, knightcode resets and cleans the clone, then runs `npm install` if `package.json` exists.
94
-
95
- **SSH examples:**
96
25
  ```bash
97
- # git@host:path shorthand (requires git: prefix)
98
- knightcode install git:git@github.com:user/repo
99
-
100
- # ssh:// protocol format
101
- knightcode install ssh://git@github.com/user/repo
102
-
103
- # With version ref
104
- knightcode install git:git@github.com:user/repo@v1.0.0
26
+ knightcode -e npm:@example/knightcode-tools
105
27
  ```
106
28
 
107
- ### Local Paths
29
+ ## Choose a source
108
30
 
109
- ```
110
- /absolute/path/to/package
111
- ./relative/path/to/package
112
- ```
31
+ | Source | Example | Behavior |
32
+ |---|---|---|
33
+ | npm | `npm:@example/knightcode-tools@1.0.0` | Installed under the KnightCode npm directory |
34
+ | git | `git:github.com/example/knightcode-tools@v1` | Cloned and reconciled to the selected ref |
35
+ | URL | `https://github.com/example/knightcode-tools` | Treated as a git source |
36
+ | Local | `./knightcode-tools` | Loaded from the resolved path without copying |
113
37
 
114
- Local paths point to files or directories on disk and are added to settings without copying. Relative paths are resolved against the settings file they appear in. If the path is a file, it loads as a single extension. If it is a directory, knightcode loads resources using package rules.
38
+ Versioned npm specifications are pinned. Git tags and commits are also pinned; package updates reconcile the checkout but do not move a configured ref.
115
39
 
116
- ## Creating a KnightCode Package
40
+ Relative local paths resolve from the settings file that contains them. A file path loads one extension. A directory follows normal package discovery rules.
117
41
 
118
- Add a `knightcode` manifest to `package.json` or use conventional directories. Include the `knightcode-package` keyword for discoverability.
42
+ ## Create a package
119
43
 
120
- ```json
121
- {
122
- "name": "my-package",
123
- "keywords": ["knightcode-package"],
124
- "knightcode": {
125
- "extensions": ["./extensions"],
126
- "skills": ["./skills"],
127
- "prompts": ["./prompts"],
128
- "themes": ["./themes"]
129
- }
130
- }
131
- ```
44
+ The simplest package uses conventional directories:
132
45
 
133
- Paths are relative to the package root. Arrays support glob patterns and `!exclusions`. Positive manifest globs discover visible paths in lexical order. List dot-prefixed paths directly. If a glob would need to continue through a symlink, list the symlinked resource root directly.
46
+ ```text
47
+ my-knightcode-package/
48
+ ├── package.json
49
+ ├── extensions/
50
+ ├── skills/
51
+ ├── prompts/
52
+ └── themes/
53
+ ```
134
54
 
135
- ### Gallery Metadata
55
+ Without a `knightcode` manifest, KnightCode discovers TypeScript and JavaScript extensions, skill directories, Markdown prompts, and JSON themes from those directories.
136
56
 
137
- The [package gallery](https://knightcode.dev/packages) displays packages tagged with `knightcode-package`. Add `video` or `image` fields to show a preview:
57
+ Use an explicit manifest when resources live elsewhere or need filtering:
138
58
 
139
59
  ```json
140
60
  {
141
- "name": "my-package",
61
+ "name": "my-knightcode-package",
142
62
  "keywords": ["knightcode-package"],
143
63
  "knightcode": {
144
- "extensions": ["./extensions"],
145
- "video": "https://example.com/demo.mp4",
146
- "image": "https://example.com/screenshot.png"
64
+ "extensions": ["./src/extension.ts"],
65
+ "skills": ["./resources/skills"],
66
+ "prompts": ["./resources/prompts/*.md"],
67
+ "themes": ["./resources/themes/*.json"]
147
68
  }
148
69
  }
149
70
  ```
150
71
 
151
- - **video**: MP4 only. On desktop, autoplays on hover. Clicking opens a fullscreen player.
152
- - **image**: PNG, JPEG, GIF, or WebP. Displayed as a static preview.
72
+ Paths are relative to the package root. Arrays accept glob patterns and exclusions. List dot-prefixed or symlinked resource roots directly when traversal through a glob would not discover them.
153
73
 
154
- If both are set, video takes precedence.
74
+ The `knightcode-package` keyword makes an npm package eligible for discovery in the [KnightCode package gallery](https://knightcode.dev/packages). Optional `knightcode.image` and `knightcode.video` fields add gallery previews.
155
75
 
156
- ## Package Structure
76
+ ## Declare dependencies
157
77
 
158
- ### Convention Directories
78
+ Put runtime packages imported by extensions in `dependencies`. KnightCode installs package dependencies when it installs an npm or git source.
159
79
 
160
- If no `knightcode` manifest is present, knightcode auto-discovers resources from these directories:
80
+ KnightCode supplies these packages to extensions and skills:
161
81
 
162
- - `extensions/` loads `.ts` and `.js` files
163
- - `skills/` recursively finds `SKILL.md` folders and loads top-level `.md` files as skills
164
- - `prompts/` loads `.md` files
165
- - `themes/` loads `.json` files
82
+ - `@knightcode/ai`
83
+ - `@knightcode/agent`
84
+ - `@knightcodeai/cli`
85
+ - `@knightcode/tui`
86
+ - `typebox`
166
87
 
167
- ## Dependencies
88
+ Declare imported KnightCode packages in `peerDependencies` with a `"*"` range and do not bundle them. Other KnightCode packages used as dependencies must be included in the published tarball and referenced through their `node_modules` resource paths.
168
89
 
169
- Third party runtime dependencies belong in `dependencies` in `package.json`. Dependencies that do not register extensions, skills, prompt templates, or themes also belong in `dependencies`. When knightcode installs a package from npm or git, it runs `npm install`, so those dependencies are installed automatically.
90
+ Installed packages load with separate module roots. Do not rely on two packages sharing one dependency instance or one package resolving another package’s undeclared dependency.
170
91
 
171
- KnightCode bundles core packages for extensions and skills. If you import any of these, list them in `peerDependencies` with a `"*"` range and do not bundle them: `@knightcode/ai`, `@knightcode/agent`, `@knightcodeai/cli`, `@knightcode/tui`, `typebox`.
92
+ ## Select package resources
172
93
 
173
- Other knightcode packages must be bundled in your tarball. Add them to `dependencies` and `bundledDependencies`, then reference their resources through `node_modules/` paths. KnightCode loads packages with separate module roots, so separate installs do not collide or share modules.
174
-
175
- Example:
176
-
177
- ```json
178
- {
179
- "dependencies": {
180
- "shitty-extensions": "^1.0.1"
181
- },
182
- "bundledDependencies": ["shitty-extensions"],
183
- "knightcode": {
184
- "extensions": ["extensions", "node_modules/shitty-extensions/extensions"],
185
- "skills": ["skills", "node_modules/shitty-extensions/skills"]
186
- }
187
- }
188
- ```
189
-
190
- ## Package Filtering
191
-
192
- Filter what a package loads using the object form in settings:
94
+ The object form in settings narrows which resources load from a package:
193
95
 
194
96
  ```json
195
97
  {
196
98
  "packages": [
197
- "npm:simple-pkg",
198
99
  {
199
- "source": "npm:my-package",
100
+ "source": "npm:@example/knightcode-tools",
200
101
  "extensions": ["extensions/*.ts", "!extensions/legacy.ts"],
201
102
  "skills": [],
202
- "prompts": ["prompts/review.md"],
203
- "themes": ["+themes/legacy.json"]
103
+ "prompts": ["prompts/review.md"]
204
104
  }
205
105
  ]
206
106
  }
207
107
  ```
208
108
 
209
- `+path` and `-path` are exact paths relative to the package root.
109
+ For each resource type:
210
110
 
211
- - Omit a key to load all of that type.
111
+ - Omit the property to load everything allowed by the package.
212
112
  - Use `[]` to load none of that type.
213
- - `!pattern` excludes matches.
214
- - `+path` force-includes an exact path.
215
- - `-path` force-excludes an exact path.
216
- - Filters layer on top of the manifest. They narrow down what is already allowed.
113
+ - Use `!pattern` to exclude glob matches.
114
+ - Use `+path` to include one exact allowed path.
115
+ - Use `-path` to exclude one exact path.
116
+
117
+ Filters narrow the package manifest. They do not expose resources that the package itself did not declare.
217
118
 
218
- ## Enable and Disable Resources
119
+ Run `knightcode config` to enable or disable discovered resources. It starts with personal configuration; press Tab to switch scope, or run `knightcode config --local` to start with project overrides.
219
120
 
220
- Use `knightcode config` to enable or disable extensions, skills, prompt templates, and themes from installed packages and local directories. `knightcode config` starts in global settings (`~/.knightcode/agent/settings.json`); press Tab to switch between global and project-local modes. Use `knightcode config -l` to start in project overrides (`.knightcode/settings.json`) with inherited global resources dimmed.
121
+ ## Understand scope and identity
221
122
 
222
- ## Scope and Deduplication
123
+ The same package can appear in personal and project settings. A project entry normally replaces the personal entry. With `autoload: false`, the project entry instead acts as a filtering delta over the personal package.
223
124
 
224
- Packages can appear in both global and project settings. If the same package appears in both, the project entry wins unless the project entry has `autoload: false`, in which case it is applied as a delta over the global entry. Identity is determined by:
125
+ KnightCode identifies npm packages by package name, git packages by repository URL without the ref, and local packages by resolved absolute path. This prevents the same package from loading twice through equivalent declarations.
225
126
 
226
- - npm: package name
227
- - git: repository URL without ref
228
- - local: resolved absolute path
127
+ Use [Extensions](extensions.md), [Skills](skills.md), [Prompt Templates](prompt-templates.md), and [Themes](themes.md) to design each resource before packaging it.
@@ -1,96 +1,59 @@
1
- > knightcode can create prompt templates. Ask it to build one for your workflow.
2
-
3
1
  # Prompt Templates
4
2
 
5
- Prompt templates are Markdown snippets that expand into full prompts. Type `/name` in the editor to invoke a template, where `name` is the filename without `.md`.
6
-
7
- ## Locations
8
-
9
- KnightCode loads prompt templates from:
3
+ Prompt templates turn Markdown files into reusable `/` commands. Use one when you want to reuse the same prompt without adding executable behavior or a larger set of supporting instructions.
10
4
 
11
- - Global: `~/.knightcode/agent/prompts/*.md`
12
- - Project: `.knightcode/prompts/*.md` (only after the project is trusted)
13
- - Packages: `prompts/` directories or `knightcode.prompts` entries in `package.json`
14
- - Settings: `prompts` array with files or directories
15
- - CLI: `--prompt-template <path>` (repeatable)
5
+ A template can accept arguments and appear in command completion. KnightCode can load templates from personal configuration, project configuration, an explicit path, or a KnightCode package. Project configuration loads only after project trust is granted.
16
6
 
17
- Disable discovery with `--no-prompt-templates`.
7
+ ## Create a template
18
8
 
19
- ## Format
9
+ Create `~/.knightcode/agent/prompts/review.md`:
20
10
 
21
11
  ```markdown
22
12
  ---
23
13
  description: Review staged git changes
14
+ argument-hint: "[focus]"
24
15
  ---
25
- Review the staged changes (`git diff --cached`). Focus on:
26
- - Bugs and logic errors
27
- - Security issues
28
- - Error handling gaps
16
+ Review the staged changes. Focus on ${1:-correctness, security, and error handling}.
29
17
  ```
30
18
 
31
- - The filename becomes the command name. `review.md` becomes `/review`.
32
- - `description` is optional. If missing, the first non-empty line is used.
33
- - `argument-hint` is optional. When set, the hint is displayed before the description in the autocomplete dropdown.
19
+ The filename becomes the command name, so this template is available as `/review`. The `description` appears in command completion. If it is omitted, KnightCode uses the first non-empty line.
34
20
 
35
- ### Argument Hints
21
+ `argument-hint` is optional. Use `<angle brackets>` for required arguments and `[square brackets]` for optional arguments.
36
22
 
37
- Use `argument-hint` in frontmatter to show expected arguments in autocomplete. Use `<angle brackets>` for required arguments and `[square brackets]` for optional ones:
38
-
39
- ```markdown
40
- ---
41
- description: Review PRs from URLs with structured issue and code analysis
42
- argument-hint: "<PR-URL>"
43
- ---
44
- ```
23
+ Run `/reload` after adding or changing a template in an active session.
45
24
 
46
- This renders in the autocomplete dropdown as:
25
+ <a id="invoke-a-template"></a>
47
26
 
48
- ```
49
- → pr <PR-URL> — Review PRs from URLs with structured issue and code analysis
50
- is <issue> — Analyze GitHub issues (bugs or feature requests)
51
- wr [instructions] — Finish the current task end-to-end
52
- cl — Audit changelog entries before release
53
- ```
27
+ ## Use a template
54
28
 
55
- ## Usage
29
+ Type the template command in the editor:
56
30
 
57
- Type `/` followed by the template name in the editor. Autocomplete shows available templates with descriptions.
58
-
59
- ```
60
- /review # Expands review.md
61
- /component Button # Expands with argument
62
- /component Button "click handler" # Multiple arguments
31
+ ```text
32
+ /review
33
+ /review concurrency
63
34
  ```
64
35
 
65
- ## Arguments
36
+ KnightCode expands the template before the resulting text enters the agent. Extensions receive the raw input first through the `input` event unless an extension command with the same name handles it.
66
37
 
67
- Templates support positional arguments, defaults, and simple slicing:
38
+ Templates support these substitutions:
68
39
 
69
- - `$1`, `$2`, ... positional args
70
- - `$@` or `$ARGUMENTS` for all args joined
71
- - `${1:-default}` uses arg 1 when present/non-empty, otherwise `default`
72
- - `${@:-default}` or `${ARGUMENTS:-default}` uses all arguments when present/non-empty, otherwise `default`
73
- - `${@:N}` for args from the Nth position (1-indexed)
74
- - `${@:N:L}` for `L` args starting at N
40
+ | Syntax | Result |
41
+ |---|---|
42
+ | `$1`, `$2`, … | One positional argument |
43
+ | `$@` or `$ARGUMENTS` | All arguments joined with spaces |
44
+ | `${1:-default}` | First argument, or a default value |
45
+ | `${@:-default}` | All arguments, or a default value |
46
+ | `${@:N}` | Arguments starting at position `N` |
47
+ | `${@:N:L}` | `L` arguments starting at position `N` |
75
48
 
76
- Example:
49
+ Arguments follow shell-like quoting, so `/review "API compatibility"` supplies one argument containing a space.
77
50
 
78
- ```markdown
79
- ---
80
- description: Create a component
81
- ---
82
- Create a React component named $1 with features: $@
83
- ```
84
-
85
- Default values are useful for optional arguments:
51
+ <a id="choose-where-it-loads"></a>
86
52
 
87
- ```markdown
88
- Summarize the current state in ${1:-7} bullet points.
89
- ```
53
+ ## Add it to KnightCode
90
54
 
91
- Usage: `/component Button "onClick handler" "disabled support"`
55
+ Place the template in your user or project prompt directory. Conventional prompt directories load direct `.md` children only.
92
56
 
93
- ## Loading Rules
57
+ Settings and packages can select nested Markdown files; a package manifest can narrow discovery with explicit paths and globs. See [Settings](settings.md#resources) and [KnightCode Packages](packages.md) for these options.
94
58
 
95
- - Template discovery in `prompts/` is non-recursive.
96
- - If you want templates in subdirectories, add them explicitly via `prompts` settings or a package manifest.
59
+ Project templates become commands in the editor after trust is granted. Review their content before trusting an unfamiliar project. See [Security](security.md#understand-project-trust).