Skip to content

Commit 6bee73e

Browse files
authored
Merge branch 'lessweb:main' into main
2 parents 83ab9f7 + 393e71b commit 6bee73e

13 files changed

Lines changed: 55 additions & 7 deletions

File tree

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"*.{ts,tsx,js,mjs,cjs,ejs,jsx}": [
2+
"*.{ts,tsx,js,mjs,cjs,jsx}": [
33
"eslint --fix",
44
"prettier --write"
55
],

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
5+
- `src/` contains the TypeScript CLI implementation, with tool handlers in `src/tools/`, MCP integration in `src/mcp/`, UI components in `src/ui/`, and shared helpers in `src/common/`.
6+
- `src/tests/` contains Node test files named `*.test.ts`.
7+
- `templates/` contains runtime prompt assets: `templates/prompts/` for EJS prompt templates and `templates/tools/` for tool instruction Markdown loaded into the system prompt.
8+
- `docs/` is reserved for user-facing documentation such as configuration and MCP guides.
9+
- `resources/` stores static images used by the documentation or UI.
10+
11+
## Build, Test, and Development Commands
12+
13+
- `npm test` runs all test files with `tsx --test`.
14+
- `npm run test:single -- src/tests/<name>.test.ts` runs one test file.
15+
- `npm run typecheck` verifies TypeScript types without emitting files.
16+
- `npm run lint` checks ESLint rules for `src/`.
17+
- `npm run build` runs checks, bundles `src/cli.tsx` to `dist/cli.js`, and marks the bundle executable.
18+
19+
## Coding Style & Naming Conventions
20+
21+
- Use TypeScript ES modules and keep imports explicit.
22+
- Prefer small, focused functions; keep filesystem path construction centralized when a path is reused.
23+
- Use two-space indentation and Prettier-compatible formatting.
24+
- Respond in standard technical English. Avoid nonstandard phrasing and corporate jargon.
25+
26+
## Testing Guidelines
27+
28+
- Add or update tests in `src/tests/` when changing command behavior, prompt rendering, session flow, tools, or settings.
29+
- Prefer Node's built-in `node:test` and `node:assert/strict` APIs, matching the existing tests.
30+
- Keep tests deterministic by using temporary directories and mocked network calls where needed.
31+
32+
## Commit & Pull Request Guidelines
33+
34+
- Keep commits focused on a single change and use concise, imperative commit messages.
35+
- In pull requests, describe the behavior change, list verification commands, and note any packaging or template path changes.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"main": "./dist/cli.js",
1616
"files": [
1717
"dist/cli.js",
18-
"docs/tools/**",
19-
"docs/prompts/**",
18+
"templates/tools/**",
19+
"templates/prompts/**",
2020
"README.md",
2121
"LICENSE"
2222
],

src/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ type PromptToolOptions = {
252252
};
253253

254254
function readToolDocs(extensionRoot: string, _options: PromptToolOptions = {}): string {
255-
const toolsDir = path.join(extensionRoot, "docs", "tools");
255+
const toolsDir = path.join(extensionRoot, "templates", "tools");
256256
if (!fs.existsSync(toolsDir)) {
257257
return "";
258258
}

src/session.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ ${skillMd}
14851485
}
14861486

14871487
private renderInitCommandPrompt(): string {
1488-
const templatePath = path.join(getExtensionRoot(), "docs", "prompts", "init_command.md.ejs");
1488+
const templatePath = path.join(getExtensionRoot(), "templates", "prompts", "init_command.md.ejs");
14891489
const template = fs.readFileSync(templatePath, "utf8");
14901490
return ejs.render(template, {
14911491
agentsMdFile: this.getEffectiveProjectAgentsMdFile(),
@@ -1747,8 +1747,9 @@ ${skillMd}
17471747
}
17481748
const params = Array.isArray(message.contentParams) ? message.contentParams : [message.contentParams];
17491749
for (const param of params) {
1750-
if (param && typeof param === "object") {
1751-
contentParts.push(param as ChatCompletionContentPart);
1750+
const part = param as ChatCompletionContentPart;
1751+
if (part && part.type !== "image_url") {
1752+
contentParts.push(part);
17521753
}
17531754
}
17541755
const contentValue: string | ChatCompletionContentPart[] = contentParts.length > 0 ? contentParts : content;

src/tests/prompt.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { test } from "node:test";
22
import assert from "node:assert/strict";
3+
import * as fs from "fs";
4+
import * as path from "path";
5+
import { fileURLToPath } from "url";
36
import { getSystemPrompt, getTools } from "../prompt";
47

8+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
9+
510
test("getTools always includes WebSearch", () => {
611
const names = getTools().map((tool) => tool.function.name);
712
assert.equal(names.includes("WebSearch"), true);
@@ -11,3 +16,10 @@ test("getSystemPrompt always includes WebSearch docs", () => {
1116
const prompt = getSystemPrompt("/tmp/project");
1217
assert.equal(prompt.includes("## WebSearch"), true);
1318
});
19+
20+
test("runtime prompt assets live under templates", () => {
21+
assert.equal(fs.existsSync(path.join(repoRoot, "templates", "tools", "web-search.md")), true);
22+
assert.equal(fs.existsSync(path.join(repoRoot, "templates", "prompts", "init_command.md.ejs")), true);
23+
assert.equal(fs.existsSync(path.join(repoRoot, "docs", "tools")), false);
24+
assert.equal(fs.existsSync(path.join(repoRoot, "docs", "prompts")), false);
25+
});
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)