Skip to content

Commit 57bbddc

Browse files
Merge remote-tracking branch 'upstream/main' into dev
2 parents 45f3ba2 + 66e34d3 commit 57bbddc

13 files changed

Lines changed: 368 additions & 219 deletions

File tree

.deepcode/AGENTS.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ src/
2222
│ ├── process-tree.ts # Process tree construction and orphan detection
2323
│ ├── shell-utils.ts # Shell path resolution (Git Bash, zsh, bash)
2424
│ ├── state.ts # In-memory file state and snippet tracking
25+
│ ├── telemetry.ts # Usage telemetry collection and reporting
2526
│ ├── update-check.ts # Latest-version check against npm registry
2627
│ └── validate.ts # Tool validation runtime helpers (was runtime.ts)
2728
├── mcp/
@@ -37,20 +38,23 @@ src/
3738
│ ├── web-search-handler.ts # Web search via natural language queries
3839
│ └── ask-user-question-handler.ts # Interactive user prompts with options
3940
├── ui/
40-
│ ├── components/ # Reusable Ink components (MessageView, DropdownMenu, ModelsDropdown, SkillsDropdown, etc.)
41+
│ ├── components/ # Reusable Ink components (MessageView, DropdownMenu, ModelsDropdown, SkillsDropdown, FileMentionMenu, RawModelDropdown, etc.)
4142
│ ├── contexts/ # React contexts (AppContext, RawModeContext)
4243
│ ├── hooks/ # Custom hooks (cursor, useHistoryNavigation, usePasteHandling, useTerminalInput)
43-
│ ├── views/ # Top-level screen components (App, PromptInput, SessionList, PermissionPrompt, ProcessStdoutView, etc.)
44-
│ ├── core/ # Core UI logic (file-mentions, slash-commands, prompt-buffer, thinking-state, etc.)
44+
│ ├── views/ # Top-level screen components (App, PromptInput, SessionList, PermissionPrompt, ProcessStdoutView, WelcomeScreen, UndoSelector, etc.)
45+
│ ├── core/ # Core UI logic (file-mentions, slash-commands, prompt-buffer, thinking-state, clipboard, prompt-undo-redo, etc.)
4546
│ ├── utils/ # Shared utility helpers
47+
│ ├── ascii-art.ts # ASCII art banner for welcome screen
48+
│ ├── exit-summary.ts # Session exit summary and cost reporting
4649
│ ├── index.ts # UI module barrel exports
4750
│ └── constants.ts # UI-wide constants
48-
├── tests/ # One *.test.ts per source module, plus run-tests.mjs
51+
├── tests/ # Test files per source module, plus run-tests.mjs
4952
templates/
5053
├── tools/ # Tool descriptions fed to the LLM
51-
├── skills/ # Built-in skill definitions (agent-drift-guard, plan-and-execute)
54+
├── skills/ # Built-in skill definitions (agent-drift-guard, plan-and-execute, karpathy-guidelines)
5255
└── prompts/ # EJS templates (e.g., init_command.md.ejs)
5356
docs/ # User-facing documentation (configuration, MCP, notify, permissions)
57+
resources/ # Static assets (intro screenshots)
5458
dist/ # Bundled CLI output (gitignored)
5559
```
5660

@@ -66,8 +70,8 @@ dist/ # Bundled CLI output (gitignored)
6670
| `npm run check` | Runs typecheck + lint + format:check together |
6771
| `npm run bundle` | esbuild bundles `src/cli.tsx``dist/cli.js` (ESM, Node 18) |
6872
| `npm run build` | `check` + `bundle` + chmod 755 — full CI gate before publish |
69-
| `npm test` | Runs all tests via `tsx --test src/tests/*.test.ts` |
70-
| `npm run test:single -- <file>` | Run a single test file (e.g., `npm run test:single -- src/tests/session.test.ts`) |
73+
| `npm test` | Runs all tests via `node src/tests/run-tests.mjs` |
74+
| `npm run test:single -- <file>` | Run a single test file via `tsx --test` (e.g., `npm run test:single -- src/tests/session.test.ts`) |
7175

7276
Run the CLI locally for manual testing: `node dist/cli.js` (after `npm run bundle`).
7377

@@ -90,7 +94,7 @@ Run the CLI locally for manual testing: `node dist/cli.js` (after `npm run bundl
9094

9195
- **Framework**: Node.js native test runner (`node:test`) with `tsx` for TypeScript
9296
- **Assertions**: `node:assert/strict`
93-
- **Coverage**: Target meaningful unit tests for core logic (session management, tool handlers, settings resolution, prompt buffer, permissions, MCP client). Test files are in `src/tests/` matching the source module name.
97+
- **Coverage**: Target meaningful unit tests for core logic (session management, tool handlers, settings resolution, prompt buffer, permissions, MCP client, telemetry). Test files are in `src/tests/` matching the source module name.
9498
- **Test naming**: `describe`/`test` blocks with descriptive names. Example: `test("SessionManager preserves structured system content when building OpenAI messages", ...)`
9599
- **Relaxed lint rules**: Test files allow `any` and unused vars.
96100
- Run all tests with `npm test` before submitting a PR. A cross-platform test runner is available at `src/tests/run-tests.mjs`.
@@ -104,6 +108,7 @@ Run the CLI locally for manual testing: `node dist/cli.js` (after `npm run bundl
104108
- `chore:` — tooling, deps, hooks (e.g., `chore: add husky + lint-staged`)
105109
- `refactor:` — code restructuring (e.g., `refactor(ui): optimize App hooks`)
106110
- `style:` — formatting-only changes (e.g., `style: adjust the tree structure symbols`)
111+
- `test:` — adding or updating tests (e.g., `test: add telemetry module unit tests`)
107112
- `docs:` — documentation (e.g., `docs: add MCP configuration guide`)
108113

109114
**Pull requests** should include:
@@ -133,4 +138,4 @@ A **file history system** (`src/common/file-history.ts`) provides undo/checkpoin
133138

134139
- **AGENTS.md loading**: The CLI loads agent instructions from `./AGENTS.md`, `./.deepcode/AGENTS.md`, or `~/.deepcode/AGENTS.md` (first found wins). Write project-specific guidance for the LLM in any of these.
135140
- **Skills**: Place skill definitions in `~/.agents/skills/<name>/SKILL.md` (user-level) or `./.agents/skills/<name>/SKILL.md` (project-level). Legacy path `./.deepcode/skills/` is also supported. Each SKILL.md uses YAML frontmatter with `name` and `description` fields.
136-
- **Built-in skills**: `agent-drift-guard` (detects and corrects execution drift) and `plan-and-execute` (structured task planning with progress tracking). Both are defined in `templates/skills/` and always injected into every session.
141+
- **Built-in skills**: `agent-drift-guard` (detects and corrects execution drift), `plan-and-execute` (structured task planning with progress tracking), and `karpathy-guidelines` (behavioral guidelines to reduce common LLM coding mistakes). All three are defined in `templates/skills/` and always injected into every session.

AGENTS.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vegamo/deepcode-cli",
3-
"version": "0.1.26",
3+
"version": "0.1.27",
44
"description": "Deep Code CLI - Vibe coding for the deepseek-v4 model in your terminal",
55
"license": "MIT",
66
"type": "module",
@@ -45,7 +45,7 @@
4545
"gray-matter": "^4.0.3",
4646
"ignore": "^7.0.5",
4747
"ink": "^7.0.4",
48-
"ink-gradient": "^4.0.0",
48+
"ink-gradient": "^4.0.1",
4949
"openai": "^6.35.0",
5050
"react": "^19.2.5",
5151
"undici": "^7.25.0",

src/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export type PromptToolOptions = {
100100
planMode?: boolean;
101101
};
102102

103-
const DEFAULT_SKILL_TEMPLATES = ["agent-drift-guard.md", "plan-and-execute.md"];
103+
const DEFAULT_SKILL_TEMPLATES = ["karpathy-guidelines.md"];
104104

105105
function readToolDocs(extensionRoot: string, options: PromptToolOptions = {}): string {
106106
const toolsDir = path.join(extensionRoot, "templates", "tools");

src/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,13 @@ ${skillMd}
11911191
this.updateSessionEntry(sessionId, (entry) => ({
11921192
...entry,
11931193
status: "failed",
1194-
failReason: "OpenAI API key not found",
1194+
failReason: "API key not found",
11951195
updateTime: now,
11961196
}));
11971197
this.onAssistantMessage(
11981198
this.buildAssistantMessage(
11991199
sessionId,
1200-
"OpenAI API key not found. Please configure ~/.deepcode/settings.json or ./.deepcode/settings.json.",
1200+
"API key not found. Please configure ~/.deepcode/settings.json or ./.deepcode/settings.json.",
12011201
null
12021202
),
12031203
false

src/tests/message-view.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
33
import { parseDiffPreview } from "../ui";
44
import {
55
buildThinkingSummary,
6+
formatBashStatusParams,
7+
formatToolStatusParams,
68
renderMessageToStdout,
79
getUpdatePlanPreviewLines,
810
parseToolPayload,
@@ -60,6 +62,26 @@ test("MessageView shows full reasoning content in Normal/Raw mode", () => {
6062
);
6163
});
6264

65+
test("formatBashStatusParams compacts multi-line commands and keeps the final description", () => {
66+
assert.equal(
67+
formatBashStatusParams('python3 -c "\nprint(1)\nprint(2)\n" # Run inline script'),
68+
'python3 -c " ... " # Run inline script'
69+
);
70+
});
71+
72+
test("formatToolStatusParams preserves compacted Bash params but truncates other tools", () => {
73+
assert.equal(
74+
formatToolStatusParams({
75+
name: "bash",
76+
params: "cat <<'EOF'\nhello\nEOF # Print heredoc",
77+
ok: true,
78+
metadata: null,
79+
}),
80+
"cat <<'EOF' ... EOF # Print heredoc"
81+
);
82+
assert.equal(formatToolStatusParams({ name: "read", params: "first\nsecond", ok: true, metadata: null }), "first");
83+
});
84+
6385
// --- renderMessageToStdout tests ---
6486

6587
function makeSessionMessage(overrides: Partial<SessionMessage> & Pick<SessionMessage, "role">): SessionMessage {
@@ -139,6 +161,18 @@ test("renderMessageToStdout renders tool messages with resultMd output", () => {
139161
assert.ok(output.includes("line 1"));
140162
});
141163

164+
test("renderMessageToStdout compacts multi-line Bash params", () => {
165+
const payload = JSON.stringify({ name: "bash", ok: true });
166+
const msg = makeSessionMessage({
167+
role: "tool",
168+
content: payload,
169+
meta: { paramsMd: 'python3 -c "\nprint(1)\nprint(2)\n" # Run inline script' },
170+
});
171+
const output = renderMessageToStdout(msg, RawMode.Raw);
172+
assert.ok(output.includes('python3 -c " ... " # Run inline script'));
173+
assert.ok(!output.includes("print(1)"));
174+
});
175+
142176
test("renderMessageToStdout renders UpdatePlan tool messages with Plan preview and resultMd", () => {
143177
const payload = JSON.stringify({
144178
name: "UpdatePlan",

src/tests/prompt.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,11 @@ test("getSystemPrompt does not include runtime context", () => {
4949
assert.equal(prompt.includes('"root path": "/tmp/project"'), false);
5050
});
5151

52-
test("getDefaultSkillPrompt loads default skill templates in order", () => {
52+
test("getDefaultSkillPrompt loads the default skill template", () => {
5353
const prompt = getDefaultSkillPrompt();
54-
const agentDriftIndex = prompt.indexOf("<agent-drift-guard-skill>");
55-
const planIndex = prompt.indexOf("<plan-and-execute-skill>");
5654

57-
assert.notEqual(agentDriftIndex, -1);
58-
assert.notEqual(planIndex, -1);
59-
assert.equal(agentDriftIndex < planIndex, true);
55+
assert.equal(prompt.includes("<karpathy-guidelines-skill>"), true);
56+
assert.equal(prompt.includes("# Karpathy Guidelines"), true);
6057
assert.equal(prompt.includes("Use the skill documents below to assist the user:"), true);
6158
assert.equal(prompt.includes('path="templates/skills/'), false);
6259
});

src/tests/session.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ test("createSession appends default system prompts in prefix-cache-friendly orde
702702
assert.match(systemContents[0] ?? "", /# Available Tools/);
703703
assert.doesNotMatch(systemContents[0] ?? "", /# Local Workspace Environment/);
704704
assert.doesNotMatch(systemContents[0] ?? "", /LLMtest-model/);
705-
assert.match(systemContents[1] ?? "", /<agent-drift-guard-skill>/);
706-
assert.match(systemContents[1] ?? "", /<plan-and-execute-skill>/);
705+
assert.match(systemContents[1] ?? "", /<karpathy-guidelines-skill>/);
706+
assert.match(systemContents[1] ?? "", /# Karpathy Guidelines/);
707707
assert.doesNotMatch(systemContents[1] ?? "", /path="templates\/skills\//);
708708
assert.doesNotMatch(systemContents[1] ?? "", /LLMtest-model/);
709709
assert.match(systemContents[2] ?? "", /# Local Workspace Environment/);

0 commit comments

Comments
 (0)