ai-agent-router 0.1.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/.claude/commands/openspec/apply.md +23 -0
- package/.claude/commands/openspec/archive.md +27 -0
- package/.claude/commands/openspec/proposal.md +28 -0
- package/.claude/settings.local.json +12 -0
- package/.claude/skills/ui-ux-pro-max/SKILL.md +228 -0
- package/.claude/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.claude/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.claude/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.claude/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.claude/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.claude/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.claude/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/.claude/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.claude/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.claude/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-311.pyc +0 -0
- package/.claude/skills/ui-ux-pro-max/scripts/core.py +238 -0
- package/.claude/skills/ui-ux-pro-max/scripts/search.py +61 -0
- package/.cursor/commands/openspec-apply.md +23 -0
- package/.cursor/commands/openspec-archive.md +27 -0
- package/.cursor/commands/openspec-proposal.md +28 -0
- package/.cursor/commands/ui-ux-pro-max.md +226 -0
- package/.eslintrc.json +3 -0
- package/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.shared/ui-ux-pro-max/scripts/core.py +238 -0
- package/.shared/ui-ux-pro-max/scripts/search.py +61 -0
- package/AGENTS.md +18 -0
- package/CLAUDE.md +18 -0
- package/IMPLEMENTATION.md +157 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/.next/types/app/api/config/route.js +52 -0
- package/dist/.next/types/app/api/gateway/[...path]/route.js +52 -0
- package/dist/.next/types/app/api/gateway/route.js +52 -0
- package/dist/.next/types/app/api/logs/route.js +52 -0
- package/dist/.next/types/app/api/models/route.js +52 -0
- package/dist/.next/types/app/api/providers/route.js +52 -0
- package/dist/.next/types/app/api/providers/test/route.js +52 -0
- package/dist/.next/types/app/api/service/start/route.js +52 -0
- package/dist/.next/types/app/api/service/status/route.js +52 -0
- package/dist/.next/types/app/api/service/stop/route.js +52 -0
- package/dist/.next/types/app/layout.js +22 -0
- package/dist/.next/types/app/logs/page.js +22 -0
- package/dist/.next/types/app/models/page.js +22 -0
- package/dist/.next/types/app/page.js +22 -0
- package/dist/.next/types/app/providers/page.js +22 -0
- package/dist/src/app/api/config/route.js +43 -0
- package/dist/src/app/api/gateway/[...path]/route.js +83 -0
- package/dist/src/app/api/gateway/route.js +63 -0
- package/dist/src/app/api/logs/route.js +34 -0
- package/dist/src/app/api/models/route.js +152 -0
- package/dist/src/app/api/providers/route.js +118 -0
- package/dist/src/app/api/providers/test/route.js +154 -0
- package/dist/src/app/api/service/start/route.js +55 -0
- package/dist/src/app/api/service/status/route.js +17 -0
- package/dist/src/app/api/service/stop/route.js +20 -0
- package/dist/src/app/components/ConfirmDialog.jsx +31 -0
- package/dist/src/app/components/Nav.jsx +45 -0
- package/dist/src/app/components/Toast.jsx +37 -0
- package/dist/src/app/components/ToastProvider.jsx +21 -0
- package/dist/src/app/layout.jsx +13 -0
- package/dist/src/app/logs/page.jsx +210 -0
- package/dist/src/app/models/page.jsx +291 -0
- package/dist/src/app/page.jsx +236 -0
- package/dist/src/app/providers/page.jsx +402 -0
- package/dist/src/cli/index.js +90 -0
- package/dist/src/db/database.js +69 -0
- package/dist/src/db/queries.js +261 -0
- package/dist/src/db/schema.js +67 -0
- package/dist/src/server/crypto.js +22 -0
- package/dist/src/server/gateway-server.js +200 -0
- package/dist/src/server/gateway.js +76 -0
- package/dist/src/server/logger.js +72 -0
- package/dist/src/server/providers/anthropic.js +52 -0
- package/dist/src/server/providers/gemini.js +64 -0
- package/dist/src/server/providers/index.js +16 -0
- package/dist/src/server/providers/openai.js +86 -0
- package/dist/src/server/providers/types.js +1 -0
- package/dist/src/server/service-manager.js +286 -0
- package/docs/TODO.md +19 -0
- package/next.config.js +7 -0
- package/openspec/AGENTS.md +456 -0
- package/openspec/changes/add-logging/proposal.md +18 -0
- package/openspec/changes/add-logging/specs/core/spec.md +21 -0
- package/openspec/changes/add-logging/tasks.md +16 -0
- package/openspec/changes/add-provider-test-connection/proposal.md +22 -0
- package/openspec/changes/add-provider-test-connection/specs/model-provider/spec.md +68 -0
- package/openspec/changes/add-provider-test-connection/tasks.md +31 -0
- package/openspec/changes/improve-gateway-startup/design.md +137 -0
- package/openspec/changes/improve-gateway-startup/proposal.md +33 -0
- package/openspec/changes/improve-gateway-startup/specs/api-gateway/spec.md +94 -0
- package/openspec/changes/improve-gateway-startup/specs/web-ui/spec.md +67 -0
- package/openspec/changes/improve-gateway-startup/tasks.md +47 -0
- package/openspec/changes/init-api-gateway/design.md +185 -0
- package/openspec/changes/init-api-gateway/proposal.md +30 -0
- package/openspec/changes/init-api-gateway/specs/api-gateway/spec.md +42 -0
- package/openspec/changes/init-api-gateway/specs/cli-tool/spec.md +40 -0
- package/openspec/changes/init-api-gateway/specs/model-management/spec.md +47 -0
- package/openspec/changes/init-api-gateway/specs/model-provider/spec.md +33 -0
- package/openspec/changes/init-api-gateway/specs/request-logging/spec.md +54 -0
- package/openspec/changes/init-api-gateway/specs/web-ui/spec.md +49 -0
- package/openspec/changes/init-api-gateway/tasks.md +84 -0
- package/openspec/project.md +58 -0
- package/package.json +51 -0
- package/postcss.config.js +6 -0
- package/src/app/api/config/route.ts +62 -0
- package/src/app/api/gateway/[...path]/route.ts +118 -0
- package/src/app/api/gateway/route.ts +77 -0
- package/src/app/api/logs/route.ts +48 -0
- package/src/app/api/models/route.ts +210 -0
- package/src/app/api/providers/route.ts +162 -0
- package/src/app/api/providers/test/route.ts +182 -0
- package/src/app/api/service/start/route.ts +73 -0
- package/src/app/api/service/status/route.ts +22 -0
- package/src/app/api/service/stop/route.ts +27 -0
- package/src/app/components/ConfirmDialog.tsx +63 -0
- package/src/app/components/Nav.tsx +66 -0
- package/src/app/components/Toast.tsx +61 -0
- package/src/app/components/ToastProvider.tsx +43 -0
- package/src/app/globals.css +71 -0
- package/src/app/layout.tsx +22 -0
- package/src/app/logs/page.tsx +261 -0
- package/src/app/models/page.tsx +500 -0
- package/src/app/page.tsx +742 -0
- package/src/app/providers/page.tsx +558 -0
- package/src/cli/index.ts +95 -0
- package/src/db/database.ts +125 -0
- package/src/db/queries.ts +339 -0
- package/src/db/schema.ts +117 -0
- package/src/server/crypto.ts +48 -0
- package/src/server/gateway-server.ts +306 -0
- package/src/server/gateway.ts +163 -0
- package/src/server/logger.ts +96 -0
- package/src/server/providers/anthropic.ts +121 -0
- package/src/server/providers/gemini.ts +112 -0
- package/src/server/providers/index.ts +20 -0
- package/src/server/providers/openai.ts +235 -0
- package/src/server/providers/types.ts +20 -0
- package/src/server/service-manager.ts +321 -0
- package/tailwind.config.js +16 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# OpenSpec Instructions
|
|
2
|
+
|
|
3
|
+
Instructions for AI coding assistants using OpenSpec for spec-driven development.
|
|
4
|
+
|
|
5
|
+
## TL;DR Quick Checklist
|
|
6
|
+
|
|
7
|
+
- Search existing work: `openspec spec list --long`, `openspec list` (use `rg` only for full-text search)
|
|
8
|
+
- Decide scope: new capability vs modify existing capability
|
|
9
|
+
- Pick a unique `change-id`: kebab-case, verb-led (`add-`, `update-`, `remove-`, `refactor-`)
|
|
10
|
+
- Scaffold: `proposal.md`, `tasks.md`, `design.md` (only if needed), and delta specs per affected capability
|
|
11
|
+
- Write deltas: use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements`; include at least one `#### Scenario:` per requirement
|
|
12
|
+
- Validate: `openspec validate [change-id] --strict` and fix issues
|
|
13
|
+
- Request approval: Do not start implementation until proposal is approved
|
|
14
|
+
|
|
15
|
+
## Three-Stage Workflow
|
|
16
|
+
|
|
17
|
+
### Stage 1: Creating Changes
|
|
18
|
+
Create proposal when you need to:
|
|
19
|
+
- Add features or functionality
|
|
20
|
+
- Make breaking changes (API, schema)
|
|
21
|
+
- Change architecture or patterns
|
|
22
|
+
- Optimize performance (changes behavior)
|
|
23
|
+
- Update security patterns
|
|
24
|
+
|
|
25
|
+
Triggers (examples):
|
|
26
|
+
- "Help me create a change proposal"
|
|
27
|
+
- "Help me plan a change"
|
|
28
|
+
- "Help me create a proposal"
|
|
29
|
+
- "I want to create a spec proposal"
|
|
30
|
+
- "I want to create a spec"
|
|
31
|
+
|
|
32
|
+
Loose matching guidance:
|
|
33
|
+
- Contains one of: `proposal`, `change`, `spec`
|
|
34
|
+
- With one of: `create`, `plan`, `make`, `start`, `help`
|
|
35
|
+
|
|
36
|
+
Skip proposal for:
|
|
37
|
+
- Bug fixes (restore intended behavior)
|
|
38
|
+
- Typos, formatting, comments
|
|
39
|
+
- Dependency updates (non-breaking)
|
|
40
|
+
- Configuration changes
|
|
41
|
+
- Tests for existing behavior
|
|
42
|
+
|
|
43
|
+
**Workflow**
|
|
44
|
+
1. Review `openspec/project.md`, `openspec list`, and `openspec list --specs` to understand current context.
|
|
45
|
+
2. Choose a unique verb-led `change-id` and scaffold `proposal.md`, `tasks.md`, optional `design.md`, and spec deltas under `openspec/changes/<id>/`.
|
|
46
|
+
3. Draft spec deltas using `## ADDED|MODIFIED|REMOVED Requirements` with at least one `#### Scenario:` per requirement.
|
|
47
|
+
4. Run `openspec validate <id> --strict` and resolve any issues before sharing the proposal.
|
|
48
|
+
|
|
49
|
+
### Stage 2: Implementing Changes
|
|
50
|
+
Track these steps as TODOs and complete them one by one.
|
|
51
|
+
1. **Read proposal.md** - Understand what's being built
|
|
52
|
+
2. **Read design.md** (if exists) - Review technical decisions
|
|
53
|
+
3. **Read tasks.md** - Get implementation checklist
|
|
54
|
+
4. **Implement tasks sequentially** - Complete in order
|
|
55
|
+
5. **Confirm completion** - Ensure every item in `tasks.md` is finished before updating statuses
|
|
56
|
+
6. **Update checklist** - After all work is done, set every task to `- [x]` so the list reflects reality
|
|
57
|
+
7. **Approval gate** - Do not start implementation until the proposal is reviewed and approved
|
|
58
|
+
|
|
59
|
+
### Stage 3: Archiving Changes
|
|
60
|
+
After deployment, create separate PR to:
|
|
61
|
+
- Move `changes/[name]/` → `changes/archive/YYYY-MM-DD-[name]/`
|
|
62
|
+
- Update `specs/` if capabilities changed
|
|
63
|
+
- Use `openspec archive <change-id> --skip-specs --yes` for tooling-only changes (always pass the change ID explicitly)
|
|
64
|
+
- Run `openspec validate --strict` to confirm the archived change passes checks
|
|
65
|
+
|
|
66
|
+
## Before Any Task
|
|
67
|
+
|
|
68
|
+
**Context Checklist:**
|
|
69
|
+
- [ ] Read relevant specs in `specs/[capability]/spec.md`
|
|
70
|
+
- [ ] Check pending changes in `changes/` for conflicts
|
|
71
|
+
- [ ] Read `openspec/project.md` for conventions
|
|
72
|
+
- [ ] Run `openspec list` to see active changes
|
|
73
|
+
- [ ] Run `openspec list --specs` to see existing capabilities
|
|
74
|
+
|
|
75
|
+
**Before Creating Specs:**
|
|
76
|
+
- Always check if capability already exists
|
|
77
|
+
- Prefer modifying existing specs over creating duplicates
|
|
78
|
+
- Use `openspec show [spec]` to review current state
|
|
79
|
+
- If request is ambiguous, ask 1–2 clarifying questions before scaffolding
|
|
80
|
+
|
|
81
|
+
### Search Guidance
|
|
82
|
+
- Enumerate specs: `openspec spec list --long` (or `--json` for scripts)
|
|
83
|
+
- Enumerate changes: `openspec list` (or `openspec change list --json` - deprecated but available)
|
|
84
|
+
- Show details:
|
|
85
|
+
- Spec: `openspec show <spec-id> --type spec` (use `--json` for filters)
|
|
86
|
+
- Change: `openspec show <change-id> --json --deltas-only`
|
|
87
|
+
- Full-text search (use ripgrep): `rg -n "Requirement:|Scenario:" openspec/specs`
|
|
88
|
+
|
|
89
|
+
## Quick Start
|
|
90
|
+
|
|
91
|
+
### CLI Commands
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Essential commands
|
|
95
|
+
openspec list # List active changes
|
|
96
|
+
openspec list --specs # List specifications
|
|
97
|
+
openspec show [item] # Display change or spec
|
|
98
|
+
openspec validate [item] # Validate changes or specs
|
|
99
|
+
openspec archive <change-id> [--yes|-y] # Archive after deployment (add --yes for non-interactive runs)
|
|
100
|
+
|
|
101
|
+
# Project management
|
|
102
|
+
openspec init [path] # Initialize OpenSpec
|
|
103
|
+
openspec update [path] # Update instruction files
|
|
104
|
+
|
|
105
|
+
# Interactive mode
|
|
106
|
+
openspec show # Prompts for selection
|
|
107
|
+
openspec validate # Bulk validation mode
|
|
108
|
+
|
|
109
|
+
# Debugging
|
|
110
|
+
openspec show [change] --json --deltas-only
|
|
111
|
+
openspec validate [change] --strict
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Command Flags
|
|
115
|
+
|
|
116
|
+
- `--json` - Machine-readable output
|
|
117
|
+
- `--type change|spec` - Disambiguate items
|
|
118
|
+
- `--strict` - Comprehensive validation
|
|
119
|
+
- `--no-interactive` - Disable prompts
|
|
120
|
+
- `--skip-specs` - Archive without spec updates
|
|
121
|
+
- `--yes`/`-y` - Skip confirmation prompts (non-interactive archive)
|
|
122
|
+
|
|
123
|
+
## Directory Structure
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
openspec/
|
|
127
|
+
├── project.md # Project conventions
|
|
128
|
+
├── specs/ # Current truth - what IS built
|
|
129
|
+
│ └── [capability]/ # Single focused capability
|
|
130
|
+
│ ├── spec.md # Requirements and scenarios
|
|
131
|
+
│ └── design.md # Technical patterns
|
|
132
|
+
├── changes/ # Proposals - what SHOULD change
|
|
133
|
+
│ ├── [change-name]/
|
|
134
|
+
│ │ ├── proposal.md # Why, what, impact
|
|
135
|
+
│ │ ├── tasks.md # Implementation checklist
|
|
136
|
+
│ │ ├── design.md # Technical decisions (optional; see criteria)
|
|
137
|
+
│ │ └── specs/ # Delta changes
|
|
138
|
+
│ │ └── [capability]/
|
|
139
|
+
│ │ └── spec.md # ADDED/MODIFIED/REMOVED
|
|
140
|
+
│ └── archive/ # Completed changes
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Creating Change Proposals
|
|
144
|
+
|
|
145
|
+
### Decision Tree
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
New request?
|
|
149
|
+
├─ Bug fix restoring spec behavior? → Fix directly
|
|
150
|
+
├─ Typo/format/comment? → Fix directly
|
|
151
|
+
├─ New feature/capability? → Create proposal
|
|
152
|
+
├─ Breaking change? → Create proposal
|
|
153
|
+
├─ Architecture change? → Create proposal
|
|
154
|
+
└─ Unclear? → Create proposal (safer)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Proposal Structure
|
|
158
|
+
|
|
159
|
+
1. **Create directory:** `changes/[change-id]/` (kebab-case, verb-led, unique)
|
|
160
|
+
|
|
161
|
+
2. **Write proposal.md:**
|
|
162
|
+
```markdown
|
|
163
|
+
# Change: [Brief description of change]
|
|
164
|
+
|
|
165
|
+
## Why
|
|
166
|
+
[1-2 sentences on problem/opportunity]
|
|
167
|
+
|
|
168
|
+
## What Changes
|
|
169
|
+
- [Bullet list of changes]
|
|
170
|
+
- [Mark breaking changes with **BREAKING**]
|
|
171
|
+
|
|
172
|
+
## Impact
|
|
173
|
+
- Affected specs: [list capabilities]
|
|
174
|
+
- Affected code: [key files/systems]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
3. **Create spec deltas:** `specs/[capability]/spec.md`
|
|
178
|
+
```markdown
|
|
179
|
+
## ADDED Requirements
|
|
180
|
+
### Requirement: New Feature
|
|
181
|
+
The system SHALL provide...
|
|
182
|
+
|
|
183
|
+
#### Scenario: Success case
|
|
184
|
+
- **WHEN** user performs action
|
|
185
|
+
- **THEN** expected result
|
|
186
|
+
|
|
187
|
+
## MODIFIED Requirements
|
|
188
|
+
### Requirement: Existing Feature
|
|
189
|
+
[Complete modified requirement]
|
|
190
|
+
|
|
191
|
+
## REMOVED Requirements
|
|
192
|
+
### Requirement: Old Feature
|
|
193
|
+
**Reason**: [Why removing]
|
|
194
|
+
**Migration**: [How to handle]
|
|
195
|
+
```
|
|
196
|
+
If multiple capabilities are affected, create multiple delta files under `changes/[change-id]/specs/<capability>/spec.md`—one per capability.
|
|
197
|
+
|
|
198
|
+
4. **Create tasks.md:**
|
|
199
|
+
```markdown
|
|
200
|
+
## 1. Implementation
|
|
201
|
+
- [ ] 1.1 Create database schema
|
|
202
|
+
- [ ] 1.2 Implement API endpoint
|
|
203
|
+
- [ ] 1.3 Add frontend component
|
|
204
|
+
- [ ] 1.4 Write tests
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
5. **Create design.md when needed:**
|
|
208
|
+
Create `design.md` if any of the following apply; otherwise omit it:
|
|
209
|
+
- Cross-cutting change (multiple services/modules) or a new architectural pattern
|
|
210
|
+
- New external dependency or significant data model changes
|
|
211
|
+
- Security, performance, or migration complexity
|
|
212
|
+
- Ambiguity that benefits from technical decisions before coding
|
|
213
|
+
|
|
214
|
+
Minimal `design.md` skeleton:
|
|
215
|
+
```markdown
|
|
216
|
+
## Context
|
|
217
|
+
[Background, constraints, stakeholders]
|
|
218
|
+
|
|
219
|
+
## Goals / Non-Goals
|
|
220
|
+
- Goals: [...]
|
|
221
|
+
- Non-Goals: [...]
|
|
222
|
+
|
|
223
|
+
## Decisions
|
|
224
|
+
- Decision: [What and why]
|
|
225
|
+
- Alternatives considered: [Options + rationale]
|
|
226
|
+
|
|
227
|
+
## Risks / Trade-offs
|
|
228
|
+
- [Risk] → Mitigation
|
|
229
|
+
|
|
230
|
+
## Migration Plan
|
|
231
|
+
[Steps, rollback]
|
|
232
|
+
|
|
233
|
+
## Open Questions
|
|
234
|
+
- [...]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Spec File Format
|
|
238
|
+
|
|
239
|
+
### Critical: Scenario Formatting
|
|
240
|
+
|
|
241
|
+
**CORRECT** (use #### headers):
|
|
242
|
+
```markdown
|
|
243
|
+
#### Scenario: User login success
|
|
244
|
+
- **WHEN** valid credentials provided
|
|
245
|
+
- **THEN** return JWT token
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**WRONG** (don't use bullets or bold):
|
|
249
|
+
```markdown
|
|
250
|
+
- **Scenario: User login** ❌
|
|
251
|
+
**Scenario**: User login ❌
|
|
252
|
+
### Scenario: User login ❌
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Every requirement MUST have at least one scenario.
|
|
256
|
+
|
|
257
|
+
### Requirement Wording
|
|
258
|
+
- Use SHALL/MUST for normative requirements (avoid should/may unless intentionally non-normative)
|
|
259
|
+
|
|
260
|
+
### Delta Operations
|
|
261
|
+
|
|
262
|
+
- `## ADDED Requirements` - New capabilities
|
|
263
|
+
- `## MODIFIED Requirements` - Changed behavior
|
|
264
|
+
- `## REMOVED Requirements` - Deprecated features
|
|
265
|
+
- `## RENAMED Requirements` - Name changes
|
|
266
|
+
|
|
267
|
+
Headers matched with `trim(header)` - whitespace ignored.
|
|
268
|
+
|
|
269
|
+
#### When to use ADDED vs MODIFIED
|
|
270
|
+
- ADDED: Introduces a new capability or sub-capability that can stand alone as a requirement. Prefer ADDED when the change is orthogonal (e.g., adding "Slash Command Configuration") rather than altering the semantics of an existing requirement.
|
|
271
|
+
- MODIFIED: Changes the behavior, scope, or acceptance criteria of an existing requirement. Always paste the full, updated requirement content (header + all scenarios). The archiver will replace the entire requirement with what you provide here; partial deltas will drop previous details.
|
|
272
|
+
- RENAMED: Use when only the name changes. If you also change behavior, use RENAMED (name) plus MODIFIED (content) referencing the new name.
|
|
273
|
+
|
|
274
|
+
Common pitfall: Using MODIFIED to add a new concern without including the previous text. This causes loss of detail at archive time. If you aren’t explicitly changing the existing requirement, add a new requirement under ADDED instead.
|
|
275
|
+
|
|
276
|
+
Authoring a MODIFIED requirement correctly:
|
|
277
|
+
1) Locate the existing requirement in `openspec/specs/<capability>/spec.md`.
|
|
278
|
+
2) Copy the entire requirement block (from `### Requirement: ...` through its scenarios).
|
|
279
|
+
3) Paste it under `## MODIFIED Requirements` and edit to reflect the new behavior.
|
|
280
|
+
4) Ensure the header text matches exactly (whitespace-insensitive) and keep at least one `#### Scenario:`.
|
|
281
|
+
|
|
282
|
+
Example for RENAMED:
|
|
283
|
+
```markdown
|
|
284
|
+
## RENAMED Requirements
|
|
285
|
+
- FROM: `### Requirement: Login`
|
|
286
|
+
- TO: `### Requirement: User Authentication`
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Troubleshooting
|
|
290
|
+
|
|
291
|
+
### Common Errors
|
|
292
|
+
|
|
293
|
+
**"Change must have at least one delta"**
|
|
294
|
+
- Check `changes/[name]/specs/` exists with .md files
|
|
295
|
+
- Verify files have operation prefixes (## ADDED Requirements)
|
|
296
|
+
|
|
297
|
+
**"Requirement must have at least one scenario"**
|
|
298
|
+
- Check scenarios use `#### Scenario:` format (4 hashtags)
|
|
299
|
+
- Don't use bullet points or bold for scenario headers
|
|
300
|
+
|
|
301
|
+
**Silent scenario parsing failures**
|
|
302
|
+
- Exact format required: `#### Scenario: Name`
|
|
303
|
+
- Debug with: `openspec show [change] --json --deltas-only`
|
|
304
|
+
|
|
305
|
+
### Validation Tips
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Always use strict mode for comprehensive checks
|
|
309
|
+
openspec validate [change] --strict
|
|
310
|
+
|
|
311
|
+
# Debug delta parsing
|
|
312
|
+
openspec show [change] --json | jq '.deltas'
|
|
313
|
+
|
|
314
|
+
# Check specific requirement
|
|
315
|
+
openspec show [spec] --json -r 1
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Happy Path Script
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# 1) Explore current state
|
|
322
|
+
openspec spec list --long
|
|
323
|
+
openspec list
|
|
324
|
+
# Optional full-text search:
|
|
325
|
+
# rg -n "Requirement:|Scenario:" openspec/specs
|
|
326
|
+
# rg -n "^#|Requirement:" openspec/changes
|
|
327
|
+
|
|
328
|
+
# 2) Choose change id and scaffold
|
|
329
|
+
CHANGE=add-two-factor-auth
|
|
330
|
+
mkdir -p openspec/changes/$CHANGE/{specs/auth}
|
|
331
|
+
printf "## Why\n...\n\n## What Changes\n- ...\n\n## Impact\n- ...\n" > openspec/changes/$CHANGE/proposal.md
|
|
332
|
+
printf "## 1. Implementation\n- [ ] 1.1 ...\n" > openspec/changes/$CHANGE/tasks.md
|
|
333
|
+
|
|
334
|
+
# 3) Add deltas (example)
|
|
335
|
+
cat > openspec/changes/$CHANGE/specs/auth/spec.md << 'EOF'
|
|
336
|
+
## ADDED Requirements
|
|
337
|
+
### Requirement: Two-Factor Authentication
|
|
338
|
+
Users MUST provide a second factor during login.
|
|
339
|
+
|
|
340
|
+
#### Scenario: OTP required
|
|
341
|
+
- **WHEN** valid credentials are provided
|
|
342
|
+
- **THEN** an OTP challenge is required
|
|
343
|
+
EOF
|
|
344
|
+
|
|
345
|
+
# 4) Validate
|
|
346
|
+
openspec validate $CHANGE --strict
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Multi-Capability Example
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
openspec/changes/add-2fa-notify/
|
|
353
|
+
├── proposal.md
|
|
354
|
+
├── tasks.md
|
|
355
|
+
└── specs/
|
|
356
|
+
├── auth/
|
|
357
|
+
│ └── spec.md # ADDED: Two-Factor Authentication
|
|
358
|
+
└── notifications/
|
|
359
|
+
└── spec.md # ADDED: OTP email notification
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
auth/spec.md
|
|
363
|
+
```markdown
|
|
364
|
+
## ADDED Requirements
|
|
365
|
+
### Requirement: Two-Factor Authentication
|
|
366
|
+
...
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
notifications/spec.md
|
|
370
|
+
```markdown
|
|
371
|
+
## ADDED Requirements
|
|
372
|
+
### Requirement: OTP Email Notification
|
|
373
|
+
...
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Best Practices
|
|
377
|
+
|
|
378
|
+
### Simplicity First
|
|
379
|
+
- Default to <100 lines of new code
|
|
380
|
+
- Single-file implementations until proven insufficient
|
|
381
|
+
- Avoid frameworks without clear justification
|
|
382
|
+
- Choose boring, proven patterns
|
|
383
|
+
|
|
384
|
+
### Complexity Triggers
|
|
385
|
+
Only add complexity with:
|
|
386
|
+
- Performance data showing current solution too slow
|
|
387
|
+
- Concrete scale requirements (>1000 users, >100MB data)
|
|
388
|
+
- Multiple proven use cases requiring abstraction
|
|
389
|
+
|
|
390
|
+
### Clear References
|
|
391
|
+
- Use `file.ts:42` format for code locations
|
|
392
|
+
- Reference specs as `specs/auth/spec.md`
|
|
393
|
+
- Link related changes and PRs
|
|
394
|
+
|
|
395
|
+
### Capability Naming
|
|
396
|
+
- Use verb-noun: `user-auth`, `payment-capture`
|
|
397
|
+
- Single purpose per capability
|
|
398
|
+
- 10-minute understandability rule
|
|
399
|
+
- Split if description needs "AND"
|
|
400
|
+
|
|
401
|
+
### Change ID Naming
|
|
402
|
+
- Use kebab-case, short and descriptive: `add-two-factor-auth`
|
|
403
|
+
- Prefer verb-led prefixes: `add-`, `update-`, `remove-`, `refactor-`
|
|
404
|
+
- Ensure uniqueness; if taken, append `-2`, `-3`, etc.
|
|
405
|
+
|
|
406
|
+
## Tool Selection Guide
|
|
407
|
+
|
|
408
|
+
| Task | Tool | Why |
|
|
409
|
+
|------|------|-----|
|
|
410
|
+
| Find files by pattern | Glob | Fast pattern matching |
|
|
411
|
+
| Search code content | Grep | Optimized regex search |
|
|
412
|
+
| Read specific files | Read | Direct file access |
|
|
413
|
+
| Explore unknown scope | Task | Multi-step investigation |
|
|
414
|
+
|
|
415
|
+
## Error Recovery
|
|
416
|
+
|
|
417
|
+
### Change Conflicts
|
|
418
|
+
1. Run `openspec list` to see active changes
|
|
419
|
+
2. Check for overlapping specs
|
|
420
|
+
3. Coordinate with change owners
|
|
421
|
+
4. Consider combining proposals
|
|
422
|
+
|
|
423
|
+
### Validation Failures
|
|
424
|
+
1. Run with `--strict` flag
|
|
425
|
+
2. Check JSON output for details
|
|
426
|
+
3. Verify spec file format
|
|
427
|
+
4. Ensure scenarios properly formatted
|
|
428
|
+
|
|
429
|
+
### Missing Context
|
|
430
|
+
1. Read project.md first
|
|
431
|
+
2. Check related specs
|
|
432
|
+
3. Review recent archives
|
|
433
|
+
4. Ask for clarification
|
|
434
|
+
|
|
435
|
+
## Quick Reference
|
|
436
|
+
|
|
437
|
+
### Stage Indicators
|
|
438
|
+
- `changes/` - Proposed, not yet built
|
|
439
|
+
- `specs/` - Built and deployed
|
|
440
|
+
- `archive/` - Completed changes
|
|
441
|
+
|
|
442
|
+
### File Purposes
|
|
443
|
+
- `proposal.md` - Why and what
|
|
444
|
+
- `tasks.md` - Implementation steps
|
|
445
|
+
- `design.md` - Technical decisions
|
|
446
|
+
- `spec.md` - Requirements and behavior
|
|
447
|
+
|
|
448
|
+
### CLI Essentials
|
|
449
|
+
```bash
|
|
450
|
+
openspec list # What's in progress?
|
|
451
|
+
openspec show [item] # View details
|
|
452
|
+
openspec validate --strict # Is it correct?
|
|
453
|
+
openspec archive <change-id> [--yes|-y] # Mark complete (add --yes for automation)
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
Remember: Specs are truth. Changes are proposals. Keep them in sync.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Change: Add Logging Functionality
|
|
2
|
+
|
|
3
|
+
## Why
|
|
4
|
+
当前项目缺乏统一的日志记录机制,难以追踪技能脚本的执行情况和调试问题。添加日志功能将帮助开发者了解系统运行状态,快速定位问题。
|
|
5
|
+
|
|
6
|
+
## What Changes
|
|
7
|
+
- 添加 Python 日志模块集成到核心脚本
|
|
8
|
+
- 支持不同日志级别(DEBUG, INFO, WARNING, ERROR)
|
|
9
|
+
- 日志输出到控制台和可选的文件
|
|
10
|
+
- 在关键操作点添加日志记录(搜索查询、结果数量、错误处理)
|
|
11
|
+
|
|
12
|
+
## Impact
|
|
13
|
+
- Affected specs: `core` (新增日志记录能力)
|
|
14
|
+
- Affected code:
|
|
15
|
+
- `.claude/skills/ui-ux-pro-max/scripts/core.py`
|
|
16
|
+
- `.claude/skills/ui-ux-pro-max/scripts/search.py`
|
|
17
|
+
- `.shared/ui-ux-pro-max/scripts/core.py`
|
|
18
|
+
- `.shared/ui-ux-pro-max/scripts/search.py`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## ADDED Requirements
|
|
2
|
+
|
|
3
|
+
### Requirement: Logging Infrastructure
|
|
4
|
+
The system SHALL provide logging functionality for debugging and monitoring script execution.
|
|
5
|
+
|
|
6
|
+
#### Scenario: Log search query
|
|
7
|
+
- **WHEN** a search query is executed
|
|
8
|
+
- **THEN** the query text and selected domain are logged at INFO level
|
|
9
|
+
|
|
10
|
+
#### Scenario: Log search results
|
|
11
|
+
- **WHEN** search results are returned
|
|
12
|
+
- **THEN** the result count and domain are logged at INFO level
|
|
13
|
+
|
|
14
|
+
#### Scenario: Log errors
|
|
15
|
+
- **WHEN** an error occurs during search or file operations
|
|
16
|
+
- **THEN** the error message and context are logged at ERROR level
|
|
17
|
+
|
|
18
|
+
#### Scenario: Configurable log levels
|
|
19
|
+
- **WHEN** logging is initialized
|
|
20
|
+
- **THEN** the log level can be configured (DEBUG, INFO, WARNING, ERROR)
|
|
21
|
+
- **AND** logs are output to console by default
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## 1. Implementation
|
|
2
|
+
- [ ] 1.1 在 `core.py` 中添加日志配置函数
|
|
3
|
+
- [ ] 1.2 在 BM25 类的关键方法中添加日志记录
|
|
4
|
+
- [ ] 1.3 在搜索函数中添加查询和结果日志
|
|
5
|
+
- [ ] 1.4 在错误处理路径中添加错误日志
|
|
6
|
+
- [ ] 1.5 更新 `search.py` 使用日志功能
|
|
7
|
+
- [ ] 1.6 同步更新 `.shared/` 目录下的脚本
|
|
8
|
+
|
|
9
|
+
## 2. Testing
|
|
10
|
+
- [ ] 2.1 验证日志在不同级别下正确输出
|
|
11
|
+
- [ ] 2.2 验证日志文件创建和写入(如果启用)
|
|
12
|
+
- [ ] 2.3 验证错误情况下的日志记录
|
|
13
|
+
|
|
14
|
+
## 3. Documentation
|
|
15
|
+
- [ ] 3.1 更新技能文档说明日志功能
|
|
16
|
+
- [ ] 3.2 添加日志配置示例
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Change: 添加供应商测试连接功能
|
|
2
|
+
|
|
3
|
+
## Why
|
|
4
|
+
用户需要验证供应商配置是否正确,特别是 API Key 和 Base URL 是否有效。通过测试连接功能,用户可以在添加或编辑供应商后立即验证配置,避免在后续使用过程中才发现配置错误,提升用户体验和配置效率。
|
|
5
|
+
|
|
6
|
+
## What Changes
|
|
7
|
+
- **新增测试连接按钮**:在供应商管理页面的操作列添加"测试连接"按钮
|
|
8
|
+
- **新增模型选择下拉菜单**:点击测试连接按钮后,显示该供应商下的可用模型列表,用户可以选择一个模型进行测试
|
|
9
|
+
- **新增测试连接 API**:实现后端 API 端点,用于测试供应商连接和模型可用性
|
|
10
|
+
- **新增测试结果反馈**:测试完成后显示成功或失败提示,失败时显示具体错误信息
|
|
11
|
+
|
|
12
|
+
## Impact
|
|
13
|
+
- Affected specs:
|
|
14
|
+
- `model-provider` (修改:添加测试连接功能)
|
|
15
|
+
- Affected code:
|
|
16
|
+
- `src/app/providers/page.tsx` (前端:添加测试连接按钮和模型选择下拉)
|
|
17
|
+
- `src/app/api/providers/route.ts` (后端:添加测试连接 API 端点)
|
|
18
|
+
- `src/server/providers/index.ts` (可能需要添加测试连接方法)
|
|
19
|
+
- `src/server/providers/types.ts` (可能需要扩展接口)
|
|
20
|
+
- 技术栈:
|
|
21
|
+
- 使用现有的 ProviderAdapter 接口进行测试
|
|
22
|
+
- 通过调用供应商的 API 验证连接
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
## MODIFIED Requirements
|
|
2
|
+
|
|
3
|
+
### Requirement: 模型供应商管理
|
|
4
|
+
The system SHALL allow users to add, configure, and manage multiple AI model providers.
|
|
5
|
+
|
|
6
|
+
#### Scenario: 添加新供应商
|
|
7
|
+
- **WHEN** 用户在 Web 界面填写供应商信息(名称、协议类型、baseUrl、API Key)
|
|
8
|
+
- **THEN** 供应商信息保存到数据库
|
|
9
|
+
- **AND** API Key 加密存储
|
|
10
|
+
- **AND** 供应商出现在供应商列表中
|
|
11
|
+
|
|
12
|
+
#### Scenario: 编辑供应商配置
|
|
13
|
+
- **WHEN** 用户修改供应商的 baseUrl 或 API Key
|
|
14
|
+
- **THEN** 更新后的配置保存到数据库
|
|
15
|
+
- **AND** 配置立即生效,无需重启网关
|
|
16
|
+
|
|
17
|
+
#### Scenario: 删除供应商
|
|
18
|
+
- **WHEN** 用户删除供应商
|
|
19
|
+
- **THEN** 供应商从数据库删除
|
|
20
|
+
- **AND** 关联的模型也被标记为不可用(或删除)
|
|
21
|
+
|
|
22
|
+
#### Scenario: 验证供应商配置
|
|
23
|
+
- **WHEN** 用户添加或编辑供应商
|
|
24
|
+
- **THEN** 系统验证 baseUrl 格式和 API Key 格式
|
|
25
|
+
- **AND** 如果配置无效,显示错误提示
|
|
26
|
+
|
|
27
|
+
### Requirement: 供应商协议类型
|
|
28
|
+
The system SHALL support different provider protocol types.
|
|
29
|
+
|
|
30
|
+
#### Scenario: 选择协议类型
|
|
31
|
+
- **WHEN** 用户添加供应商
|
|
32
|
+
- **THEN** 可以从下拉列表选择协议类型(OpenAI、Anthropic、Gemini)
|
|
33
|
+
- **AND** 根据协议类型显示相应的配置字段
|
|
34
|
+
|
|
35
|
+
## ADDED Requirements
|
|
36
|
+
|
|
37
|
+
### Requirement: 供应商测试连接功能
|
|
38
|
+
The system SHALL allow users to test the connection to a provider by selecting a model and sending a test request.
|
|
39
|
+
|
|
40
|
+
#### Scenario: 测试连接成功
|
|
41
|
+
- **WHEN** 用户在供应商列表点击"测试连接"按钮
|
|
42
|
+
- **AND** 从下拉菜单选择一个模型
|
|
43
|
+
- **AND** 点击"开始测试"
|
|
44
|
+
- **THEN** 系统发送测试请求到供应商 API
|
|
45
|
+
- **AND** 如果连接成功,显示成功提示(例如:"连接成功,模型可用")
|
|
46
|
+
- **AND** 测试过程中显示加载状态
|
|
47
|
+
|
|
48
|
+
#### Scenario: 测试连接失败 - API Key 无效
|
|
49
|
+
- **WHEN** 用户测试连接时 API Key 无效或已过期
|
|
50
|
+
- **THEN** 系统显示错误提示(例如:"API Key 无效,请检查配置")
|
|
51
|
+
- **AND** 错误信息清晰明确,帮助用户定位问题
|
|
52
|
+
|
|
53
|
+
#### Scenario: 测试连接失败 - Base URL 不可访问
|
|
54
|
+
- **WHEN** 用户测试连接时 Base URL 无法访问(网络错误、DNS 解析失败等)
|
|
55
|
+
- **THEN** 系统显示网络错误提示(例如:"无法连接到服务器,请检查 Base URL 和网络连接")
|
|
56
|
+
|
|
57
|
+
#### Scenario: 测试连接失败 - 模型不存在
|
|
58
|
+
- **WHEN** 用户选择的模型在供应商中不存在或不可用
|
|
59
|
+
- **THEN** 系统显示模型错误提示(例如:"模型不存在或不可用")
|
|
60
|
+
|
|
61
|
+
#### Scenario: 测试连接超时
|
|
62
|
+
- **WHEN** 测试请求超过 10 秒未响应
|
|
63
|
+
- **THEN** 系统显示超时错误提示(例如:"连接超时,请检查网络或稍后重试")
|
|
64
|
+
|
|
65
|
+
#### Scenario: 模型列表为空
|
|
66
|
+
- **WHEN** 用户点击"测试连接"按钮
|
|
67
|
+
- **AND** 该供应商下没有配置任何模型
|
|
68
|
+
- **THEN** 系统提示用户先添加或拉取模型(例如:"该供应商下没有模型,请先添加或拉取模型")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## 1. 后端 API 实现
|
|
2
|
+
- [x] 1.1 在 `src/app/api/providers/test/route.ts` 添加 `POST /api/providers/test` 端点
|
|
3
|
+
- [x] 1.2 实现测试连接逻辑:根据 provider_id 和 model_id 获取供应商和模型信息
|
|
4
|
+
- [x] 1.3 使用 ProviderAdapter 发送测试请求(可以发送一个简单的 chat completion 请求)
|
|
5
|
+
- [x] 1.4 处理测试结果:成功返回成功信息,失败返回错误详情
|
|
6
|
+
- [x] 1.5 添加超时处理(建议 10 秒超时)
|
|
7
|
+
|
|
8
|
+
## 2. 前端 UI 实现
|
|
9
|
+
- [x] 2.1 在供应商列表的操作列添加"测试连接"按钮
|
|
10
|
+
- [x] 2.2 实现点击按钮后显示模型选择下拉菜单(显示该供应商下的所有模型)
|
|
11
|
+
- [x] 2.3 实现选择模型后触发测试连接请求
|
|
12
|
+
- [x] 2.4 实现测试过程中的加载状态显示
|
|
13
|
+
- [x] 2.5 实现测试结果提示(成功/失败 Toast 提示)
|
|
14
|
+
- [x] 2.6 失败时显示详细错误信息
|
|
15
|
+
|
|
16
|
+
## 3. 测试连接逻辑
|
|
17
|
+
- [x] 3.1 确定测试请求的方式(发送一个简单的 chat completion 请求验证连接)
|
|
18
|
+
- [x] 3.2 处理不同协议的错误响应格式
|
|
19
|
+
- [x] 3.3 验证 API Key 有效性
|
|
20
|
+
- [x] 3.4 验证 Base URL 可访问性
|
|
21
|
+
|
|
22
|
+
## 4. 错误处理
|
|
23
|
+
- [x] 4.1 处理网络错误(连接超时、DNS 解析失败等)
|
|
24
|
+
- [x] 4.2 处理认证错误(API Key 无效)
|
|
25
|
+
- [x] 4.3 处理模型不存在错误
|
|
26
|
+
- [x] 4.4 处理其他 API 错误(返回友好的错误信息)
|
|
27
|
+
|
|
28
|
+
## 5. 用户体验优化
|
|
29
|
+
- [x] 5.1 测试过程中禁用按钮,防止重复点击
|
|
30
|
+
- [x] 5.2 优化加载状态显示(按钮显示加载动画)
|
|
31
|
+
- [x] 5.3 优化错误信息展示(可读性更好的错误提示)
|