@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,123 +1,40 @@
1
- # Sessions
1
+ # Sessions and Context
2
2
 
3
- KnightCode saves conversations as sessions so you can continue work, branch from earlier turns, and revisit previous paths.
3
+ KnightCode saves a conversation as a session. The active branch of that session supplies conversation history for the next model request. Use session commands to continue work, explore another branch, or reduce the amount of history sent to the model.
4
4
 
5
- ## Session Storage
5
+ ## Continue or switch sessions
6
6
 
7
- Sessions auto-save to `~/.knightcode/agent/sessions/`, organized by working directory. Each session is a JSONL file with a tree structure.
7
+ KnightCode saves sessions automatically unless you start it with `--no-session`.
8
8
 
9
9
  ```bash
10
- knightcode -c # Continue most recent session
11
- knightcode -r # Browse and select from past sessions
12
- knightcode --no-session # Ephemeral mode; do not save
13
- knightcode --name "my task" # Set session display name at startup
14
- knightcode --session <path|id> # Use a specific session file or partial session ID
15
- knightcode --fork <path|id> # Fork a session file or partial session ID into a new session
10
+ knightcode --continue
11
+ knightcode --resume
16
12
  ```
17
13
 
18
- Use `/session` in interactive mode to see the current session file, session ID, message count, tokens, and cost.
14
+ `--continue` opens the most recent session for the current working directory. `--resume` opens the session picker. In interactive mode, `/resume` opens the same picker and `/new` starts a new session.
19
15
 
20
- For the JSONL file format and SessionManager API, see [Session Format](session-format.md).
16
+ Use `/name` or `--name` to assign a recognizable session name. Run `/session` to verify the current session file, ID, message count, token usage, and cost.
21
17
 
22
- ## Session Commands
18
+ The session picker lets you search, rename, and delete sessions. It can also show paths, change sorting, and limit results to named sessions. See [Keybindings](keybindings.md#sessions) for its shortcuts.
23
19
 
24
- | Command | Description |
25
- |---------|-------------|
26
- | `/resume` | Browse and select previous sessions |
27
- | `/new` | Start a new session |
28
- | `/name <name>` | Set the current session display name |
29
- | `/session` | Show session info |
30
- | `/tree` | Navigate the current session tree |
31
- | `/undo` | Go back to an earlier user message, optionally restoring files |
32
- | `/fork` | Create a new session from a previous user message |
33
- | `/clone` | Duplicate the current active branch into a new session |
34
- | `/compact [prompt]` | Summarize older context; see [Compaction](compaction.md) |
35
- | `/export [file]` | Export session to HTML |
36
- | `/share` | Upload as private GitHub gist with shareable HTML link |
37
- | `/bug [description]` | Report a bug to the KnightCode developers; see [Reporting Bugs](#reporting-bugs) |
20
+ ## Choose how to branch
38
21
 
39
- ## Resuming and Deleting Sessions
22
+ KnightCode stores entries as a tree, so returning to an earlier point does not erase the branch you leave.
40
23
 
41
- `/resume` opens an interactive session picker for the current project. `knightcode -r` opens the same picker at startup.
24
+ | Action | Result | Use it when |
25
+ |---|---|---|
26
+ | `/tree` | Moves within the current session file | Related alternatives should stay together |
27
+ | `/fork` | Creates a new session from an earlier user message | The alternative should become separate work |
28
+ | `/clone` | Copies the active branch into a new session | You want a separate copy of the current state |
29
+ | `/undo` | Returns to an earlier user message on the current branch, optionally restoring files | You want to take back the last turns |
42
30
 
43
- In the picker you can:
44
-
45
- - search by typing
46
- - toggle path display with Ctrl+P
47
- - toggle sort mode with Ctrl+S
48
- - filter to named sessions with Ctrl+N
49
- - rename with Ctrl+R
50
- - delete with Ctrl+D, then confirm
51
-
52
- When available, knightcode uses the `trash` CLI for deletion instead of permanently removing files.
53
-
54
- ## Naming Sessions
55
-
56
- Use `/name <name>` to set a human-readable session name:
57
-
58
- ```text
59
- /name Refactor auth module
60
- ```
61
-
62
- Set the name at startup with `--name` or `-n`:
63
-
64
- ```bash
65
- knightcode --name "Refactor auth module"
66
- knightcode --name "CI audit" -p "Review this build failure"
67
- ```
68
-
69
- Named sessions are easier to find in `/resume` and `knightcode -r`.
70
-
71
- ## Branching with `/tree`
72
-
73
- Sessions are stored as trees. Every entry has an `id` and `parentId`, and the current position is the active leaf. `/tree` lets you jump to any previous point and continue from there without creating a new file.
31
+ In `/tree`, select a user message to put its text back in the editor. Edit and submit it to create another branch. Selecting an assistant response or another entry continues after that entry with an empty editor.
74
32
 
75
33
  Selecting a point while the model is responding cancels that response. Navigation cannot proceed while compaction or another tree navigation is still running; wait for it to finish and retry.
76
34
 
77
- <p align="center"><img src="images/tree-view.png" alt="Tree View" width="600"></p>
78
-
79
- Example shape:
35
+ When you leave a branch, KnightCode can summarize it and attach that summary to the branch you enter. This preserves relevant work from the abandoned path without including every message from it.
80
36
 
81
- ```text
82
- ├─ user: "Hello, can you help..."
83
- │ └─ assistant: "Of course! I can..."
84
- │ ├─ user: "Let's try approach A..."
85
- │ │ └─ assistant: "For approach A..."
86
- │ │ └─ user: "That worked..." ← active
87
- │ └─ user: "Actually, approach B..."
88
- │ └─ assistant: "For approach B..."
89
- ```
90
-
91
- ### Tree Controls
92
-
93
- | Key | Action |
94
- |-----|--------|
95
- | ↑/↓ | Navigate visible entries |
96
- | ←/→ | Page up/down |
97
- | Ctrl+←/Ctrl+→ or Alt+←/Alt+→ | Fold/unfold or jump between branch segments |
98
- | Shift+L | Set or clear a label on the selected entry |
99
- | Shift+T | Toggle label timestamps |
100
- | Enter | Select entry |
101
- | Escape/Ctrl+C | Cancel |
102
- | Ctrl+O | Cycle filter mode |
103
-
104
- Filter modes are: default, no-tools, user-only, labeled-only, and all. Configure the default with `treeFilterMode` in [Settings](settings.md).
105
-
106
- ### Selection Behavior
107
-
108
- Selecting a user or custom message:
109
-
110
- 1. Moves the leaf to the selected message's parent.
111
- 2. Places the selected message text in the editor.
112
- 3. Lets you edit and resubmit, creating a new branch.
113
-
114
- Selecting an assistant, tool, compaction, or other non-user entry:
115
-
116
- 1. Moves the leaf to that entry.
117
- 2. Leaves the editor empty.
118
- 3. Lets you continue from that point.
119
-
120
- Selecting the root user message resets the leaf to an empty conversation and places the original prompt in the editor.
37
+ For the persisted tree and entry types, see [Session Format](session-format.md).
121
38
 
122
39
  ## Undoing with `/undo`
123
40
 
@@ -125,7 +42,8 @@ Selecting the root user message resets the leaf to an empty conversation and pla
125
42
  branch and go back to it. It lists only user messages, newest at the bottom, with the time
126
43
  and how many files an undo to that point would restore. Enter goes back; the turns after the
127
44
  chosen message are left as an abandoned branch (still reachable through `/tree`) and the
128
- message text returns to the editor for editing and resubmitting.
45
+ message text returns to the editor for editing and resubmitting. `/undo` never summarizes the
46
+ branch it leaves.
129
47
 
130
48
  ### File Restore
131
49
 
@@ -153,57 +71,34 @@ Limits:
153
71
  Backups older than 30 days are removed at startup. Set `KNIGHTCODE_DISABLE_FILE_CHECKPOINTS=1`
154
72
  to turn file tracking off; `/undo` then rewinds the conversation only.
155
73
 
156
- ## `/tree`, `/fork`, and `/clone`
157
-
158
- | Feature | `/tree` | `/fork` | `/clone` |
159
- |---------|---------|---------|----------|
160
- | Output | Same session file | New session file | New session file |
161
- | View | Full tree | User-message selector | Current active branch |
162
- | Typical use | Explore alternatives in place | Start a new session from an earlier prompt | Duplicate current work before continuing |
163
- | Summary | Optional branch summary | None | None |
164
-
165
- Use `/tree` when you want to keep alternatives together. Use `/fork` or `/clone` when you want a separate session file.
166
-
167
- ## Branch Summaries
168
-
169
- When `/tree` switches away from one branch to another, knightcode can summarize the abandoned branch and attach that summary at the new position. This preserves important context from the path you left without replaying the whole branch.
170
-
171
- When prompted, choose one of:
74
+ ## Manage conversation context
172
75
 
173
- 1. no summary
174
- 2. summarize with the default prompt
175
- 3. summarize with custom focus instructions
76
+ The model receives the active branch, not every branch in the session file. KnightCode combines that history with the system prompt, discovered context files, available tools, and loaded skill descriptions. [How KnightCode Works](how-knightcode-works.md#context) describes how those inputs are assembled.
176
77
 
177
- See [Compaction](compaction.md) for branch summarization internals and extension hooks.
78
+ The footer shows current context usage. When the active context approaches the model's limit, KnightCode normally compacts older history automatically. Compaction adds a summary and keeps recent messages. It does not delete the original session entries.
178
79
 
179
- ## Reporting Bugs
80
+ Run `/compact` to compact manually. You can add instructions when the summary should preserve a particular topic or decision. Configure automatic compaction and retained history through [Settings](settings.md#compaction).
180
81
 
181
- `/bug [description]` collects a bug report for the KnightCode maintainers. The report is not shared publicly. The dialog asks for an optional description and whether to include the session transcript. If you decline the transcript, KnightCode offers to have the current model write a summary of what went wrong instead; the transcript is sent to your provider with your credentials, and only the summary is attached.
82
+ Compaction can fail if the provider is unavailable or cannot accept the summarization request. Correct the provider problem and run `/compact` again. Disabling automatic compaction does not disable the manual command.
182
83
 
183
- The last step chooses where the report goes:
84
+ See [Compaction Reference](compaction.md) for thresholds, retained boundaries, branch-summary behavior, and extension hooks.
184
85
 
185
- - **Upload Report** sends it to the KnightCode maintainers through `remote.knightcode.dev`. No login is required and reports are always anonymous. If the upload fails, KnightCode offers to export the zip instead.
186
- - **Export as Zip** writes a zip archive to the current directory. Attach it to an issue or send it to the developers yourself.
86
+ ## Control session storage
187
87
 
188
- Both contain the same files:
88
+ By default, KnightCode stores sessions under `~/.knightcode/agent/sessions/`, grouped by working directory. Use `--session-dir`, `KNIGHTCODE_CODING_AGENT_SESSION_DIR`, or the `sessionDir` setting to choose another location. The CLI option has highest precedence.
189
89
 
190
- | File | Content |
191
- |------|---------|
192
- | `report.json` | KnightCode version, runtime, OS, terminal, current model and provider configuration, loaded extensions, and settings. API keys, header values, URL credentials, and the analytics tracking id are never included. |
193
- | `diagnostics.json` | Provider and runtime error diagnostics attached to assistant messages across the whole session (failed or aborted turns, retries, error messages), plus any recorded crashes. Always included; message content is not. |
194
- | `session.jsonl` | The current branch of the session, only when you chose to include it. It contains file contents and command output read during the session. |
195
- | `summary.md` | The model-written summary, only when you chose to generate one. |
90
+ Use `--no-session` for an ephemeral run. An ephemeral session cannot be resumed after KnightCode exits.
196
91
 
197
- Each report has a UUID. KnightCode shows it after upload or export and records it in the session as a `knightcode.bug-report` entry so you can refer to it later.
92
+ Use `--session` when you already know the session path or ID. Use `--fork` to create a new session from an existing session before interactive mode starts.
198
93
 
199
- Set `KNIGHTCODE_RADIUS_GATEWAY` to upload to a different Radius deployment.
94
+ ## Export or share a session
200
95
 
201
- ### Crashes
96
+ Use `/export` to write the current session as HTML or JSONL. Use `/share` to upload it and get a viewer link. KnightCode uses a Radius artifact when Radius authentication is configured; otherwise, it uses a private GitHub gist.
202
97
 
203
- When KnightCode exits because of an uncaught exception or a fatal runtime error, it stores the error message and stack trace in `~/.knightcode/agent/crashes.json` (the newest five). The next interactive start shows a warning once; running `/bug` attaches the stored crashes to `diagnostics.json` and removes the file after the report is uploaded or exported. Resume the crashed session with `knightcode -r` first if you want the transcript in the report.
98
+ Review exported or shared sessions first. They can contain prompts, model responses, tool arguments, command output, file contents, and extension messages.
204
99
 
205
- ## Session Format
100
+ ## Report a bug
206
101
 
207
- Session files are JSONL and contain message entries, model changes, thinking-level changes, labels, compactions, branch summaries, and extension entries.
102
+ Run `/bug [description]` to prepare a private report for the KnightCode maintainers. You can include the session transcript, omit it, or ask the current model to summarize the problem. Review any transcript or generated summary because it can contain sensitive conversation data.
208
103
 
209
- For parsers, extensions, SDK usage, and the full SessionManager API, see [Session Format](session-format.md).
104
+ The report includes environment and provider configuration without credential values, plus recorded error diagnostics. Upload it to the maintainers through `remote.knightcode.dev` or export the same report as a zip to inspect and share yourself. Uploads do not require a login and are always anonymous. If an upload fails, KnightCode offers to export the zip.