Skip to content

Commit ad9ef42

Browse files
committed
docs: adopt 立意 (liyi) intent spec convention
Add 立意 pattern support for making code intent explicit and reviewable: - Extend AGENTS.md with 立意 workflow section - Add .liyiignore for node_modules and generated files - Add example sidecar for generateDatabase.ts with 4 item specs - Add @liyi:requirement marker for data-integrity requirement Original prompt: > Now for something different -- try to make https://github.com/loongson-community/loongfans adopt the 立意 design pattern. AI-assisted-by: Kimi K2.5 (OpenClaw)
1 parent a00efd6 commit ad9ef42

4 files changed

Lines changed: 126 additions & 0 deletions

File tree

.liyiignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
.vitepress/dist/
6+
7+
# Generated files
8+
*.generated.ts
9+
*.generated.js
10+
11+
# Lock files
12+
pnpm-lock.yaml
13+
14+
# Data files (content, not code)
15+
data/

AGENTS.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,74 @@ Every commit must pass the relevant checks below **before** being finalized. Des
135135
## Notes on dev server behavior
136136

137137
VitePress HMR is enabled, but dynamic route metadata may not update when data files are added or removed. Restart the dev server if route titles or page lists do not refresh.
138+
139+
---
140+
141+
## 立意 (Lìyì) — Intent Specs
142+
143+
This repository adopts the [立意 (Lìyì)](https://github.com/liyi-run/liyi) convention for making intent explicit, persistent, and reviewable in AI-assisted development.
144+
145+
### What is 立意
146+
147+
For every non-trivial code item (function, class, complex transformation), we maintain a sidecar file (`<filename>.liyi.jsonc`) that documents:
148+
- **Intent**: What the item SHOULD do (not what it currently does)
149+
- **Source span**: Line range in the source file
150+
- **Review status**: Whether a human has reviewed the intent
151+
152+
### When to write intent specs
153+
154+
Write or update a sidecar entry when:
155+
- Creating new transformation functions in `src/node/`
156+
- Adding complex validation logic
157+
- Modifying data pipeline behavior
158+
- The function's contract is subtle or has edge cases
159+
160+
Skip intent specs for:
161+
- Simple getters/setters
162+
- One-line wrappers
163+
- Obvious boilerplate
164+
165+
### Marker conventions
166+
167+
Use these markers in source code:
168+
169+
- `// @liyi:requirement(<name>)` — Declare a named requirement that multiple items depend on
170+
- `// @liyi:related <name>` — Mark that a function participates in a requirement
171+
- `// @liyi:trivial` — Opt out of intent specs for simple items
172+
- `// @liyi:intent <prose>` — Inline intent (alternative to sidecar)
173+
174+
### Workflow
175+
176+
1. **During development**: Write intent to the sidecar (or use `@liyi:intent` marker)
177+
2. **Before commit**: Run `liyi check` to verify specs are current
178+
3. **Review**: Humans set `"reviewed": true` in sidecar after reviewing intent
179+
4. **Staleness detection**: CI runs `liyi check --fail-on-stale` to catch drift
180+
181+
### File naming
182+
183+
Sidecar files follow the pattern: `<source_filename>.liyi.jsonc`
184+
185+
Examples:
186+
- `src/node/plugins/loongfans-data/generateDatabase.ts``generateDatabase.ts.liyi.jsonc`
187+
- `src/client/components/devices/DeviceCard.vue``DeviceCard.vue.liyi.jsonc`
188+
189+
### Schema
190+
191+
Sidecar files use the 立意 v0.1 schema:
192+
193+
```jsonc
194+
{
195+
"version": "0.1",
196+
"source": "relative/path/to/file.ts",
197+
"specs": [
198+
{
199+
"item": "functionName",
200+
"intent": "Transform raw YAML chip data into validated ChipInfoDB, ensuring all required fields are present and foreign key references resolve.",
201+
"source_span": [45, 89],
202+
"reviewed": false
203+
}
204+
]
205+
}
206+
```
207+
208+
See the [liyi documentation](https://github.com/liyi-run/liyi) for full schema details.

src/node/plugins/loongfans-data/generateDatabase.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { parse as yamlParse } from "yaml"
88
import { createGenerator, type Config } from "ts-json-schema-generator"
99
import { createMarkdownRenderer } from "vitepress"
1010

11+
// @liyi:requirement(data-integrity)
12+
// All data transformations must validate input against schemas, preserve type
13+
// safety, and ensure foreign key references resolve correctly.
14+
1115
import type {
1216
BiweeklyDB,
1317
ChipInfoDB,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// liyi v0.1 spec file
2+
{
3+
"version": "0.1",
4+
"source": "src/node/plugins/loongfans-data/generateDatabase.ts",
5+
"specs": [
6+
{
7+
"requirement": "data-integrity",
8+
"source_span": [1, 4],
9+
"intent": "All data transformations must validate input against schemas, preserve type safety, and ensure foreign key references resolve correctly."
10+
},
11+
{
12+
"item": "validate",
13+
"intent": "Validate parsed YAML data against JSON schema using Ajv. Throw ValidationError with descriptive message including file name and validation errors if schema check fails.",
14+
"source_span": [79, 99],
15+
"reviewed": false
16+
},
17+
{
18+
"item": "generateChipsDB",
19+
"intent": "Transform raw chip YAML data into ChipInfoDB. Validate CPU and chipset entries against schemas, collect into database keyed by unique identifiers. Ensure all references between chips and chipsets are internally consistent.",
20+
"source_span": [145, 210],
21+
"reviewed": false
22+
},
23+
{
24+
"item": "generateDevicesDB",
25+
"intent": "Transform device YAML metadata and markdown content into DeviceInfoDB. Merge per-device markdown with YAML metadata, resolve family configurations, and produce searchable device database with rendered HTML content.",
26+
"source_span": [280, 380],
27+
"reviewed": false
28+
},
29+
{
30+
"item": "generateDownloadsDB",
31+
"intent": "Collect all download resources from YAML files, render markdown descriptions, and organize by resource key for efficient lookup by device pages.",
32+
"source_span": [390, 450],
33+
"reviewed": false
34+
}
35+
]
36+
}

0 commit comments

Comments
 (0)