truecourse 0.5.12 → 0.6.0-next.0
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/README.md +108 -1
- package/cli.mjs +26006 -3178
- package/package.json +1 -1
- package/public/assets/index-DK_4amwn.css +1 -0
- package/public/assets/index-agCyYXoU.js +765 -0
- package/public/index.html +2 -2
- package/server.mjs +24178 -3157
- package/vscode-extension/README.md +18 -0
- package/vscode-extension/language-configuration.json +21 -0
- package/vscode-extension/package.json +35 -0
- package/vscode-extension/syntaxes/tc.tmLanguage.json +231 -0
- package/public/assets/index-BD5op9En.css +0 -1
- package/public/assets/index-B_bI5uNZ.js +0 -681
package/README.md
CHANGED
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
<a href="https://discord.gg/8AYwf26A"><img src="https://img.shields.io/badge/Discord-join-5865F2?logo=discord&logoColor=white" alt="Discord" /></a>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
|
-
TrueCourse
|
|
20
|
+
TrueCourse catches two classes of defect:
|
|
21
|
+
|
|
22
|
+
- **Code defects** — from the same categories linters cover (unused code, style, missing types) through to ones they don't reach: circular dependencies, layer violations, dead modules, race conditions, security anti-patterns, performance footguns. Tree-sitter analysis combined with LLM review.
|
|
23
|
+
- **Business-logic drift** — when the implementation no longer matches what the docs say it should do. Wrong response codes, missing entity fields, illegal state transitions, bypassed auth, silently-dropped effects, formulas that have lost an input. TrueCourse extracts the contract from your PRDs/ADRs/READMEs and checks the code against it.
|
|
24
|
+
|
|
25
|
+
Two commands, two concerns. `truecourse analyze` produces code findings. `truecourse verify` produces drift findings, once you've materialised the canonical spec and extracted contracts. Both kinds of output are structured — queryable as JSON for agent workflows, rendered in a dashboard for human review.
|
|
21
26
|
|
|
22
27
|
<p align="center">
|
|
23
28
|
<img src="assets/demo.gif" alt="TrueCourse Screenshot" width="100%" />
|
|
@@ -41,6 +46,8 @@ TrueCourse analyzes your codebase architecture and code to detect violations tha
|
|
|
41
46
|
|
|
42
47
|
**Style** — Import ordering, naming conventions, docstring completeness, formatting preferences
|
|
43
48
|
|
|
49
|
+
**Spec / BL drift** — Operations whose responses, status codes, or headers don't match the spec. Entities with missing or mistyped fields. Immutability and lifecycle violations on state machines. Missing or forbidden side-effect emissions. Auth requirements bypassed. Pagination, idempotency, and error-envelope contracts violated. Formulas producing wrong results from drifted inputs.
|
|
50
|
+
|
|
44
51
|
## Quick Start
|
|
45
52
|
|
|
46
53
|
```bash
|
|
@@ -99,6 +106,37 @@ truecourse dashboard stop # Stop the dashboard
|
|
|
99
106
|
truecourse dashboard status # Show dashboard status
|
|
100
107
|
truecourse dashboard logs # Tail dashboard logs (service mode only)
|
|
101
108
|
truecourse dashboard uninstall # Remove the background service
|
|
109
|
+
|
|
110
|
+
# Spec consolidation (docs → canonical spec)
|
|
111
|
+
truecourse spec scan # Read docs, extract claims, surface conflicts, write claims.json
|
|
112
|
+
truecourse spec resolve --all-defaults # Accept the engine's recommended pick on every open conflict
|
|
113
|
+
truecourse spec status # Summary: docs, claims, modules, pending decisions
|
|
114
|
+
|
|
115
|
+
# Agent-friendly conflict surface (all support --json)
|
|
116
|
+
truecourse spec conflicts list # List open conflicts (add --decided / --all)
|
|
117
|
+
truecourse spec conflicts show <id> # Full detail for one conflict
|
|
118
|
+
truecourse spec conflicts pick <id> <index> # Resolve by picking a candidate
|
|
119
|
+
truecourse spec conflicts custom <id> --text "…" # Resolve with a custom answer
|
|
120
|
+
truecourse spec conflicts revoke <id> # Re-open a decided conflict
|
|
121
|
+
truecourse spec chains add --older A --newer B # Manually mark a version chain (escape hatch)
|
|
122
|
+
truecourse spec chains list / remove …
|
|
123
|
+
truecourse spec docs skipped # Docs the LLM relevance filter excluded
|
|
124
|
+
truecourse spec docs include <path> # Force-include a skipped doc
|
|
125
|
+
truecourse spec docs uninclude <path>
|
|
126
|
+
|
|
127
|
+
# Contract extraction (canonical spec → .tc artifacts)
|
|
128
|
+
truecourse contracts generate # Extract / re-extract TC contract files
|
|
129
|
+
truecourse contracts list # List generated contracts
|
|
130
|
+
truecourse contracts validate # Parse + resolve TC files; report unresolved refs
|
|
131
|
+
|
|
132
|
+
# Verification (code against contracts) — separate command, not part of `analyze`
|
|
133
|
+
truecourse verify # Full run: stashes dirty tree (prompts), writes verifier/runs + LATEST + history
|
|
134
|
+
truecourse verify --diff # Git diff: working-tree drifts vs committed baseline (added/resolved/unchanged)
|
|
135
|
+
truecourse verify --stash / --no-stash # Pre-approve / skip stashing on a full run
|
|
136
|
+
|
|
137
|
+
# Inference (code → inferred contracts) — reverse-engineer undocumented decisions
|
|
138
|
+
truecourse infer # Write inferred .tc files to contracts/_inferred/
|
|
139
|
+
truecourse infer --dry-run # Report what would be written, touch nothing
|
|
102
140
|
```
|
|
103
141
|
|
|
104
142
|
### Rules
|
|
@@ -134,6 +172,75 @@ In the dashboard you can also toggle rules from the Rules panel
|
|
|
134
172
|
(Shield icon in the top-right) or silence a noisy rule directly from
|
|
135
173
|
any violation card via the **⋮** menu → **Disable rule for this repo**.
|
|
136
174
|
|
|
175
|
+
### Spec → Contracts → Verify (BL drift detection)
|
|
176
|
+
|
|
177
|
+
In addition to the rule-based static analysis, TrueCourse builds a
|
|
178
|
+
machine-readable spec from your docs and verifies the code against it.
|
|
179
|
+
Three stages run in order, each producing artifacts the next stage
|
|
180
|
+
consumes:
|
|
181
|
+
|
|
182
|
+
**1. Spec consolidation** — Walks every `.md` file in the repo (PRDs,
|
|
183
|
+
ADRs, RFCs, READMEs, design notes; `.truecourse/`, `node_modules/`,
|
|
184
|
+
`.git/` etc. are skipped). An LLM relevance filter drops obvious
|
|
185
|
+
non-spec material (task lists, research logs, AI agent prompts). For
|
|
186
|
+
the docs that remain, an LLM extracts structured claims per block and
|
|
187
|
+
groups them by `(topic, subject)`. Agreements auto-merge; genuine
|
|
188
|
+
disagreements surface as **conflicts** in the dashboard with a plain-
|
|
189
|
+
English explanation of what differs. Output:
|
|
190
|
+
`.truecourse/specs/claims.json` (the structured snapshot every
|
|
191
|
+
downstream stage consumes — modules + per-claim content + provenance)
|
|
192
|
+
and `.truecourse/specs/decisions.json` (the user's resolutions, version
|
|
193
|
+
chains, and overrides — committable).
|
|
194
|
+
|
|
195
|
+
Auto-resolve rules cut the conflict count substantially: byte-
|
|
196
|
+
identical content, status-tolerant duplicates, same-file consolidation,
|
|
197
|
+
docKind-dominance pickups, and detected version chains.
|
|
198
|
+
[Plan](docs/contracts/PLAN_CONFLICT_RESOLUTION.md).
|
|
199
|
+
|
|
200
|
+
**2. Contract extraction** — Reads `claims.json` and emits
|
|
201
|
+
`.truecourse/contracts/*.tc` files in a hand-written DSL
|
|
202
|
+
covering 13 artifact kinds: `operation`, `entity`, `enum`,
|
|
203
|
+
`state-machine`, `auth-requirement`, `authorization-rule`,
|
|
204
|
+
`error-envelope`, `pagination-contract`, `idempotency-contract`,
|
|
205
|
+
`effect-group`, `formula`, plus `unenforceable-obligation` for prose
|
|
206
|
+
the verifier can't structurally check. A post-extraction **repair
|
|
207
|
+
pass** validates structural completeness and re-prompts the LLM to fix
|
|
208
|
+
deficient artifacts (missing forbids clauses, broad role selectors,
|
|
209
|
+
unresolved cross-references). On the bundled fixture this hits
|
|
210
|
+
**22/22 planted bugs with 0 false positives**.
|
|
211
|
+
|
|
212
|
+
**3. Verification** — Parses the contracts, walks the source tree, and runs per-kind comparators (operations, entities, state machines, etc.). Drifts surface in the dashboard alongside code violations and from the CLI as JSON. Verification is its own command — `truecourse verify` — not a stage of `truecourse analyze`, because the two pipelines answer different questions, have different prerequisites, and run on different time scales.
|
|
213
|
+
|
|
214
|
+
**4. Inference** — The mirror image of verification. `verify` asks "the spec says X — does the code do X?"; `truecourse infer` asks "the code does X — does any spec mention X?". It runs code-side extractors *un-driven by a spec*, subtracts whatever the authored contracts already cover, and writes the remainder to `.truecourse/contracts/_inferred/` as `.tc` artifacts tagged with an `inferred-from "<code-path>" a..b` provenance line and a `confidence` level (instead of the authored `origin SOURCE "section" a..b`). It covers the full artifact spread — undocumented endpoints, entities (from ORM schema), enums, named constants, query policies, emitted events, computed formulas, architecture choices, and the cross-cutting conventions (auth, pagination, idempotency, error envelope). Confidence reflects fidelity: a value read straight from code is `high`; a synthesized convention (e.g. an assumed auth scheme, or a state machine whose transitions can't be reconstructed) is a `low`-confidence draft to confirm. Because coverage is computed from authored contracts only, a decision drops out of `_inferred/` the moment it's documented — the directory is a shrinking backlog of "decisions your code made that your docs never recorded". Inferred contracts are descriptive, not prescriptive, so `verify` skips `_inferred/` by default.
|
|
215
|
+
|
|
216
|
+
**Storage layout** (per repo, under `.truecourse/`):
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
.truecourse/
|
|
220
|
+
├── specs/ ← canonical spec (committable)
|
|
221
|
+
│ ├── claims.json ← structured snapshot: modules + claims + provenance
|
|
222
|
+
│ └── decisions.json ← user resolutions + version chains + manual includes
|
|
223
|
+
├── contracts/ ← generated TC contract artifacts (gitignored by default)
|
|
224
|
+
│ └── _inferred/ ← reverse-engineered, undocumented decisions (`truecourse infer`)
|
|
225
|
+
├── analyses/ ← analysis snapshots (gitignored)
|
|
226
|
+
├── LATEST.json ← analyze current-state view (committable)
|
|
227
|
+
├── verifier/ ← drift store (mirrors analyze; `truecourse verify`)
|
|
228
|
+
│ ├── runs/ ← per-run drift snapshots (gitignored)
|
|
229
|
+
│ ├── LATEST.json ← current drift state + diff baseline (committable)
|
|
230
|
+
│ ├── history.json ← per-run summaries (gitignored)
|
|
231
|
+
│ └── diff.json ← current-vs-baseline drift diff (gitignored)
|
|
232
|
+
└── .cache/ ← LLM + slice cache (gitignored)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The dashboard's Spec tab walks you through resolving each conflict
|
|
236
|
+
(pick / write custom / mark superseded / include skipped doc). The
|
|
237
|
+
same actions are also available via the CLI subcommands shown above
|
|
238
|
+
(every command supports `--json` for agent-driven workflows).
|
|
239
|
+
|
|
240
|
+
**Prerequisite:** the contract extractor and the conflict resolver
|
|
241
|
+
shell out to the Claude Code CLI (`claude -p`). Install Claude Code
|
|
242
|
+
and sign in once before running `spec scan` or `contracts generate`.
|
|
243
|
+
|
|
137
244
|
### Git Hooks
|
|
138
245
|
|
|
139
246
|
TrueCourse can install a pre-commit hook that blocks commits introducing new violations at or above a configured severity:
|