codeep 2.13.0 → 2.13.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.
@@ -26,4 +26,13 @@ export interface AgentSessionOptions {
26
26
  * Falls back to a minimal synthetic context if scanning fails.
27
27
  */
28
28
  export declare function buildProjectContext(workspaceRoot: string): ProjectContext;
29
+ export declare function toolCallMeta(toolName: string, params: Record<string, string>, workspaceRoot: string): {
30
+ kind: string;
31
+ title: string;
32
+ };
33
+ export declare function buildRawOutput(toolName: string, params: Record<string, string>, toolResult: {
34
+ success: boolean;
35
+ output: string;
36
+ error?: string;
37
+ }): string | undefined;
29
38
  export declare function runAgentSession(opts: AgentSessionOptions): Promise<void>;
@@ -24,7 +24,10 @@ export function buildProjectContext(workspaceRoot) {
24
24
  };
25
25
  }
26
26
  // Maps internal tool names to ACP tool_call kind values and human titles.
27
- function toolCallMeta(toolName, params, workspaceRoot) {
27
+ // Exported (not just module-private) so it can be unit-tested in isolation —
28
+ // testing it through runAgentSession would require mocking the entire agent
29
+ // loop, which would defeat the point of covering this mapping.
30
+ export function toolCallMeta(toolName, params, workspaceRoot) {
28
31
  const file = params.path ?? params.file ?? '';
29
32
  // Use full path for edit tools (Zed renders it as a clickable file link)
30
33
  const absFile = file
@@ -51,7 +54,8 @@ function toolCallMeta(toolName, params, workspaceRoot) {
51
54
  // Builds rawOutput content to display inside tool call cards.
52
55
  // For write/edit operations, returns the code content or diff.
53
56
  // For command execution, returns the command output.
54
- function buildRawOutput(toolName, params, toolResult) {
57
+ // Exported for direct unit testing (see session.test.ts).
58
+ export function buildRawOutput(toolName, params, toolResult) {
55
59
  // Always surface error details when a tool fails
56
60
  if (!toolResult.success && toolResult.error) {
57
61
  return `Error: ${toolResult.error}`;
@@ -14,8 +14,8 @@ interface ProviderApiKey {
14
14
  providerId: string;
15
15
  apiKey: string;
16
16
  }
17
- type AgentMode = 'on' | 'manual';
18
- interface ConfigSchema {
17
+ type AgentMode = 'on' | 'manual' | 'off';
18
+ export interface ConfigSchema {
19
19
  apiKey: string;
20
20
  provider: string;
21
21
  model: string;
@@ -23,125 +23,12 @@ const LOGO_LINES = [
23
23
  ' ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ',
24
24
  ];
25
25
  const LOGO_HEIGHT = LOGO_LINES.length;
26
- // Command descriptions for autocomplete
27
- const COMMAND_DESCRIPTIONS = {
28
- 'help': 'Show help',
29
- 'status': 'Show status',
30
- 'settings': 'Adjust settings',
31
- 'version': 'Show version',
32
- 'update': 'Check updates',
33
- 'clear': 'Clear chat',
34
- 'exit': 'Quit',
35
- 'sessions': 'Manage sessions',
36
- 'new': 'New session',
37
- 'rename': 'Rename session',
38
- 'search': 'Search history',
39
- 'export': 'Export chat',
40
- 'agent': 'Run agent for a task',
41
- 'agent-dry': 'Preview agent actions',
42
- 'stop': 'Stop running agent',
43
- 'undo': 'Undo last action',
44
- 'undo-all': 'Undo all actions',
45
- 'history': 'Show agent history',
46
- 'changes': 'Show session changes',
47
- 'diff': 'Review git changes',
48
- 'commit': 'Generate commit message',
49
- 'git-commit': 'Commit with message',
50
- 'push': 'Git push',
51
- 'pull': 'Git pull',
52
- 'amend': 'Amend the last commit',
53
- 'pr': 'Create a pull request description',
54
- 'changelog': 'Generate changelog from recent commits',
55
- 'branch': 'Create a new branch with smart naming',
56
- 'stash': 'Stash changes with a meaningful message',
57
- 'unstash': 'Apply and drop the most recent stash',
58
- 'init': 'Initialize project (.codeep/)',
59
- 'scan': 'Scan project',
60
- 'memory': 'Add/list/remove project memory notes',
61
- 'review': 'Code review',
62
- 'copy': 'Copy code block',
63
- 'paste': 'Paste from clipboard',
64
- 'apply': 'Apply file changes',
65
- 'add': 'Add file to context',
66
- 'drop': 'Remove file from context',
67
- 'multiline': 'Toggle multi-line input',
68
- 'test': 'Generate/run tests',
69
- 'docs': 'Open web docs for a command (e.g. /docs personality)',
70
- 'refactor': 'Improve code quality',
71
- 'fix': 'Debug and fix issues',
72
- 'explain': 'Explain code',
73
- 'optimize': 'Optimize performance',
74
- 'debug': 'Debug problems',
75
- 'test-fix': 'Fix failing tests',
76
- 'coverage': 'Analyze test coverage and suggest improvements',
77
- 'e2e': 'Generate end-to-end tests',
78
- 'mock': 'Generate mock data for testing',
79
- 'readme': 'Generate or update README',
80
- 'api-docs': 'Generate API documentation',
81
- 'translate': 'Translate code comments to English',
82
- 'types': 'Add or improve TypeScript types',
83
- 'cleanup': 'Clean up code (remove unused, format)',
84
- 'modernize': 'Update code to use modern syntax',
85
- 'migrate': 'Migrate code to newer version',
86
- 'split': 'Split a large file into smaller modules',
87
- 'security': 'Security audit',
88
- 'log': 'Add logging to code',
89
- 'build': 'Build the project',
90
- 'deploy': 'Build and deploy',
91
- 'release': 'Create a new release',
92
- 'publish': 'Publish package to npm',
93
- 'component': 'Generate a React/Vue component',
94
- 'api': 'Generate an API endpoint',
95
- 'hook': 'Generate a React hook',
96
- 'service': 'Generate a service/utility module',
97
- 'page': 'Generate a new page/route',
98
- 'form': 'Generate a form with validation',
99
- 'crud': 'Generate full CRUD for an entity',
100
- 'docker': 'Generate Dockerfile and docker-compose',
101
- 'ci': 'Generate CI/CD configuration',
102
- 'env': 'Setup environment configuration',
103
- 'k8s': 'Generate Kubernetes manifests',
104
- 'terraform': 'Generate Terraform configuration',
105
- 'nginx': 'Generate Nginx configuration',
106
- 'monitor': 'Add monitoring and observability',
107
- 'skills': 'List all skills',
108
- 'provider': 'Switch provider',
109
- 'model': 'Switch model',
110
- 'protocol': 'Switch protocol',
111
- 'lang': 'Set language',
112
- 'grant': 'Grant write permission',
113
- 'login': 'Change API key',
114
- 'logout': 'Logout',
115
- 'account': 'Link this machine to your codeep.dev account',
116
- 'context-save': 'Save conversation',
117
- 'context-load': 'Load conversation',
118
- 'context-clear': 'Clear saved context',
119
- 'learn': 'Learn code preferences',
120
- 'cost': 'Show session cost and token usage',
121
- 'profile': 'Save/load settings profiles',
122
- 'tasks': 'List/add/done/delete codeep.dev tasks — add <title> [--bug|--feature]',
123
- 'sync': 'Sync learning preferences and profiles to codeep.dev',
124
- 'telemetry': 'Show or toggle automatic cloud telemetry (on/off)',
125
- 'keysync': 'Show or toggle syncing API keys to codeep.dev (on/off)',
126
- 'thinking': 'Set the thinking/reasoning-effort tier (auto/low/medium/high/max) for models that support it',
127
- 'effort': 'Alias for /thinking — set the reasoning-effort tier',
128
- // 2.0 — surfaced for `/` autocomplete; documented in /help too.
129
- 'compact': 'Summarize older messages to free up context',
130
- 'commands': 'List custom slash commands in .codeep/commands/*.md',
131
- 'checkpoint': 'Snapshot the session (conversation + provider/model + git HEAD)',
132
- 'checkpoints': 'List saved checkpoints for this workspace',
133
- 'rewind': 'Restore conversation from a saved checkpoint',
134
- 'hooks': 'List installed lifecycle hooks (.codeep/hooks/<event>.sh)',
135
- 'mcp': 'Manage MCP servers (browse, install, add, remove, resources, prompts)',
136
- 'openrouter': 'Tune OpenRouter routing (preferred / ignore providers, fallbacks, privacy)',
137
- 'plan': 'Generate a numbered plan for a task — review before /go executes it',
138
- 'go': 'Execute the pending plan from /plan',
139
- 'personality': 'Switch agent tone: concise / verbose / security / senior-reviewer / etc',
140
- 'me': 'Your user profile (reply language, style, stack) — adapts the agent to you. /me init, /me learn, /me sync',
141
- 'agents': 'List sub-agents the agent can delegate self-contained tasks to (researcher / reviewer / tester / custom)',
142
- 'insights': 'Activity summary over the last N days (default 7): runs, files, tools, projects',
143
- 'recall': 'Search across ALL saved sessions (cross-session; /search is current-session only)',
144
- };
26
+ // ─── Command metadata ────────────────────────────────────────────────────────
27
+ //
28
+ // `COMMAND_DESCRIPTIONS` used to be hand-maintained here in App.ts and kept in
29
+ // sync (manually) with the `/help` screen in components/Help.ts. Both now derive
30
+ // from the single source of truth in `./commands/registry.ts`.
31
+ import { COMMAND_DESCRIPTIONS } from './commands/registry.js';
145
32
  import { helpCategories, keyboardShortcuts } from './components/Help.js';
146
33
  import { handleSettingsKey, SETTINGS } from './components/Settings.js';
147
34
  import { renderExportPanel, handleExportKey as handleExportKeyComponent } from './components/Export.js';
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Single source of truth for Codeep slash commands.
3
+ *
4
+ * Every other place that needs command metadata — the `/` autocomplete in
5
+ * `App.ts`, the `/help` screen in `components/Help.ts`, the dispatcher in
6
+ * `commands.ts`, and the ACP command handler in `acp/commands.ts` — derives
7
+ * from this registry. Adding a command means adding one entry here; the
8
+ * autocomplete list, help screen, and command index all pick it up.
9
+ *
10
+ * ## What lives here vs. elsewhere
11
+ *
12
+ * - **`CommandDef`** is metadata only: name, aliases, description, category.
13
+ * The actual handler logic stays in `renderer/commands.ts` (CLI) and
14
+ * `acp/commands.ts` (ACP) — those files keep their per-command `case`
15
+ * blocks, but they now look up the canonical name/description/alias map here.
16
+ * - **Argument syntax** (e.g. `/rename <name>`, `/mcp browse [id]`) is
17
+ * documented via the optional `usage` field — surfaced in `/help` only.
18
+ * The autocomplete list shows just the bare command name.
19
+ * - **Hidden commands** (`hidden: true`) are valid and dispatched, but don't
20
+ * appear in the autocomplete dropdown or `/help`. Use for aliases that
21
+ * would clutter the list (single-letter shortcuts) and internal commands.
22
+ *
23
+ * ## Invariants (enforced by `registry.test.ts`)
24
+ *
25
+ * - No two commands share a name or alias.
26
+ * - Every `category` referenced exists in `CATEGORY_ORDER`.
27
+ * - `usage` keys never collide with a sibling command's name.
28
+ */
29
+ /** Display categories, in the order `/help` shows them. */
30
+ export declare const CATEGORY_ORDER: readonly ["general", "sessions", "checkpoints", "agent", "git", "code", "skills", "settings", "extensions", "cloud", "codegen", "thinking"];
31
+ export type CommandCategory = (typeof CATEGORY_ORDER)[number];
32
+ /** Human-readable title for each category (used by `/help`). */
33
+ export declare const CATEGORY_TITLES: Record<CommandCategory, string>;
34
+ export interface CommandDef {
35
+ /** Primary command name, without the leading `/`. */
36
+ name: string;
37
+ /** Alternate names that dispatch to the same handler. Hidden from `/help`
38
+ * by default (set `aliasListed: true` to show them, e.g. `/effort`). */
39
+ aliases?: string[];
40
+ /** One-line description shown in autocomplete and `/help`. */
41
+ description: string;
42
+ /** Display group in `/help`. */
43
+ category: CommandCategory;
44
+ /** Extra usage rows shown only in `/help` (e.g. `/mcp browse [id]`).
45
+ * Each entry is rendered as a separate row under the same command. */
46
+ usage?: string[];
47
+ /** When true, the command is valid but hidden from autocomplete + `/help`.
48
+ * Used for single-letter shortcuts and internal aliases. */
49
+ hidden?: boolean;
50
+ /** When true, an alias is listed in `/help` alongside the primary name
51
+ * (e.g. `/effort` appears next to `/thinking`). Default false — most
52
+ * aliases are hidden shortcuts. */
53
+ aliasListed?: boolean;
54
+ }
55
+ /**
56
+ * The registry. Order within a category is preserved as-is in `/help`,
57
+ * so keep entries grouped by category in source for readability.
58
+ */
59
+ export declare const COMMANDS: CommandDef[];
60
+ /** `name → description` for every visible (non-hidden) command + listed alias.
61
+ * This is the data behind the `/` autocomplete dropdown in `App.ts`.
62
+ *
63
+ * Single-letter aliases (the `c`/`t`/`d`/… shortcuts) are deliberately
64
+ * EXCLUDED from the dropdown — bare one-letter rows just clutter it (they
65
+ * stay fully routable via the dispatcher + show in `/help` as `(/c)` suffixes).
66
+ * Multi-letter listed aliases (`effort`, `stats`) are kept; they read as real
67
+ * commands, not noise. */
68
+ export declare const COMMAND_DESCRIPTIONS: Record<string, string>;
69
+ /** Every valid command name, including hidden ones and aliases — used by the
70
+ * dispatcher to validate input before looking up a handler. */
71
+ export declare const ALL_COMMAND_NAMES: ReadonlySet<string>;
72
+ export declare function resolveCommand(token: string): CommandDef | undefined;
73
+ /** All aliases (every value in `aliases` across the registry), for quick
74
+ * "is this a shortcut?" checks. */
75
+ export declare const ALL_ALIASES: ReadonlySet<string>;
76
+ export interface HelpItemSpec {
77
+ /** Visible key in `/help`, including the leading `/`. */
78
+ key: string;
79
+ description: string;
80
+ }
81
+ export interface HelpCategorySpec {
82
+ title: string;
83
+ items: HelpItemSpec[];
84
+ }
85
+ /**
86
+ * Hand-curated help layout. Categories appear in this order; each item's `key`
87
+ * is rendered verbatim. The command registry provides autocomplete + dispatch
88
+ * metadata; this layout provides the `/help` rendering. They overlap by design
89
+ * — keeping both lets the help screen document env vars, subcommand flavors,
90
+ * and recommended workflows that don't fit the strict command/alias shape.
91
+ */
92
+ export declare const HELP_LAYOUT: HelpCategorySpec[];