@turingcode/cli 0.3.19 → 0.3.22

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 (24) hide show
  1. package/dist/cli/create-cli.js +13 -12
  2. package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/SKILL.md +33 -10
  3. package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code/references/app-startup.md → turingcode/references/app-main-and-startup.md} +1 -1
  4. package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/driver/driver.md +2 -13
  5. package/mods/claude/turingcode-skills/skills/turingcode/references/fact-check.md +14 -0
  6. package/mods/claude/turingcode-skills/skills/{turingcode-cli → turingcode}/references/newproject.md +2 -0
  7. package/package.json +1 -1
  8. package/mods/claude/turingcode-skills/skills/turingcode-cli/SKILL.md +0 -48
  9. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/M_StatusEnum.md +0 -0
  10. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/BusMutexRegistry.hpp +0 -0
  11. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/COM_Driver.hpp +0 -0
  12. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/COM_I2C.hpp +0 -0
  13. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/COM_SPI.hpp +0 -0
  14. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/COM_USART.hpp +0 -0
  15. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/code/Util_MutexManager.hpp +0 -0
  16. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/driver/driver_ic.md +0 -0
  17. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/driver/driver_protocol.md +0 -0
  18. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/driver/driver_rtos.md +0 -0
  19. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/driver/driver_test.md +0 -0
  20. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/host-protocol.md +0 -0
  21. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/init-pins.md +0 -0
  22. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/registers-and-units.md +0 -0
  23. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/storage.md +0 -0
  24. /package/mods/claude/turingcode-skills/skills/{turingcode-firmware-code → turingcode}/references/tasks-and-interrupts.md +0 -0
@@ -44,18 +44,19 @@ export function createCli(args) {
44
44
  .scriptName('turingcode')
45
45
  .usage("Usage: $0 <command> [options]; $0 <command> --help for each command's usage")
46
46
  .epilogue([
47
- 'Turing Code toolkit for AI agents.',
48
- '- Server tools: `tool list` to find a tool, `tool describe <name>` for its arguments,',
49
- ' `tool call <name> --args ...` to run it.',
50
- '- Tables: check Markdown or CSV tables against a contract (a JSON file of tables, columns and',
51
- ' MongoDB-style checks): `contract describe` shows the tables to write; `table check` until PASS.',
52
- ' Contract format: $0 contract --help.',
53
- '- STM32 projects: `project sync -b` to build on the server, `syntax-check [paths..]` for a clang syntax',
54
- ' check of the project or of loose files, `probe program` to flash the board,',
55
- ' `probe read` and `probe peripheral` to inspect it, `debug start` ... `debug stop` for a live debug',
56
- ' session; `status` shows the project and the installed debug tools.',
57
- '- Agent skills: `install-skills` copies them into ~/.agents/skills (Codex, OpenCode);',
58
- ' `install-mods` installs them into Claude Code as the turingcode-skills plugin.',
47
+ '`turingcode` handles project setup, building, configuration, flashing and debugging.',
48
+ '',
49
+ 'Each command group has its own `--help` with flags and examples.',
50
+ ' Read it before using commands in that area.',
51
+ '',
52
+ '- Run `turingcode status` first.',
53
+ '',
54
+ 'Most useful commands:',
55
+ '- `project sync -b` to build on the server',
56
+ '- `probe program` to flash the board',
57
+ '- `probe --help` to learn more about debugging, breakpoints, stepping, ...',
58
+ '- Server mcp tools: `tool list` to find mcp tools on the turingcode server,',
59
+ ' then `tool call <name> --args ...` to run it.',
59
60
  ].join('\n'))
60
61
  .command(commands)
61
62
  .demandCommand(1, `Name a command: ${names.slice(0, -1).join(', ')} or ${names.at(-1)}`)
@@ -1,30 +1,38 @@
1
1
  ---
2
- name: turingcode-firmware-code
3
- description: Coding rules for embedded C/C++ firmware on STM32. Use whenever writing, editing, reviewing or organizing .c, .cpp, .h or .hpp files for a microcontroller or sensor driver.
2
+ name: turingcode
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
- # Embedded C/C++ rules
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
- ## Read the matching references
20
+ ### Read the matching references
15
21
 
16
22
  | Read | When changing or making |
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 |
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, ...) |
19
27
  | `references/driver/driver.md` | a driver for an external IC or bus protocol |
20
28
  | `references/registers-and-units.md` | datasheet registers, bit fields, signedness, units, conversions |
21
29
  | `references/tasks-and-interrupts.md` | ISRs, HAL callbacks, the main loop, RTOS tasks and their wakeups, DMA, shared data |
22
- | `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 |
23
31
  | `references/storage.md` | saving settings, calibration or data to flash/EEPROM |
24
32
  | `references/host-protocol.md` | host frames, command dispatch, register writes, replies/telemetry |
25
33
  | `references/M_StatusEnum.md` | no `M_Status.hpp`, or how to return and combine statuses |
26
34
 
27
- ## Generated code
35
+ ### Generated code
28
36
 
29
37
  - In generated files (`main.c`, peripheral init, ...), write only inside
30
38
  `/* USER CODE BEGIN/END */` blocks and leave the markers alone. CubeMX
@@ -34,14 +42,14 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
34
42
  one (often in `main.c` or `stm32xxxx_it.c`), call your handler from its
35
43
  USER CODE block.
36
44
 
37
- ## Application Code Location
45
+ ### Application Code Location
38
46
 
39
47
  - Keep `main.c` thin: it only calls `App/app.h` (`app_init()`, `app_loop()`),
40
48
  which needs `extern "C"` guards.
41
49
  - All application code lives in `<Project>/App/`, generic code lives in the project's shared helper location (or `App/Utils/`/`App/Math/`).
42
50
  - A shared library or SDK inside `App/` is not a Code Area: use it, don't restructure it, ask before changing it.
43
51
 
44
- ## File layout
52
+ ### File layout
45
53
 
46
54
  - put source (c,cpp) and header (h,hpp) files in the same folder with the same base name.
47
55
  - Include project headers by file name only (`#include "com_spi.hpp"`), never with a folder or `../` path.
@@ -62,7 +70,7 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
62
70
  | `Math/` | numeric types and linear algebra |
63
71
  | `Utils/` | domain-free helpers |
64
72
 
65
- ## House style
73
+ ### House style
66
74
 
67
75
  - **Methods**: lowerCamelCase
68
76
  - **Members**:
@@ -96,8 +104,23 @@ description: Coding rules for embedded C/C++ firmware on STM32. Use whenever wri
96
104
  */
97
105
  ```
98
106
 
99
- ## Safety rules
107
+ ### Typical loop
108
+
109
+ 1. Edit the code, run `turingcode project sync -b` and fix the reported errors.
110
+ - Before finishing a change, run `turingcode project sync -b -a` for static analysis.
111
+ 2. Flash with `turingcode probe program`.
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.
113
+ 4. On a crash, run `turingcode probe faults`, or `turingcode debug start` with breakpoints to find the cause.
114
+
115
+ ### Code Safety rules
100
116
 
101
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.
102
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.
103
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.
120
+
121
+ ### Tool Safety rules
122
+
123
+ - Don't ever write debug registers by hand (DHCSR, DEMCR, DCRSR, DCRDR, FPB). doing so may brick the mcu.
124
+ - Halt, step and breakpoints go through `turingcode debug`, which releases the debug state on exit.
125
+ - NEVER touch RDP without asking first.
126
+ - Level 1 → 0 mass-erases the flash, and Level 2 is permanent.
@@ -9,7 +9,7 @@
9
9
 
10
10
  ```c
11
11
  #ifdef __cplusplus
12
- extern "C" {
12
+ extern "C" {
13
13
  #endif
14
14
  typedef struct {
15
15
  SPI_HandleTypeDef* spi_1;
@@ -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
- - Turingcode tools have a knowledge base tool that you should use to find these information (see: `turingcode tool list`)
35
- - when using the knowledge base tool first list file names then search on related files
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.
@@ -2,6 +2,8 @@
2
2
 
3
3
  Only when the user asks for a new project.
4
4
 
5
+ ## Workflow
6
+
5
7
  1. Run `turingcode probe info` to identify the connected chip.
6
8
  2. The package (pin count) can't be read over SWD, so ask the user
7
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turingcode/cli",
3
- "version": "0.3.19",
3
+ "version": "0.3.22",
4
4
  "description": "Turing Code toolkit for AI agents: check Markdown/CSV tables against table contracts, e.g. `turingcode table check`.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,48 +0,0 @@
1
- ---
2
- name: turingcode-cli
3
- description: use for creating, build, debug, program, flash or analyze any STM32 project
4
- ---
5
-
6
- # turingcode CLI for STM32
7
-
8
- `turingcode` handles the whole STM32 workflow: project setup, building, configuration, flashing and debugging. Use it instead of calling probe-rs or STM32_Programmer_CLI directly.
9
-
10
- ## Start here
11
-
12
- - Run `turingcode status` first. It shows the project, token, last build, debug session and installed probe tools.
13
-
14
- ## Commands
15
-
16
- Each command group has its own `--help` with flags and examples. Read it before using commands in that area.
17
-
18
- - `turingcode project --help`: sync, build, pull, regen and static analysis.
19
- - `turingcode syntax-check --help`: clang syntax check of the project, or of loose files, folders or globs.
20
- - `turingcode probe --help`: flash, reset, read memory or registers, decode faults, recover a stuck probe.
21
- - `turingcode debug --help`: breakpoints, stepping, stack, variables.
22
-
23
- ## Server tools
24
-
25
- Pins, clocks, `.ioc` edits, register lookup and the datasheet knowledge base (MCUs and components) run as server tools:
26
-
27
- - `turingcode tool list` shows the available tools.
28
- - `turingcode tool call <name> --args '<json>' > result.md` runs one.
29
- - On Windows PowerShell or cmd, inline JSON loses its quotes: write the JSON to a `.json` file and pass `--args args.json`.
30
-
31
- ## New project
32
-
33
- Only when the user asks for a new project: follow [references/newproject.md](references/newproject.md).
34
-
35
- ## Typical loop
36
-
37
- 1. Edit the code, run `turingcode project sync -b` and fix the reported errors.
38
- - Before finishing a change, run `turingcode project sync -b -a` for static analysis.
39
- 2. Flash with `turingcode probe program`.
40
- 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.
41
- 4. On a crash, run `turingcode probe faults`, or `turingcode debug start` with breakpoints to find the cause.
42
-
43
- ## CRITICAL Safety rules
44
-
45
- - Don't ever write debug registers by hand (DHCSR, DEMCR, DCRSR, DCRDR, FPB). doing so may brick the mcu.
46
- - Halt, step and breakpoints go through `turingcode debug`, which releases the debug state on exit.
47
- - NEVER touch RDP without asking first.
48
- - Level 1 → 0 mass-erases the flash, and Level 2 is permanent.