@ai-content-space/loopx 0.1.9 → 0.2.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/AGENTS.md +50 -0
- package/README.md +59 -446
- package/README.zh-CN.md +59 -457
- package/docs/loopx/design/loopx-skill-suite-v1-design.md +73 -0
- package/docs/loopx/plans/loopx-skill-suite-v1-implementation.md +77 -0
- package/package.json +5 -2
- package/plugins/loopx/.codex-plugin/plugin.json +4 -4
- package/plugins/loopx/scripts/plugin-install.test.mjs +20 -20
- package/plugins/loopx/skills/clarify/SKILL.md +38 -311
- package/plugins/loopx/skills/debug/SKILL.md +1 -1
- package/plugins/loopx/skills/exec/SKILL.md +71 -0
- package/plugins/loopx/skills/finish/SKILL.md +254 -0
- package/plugins/loopx/skills/fix-review/SKILL.md +216 -0
- package/plugins/loopx/skills/go-style/SKILL.md +1 -1
- package/plugins/loopx/skills/kratos/SKILL.md +1 -1
- package/plugins/loopx/skills/plan/SKILL.md +136 -258
- package/plugins/loopx/skills/refactor-plan/SKILL.md +71 -0
- package/plugins/loopx/skills/review/SKILL.md +72 -105
- package/plugins/loopx/skills/review/code-reviewer.md +168 -0
- package/plugins/loopx/skills/spec/DESIGN_SPEC_TEMPLATE.md +323 -0
- package/plugins/loopx/skills/spec/SKILL.md +76 -0
- package/plugins/loopx/skills/subagent-exec/SKILL.md +282 -0
- package/plugins/loopx/skills/subagent-exec/agents/openai.yaml +3 -0
- package/plugins/loopx/skills/subagent-exec/code-quality-reviewer-prompt.md +25 -0
- package/plugins/loopx/skills/subagent-exec/codex-subagents.md +37 -0
- package/plugins/loopx/skills/subagent-exec/implementer-prompt.md +113 -0
- package/plugins/loopx/skills/subagent-exec/spec-reviewer-prompt.md +61 -0
- package/plugins/loopx/skills/tdd/SKILL.md +1 -1
- package/plugins/loopx/skills/verify/SKILL.md +1 -1
- package/scripts/claude-workflow-hook.mjs +109 -0
- package/scripts/codex-workflow-hook.mjs +2 -5
- package/scripts/install-skills.mjs +3 -3
- package/scripts/verify-skills.mjs +32 -1
- package/skills/RESOLVER.md +26 -17
- package/skills/clarify/SKILL.md +38 -311
- package/skills/debug/SKILL.md +1 -1
- package/skills/exec/SKILL.md +71 -0
- package/skills/finish/SKILL.md +254 -0
- package/skills/fix-review/SKILL.md +216 -0
- package/skills/go-style/SKILL.md +1 -1
- package/skills/kratos/SKILL.md +1 -1
- package/skills/plan/SKILL.md +136 -258
- package/skills/refactor-plan/SKILL.md +71 -0
- package/skills/review/SKILL.md +72 -105
- package/skills/review/code-reviewer.md +168 -0
- package/skills/spec/DESIGN_SPEC_TEMPLATE.md +323 -0
- package/skills/spec/SKILL.md +76 -0
- package/skills/subagent-exec/SKILL.md +282 -0
- package/skills/subagent-exec/agents/openai.yaml +3 -0
- package/skills/subagent-exec/code-quality-reviewer-prompt.md +25 -0
- package/skills/subagent-exec/codex-subagents.md +37 -0
- package/skills/subagent-exec/implementer-prompt.md +113 -0
- package/skills/subagent-exec/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +1 -1
- package/skills/verify/SKILL.md +1 -1
- package/src/autopilot-runtime.mjs +1 -1
- package/src/cli.mjs +79 -5
- package/src/context-manifest.mjs +2 -2
- package/src/html-views.mjs +457 -95
- package/src/install-discovery.mjs +210 -6
- package/src/next-skill.mjs +2 -4
- package/src/plan-runtime.mjs +572 -93
- package/src/runtime-maintenance.mjs +60 -16
- package/src/workflow.mjs +989 -65
- package/templates/architecture.md +58 -16
- package/templates/development-plan.md +42 -12
- package/plugins/loopx/skills/archive/SKILL.md +0 -55
- package/plugins/loopx/skills/autopilot/SKILL.md +0 -93
- package/plugins/loopx/skills/build/SKILL.md +0 -228
- package/skills/archive/SKILL.md +0 -55
- package/skills/autopilot/SKILL.md +0 -93
- package/skills/build/SKILL.md +0 -228
package/skills/review/SKILL.md
CHANGED
|
@@ -1,139 +1,106 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review
|
|
3
|
-
description: "
|
|
4
|
-
when_to_use: "
|
|
3
|
+
description: "Dispatches a loopx code reviewer subagent against a concrete git range and requirements. Not for implementation, planning, or unresolved review scope."
|
|
4
|
+
when_to_use: "request code review, completed task review, major feature review, pre-merge review, subagent code quality check"
|
|
5
5
|
metadata:
|
|
6
|
-
version: "0.
|
|
7
|
-
argument-hint: "<execution-record path or workflow slug>"
|
|
6
|
+
version: "0.2.0"
|
|
8
7
|
---
|
|
9
8
|
|
|
10
|
-
#
|
|
9
|
+
# Review
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Dispatch a code reviewer subagent to catch issues before they cascade. The reviewer gets precisely crafted context for evaluation — never your session's history. This keeps the reviewer focused on the work product, not your thought process, and preserves your own context for continued work.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
**Core principle:** Review early, review often.
|
|
15
14
|
|
|
16
|
-
##
|
|
15
|
+
## When to Request Review
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
**Mandatory:**
|
|
18
|
+
- After each task in subagent-exec
|
|
19
|
+
- After completing major feature
|
|
20
|
+
- Before merge to main
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
**Optional but valuable:**
|
|
23
|
+
- When stuck (fresh perspective)
|
|
24
|
+
- Before refactoring (baseline check)
|
|
25
|
+
- After fixing complex bug
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
## How to Request
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
When present, use `.loopx/config.json` as supporting context for project-native verification commands, existing AI rule files, and existing spec sources. Do not treat those external or pre-existing sources as replacements for the loopx execution record and review artifact.
|
|
29
|
-
|
|
30
|
-
## Expected Outputs
|
|
31
|
-
|
|
32
|
-
- a review artifact tied to the run being evaluated
|
|
33
|
-
- verdict and rationale
|
|
34
|
-
- code review findings for the implementation diff, including file / line references when issues are found
|
|
35
|
-
- architecture-smell findings from the internal review lane, focused on module depth, test seams, domain vocabulary, duplicated rules, and plan architecture alignment
|
|
36
|
-
- rollback/fix guidance when execution is incomplete, unstable, or needs another iteration
|
|
37
|
-
- an explicit `Next:` block with the exact next skill command when more work remains
|
|
38
|
-
|
|
39
|
-
## User Notification Language
|
|
40
|
-
|
|
41
|
-
The final user-facing review result must be written in Chinese.
|
|
42
|
-
|
|
43
|
-
Use stable machine values only where they are commands, file paths, JSON/state fields, or exact verdict identifiers. The human-readable summary, rationale, findings, residual risks, rollback guidance, and next-step instruction must be Chinese.
|
|
44
|
-
|
|
45
|
-
## Decision Boundary
|
|
46
|
-
|
|
47
|
-
- Use this only after build has produced execution and verification evidence for a specific run.
|
|
48
|
-
- Stop here if review evidence is incomplete. `review` remains an independent gate and does not auto-complete the workflow.
|
|
49
|
-
- Review must include code review of the build-owned implementation diff. Do not limit review to artifact/schema checks.
|
|
50
|
-
- Review should compare verification evidence against project-native commands recorded in `.loopx/config.json` when available, while still accepting stronger task-specific verification from the approved plan.
|
|
51
|
-
- Review must include the architecture-smell lane as part of review evidence. This is not a new workflow stage and must not create extra user steps.
|
|
52
|
-
- Review must compare the execution scope against the approved workflow scope. If `execution-record.md` declares non-empty `remaining_scope`, `completion_claim` other than `full`, or a mismatch between `planned_scope` and `implemented_scope`, review must return no-go and route to build or plan. A partial slice may be accepted as useful work, but it must not be approved as full workflow completion.
|
|
53
|
-
- Review must compare implementation evidence against the original source requirements and `.loopx/workflows/<slug>/requirement-traceability.md`, not only against the generated plan. If the traceability matrix is missing, partial, or contradicted by code/tests, route to `review -> plan` or `review -> clarify` depending on whether the plan or requirements are wrong.
|
|
54
|
-
- Code review findings should focus on real bugs, regressions, missing tests, broken contracts, security/data-integrity risks, and user-visible behavior gaps.
|
|
55
|
-
- If code review finds blocking high or medium severity issues, return a no-go verdict and rollback guidance instead of approving completion.
|
|
56
|
-
- If architecture-smell findings are only advisory, record them as warnings without blocking. Block only when module seams, testability, domain boundaries, duplicated rules, or plan architecture assumptions are materially wrong.
|
|
57
|
-
- Route request-changes by problem type:
|
|
58
|
-
- implementation bugs, missing tests, small contract fixes: `review -> build`
|
|
59
|
-
- wrong plan, wrong architecture, unresolved execution inputs: `review -> plan`
|
|
60
|
-
- unclear product requirements or decision boundaries: `review -> clarify`
|
|
61
|
-
- Do not route implementation-only fixes back to plan unless the plan itself is wrong.
|
|
62
|
-
|
|
63
|
-
## Next Step Format
|
|
64
|
-
|
|
65
|
-
Every no-go review result must end with a concrete next command block.
|
|
66
|
-
|
|
67
|
-
For implementation fixes:
|
|
68
|
-
|
|
69
|
-
Default implementation-fix handoff:
|
|
70
|
-
|
|
71
|
-
```text
|
|
72
|
-
Next:
|
|
73
|
-
$build --from-review .loopx/workflows/<slug>/review-report.md
|
|
29
|
+
**1. Get git SHAs:**
|
|
30
|
+
```bash
|
|
31
|
+
BASE_SHA=$(git rev-parse HEAD~1) # or origin/main
|
|
32
|
+
HEAD_SHA=$(git rev-parse HEAD)
|
|
74
33
|
```
|
|
75
34
|
|
|
76
|
-
|
|
35
|
+
**2. Dispatch code reviewer subagent:**
|
|
77
36
|
|
|
78
|
-
|
|
37
|
+
Use the platform's native subagent mechanism when available and fill template at `code-reviewer.md`.
|
|
79
38
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
39
|
+
**Placeholders:**
|
|
40
|
+
- `{DESCRIPTION}` - Brief summary of what you built
|
|
41
|
+
- `{PLAN_OR_REQUIREMENTS}` - What it should do
|
|
42
|
+
- `{BASE_SHA}` - Starting commit
|
|
43
|
+
- `{HEAD_SHA}` - Ending commit
|
|
83
44
|
|
|
84
|
-
|
|
45
|
+
**3. Act on feedback:**
|
|
46
|
+
- Fix Critical issues immediately
|
|
47
|
+
- Fix Important issues before proceeding
|
|
48
|
+
- Note Minor issues for later
|
|
49
|
+
- Push back if reviewer is wrong (with reasoning)
|
|
85
50
|
|
|
86
|
-
|
|
87
|
-
Next:
|
|
88
|
-
loopx approve <slug> --from review --to plan
|
|
89
|
-
$plan <slug>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
For clarify fixes:
|
|
51
|
+
## Example
|
|
93
52
|
|
|
94
|
-
```text
|
|
95
|
-
Next:
|
|
96
|
-
loopx approve <slug> --from review --to clarify
|
|
97
|
-
$clarify <slug>
|
|
98
53
|
```
|
|
54
|
+
[Just completed Task 2: Add verification function]
|
|
99
55
|
|
|
100
|
-
|
|
56
|
+
You: Let me request code review before proceeding.
|
|
101
57
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
$archive <slug>
|
|
105
|
-
```
|
|
58
|
+
BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}')
|
|
59
|
+
HEAD_SHA=$(git rev-parse HEAD)
|
|
106
60
|
|
|
107
|
-
|
|
61
|
+
[Dispatch code reviewer subagent]
|
|
62
|
+
DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types
|
|
63
|
+
PLAN_OR_REQUIREMENTS: Task 2 from docs/loopx/plans/deployment-plan.md
|
|
64
|
+
BASE_SHA: a7981ec
|
|
65
|
+
HEAD_SHA: 3df7661
|
|
108
66
|
|
|
109
|
-
|
|
67
|
+
[Subagent returns]:
|
|
68
|
+
Strengths: Clean architecture, real tests
|
|
69
|
+
Issues:
|
|
70
|
+
Important: Missing progress indicators
|
|
71
|
+
Minor: Magic number (100) for reporting interval
|
|
72
|
+
Assessment: Ready to proceed
|
|
110
73
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
loopx archive <slug>
|
|
74
|
+
You: [Fix progress indicators]
|
|
75
|
+
[Continue to Task 3]
|
|
114
76
|
```
|
|
115
77
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
## Support Skill Review Lenses
|
|
78
|
+
## Integration with Workflows
|
|
119
79
|
|
|
120
|
-
|
|
80
|
+
**Subagent Exec:**
|
|
81
|
+
- Review after EACH task
|
|
82
|
+
- Catch issues before they compound
|
|
83
|
+
- Fix before moving to next task
|
|
121
84
|
|
|
122
|
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
- `debug`: Failure-analysis lens. Fixes for bugs, test failures, build failures, and unexpected behavior should document root cause, not only symptoms or attempted patches.
|
|
126
|
-
- `go-style`: Go diff lens. For `.go` changes, review happy-path structure, error handling, context usage, interface boundaries, naming, table tests, and `gofmt`/Go verification evidence.
|
|
127
|
-
- `kratos`: Kratos diff lens. For Kratos/proto/service/biz/data/middleware/auth/config changes, review layer boundaries, generated-code flow, proto/package contracts, middleware/auth ordering, config compatibility, and project-native verification.
|
|
85
|
+
**Exec:**
|
|
86
|
+
- Review after each task or at natural checkpoints
|
|
87
|
+
- Get feedback, apply, continue
|
|
128
88
|
|
|
129
|
-
|
|
89
|
+
**Ad-Hoc Development:**
|
|
90
|
+
- Review before merge
|
|
91
|
+
- Review when stuck
|
|
130
92
|
|
|
131
|
-
##
|
|
93
|
+
## Red Flags
|
|
132
94
|
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
95
|
+
**Never:**
|
|
96
|
+
- Skip review because "it's simple"
|
|
97
|
+
- Ignore Critical issues
|
|
98
|
+
- Proceed with unfixed Important issues
|
|
99
|
+
- Argue with valid technical feedback
|
|
136
100
|
|
|
137
|
-
|
|
101
|
+
**If reviewer wrong:**
|
|
102
|
+
- Push back with technical reasoning
|
|
103
|
+
- Show code/tests that prove it works
|
|
104
|
+
- Request clarification
|
|
138
105
|
|
|
139
|
-
|
|
106
|
+
See template at: review/code-reviewer.md
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Code Reviewer Prompt Template
|
|
2
|
+
|
|
3
|
+
Use this template when dispatching a code reviewer subagent.
|
|
4
|
+
|
|
5
|
+
**Purpose:** Review completed work against requirements and code quality standards before it cascades into more work.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Native subagent:
|
|
9
|
+
description: "Review code changes"
|
|
10
|
+
prompt: |
|
|
11
|
+
You are a Senior Code Reviewer with expertise in software architecture,
|
|
12
|
+
design patterns, and best practices. Your job is to review completed work
|
|
13
|
+
against its plan or requirements and identify issues before they cascade.
|
|
14
|
+
|
|
15
|
+
## What Was Implemented
|
|
16
|
+
|
|
17
|
+
{DESCRIPTION}
|
|
18
|
+
|
|
19
|
+
## Requirements / Plan
|
|
20
|
+
|
|
21
|
+
{PLAN_OR_REQUIREMENTS}
|
|
22
|
+
|
|
23
|
+
## Git Range to Review
|
|
24
|
+
|
|
25
|
+
**Base:** {BASE_SHA}
|
|
26
|
+
**Head:** {HEAD_SHA}
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git diff --stat {BASE_SHA}..{HEAD_SHA}
|
|
30
|
+
git diff {BASE_SHA}..{HEAD_SHA}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What to Check
|
|
34
|
+
|
|
35
|
+
**Plan alignment:**
|
|
36
|
+
- Does the implementation match the plan / requirements?
|
|
37
|
+
- Are deviations justified improvements, or problematic departures?
|
|
38
|
+
- Is all planned functionality present?
|
|
39
|
+
|
|
40
|
+
**Code quality:**
|
|
41
|
+
- Clean separation of concerns?
|
|
42
|
+
- Proper error handling?
|
|
43
|
+
- Type safety where applicable?
|
|
44
|
+
- DRY without premature abstraction?
|
|
45
|
+
- Edge cases handled?
|
|
46
|
+
|
|
47
|
+
**Architecture:**
|
|
48
|
+
- Sound design decisions?
|
|
49
|
+
- Reasonable scalability and performance?
|
|
50
|
+
- Security concerns?
|
|
51
|
+
- Integrates cleanly with surrounding code?
|
|
52
|
+
|
|
53
|
+
**Testing:**
|
|
54
|
+
- Tests verify real behavior, not mocks?
|
|
55
|
+
- Edge cases covered?
|
|
56
|
+
- Integration tests where they matter?
|
|
57
|
+
- All tests passing?
|
|
58
|
+
|
|
59
|
+
**Production readiness:**
|
|
60
|
+
- Migration strategy if schema changed?
|
|
61
|
+
- Backward compatibility considered?
|
|
62
|
+
- Documentation complete?
|
|
63
|
+
- No obvious bugs?
|
|
64
|
+
|
|
65
|
+
## Calibration
|
|
66
|
+
|
|
67
|
+
Categorize issues by actual severity. Not everything is Critical.
|
|
68
|
+
Acknowledge what was done well before listing issues — accurate praise
|
|
69
|
+
helps the implementer trust the rest of the feedback.
|
|
70
|
+
|
|
71
|
+
If you find significant deviations from the plan, flag them specifically
|
|
72
|
+
so the implementer can confirm whether the deviation was intentional.
|
|
73
|
+
If you find issues with the plan itself rather than the implementation,
|
|
74
|
+
say so.
|
|
75
|
+
|
|
76
|
+
## Output Format
|
|
77
|
+
|
|
78
|
+
### Strengths
|
|
79
|
+
[What's well done? Be specific.]
|
|
80
|
+
|
|
81
|
+
### Issues
|
|
82
|
+
|
|
83
|
+
#### Critical (Must Fix)
|
|
84
|
+
[Bugs, security issues, data loss risks, broken functionality]
|
|
85
|
+
|
|
86
|
+
#### Important (Should Fix)
|
|
87
|
+
[Architecture problems, missing features, poor error handling, test gaps]
|
|
88
|
+
|
|
89
|
+
#### Minor (Nice to Have)
|
|
90
|
+
[Code style, optimization opportunities, documentation polish]
|
|
91
|
+
|
|
92
|
+
For each issue:
|
|
93
|
+
- File:line reference
|
|
94
|
+
- What's wrong
|
|
95
|
+
- Why it matters
|
|
96
|
+
- How to fix (if not obvious)
|
|
97
|
+
|
|
98
|
+
### Recommendations
|
|
99
|
+
[Improvements for code quality, architecture, or process]
|
|
100
|
+
|
|
101
|
+
### Assessment
|
|
102
|
+
|
|
103
|
+
**Ready to merge?** [Yes | No | With fixes]
|
|
104
|
+
|
|
105
|
+
**Reasoning:** [1-2 sentence technical assessment]
|
|
106
|
+
|
|
107
|
+
## Critical Rules
|
|
108
|
+
|
|
109
|
+
**DO:**
|
|
110
|
+
- Categorize by actual severity
|
|
111
|
+
- Be specific (file:line, not vague)
|
|
112
|
+
- Explain WHY each issue matters
|
|
113
|
+
- Acknowledge strengths
|
|
114
|
+
- Give a clear verdict
|
|
115
|
+
|
|
116
|
+
**DON'T:**
|
|
117
|
+
- Say "looks good" without checking
|
|
118
|
+
- Mark nitpicks as Critical
|
|
119
|
+
- Give feedback on code you didn't actually read
|
|
120
|
+
- Be vague ("improve error handling")
|
|
121
|
+
- Avoid giving a clear verdict
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Placeholders:**
|
|
125
|
+
- `{DESCRIPTION}` — brief summary of what was built
|
|
126
|
+
- `{PLAN_OR_REQUIREMENTS}` — what it should do (plan file path, task text, or requirements)
|
|
127
|
+
- `{BASE_SHA}` — starting commit
|
|
128
|
+
- `{HEAD_SHA}` — ending commit
|
|
129
|
+
|
|
130
|
+
**Reviewer returns:** Strengths, Issues (Critical / Important / Minor), Recommendations, Assessment
|
|
131
|
+
|
|
132
|
+
## Example Output
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
### Strengths
|
|
136
|
+
- Clean database schema with proper migrations (db.ts:15-42)
|
|
137
|
+
- Comprehensive test coverage (18 tests, all edge cases)
|
|
138
|
+
- Good error handling with fallbacks (summarizer.ts:85-92)
|
|
139
|
+
|
|
140
|
+
### Issues
|
|
141
|
+
|
|
142
|
+
#### Important
|
|
143
|
+
1. **Missing help text in CLI wrapper**
|
|
144
|
+
- File: index-conversations:1-31
|
|
145
|
+
- Issue: No --help flag, users won't discover --concurrency
|
|
146
|
+
- Fix: Add --help case with usage examples
|
|
147
|
+
|
|
148
|
+
2. **Date validation missing**
|
|
149
|
+
- File: search.ts:25-27
|
|
150
|
+
- Issue: Invalid dates silently return no results
|
|
151
|
+
- Fix: Validate ISO format, throw error with example
|
|
152
|
+
|
|
153
|
+
#### Minor
|
|
154
|
+
1. **Progress indicators**
|
|
155
|
+
- File: indexer.ts:130
|
|
156
|
+
- Issue: No "X of Y" counter for long operations
|
|
157
|
+
- Impact: Users don't know how long to wait
|
|
158
|
+
|
|
159
|
+
### Recommendations
|
|
160
|
+
- Add progress reporting for user experience
|
|
161
|
+
- Consider config file for excluded projects (portability)
|
|
162
|
+
|
|
163
|
+
### Assessment
|
|
164
|
+
|
|
165
|
+
**Ready to merge: With fixes**
|
|
166
|
+
|
|
167
|
+
**Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality.
|
|
168
|
+
```
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# <项目/功能>设计文档
|
|
2
|
+
|
|
3
|
+
> 模板用途:用于需求已澄清后的软件设计方案、概要设计、详细设计和评审材料。保持章节顺序;不适用的章节写“无/不涉及”并说明原因。
|
|
4
|
+
|
|
5
|
+
## 一、修订历史
|
|
6
|
+
|
|
7
|
+
| 版本号 | 修订内容 | 修订时间 | 修订人 |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| V1.0.0 | 新建初稿 | YYYY-MM-DD | <姓名> |
|
|
10
|
+
|
|
11
|
+
## 二、需求信息
|
|
12
|
+
|
|
13
|
+
### 2.1 需求背景
|
|
14
|
+
|
|
15
|
+
- 背景:
|
|
16
|
+
- 需求目的:
|
|
17
|
+
- 目标用户/使用方:
|
|
18
|
+
- 需求链接:
|
|
19
|
+
- 关联原始材料:
|
|
20
|
+
|
|
21
|
+
### 2.2 需求范围
|
|
22
|
+
|
|
23
|
+
- 本期范围:
|
|
24
|
+
- 非目标:
|
|
25
|
+
- 决策边界:
|
|
26
|
+
- 依赖方:
|
|
27
|
+
- 约束条件:
|
|
28
|
+
|
|
29
|
+
### 2.3 可行性分析
|
|
30
|
+
|
|
31
|
+
- 业务可行性:
|
|
32
|
+
- 技术可行性:
|
|
33
|
+
- 团队接受能力:
|
|
34
|
+
- 时间成本:
|
|
35
|
+
- 资源成本:
|
|
36
|
+
- 替代方案:
|
|
37
|
+
- 关键风险:
|
|
38
|
+
|
|
39
|
+
## 三、概要设计
|
|
40
|
+
|
|
41
|
+
### 3.1 方案总述
|
|
42
|
+
|
|
43
|
+
- 设计目标:
|
|
44
|
+
- 总体思路:
|
|
45
|
+
- 核心模块:
|
|
46
|
+
- 主要难点:
|
|
47
|
+
- 技术指标:
|
|
48
|
+
|
|
49
|
+
### 3.2 整体架构设计
|
|
50
|
+
|
|
51
|
+
- 业务模式:
|
|
52
|
+
- 系统边界:
|
|
53
|
+
- 上下游系统:
|
|
54
|
+
- 应用架构:
|
|
55
|
+
- 技术架构:
|
|
56
|
+
- 数据流转:
|
|
57
|
+
|
|
58
|
+
### 3.3 核心流程设计
|
|
59
|
+
|
|
60
|
+
按核心业务流程描述触发方、参与系统、关键状态、数据变化和异常分支。
|
|
61
|
+
|
|
62
|
+
| 流程 | 触发条件 | 参与系统/模块 | 主流程 | 异常/补偿 | 输出 |
|
|
63
|
+
|---|---|---|---|---|---|
|
|
64
|
+
| <流程名> | <条件> | <模块> | <步骤> | <处理> | <结果> |
|
|
65
|
+
|
|
66
|
+
### 3.4 功能模块
|
|
67
|
+
|
|
68
|
+
| 模块 | 职责 | 关键功能 | 依赖 | 备注 |
|
|
69
|
+
|---|---|---|---|---|
|
|
70
|
+
| <模块名> | <职责> | <功能> | <依赖> | <备注> |
|
|
71
|
+
|
|
72
|
+
### 3.5 新增/调整功能说明
|
|
73
|
+
|
|
74
|
+
按端、系统或业务域拆分,例如 H5、后台、开放接口、清结算、资金资产、权限等。
|
|
75
|
+
|
|
76
|
+
## 四、详细设计
|
|
77
|
+
|
|
78
|
+
> 每个模块使用同一结构展开;复杂模块可继续拆到 4.x.x。
|
|
79
|
+
|
|
80
|
+
### 4.x <模块/领域>详细设计
|
|
81
|
+
|
|
82
|
+
#### 4.x.1 需求内容
|
|
83
|
+
|
|
84
|
+
- 入口:
|
|
85
|
+
- 操作人/调用方:
|
|
86
|
+
- 前置条件:
|
|
87
|
+
- 输出结果:
|
|
88
|
+
|
|
89
|
+
#### 4.x.2 方案设计
|
|
90
|
+
|
|
91
|
+
- 核心逻辑:
|
|
92
|
+
- 状态流转:
|
|
93
|
+
- 数据变更:
|
|
94
|
+
- 计算公式:
|
|
95
|
+
- 幂等设计:
|
|
96
|
+
- 权限/越权控制:
|
|
97
|
+
- 异常处理:
|
|
98
|
+
- 补偿/重试:
|
|
99
|
+
- 日志与审计:
|
|
100
|
+
|
|
101
|
+
#### 4.x.3 流程步骤
|
|
102
|
+
|
|
103
|
+
1. <步骤>
|
|
104
|
+
2. <步骤>
|
|
105
|
+
3. <步骤>
|
|
106
|
+
|
|
107
|
+
#### 4.x.4 边界条件
|
|
108
|
+
|
|
109
|
+
| 场景 | 处理方式 | 用户/调用方感知 | 监控/告警 |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| <场景> | <处理> | <感知> | <告警> |
|
|
112
|
+
|
|
113
|
+
## 五、存储类设计
|
|
114
|
+
|
|
115
|
+
### 5.1 库表设计
|
|
116
|
+
|
|
117
|
+
#### 5.1.1 数据库模型图
|
|
118
|
+
|
|
119
|
+
说明核心实体关系;如使用图,请附图或 Mermaid。
|
|
120
|
+
|
|
121
|
+
#### 5.1.2 表结构
|
|
122
|
+
|
|
123
|
+
| 表名 | 用途 | 主键 | 关键索引 | 数据量预估 | 备注 |
|
|
124
|
+
|---|---|---|---|---|---|
|
|
125
|
+
| <table> | <用途> | <pk> | <idx> | <规模> | <备注> |
|
|
126
|
+
|
|
127
|
+
字段明细:
|
|
128
|
+
|
|
129
|
+
| 字段 | 类型 | 是否必填 | 默认值 | 含义 | 来源/取值逻辑 | 备注 |
|
|
130
|
+
|---|---|---|---|---|---|---|
|
|
131
|
+
| <field> | <type> | 是/否 | <default> | <含义> | <逻辑> | <备注> |
|
|
132
|
+
|
|
133
|
+
### 5.2 数据迁移/初始化
|
|
134
|
+
|
|
135
|
+
- DDL:
|
|
136
|
+
- DML:
|
|
137
|
+
- 数据回填:
|
|
138
|
+
- 老数据兼容:
|
|
139
|
+
- 新老系统读写关系:
|
|
140
|
+
|
|
141
|
+
### 5.3 缓存设计
|
|
142
|
+
|
|
143
|
+
| 场景 | Key | Value | 数据结构 | 过期时长 | 容量预估 | 失效/刷新策略 |
|
|
144
|
+
|---|---|---|---|---|---|---|
|
|
145
|
+
| <场景> | <key> | <value> | <结构> | <TTL> | <容量> | <策略> |
|
|
146
|
+
|
|
147
|
+
## 六、其他组件设计
|
|
148
|
+
|
|
149
|
+
### 6.1 消息设计
|
|
150
|
+
|
|
151
|
+
| 场景 | Group | Topic | 生产者 | 消费者 | 幂等键 | 失败补偿 |
|
|
152
|
+
|---|---|---|---|---|---|---|
|
|
153
|
+
| <场景> | <group> | <topic> | <producer> | <consumer> | <key> | <补偿> |
|
|
154
|
+
|
|
155
|
+
### 6.2 配置设计
|
|
156
|
+
|
|
157
|
+
| 配置项 | 环境 | 默认值 | 是否动态生效 | 说明 | 风险 |
|
|
158
|
+
|---|---|---|---|---|---|
|
|
159
|
+
| <config> | <env> | <value> | 是/否 | <说明> | <风险> |
|
|
160
|
+
|
|
161
|
+
### 6.3 定时任务/批处理
|
|
162
|
+
|
|
163
|
+
| 任务 | 触发时间 | 处理范围 | 幂等 | 失败重试 | 影响评估 |
|
|
164
|
+
|---|---|---|---|---|---|
|
|
165
|
+
| <job> | <cron> | <范围> | <方式> | <策略> | <影响> |
|
|
166
|
+
|
|
167
|
+
### 6.4 技术组件
|
|
168
|
+
|
|
169
|
+
- 分布式锁:
|
|
170
|
+
- 唯一 ID:
|
|
171
|
+
- 加解密/验签:
|
|
172
|
+
- 字典转换:
|
|
173
|
+
- Excel/文件处理:
|
|
174
|
+
- 用户信息透传:
|
|
175
|
+
- 限流/熔断:
|
|
176
|
+
|
|
177
|
+
## 七、接口设计
|
|
178
|
+
|
|
179
|
+
### 7.1 接口设计原则
|
|
180
|
+
|
|
181
|
+
- 接口和字段注释必须完整,明确必填、非必填、默认值和枚举。
|
|
182
|
+
- 非纯查询接口必须说明幂等策略。
|
|
183
|
+
- 异常码、异常文案和抛出条件必须明确。
|
|
184
|
+
- 重要接口必须说明日志、链路字段、性能、限流、熔断和数据流水。
|
|
185
|
+
- 如接口文档在 YApi/OpenAPI/Apifox 等平台维护,必须给出链接。
|
|
186
|
+
|
|
187
|
+
### 7.2 接口清单
|
|
188
|
+
|
|
189
|
+
| 接口 | 调用方 | 服务方 | 权限/认证 | 幂等 | 文档地址 | 备注 |
|
|
190
|
+
|---|---|---|---|---|---|---|
|
|
191
|
+
| <接口名> | <caller> | <provider> | <auth> | <key> | <url> | <备注> |
|
|
192
|
+
|
|
193
|
+
### 7.3 接口明细
|
|
194
|
+
|
|
195
|
+
#### 7.3.x <接口名>
|
|
196
|
+
|
|
197
|
+
- 路径/方法:
|
|
198
|
+
- 请求头:
|
|
199
|
+
- 请求参数:
|
|
200
|
+
- 响应参数:
|
|
201
|
+
- 错误码:
|
|
202
|
+
- 业务校验:
|
|
203
|
+
- 数据变更:
|
|
204
|
+
- 日志字段:
|
|
205
|
+
|
|
206
|
+
## 八、系统发布
|
|
207
|
+
|
|
208
|
+
### 8.1 灰度方案
|
|
209
|
+
|
|
210
|
+
- 灰度范围:
|
|
211
|
+
- 灰度开关:
|
|
212
|
+
- 验证指标:
|
|
213
|
+
- 放量节奏:
|
|
214
|
+
|
|
215
|
+
### 8.2 降级方案
|
|
216
|
+
|
|
217
|
+
- 降级触发条件:
|
|
218
|
+
- 降级行为:
|
|
219
|
+
- 用户影响:
|
|
220
|
+
- 恢复方式:
|
|
221
|
+
|
|
222
|
+
### 8.3 关联系统/功能影响
|
|
223
|
+
|
|
224
|
+
| 系统/功能 | 影响 | 依赖动作 | 负责人 | 验证方式 |
|
|
225
|
+
|---|---|---|---|---|
|
|
226
|
+
| <系统> | <影响> | <动作> | <负责人> | <验证> |
|
|
227
|
+
|
|
228
|
+
### 8.4 回滚方案
|
|
229
|
+
|
|
230
|
+
- 回滚条件:
|
|
231
|
+
- 回滚步骤:
|
|
232
|
+
- 数据回滚:
|
|
233
|
+
- 配置回滚:
|
|
234
|
+
- 风险:
|
|
235
|
+
|
|
236
|
+
## 九、系统监控与维护
|
|
237
|
+
|
|
238
|
+
### 9.1 监控与告警
|
|
239
|
+
|
|
240
|
+
- 系统异常:
|
|
241
|
+
- 业务异常:
|
|
242
|
+
- 重试异常:
|
|
243
|
+
- 超时:
|
|
244
|
+
- 关键接口指标:
|
|
245
|
+
- 告警渠道:
|
|
246
|
+
|
|
247
|
+
### 9.2 性能与容量
|
|
248
|
+
|
|
249
|
+
- TPS/吞吐:
|
|
250
|
+
- CPU/内存/磁盘 IO/网络 IO:
|
|
251
|
+
- 数据容量:
|
|
252
|
+
- 缓存容量:
|
|
253
|
+
- 跑批耗时:
|
|
254
|
+
- 是否压测:
|
|
255
|
+
|
|
256
|
+
### 9.3 可靠性与兜底
|
|
257
|
+
|
|
258
|
+
- 幂等击穿:
|
|
259
|
+
- 并发失效:
|
|
260
|
+
- 冷热备:
|
|
261
|
+
- 关键任务独立性:
|
|
262
|
+
- 字段兜底:
|
|
263
|
+
- 老新数据兼容:
|
|
264
|
+
|
|
265
|
+
## 十、排期与规划
|
|
266
|
+
|
|
267
|
+
### 10.1 任务拆分与工作量评估
|
|
268
|
+
|
|
269
|
+
| 任务 | 范围 | 负责人 | 工作量 | 依赖 | 备注 |
|
|
270
|
+
|---|---|---|---|---|---|
|
|
271
|
+
| <任务> | <范围> | <负责人> | <人天> | <依赖> | <备注> |
|
|
272
|
+
|
|
273
|
+
### 10.2 计划时间
|
|
274
|
+
|
|
275
|
+
- 数据方案评审:
|
|
276
|
+
- 开发开始/结束:
|
|
277
|
+
- CR:
|
|
278
|
+
- 联调完成/提测:
|
|
279
|
+
- 测试用例评审:
|
|
280
|
+
- 测试开始/结束:
|
|
281
|
+
- 预发布:
|
|
282
|
+
- 上线:
|
|
283
|
+
- 线上验证:
|
|
284
|
+
|
|
285
|
+
### 10.3 发布计划
|
|
286
|
+
|
|
287
|
+
1. 需求纳入发布版本
|
|
288
|
+
2. 测试环境申请与部署
|
|
289
|
+
3. 代码 CR
|
|
290
|
+
4. 发布评审 checklist
|
|
291
|
+
5. 预发布/灰度/线上环境部署
|
|
292
|
+
6. 稳定观察
|
|
293
|
+
|
|
294
|
+
### 10.4 遗留问题与后续规划
|
|
295
|
+
|
|
296
|
+
| 问题 | 影响 | 处理计划 | 负责人 | 截止时间 |
|
|
297
|
+
|---|---|---|---|---|
|
|
298
|
+
| <问题> | <影响> | <计划> | <负责人> | <时间> |
|
|
299
|
+
|
|
300
|
+
### 10.5 Planning Handoff
|
|
301
|
+
|
|
302
|
+
- `plan` 可以决定:
|
|
303
|
+
- 必须返回 `spec` 的事项:
|
|
304
|
+
- 必须返回 `clarify` 的事项:
|
|
305
|
+
- 推荐下一步:
|
|
306
|
+
|
|
307
|
+
```text
|
|
308
|
+
$plan --direct docs/loopx/design/<需求名>需求设计文档.md
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## 十一、QA
|
|
312
|
+
|
|
313
|
+
### 11.1 评审记录
|
|
314
|
+
|
|
315
|
+
| 评审时间 | 评审人 | 评审问题 | 处理进展 | 结论 |
|
|
316
|
+
|---|---|---|---|---|
|
|
317
|
+
| <时间> | <姓名> | <问题> | <进展> | <结论> |
|
|
318
|
+
|
|
319
|
+
### 11.2 待确认问题
|
|
320
|
+
|
|
321
|
+
| 问题 | 需要谁确认 | 阻塞阶段 | 推荐答案 | 状态 |
|
|
322
|
+
|---|---|---|---|---|
|
|
323
|
+
| <问题> | <角色> | clarify/spec/plan/build | <建议> | open/closed |
|