@chongyan/autospec 1.0.1
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/LICENSE +21 -0
- package/README.en.md +472 -0
- package/README.md +476 -0
- package/bin/autospec.js +3 -0
- package/knowledge/README.md +144 -0
- package/knowledge/checklists/code.md +182 -0
- package/knowledge/checklists/design.md +196 -0
- package/knowledge/checklists/release.md +70 -0
- package/knowledge/checklists/requirement.md +169 -0
- package/knowledge/checklists/test.md +46 -0
- package/knowledge/config/README.en.md +44 -0
- package/knowledge/config/README.md +44 -0
- package/knowledge/config/role-composition.yaml +98 -0
- package/knowledge/config/role-extensions.yaml +140 -0
- package/knowledge/config/skill-compositions.yaml +142 -0
- package/knowledge/config/team-stage.yaml +95 -0
- package/knowledge/config/team-tasks.yaml +139 -0
- package/knowledge/config/team-triggers.yaml +198 -0
- package/knowledge/config/validation-patterns.yaml +137 -0
- package/knowledge/domain/README.md +115 -0
- package/knowledge/domain/flows/README.md +194 -0
- package/knowledge/domain/glossary.md +143 -0
- package/knowledge/domain/rules.md +138 -0
- package/knowledge/environment/README.en.md +36 -0
- package/knowledge/environment/README.md +87 -0
- package/knowledge/environment/component-knowledge.md +316 -0
- package/knowledge/environment/detection-patterns.yaml +502 -0
- package/knowledge/environment/middleware-knowledge.md +237 -0
- package/knowledge/environment/template-registry.md +321 -0
- package/knowledge/guides/domain-driven-design.md +345 -0
- package/knowledge/guides/knowledge-management.md +369 -0
- package/knowledge/guides/requirement-engineering.md +329 -0
- package/knowledge/guides/stages/ai-effect-evaluator.md +93 -0
- package/knowledge/guides/stages/code-implementer.md +205 -0
- package/knowledge/guides/stages/code-reviewer.md +111 -0
- package/knowledge/guides/stages/consistency-checker.md +177 -0
- package/knowledge/guides/stages/design-planner.md +401 -0
- package/knowledge/guides/stages/design-reviewer.md +83 -0
- package/knowledge/guides/stages/integration-test-runner.md +105 -0
- package/knowledge/guides/stages/release-checker.md +205 -0
- package/knowledge/guides/stages/requirement-analyzer.md +195 -0
- package/knowledge/guides/stages/requirement-reviewer.md +83 -0
- package/knowledge/guides/stages/security-reviewer.md +89 -0
- package/knowledge/guides/stages/test-context-analyzer.md +250 -0
- package/knowledge/guides/stages/test-generator.md +241 -0
- package/knowledge/guides/stages/test-planner.md +183 -0
- package/knowledge/guides/stages/test-reviewer.md +76 -0
- package/knowledge/guides/stages/unit-test-runner.md +83 -0
- package/knowledge/guides/support/ai-agent-analyzer.md +362 -0
- package/knowledge/guides/support/ai-anomaly-analyzer.md +213 -0
- package/knowledge/guides/support/ai-artifact-evaluator.md +192 -0
- package/knowledge/guides/support/ai-capability-analyzer.md +193 -0
- package/knowledge/guides/support/ai-component-analyzer.md +169 -0
- package/knowledge/guides/support/ai-data-validator.md +276 -0
- package/knowledge/guides/support/ai-evaluation-planner.md +374 -0
- package/knowledge/guides/support/ai-path-evaluator.md +274 -0
- package/knowledge/guides/support/ai-pipeline-evaluator.md +219 -0
- package/knowledge/guides/support/ai-rag-analyzer.md +339 -0
- package/knowledge/guides/support/ai-task-assessor.md +418 -0
- package/knowledge/guides/support/ai-test-diagnostics.md +133 -0
- package/knowledge/guides/support/complexity-assessor.md +268 -0
- package/knowledge/guides/support/component-discovery.md +183 -0
- package/knowledge/guides/support/environment-scanner.md +207 -0
- package/knowledge/guides/support/environment-validator.md +207 -0
- package/knowledge/guides/support/knowledge-generator.md +234 -0
- package/knowledge/guides/support/methodology-extractor.md +55 -0
- package/knowledge/guides/support/pipeline-protocol.md +438 -0
- package/knowledge/guides/support/practice-logger.md +359 -0
- package/knowledge/guides/support/scope-inference.md +174 -0
- package/knowledge/guides/support/skill-distiller.md +91 -0
- package/knowledge/guides/support/skill-updater.md +45 -0
- package/knowledge/guides/support/skill-validator.md +72 -0
- package/knowledge/guides/support/team-orchestrator.md +323 -0
- package/knowledge/guides/support/tech-stack-analyzer.md +139 -0
- package/knowledge/guides/support/test-runner.md +254 -0
- package/knowledge/guides/system-design.md +352 -0
- package/knowledge/organization/ai-native-team.md +318 -0
- package/knowledge/organization/team-metrics.md +228 -0
- package/knowledge/principles/constitution.md +134 -0
- package/knowledge/principles/core-principles.md +368 -0
- package/knowledge/principles/design-philosophy.md +877 -0
- package/knowledge/principles/evolution.md +553 -0
- package/knowledge/process/01-requirement.md +113 -0
- package/knowledge/process/02-design.md +123 -0
- package/knowledge/process/03-implementation.md +90 -0
- package/knowledge/process/04-review.md +80 -0
- package/knowledge/process/05-testing.md +90 -0
- package/knowledge/process/06-delivery.md +88 -0
- package/knowledge/process/README.en.md +38 -0
- package/knowledge/process/README.md +48 -0
- package/knowledge/process/ai-sdlc.md +475 -0
- package/knowledge/process/overview.md +319 -0
- package/knowledge/standards/code-review.md +876 -0
- package/knowledge/standards/coding-style.md +940 -0
- package/knowledge/standards/data-consistency.md +1085 -0
- package/knowledge/standards/document-versioning.md +210 -0
- package/knowledge/standards/risk-detection.md +186 -0
- package/knowledge/templates/ai-evaluation.md +150 -0
- package/knowledge/templates/api-design.md +117 -0
- package/knowledge/templates/database-design.md +132 -0
- package/knowledge/templates/domain-driven-design.md +321 -0
- package/knowledge/templates/product-proposal.md +201 -0
- package/knowledge/templates/system-design.md +227 -0
- package/knowledge/templates/task-breakdown.md +107 -0
- package/knowledge/templates/test-case.md +170 -0
- package/package.json +53 -0
- package/plugins/.claude-plugin/plugin.json +134 -0
- package/plugins/agents/roles/ai-engineer.md +129 -0
- package/plugins/agents/roles/backend-engineer.md +165 -0
- package/plugins/agents/roles/ceo.md +94 -0
- package/plugins/agents/roles/data-engineer.md +135 -0
- package/plugins/agents/roles/devops-engineer.md +181 -0
- package/plugins/agents/roles/frontend-engineer.md +129 -0
- package/plugins/agents/roles/product-owner.md +98 -0
- package/plugins/agents/roles/quality-engineer.md +129 -0
- package/plugins/agents/roles/security-engineer.md +180 -0
- package/plugins/agents/roles/tech-lead.md +97 -0
- package/plugins/agents/support/blind-comparator.md +88 -0
- package/plugins/agents/support/consistency-checker.md +103 -0
- package/plugins/agents/support/failure-diagnostician.md +141 -0
- package/plugins/agents/support/independent-reviewer.md +80 -0
- package/plugins/agents/support/safety-auditor.md +121 -0
- package/plugins/agents/support/skill-benchmarker.md +86 -0
- package/plugins/agents/support/skill-forger.md +105 -0
- package/plugins/agents/support/stage-gate-evaluator.md +121 -0
- package/plugins/agents/support/test-coverage-reviewer.md +73 -0
- package/plugins/benchmarks/templates/README.md +44 -0
- package/plugins/benchmarks/templates/commands/explore-template.yaml +48 -0
- package/plugins/benchmarks/templates/pipeline/agile-template.yaml +84 -0
- package/plugins/benchmarks/templates/pipeline/waterfall-template.yaml +106 -0
- package/plugins/benchmarks/templates/skills/requirement-analyzer-template.yaml +48 -0
- package/plugins/commands/README.en.md +96 -0
- package/plugins/commands/README.md +96 -0
- package/plugins/commands/apply.md +191 -0
- package/plugins/commands/archive.md +76 -0
- package/plugins/commands/env-export.md +79 -0
- package/plugins/commands/env-sync.md +640 -0
- package/plugins/commands/env-template.md +223 -0
- package/plugins/commands/env-update.md +264 -0
- package/plugins/commands/env-validate.md +176 -0
- package/plugins/commands/env.md +79 -0
- package/plugins/commands/explore.md +76 -0
- package/plugins/commands/field-evolve.md +536 -0
- package/plugins/commands/memory.md +249 -0
- package/plugins/commands/project-evolve.md +821 -0
- package/plugins/commands/propose.md +93 -0
- package/plugins/commands/review.md +140 -0
- package/plugins/commands/run.md +224 -0
- package/plugins/commands/status.md +62 -0
- package/plugins/commands/validate.md +108 -0
- package/plugins/hooks/README.en.md +56 -0
- package/plugins/hooks/README.md +56 -0
- package/plugins/hooks/ai-project-guard.js +329 -0
- package/plugins/hooks/artifact-evaluation-hook.js +237 -0
- package/plugins/hooks/constitution-guard.js +211 -0
- package/plugins/hooks/environment-autocommit.js +264 -0
- package/plugins/hooks/environment-manager.js +778 -0
- package/plugins/hooks/execution-tracker.js +354 -0
- package/plugins/hooks/frozen-zone-guard.js +140 -0
- package/plugins/hooks/layer1-validator.js +423 -0
- package/plugins/hooks/lib/artifact-evaluator.js +414 -0
- package/plugins/hooks/lib/benchmarks/change-detector.js +390 -0
- package/plugins/hooks/lib/benchmarks/evaluator.js +605 -0
- package/plugins/hooks/lib/benchmarks/integration-example.js +169 -0
- package/plugins/hooks/lib/data-and-ai-detector.js +275 -0
- package/plugins/hooks/lib/detection-pattern-loader.js +865 -0
- package/plugins/hooks/lib/directory-discovery.js +395 -0
- package/plugins/hooks/lib/environment-config-loader.js +341 -0
- package/plugins/hooks/lib/environment-detector.js +553 -0
- package/plugins/hooks/lib/environment-evolver.js +564 -0
- package/plugins/hooks/lib/environment-registry.js +813 -0
- package/plugins/hooks/lib/execution-path.js +427 -0
- package/plugins/hooks/lib/hook-error-recorder.js +245 -0
- package/plugins/hooks/lib/hook-logger.js +538 -0
- package/plugins/hooks/lib/hook-runner.js +97 -0
- package/plugins/hooks/lib/hook-runner.sh +44 -0
- package/plugins/hooks/lib/hook-state-manager.js +480 -0
- package/plugins/hooks/lib/memory-extractor.js +377 -0
- package/plugins/hooks/lib/memory-manager.js +673 -0
- package/plugins/hooks/lib/metrics-analyzer.js +489 -0
- package/plugins/hooks/lib/project-evolution/auto-fixer.js +511 -0
- package/plugins/hooks/lib/project-evolution/memory-manager.js +346 -0
- package/plugins/hooks/lib/project-evolution/pattern-detector.js +476 -0
- package/plugins/hooks/lib/project-evolution/semantic-indexer.js +480 -0
- package/plugins/hooks/lib/project-structure-detector.js +326 -0
- package/plugins/hooks/lib/rollback-tracker.js +346 -0
- package/plugins/hooks/lib/source-code-scanner.js +596 -0
- package/plugins/hooks/lib/technology-stack-detector.js +374 -0
- package/plugins/hooks/lib/test-failure-analyzer.js +375 -0
- package/plugins/hooks/lib/test-failure-fixer.js +268 -0
- package/plugins/hooks/lib/trace-context.js +277 -0
- package/plugins/hooks/lib/validation-patterns.js +415 -0
- package/plugins/hooks/memory-sync.js +171 -0
- package/plugins/hooks/pipeline-observer.js +413 -0
- package/plugins/hooks/scope-sentinel.js +204 -0
- package/plugins/hooks/trace-initialization.js +169 -0
- package/plugins/memory/templates/code-quality.yaml +149 -0
- package/plugins/memory/templates/multi-system.yaml +155 -0
- package/plugins/memory/templates/team-habits.yaml +119 -0
- package/plugins/memory/templates/testing.yaml +121 -0
- package/plugins/skills/README.en.md +47 -0
- package/plugins/skills/README.md +104 -0
- package/plugins/skills/benchmark-executor/README.md +93 -0
- package/plugins/skills/benchmark-executor/SKILL.md +647 -0
- package/plugins/skills/benchmark-generator/SKILL.md +349 -0
- package/plugins/skills/delivery-stage/SKILL.md +203 -0
- package/plugins/skills/design-stage/SKILL.md +216 -0
- package/plugins/skills/evolution-process/SKILL.md +291 -0
- package/plugins/skills/exploration-phase/SKILL.md +133 -0
- package/plugins/skills/implementation-stage/SKILL.md +179 -0
- package/plugins/skills/layer1-validation/SKILL.md +79 -0
- package/plugins/skills/pending-dashboard/SKILL.md +109 -0
- package/plugins/skills/project-evolution/SKILL.md +847 -0
- package/plugins/skills/requirement-stage/SKILL.md +183 -0
- package/plugins/skills/skill-forge/SKILL.md +223 -0
- package/plugins/skills/skill-forge/references/description-guide.md +92 -0
- package/plugins/skills/skill-forge/references/quality-rubric.md +104 -0
- package/plugins/skills/skill-forge/references/skill-template.md +106 -0
- package/plugins/skills/startup-guard/SKILL.md +38 -0
- package/plugins/skills/testing-stage/SKILL.md +195 -0
- package/scripts/cli/global-init.js +288 -0
- package/scripts/cli/global.js +324 -0
- package/scripts/cli/index.js +55 -0
- package/scripts/cli/init.js +382 -0
- package/scripts/cli/list.js +69 -0
- package/scripts/cli/org.js +340 -0
- package/scripts/cli/update.js +44 -0
- package/scripts/config/commands.config.js +145 -0
- package/scripts/config/hooks.config.js +197 -0
- package/scripts/evolution/evolution-router.js +273 -0
- package/scripts/evolution/evolution-signal-collector.js +307 -0
- package/scripts/evolution/knowledge-loader.js +346 -0
- package/scripts/evolution/marketplace.js +317 -0
- package/scripts/evolution/version-manager.js +371 -0
- package/scripts/install/agents.js +106 -0
- package/scripts/install/commands.js +133 -0
- package/scripts/install/constants.js +424 -0
- package/scripts/install/hook-logger.js +536 -0
- package/scripts/install/hooks.js +110 -0
- package/scripts/install/index.js +39 -0
- package/scripts/install/skills.js +95 -0
- package/scripts/postinstall.js +25 -0
- package/scripts/state.js +376 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# 组件知识模板
|
|
2
|
+
|
|
3
|
+
> 本模板定义组件知识的标准格式。供 env-sync 生成知识文件时参考。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 文件位置
|
|
8
|
+
|
|
9
|
+
`.autospec/environment/component-lib/components/{name}/component.md`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 基本信息
|
|
14
|
+
|
|
15
|
+
| 字段 | 必填 | 说明 |
|
|
16
|
+
|------|------|------|
|
|
17
|
+
| 名称 | 是 | 组件名称,如 auth、payment |
|
|
18
|
+
| 类型 | 是 | 参见类型枚举 |
|
|
19
|
+
| 版本 | 是 | 组件版本,如 v2.1.0 |
|
|
20
|
+
| 维护者 | 否 | 维护团队或个人 |
|
|
21
|
+
| 最后更新 | 否 | 更新日期 |
|
|
22
|
+
|
|
23
|
+
### 类型枚举
|
|
24
|
+
|
|
25
|
+
| 类型 | 说明 | 典型示例 |
|
|
26
|
+
|------|------|---------|
|
|
27
|
+
| service-component | 服务组件,封装外部服务调用 | 认证组件、支付网关 |
|
|
28
|
+
| utility | 工具组件,提供通用功能 | 日志组件、配置组件 |
|
|
29
|
+
| library | 库组件,封装业务逻辑 | 领域模型、数据访问层 |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 功能描述
|
|
34
|
+
|
|
35
|
+
简要描述组件的核心功能和用途。
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 接口定义
|
|
40
|
+
|
|
41
|
+
| 方法名 | 说明 |
|
|
42
|
+
|--------|------|
|
|
43
|
+
| {method1} | 方法说明 |
|
|
44
|
+
| {method2} | 方法说明 |
|
|
45
|
+
|
|
46
|
+
### 方法详情
|
|
47
|
+
|
|
48
|
+
#### {method1}
|
|
49
|
+
|
|
50
|
+
**输入参数**
|
|
51
|
+
|
|
52
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
53
|
+
|--------|------|------|------|
|
|
54
|
+
| param1 | string | 是 | 参数说明 |
|
|
55
|
+
| param2 | number | 否 | 参数说明 |
|
|
56
|
+
|
|
57
|
+
**输出参数**
|
|
58
|
+
|
|
59
|
+
| 字段名 | 类型 | 说明 |
|
|
60
|
+
|--------|------|------|
|
|
61
|
+
| result | any | 返回结果 |
|
|
62
|
+
|
|
63
|
+
**错误码**
|
|
64
|
+
|
|
65
|
+
| 错误码 | 说明 |
|
|
66
|
+
|--------|------|
|
|
67
|
+
| ERROR_CODE_1 | 错误描述 |
|
|
68
|
+
| ERROR_CODE_2 | 错误描述 |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 使用示例
|
|
73
|
+
|
|
74
|
+
按语言分节,提供安装命令和代码示例。
|
|
75
|
+
|
|
76
|
+
### Node.js
|
|
77
|
+
|
|
78
|
+
**安装**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install @org/component-name
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**使用**
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import { Component } from '@org/component-name';
|
|
88
|
+
|
|
89
|
+
const component = new Component({
|
|
90
|
+
endpoint: process.env.COMPONENT_ENDPOINT,
|
|
91
|
+
timeout: 30000
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// 调用方法
|
|
95
|
+
const result = await component.method1(param1, param2);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Python
|
|
99
|
+
|
|
100
|
+
**安装**
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install org-component
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**使用**
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from org_component import Component
|
|
110
|
+
|
|
111
|
+
component = Component(
|
|
112
|
+
endpoint=os.environ['COMPONENT_ENDPOINT'],
|
|
113
|
+
timeout=30000
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# 调用方法
|
|
117
|
+
result = component.method1(param1, param2)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 配置项
|
|
123
|
+
|
|
124
|
+
### 必需配置
|
|
125
|
+
|
|
126
|
+
| 配置项 | 说明 |
|
|
127
|
+
|--------|------|
|
|
128
|
+
| CONFIG_ENDPOINT | 服务地址 |
|
|
129
|
+
| CONFIG_API_KEY | API密钥 |
|
|
130
|
+
|
|
131
|
+
### 可选配置
|
|
132
|
+
|
|
133
|
+
| 配置项 | 默认值 | 说明 |
|
|
134
|
+
|--------|--------|------|
|
|
135
|
+
| CONFIG_TIMEOUT | 30 | 超时时间(秒) |
|
|
136
|
+
| CONFIG_RETRY | 3 | 重试次数 |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 环境差异配置
|
|
141
|
+
|
|
142
|
+
| 环境 | 配置项 | 值 |
|
|
143
|
+
|------|--------|-----|
|
|
144
|
+
| development | CONFIG_ENDPOINT | http://dev.example.com |
|
|
145
|
+
| staging | CONFIG_ENDPOINT | http://staging.example.com |
|
|
146
|
+
| production | CONFIG_ENDPOINT | http://api.example.com |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 使用检查清单
|
|
151
|
+
|
|
152
|
+
### 使用前检查
|
|
153
|
+
|
|
154
|
+
- [ ] 确认依赖服务已部署且可访问
|
|
155
|
+
- [ ] 确认必需环境变量已配置
|
|
156
|
+
- [ ] 确认应用已注册到服务
|
|
157
|
+
|
|
158
|
+
### 使用后检查
|
|
159
|
+
|
|
160
|
+
- [ ] 验证核心功能正常
|
|
161
|
+
- [ ] 验证错误处理正确
|
|
162
|
+
- [ ] 验证日志记录完整
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 最佳实践
|
|
167
|
+
|
|
168
|
+
1. 使用前检查服务可用性
|
|
169
|
+
2. 实现完善的错误处理
|
|
170
|
+
3. 记录关键操作日志
|
|
171
|
+
4. 设置合理的超时时间
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 反模式清单
|
|
176
|
+
|
|
177
|
+
| 反模式 | 风险 | 替代方案 |
|
|
178
|
+
|--------|------|----------|
|
|
179
|
+
| 硬编码服务地址 | 环境切换困难 | 使用环境变量 |
|
|
180
|
+
| 忽略错误处理 | 系统不稳定 | 实现完善的错误处理 |
|
|
181
|
+
| 不设置超时 | 请求阻塞 | 设置合理的超时时间 |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 示例:认证组件知识
|
|
186
|
+
|
|
187
|
+
```markdown
|
|
188
|
+
# 认证组件知识
|
|
189
|
+
|
|
190
|
+
## 基本信息
|
|
191
|
+
|
|
192
|
+
| 字段 | 值 |
|
|
193
|
+
|------|-----|
|
|
194
|
+
| 名称 | auth |
|
|
195
|
+
| 类型 | service-component |
|
|
196
|
+
| 版本 | v2.1.0 |
|
|
197
|
+
| 维护者 | platform-team |
|
|
198
|
+
|
|
199
|
+
## 功能描述
|
|
200
|
+
|
|
201
|
+
统一认证组件,支持 JWT Token、OAuth2.0、Session 等多种认证方式。
|
|
202
|
+
提供用户登录、登出、Token 刷新、权限校验等核心功能。
|
|
203
|
+
|
|
204
|
+
## 接口定义
|
|
205
|
+
|
|
206
|
+
| 方法名 | 说明 |
|
|
207
|
+
|--------|------|
|
|
208
|
+
| login | 用户登录 |
|
|
209
|
+
| validateToken | 验证Token |
|
|
210
|
+
| logout | 用户登出 |
|
|
211
|
+
|
|
212
|
+
### 方法详情
|
|
213
|
+
|
|
214
|
+
#### login
|
|
215
|
+
|
|
216
|
+
**输入参数**
|
|
217
|
+
|
|
218
|
+
| 参数名 | 类型 | 必填 | 说明 |
|
|
219
|
+
|--------|------|------|------|
|
|
220
|
+
| username | string | 是 | 用户名 |
|
|
221
|
+
| password | string | 是 | 密码 |
|
|
222
|
+
|
|
223
|
+
**输出参数**
|
|
224
|
+
|
|
225
|
+
| 字段名 | 类型 | 说明 |
|
|
226
|
+
|--------|------|------|
|
|
227
|
+
| success | boolean | 是否成功 |
|
|
228
|
+
| token | string | Token(成功时) |
|
|
229
|
+
| errorCode | string | 错误码(失败时) |
|
|
230
|
+
|
|
231
|
+
**错误码**
|
|
232
|
+
|
|
233
|
+
| 错误码 | 说明 |
|
|
234
|
+
|--------|------|
|
|
235
|
+
| AUTH_FAILED | 用户名或密码错误 |
|
|
236
|
+
| ACCOUNT_LOCKED | 账户已被锁定 |
|
|
237
|
+
|
|
238
|
+
## 使用示例
|
|
239
|
+
|
|
240
|
+
### Node.js
|
|
241
|
+
|
|
242
|
+
**安装**
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npm install @acme/auth-client
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**使用**
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
import { AuthClient } from '@acme/auth-client';
|
|
252
|
+
|
|
253
|
+
const authClient = new AuthClient({
|
|
254
|
+
endpoint: process.env.AUTH_SERVICE_ENDPOINT,
|
|
255
|
+
redisUrl: process.env.REDIS_URL
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// 登录
|
|
259
|
+
const result = await authClient.login(username, password);
|
|
260
|
+
|
|
261
|
+
// 验证Token
|
|
262
|
+
const user = await authClient.validateToken(token);
|
|
263
|
+
|
|
264
|
+
// 登出
|
|
265
|
+
await authClient.logout(token);
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## 配置项
|
|
269
|
+
|
|
270
|
+
### 必需配置
|
|
271
|
+
|
|
272
|
+
| 配置项 | 说明 |
|
|
273
|
+
|--------|------|
|
|
274
|
+
| AUTH_SERVICE_ENDPOINT | 认证服务地址 |
|
|
275
|
+
| REDIS_URL | Redis连接地址 |
|
|
276
|
+
|
|
277
|
+
### 可选配置
|
|
278
|
+
|
|
279
|
+
| 配置项 | 默认值 | 说明 |
|
|
280
|
+
|--------|--------|------|
|
|
281
|
+
| AUTH_TOKEN_EXPIRY | 3600 | Token过期时间(秒) |
|
|
282
|
+
| AUTH_MAX_RETRY | 3 | 最大重试次数 |
|
|
283
|
+
|
|
284
|
+
## 使用检查清单
|
|
285
|
+
|
|
286
|
+
### 使用前检查
|
|
287
|
+
|
|
288
|
+
- [ ] 确认Redis已部署且可访问
|
|
289
|
+
- [ ] 确认AUTH_SERVICE_ENDPOINT环境变量已配置
|
|
290
|
+
- [ ] 确认应用已注册到认证服务
|
|
291
|
+
|
|
292
|
+
### 使用后检查
|
|
293
|
+
|
|
294
|
+
- [ ] 验证登录流程正常
|
|
295
|
+
- [ ] 验证Token刷新机制
|
|
296
|
+
- [ ] 验证权限校验正确
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 自检清单
|
|
302
|
+
|
|
303
|
+
生成组件知识文件后,检查以下项目:
|
|
304
|
+
|
|
305
|
+
- [ ] 基本信息章节完整,包含名称、类型、版本
|
|
306
|
+
- [ ] 功能描述清晰
|
|
307
|
+
- [ ] 接口定义包含方法名和参数说明
|
|
308
|
+
- [ ] 使用示例包含安装命令和代码
|
|
309
|
+
- [ ] 配置项包含必需和可选配置
|
|
310
|
+
- [ ] 使用检查清单完整
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
**维护者**: AutoSpec 团队
|
|
315
|
+
**进化分区**: 🟡 受控区
|
|
316
|
+
**关联文档**: `knowledge/environment/template-registry.md`
|