@turingcode/cli 0.3.21 → 0.3.23
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.
- package/dist/core/mcp.d.ts +2 -2
- package/dist/core/mcp.js +3 -3
- package/dist/features/tool/command.js +4 -3
- package/dist/stm32/build.d.ts +1 -1
- package/dist/stm32/build.js +3 -4
- package/mods/claude/turingcode-skills/skills/turingcode/SKILL.md +19 -12
- package/mods/claude/turingcode-skills/skills/turingcode/references/{app-startup.md → app-main-and-startup.md} +1 -1
- package/mods/claude/turingcode-skills/skills/turingcode/references/driver/driver.md +2 -13
- package/mods/claude/turingcode-skills/skills/turingcode/references/fact-check.md +14 -0
- package/mods/claude/turingcode-skills/skills/turingcode/references/init-pins.md +8 -2
- package/package.json +1 -1
package/dist/core/mcp.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export declare function callTool(name: string, args: Record<string, unknown>, to
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function callToolText(name: string, args: object, token: string, url?: string, timeoutMs?: number): Promise<string>;
|
|
38
38
|
/**
|
|
39
|
-
* A tool reply without the server's trailing footer lines (`Credits: ...`)
|
|
40
|
-
*
|
|
39
|
+
* A tool reply without the server's trailing footer lines (`Credits: ...`); every tool result goes through
|
|
40
|
+
* it so agents never see them.
|
|
41
41
|
*
|
|
42
42
|
* @param {string} text - Tool reply.
|
|
43
43
|
* @returns {string} The reply body, trimmed.
|
package/dist/core/mcp.js
CHANGED
|
@@ -89,8 +89,8 @@ export async function callToolText(name, args, token, url = DEFAULT_URL, timeout
|
|
|
89
89
|
return result.text;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* A tool reply without the server's trailing footer lines (`Credits: ...`)
|
|
93
|
-
*
|
|
92
|
+
* A tool reply without the server's trailing footer lines (`Credits: ...`); every tool result goes through
|
|
93
|
+
* it so agents never see them.
|
|
94
94
|
*
|
|
95
95
|
* @param {string} text - Tool reply.
|
|
96
96
|
* @returns {string} The reply body, trimmed.
|
|
@@ -141,7 +141,7 @@ export function parseRpcReply(body) {
|
|
|
141
141
|
export function toToolResult(result) {
|
|
142
142
|
const content = result?.content ?? [];
|
|
143
143
|
return {
|
|
144
|
-
text: content.filter(c => c.type === "text").map(c => c.text).join("\n"),
|
|
144
|
+
text: replyBody(content.filter(c => c.type === "text").map(c => c.text).join("\n")),
|
|
145
145
|
isError: Boolean(result?.isError),
|
|
146
146
|
};
|
|
147
147
|
}
|
|
@@ -130,12 +130,13 @@ async function runToolCall(name, args, full) {
|
|
|
130
130
|
process.exitCode = 1;
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
const
|
|
133
|
+
const text = result.text;
|
|
134
|
+
const bytes = Buffer.byteLength(text);
|
|
134
135
|
if (full || bytes <= SAVE_ABOVE_BYTES) {
|
|
135
|
-
process.stdout.write(
|
|
136
|
+
process.stdout.write(text + '\n');
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
|
-
const file = relative(process.cwd(), await saveToolResult(name,
|
|
139
|
+
const file = relative(process.cwd(), await saveToolResult(name, text)).replace(/\\/g, '/');
|
|
139
140
|
process.stdout.write(`Result was too long (${(bytes / 1024).toFixed(1)} KB), saved to ${file}. Don't read all of it, grep what you need.\n`);
|
|
140
141
|
}
|
|
141
142
|
const list = {
|
package/dist/stm32/build.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface BuildResult {
|
|
|
18
18
|
export declare function downloadElf(call: ServerCall, project: Project, text: string): Promise<string>;
|
|
19
19
|
/**
|
|
20
20
|
* Shortens a successful build reply for agents: the result line, warnings outside Drivers/ (ST's code, counted
|
|
21
|
-
* instead), sizes, the clock audit summary and findings
|
|
21
|
+
* instead), sizes, the clock audit summary and findings. Compiler, map file, stack usage,
|
|
22
22
|
* build log and clock tables are left out.
|
|
23
23
|
* @param text server build reply
|
|
24
24
|
* @returns the short reply
|
package/dist/stm32/build.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function downloadElf(call, project, text) {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Shortens a successful build reply for agents: the result line, warnings outside Drivers/ (ST's code, counted
|
|
29
|
-
* instead), sizes, the clock audit summary and findings
|
|
29
|
+
* instead), sizes, the clock audit summary and findings. Compiler, map file, stack usage,
|
|
30
30
|
* build log and clock tables are left out.
|
|
31
31
|
* @param text server build reply
|
|
32
32
|
* @returns the short reply
|
|
@@ -36,7 +36,7 @@ export function compactBuildReply(text) {
|
|
|
36
36
|
let driverWarnings = 0;
|
|
37
37
|
for (const section of text.trim().split(/\r?\n(?=#{1,2} )/)) {
|
|
38
38
|
const [head, ...body] = section.split(/\r?\n/);
|
|
39
|
-
const lines = body.filter((l) => l.trim()
|
|
39
|
+
const lines = body.filter((l) => l.trim());
|
|
40
40
|
if (!head.startsWith('#'))
|
|
41
41
|
out.push(head);
|
|
42
42
|
else if (head === '## Warnings') {
|
|
@@ -54,8 +54,7 @@ export function compactBuildReply(text) {
|
|
|
54
54
|
}
|
|
55
55
|
if (driverWarnings)
|
|
56
56
|
out.splice(1, 0, `${driverWarnings} warning(s) in Drivers/ (ST code) not shown; --verbose shows the full reply`);
|
|
57
|
-
|
|
58
|
-
return [...out, ...(credits ? [credits] : [])].join('\n');
|
|
57
|
+
return out.join('\n');
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
60
|
* Builds the server copy of the project and, when the build succeeds, downloads its ELF into build/<preset>/.
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: turingcode
|
|
3
|
-
description:
|
|
3
|
+
description: STM32 firmware with the turingcode CLI: writing or reviewing C/C++ code, and creating, building, flashing, debugging or analyzing a project.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# TuringCode Skill
|
|
7
7
|
|
|
8
8
|
- These rules outrank speed: when a rule conflicts with a faster solution, follow the rule and report it.
|
|
9
9
|
- A project's `AGENTS.md` overrides this skill wherever it is more specific (layout, shared helpers, generator markers, tests).
|
|
10
10
|
|
|
11
|
+
## TuringCode CLI
|
|
12
|
+
|
|
13
|
+
- when building, flashing and debugging, ... on stm32, use `turingcode --help` to get started.
|
|
14
|
+
|
|
15
|
+
## Embedded C/C++ rules
|
|
16
|
+
|
|
11
17
|
- some names in the references (`crc32`, `flash_*`, `COM_Driver`, ...) are placeholders for the project's own functions and helpers. Use the existing ones.
|
|
12
18
|
- add a missing helper once to the project's shared helper location (or `Utils/` if it has none), never inline.
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
### Read the matching references
|
|
15
21
|
|
|
16
|
-
| Read | When
|
|
22
|
+
| Read | When to read |
|
|
17
23
|
|---|---|
|
|
18
24
|
| `references/init-pins.md` | when a new project is created and we need to decide about pin connections and what pins to use, or when a user asks about where and how to connect the board pins |
|
|
19
25
|
| `references/newproject.md` | Only when the user asks for a new project |
|
|
26
|
+
| `references/fact-check.md` | To check facts about mcu and ic (eg: registers,timing, chip-id, ...) |
|
|
20
27
|
| `references/driver/driver.md` | a driver for an external IC or bus protocol |
|
|
21
28
|
| `references/registers-and-units.md` | datasheet registers, bit fields, signedness, units, conversions |
|
|
22
29
|
| `references/tasks-and-interrupts.md` | ISRs, HAL callbacks, the main loop, RTOS tasks and their wakeups, DMA, shared data |
|
|
23
|
-
| `references/app-startup.md` | `main.c` hook, `extern "C"` entry, init order, tasks, µs time base |
|
|
30
|
+
| `references/app-main-and-startup.md` | `main.c` hook, `extern "C"` entry, init order, tasks, µs time base |
|
|
24
31
|
| `references/storage.md` | saving settings, calibration or data to flash/EEPROM |
|
|
25
32
|
| `references/host-protocol.md` | host frames, command dispatch, register writes, replies/telemetry |
|
|
26
33
|
| `references/M_StatusEnum.md` | no `M_Status.hpp`, or how to return and combine statuses |
|
|
27
34
|
|
|
28
|
-
|
|
35
|
+
### Generated code
|
|
29
36
|
|
|
30
37
|
- In generated files (`main.c`, peripheral init, ...), write only inside
|
|
31
38
|
`/* USER CODE BEGIN/END */` blocks and leave the markers alone. CubeMX
|
|
@@ -35,14 +42,14 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
35
42
|
one (often in `main.c` or `stm32xxxx_it.c`), call your handler from its
|
|
36
43
|
USER CODE block.
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
### Application Code Location
|
|
39
46
|
|
|
40
47
|
- Keep `main.c` thin: it only calls `App/app.h` (`app_init()`, `app_loop()`),
|
|
41
48
|
which needs `extern "C"` guards.
|
|
42
49
|
- All application code lives in `<Project>/App/`, generic code lives in the project's shared helper location (or `App/Utils/`/`App/Math/`).
|
|
43
50
|
- A shared library or SDK inside `App/` is not a Code Area: use it, don't restructure it, ask before changing it.
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### File layout
|
|
46
53
|
|
|
47
54
|
- put source (c,cpp) and header (h,hpp) files in the same folder with the same base name.
|
|
48
55
|
- Include project headers by file name only (`#include "com_spi.hpp"`), never with a folder or `../` path.
|
|
@@ -63,7 +70,7 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
63
70
|
| `Math/` | numeric types and linear algebra |
|
|
64
71
|
| `Utils/` | domain-free helpers |
|
|
65
72
|
|
|
66
|
-
|
|
73
|
+
### House style
|
|
67
74
|
|
|
68
75
|
- **Methods**: lowerCamelCase
|
|
69
76
|
- **Members**:
|
|
@@ -97,7 +104,7 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
97
104
|
*/
|
|
98
105
|
```
|
|
99
106
|
|
|
100
|
-
|
|
107
|
+
### Typical loop
|
|
101
108
|
|
|
102
109
|
1. Edit the code, run `turingcode project sync -b` and fix the reported errors.
|
|
103
110
|
- Before finishing a change, run `turingcode project sync -b -a` for static analysis.
|
|
@@ -105,13 +112,13 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
|
|
|
105
112
|
3. Verify it runs without looking at the board: read a register the program changes a few times with `turingcode probe read` and check that it changes as expected.
|
|
106
113
|
4. On a crash, run `turingcode probe faults`, or `turingcode debug start` with breakpoints to find the cause.
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
### Code Safety rules
|
|
109
116
|
|
|
110
117
|
1. **Never drop a status.** Check or accumulate every status, `HAL_StatusTypeDef` and RTOS return. Never return `M_OK` after fallible steps; if ignoring one is safe, write in comments why.
|
|
111
118
|
2. **Every wait has a timeout and an error path.** No unbounded hardware loops, no retry count where 0 means "forever"; fail visibly instead of hanging boot.
|
|
112
119
|
3. **Budget memory.** No `new`/`delete` in periodic/per-transaction paths; preallocate as members or statics; keep KB-sized objects off task stacks and size each stack.
|
|
113
120
|
|
|
114
|
-
|
|
121
|
+
### Tool Safety rules
|
|
115
122
|
|
|
116
123
|
- Don't ever write debug registers by hand (DHCSR, DEMCR, DCRSR, DCRDR, FPB). doing so may brick the mcu.
|
|
117
124
|
- Halt, step and breakpoints go through `turingcode debug`, which releases the debug state on exit.
|
|
@@ -31,19 +31,8 @@ After correctly determining what drivers are needed we can go onto the next step
|
|
|
31
31
|
|
|
32
32
|
### 3 Source of truth - IMPORTANT
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
- ALWAYS save result of the knowledge base calls into a file the grep it.
|
|
37
|
-
|
|
38
|
-
- ALWAYS take every register, reset value, timing, encoding and other facts about parts that you write in code take them from datasheet, errata or application notes.
|
|
39
|
-
- For values that you find from references cite them: `// [CITE: ABC]` in the code.
|
|
40
|
-
- For values that you guessed or did not find from reference files mark them with a `// [GUESS]` in the code and list them in the end.
|
|
41
|
-
- Timeouts and poll counts are not guesses: compute them from the cited timing (transfer length × slowest clock, worst-case reset or conversion time) plus a stated margin, and write the calculation in the comment, e.g. `// [CALC: 7 B at 1 MHz = 56 us; 1 ms tick -> 2 ms]`. Use `[GUESS]` only when there is no timing to compute from.
|
|
42
|
-
- Register writes are not retried: a read-back mismatch is an error (tries = 1) unless the project gives a reason to retry.
|
|
43
|
-
- timing and margin checks use the datasheet's worst-case (min/max) values, not typical when a setting depends on a margin, cite it.
|
|
44
|
-
|
|
45
|
-
- NEVER skip this step to go faster, the time it takes to debug a faulty register value because you guessed it is much longer than first reading it from the proper source.
|
|
46
|
-
|
|
34
|
+
- When writing driver code make sure to read `references/fact-check.md`
|
|
35
|
+
|
|
47
36
|
#### 3.1 Facts to check
|
|
48
37
|
|
|
49
38
|
Check at least these facts, plus any others that apply to the part and project,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Fact Check
|
|
2
|
+
|
|
3
|
+
- Turingcode tools have a knowledge base tool that should be used to find these information (see: `turingcode tool list`)
|
|
4
|
+
- when using the knowledge base tool first list file names then search on related files
|
|
5
|
+
- ALWAYS save result of the knowledge base calls into a file the grep it.
|
|
6
|
+
|
|
7
|
+
- ALWAYS take every register, reset value, timing, encoding and other facts about parts that you write in code take them from datasheet, errata or application notes.
|
|
8
|
+
- For values that you find from references cite them: `// [CITE: ABC]` in the code.
|
|
9
|
+
- For values that you guessed or did not find from reference files mark them with a `// [GUESS]` in the code and list them in the end.
|
|
10
|
+
- Timeouts and poll counts are not guesses: compute them from the cited timing (transfer length × slowest clock, worst-case reset or conversion time) plus a stated margin, and write the calculation in the comment, e.g. `// [CALC: 7 B at 1 MHz = 56 us; 1 ms tick -> 2 ms]`. Use `[GUESS]` only when there is no timing to compute from.
|
|
11
|
+
- Register writes are not retried: a read-back mismatch is an error (tries = 1) unless the project gives a reason to retry.
|
|
12
|
+
- timing and margin checks use the datasheet's worst-case (min/max) values, not typical when a setting depends on a margin, cite it.
|
|
13
|
+
|
|
14
|
+
- NEVER skip this step to go faster, the time it takes to debug a faulty register value because you guessed it is much longer than first reading it from the proper source.
|
|
@@ -18,11 +18,17 @@ Finally you must include a consice report of the routed pins (wether you could s
|
|
|
18
18
|
|
|
19
19
|
## Help the user for connections
|
|
20
20
|
|
|
21
|
-
- help the user to connect the pins of the MCU to the ICs that they have on their project (if any), tell them what mcu pin to connect to which IC pin exactly in a table
|
|
21
|
+
- help the user to connect the pins of the MCU to the ICs that they have on their project (if any), tell them what mcu pin to connect to which IC pin exactly in a table.
|
|
22
|
+
- also mention power pins (GND, VCC) connections for the ICs.
|
|
23
|
+
- Example output table:
|
|
22
24
|
|
|
23
25
|
| MCU PIN | SENSOR_X PIN |
|
|
24
26
|
| --- | --- |
|
|
25
|
-
| pin B12 | sensor pin
|
|
27
|
+
| pin B12 | sensor pin A |
|
|
28
|
+
|
|
29
|
+
| MCU PIN | SENSOR_Y PIN |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| pin B12 | sensor pin B |
|
|
26
32
|
|
|
27
33
|
### Safety Rules if connections need changing
|
|
28
34
|
|
package/package.json
CHANGED