zefiro 0.3.4 → 0.3.7

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 CHANGED
@@ -6,56 +6,63 @@ AI-powered codebase scanner and QA map generator. Scans your project's AST, iden
6
6
 
7
7
  ```bash
8
8
  npm install -g zefiro
9
+ # or
10
+ bun add -g zefiro
9
11
  ```
10
12
 
11
- ### Environment Variables
12
-
13
- | Variable | Required | Description |
14
- |----------|----------|-------------|
15
- | `OPENAI_API_KEY` | Yes (if using OpenAI) | OpenAI API key |
16
- | `ANTHROPIC_API_KEY` | Yes (if using Anthropic) | Anthropic API key |
17
- | `E2E_AI_API_URL` | No | Remote API URL for QA map push |
18
- | `E2E_AI_API_KEY` | No | API key for push authentication |
19
-
20
13
  ## Quick Start
21
14
 
22
15
  ```bash
23
- # Initialize config and agents
16
+ # 1. Initialize copies agents, writes QAI_* env vars to .env
24
17
  zefiro init
25
18
 
26
- # Scan → Analyze → Push
19
+ # 2. Scan → Analyze → Push
27
20
  zefiro scan
28
21
  zefiro analyze
29
22
  zefiro push
30
23
  ```
31
24
 
32
- ## CLI Usage
25
+ ---
33
26
 
34
- ### Global Options
27
+ ## Environment Variables
35
28
 
36
- ```
37
- -k, --key <KEY> Issue key (e.g., PROJ-101)
38
- --provider <provider> LLM provider: openai | anthropic
39
- --model <model> LLM model override
40
- -v, --verbose Verbose output
41
- ```
29
+ `zefiro init` writes the `QAI_*` variables to your `.env`. You can also set them manually.
42
30
 
43
- ### Commands
31
+ | Variable | Description |
32
+ |----------|-------------|
33
+ | `QAI_INPUT_SOURCE` | Issue tracker: `none` \| `jira` \| `linear` |
34
+ | `QAI_OUTPUT_TARGET` | QA format: `markdown` \| `zephyr` \| `both` |
35
+ | `QAI_BASE_URL` | QA Intelligence API base URL |
36
+ | `QAI_API_URL` | Full push endpoint (overrides base URL) |
37
+ | `QAI_API_KEY` | API key for authenticated push |
38
+ | `OPENAI_API_KEY` | OpenAI API key (for `analyze` with OpenAI) |
39
+ | `ANTHROPIC_API_KEY` | Anthropic API key (for `analyze` with Anthropic) |
44
40
 
45
- #### `zefiro init`
41
+ ---
46
42
 
47
- Initialize zefiro in your project. Creates `.qai/zefiro/` with config and agent templates.
43
+ ## Commands
44
+
45
+ ### `zefiro init`
46
+
47
+ Initialize zefiro in your project. Copies agent templates to `.qai/zefiro/agents/` and writes `QAI_*` variables to `.env`.
48
48
 
49
49
  ```bash
50
50
  zefiro init
51
- zefiro init --non-interactive
51
+ zefiro init --non-interactive # skip prompts, use defaults
52
52
  ```
53
53
 
54
- Interactive setup prompts for issue tracker, output format, LLM provider, and base URL.
54
+ On re-run (`.qai/zefiro/agents/` already exists), preserves your existing setup and only updates agents and workflow guide.
55
+
56
+ **After init:**
57
+ 1. Generate `.qai/zefiro/context.md` using the `init-agent` prompt in your AI tool, or via MCP (`zefiro_scan_codebase`)
58
+ 2. Review the generated context
59
+ 3. Run `zefiro scan`
60
+
61
+ ---
55
62
 
56
- #### `zefiro scan`
63
+ ### `zefiro scan`
57
64
 
58
- Scan your codebase AST to extract routes, components, hooks, imports, and dependencies.
65
+ Scan your codebase AST extracts routes, components, hooks, imports, and dependencies.
59
66
 
60
67
  ```bash
61
68
  zefiro scan
@@ -70,17 +77,19 @@ zefiro scan --no-cache
70
77
  | `--scan-dir <dir>` | Directory to scan (overrides config) |
71
78
  | `--no-cache` | Disable file-level MD5 caching |
72
79
 
73
- #### `zefiro analyze [input]`
80
+ ---
74
81
 
75
- Run two-stage AI analysis to generate a QA map from the AST scan.
82
+ ### `zefiro analyze [input]`
76
83
 
77
- **Stage 1:** Feature analysis identifies features, workflows, and components.
78
- **Stage 2:** Scenario planning — generates test scenarios for each workflow.
84
+ Two-stage AI analysis that generates a QA map from the AST scan.
85
+
86
+ **Stage 1:** Feature analysis — identifies features, workflows, and components (runs in parallel).
87
+ **Stage 2:** Scenario planning — generates test scenarios for each workflow (runs in parallel).
79
88
 
80
89
  ```bash
81
90
  zefiro analyze
82
91
  zefiro analyze custom-scan.json
83
- zefiro analyze --skip-scenarios
92
+ zefiro analyze --skip-scenarios # features and workflows only
84
93
  zefiro analyze --output custom-qa-map.json
85
94
  ```
86
95
 
@@ -88,11 +97,15 @@ zefiro analyze --output custom-qa-map.json
88
97
  |--------|-------------|
89
98
  | `[input]` | AST scan file (default: `.qai/zefiro/ast-scan.json`) |
90
99
  | `--output <file>` | QA map output (default: `.qai/zefiro/qa-map.json`) |
91
- | `--skip-scenarios` | Only run feature analysis, skip scenario generation |
100
+ | `--skip-scenarios` | Skip scenario generation |
101
+
102
+ **Incremental:** if the AST is unchanged since the last run, analysis is skipped. If the AST changed, only affected features are re-analyzed.
92
103
 
93
- #### `zefiro push [input]`
104
+ ---
94
105
 
95
- Push the generated QA map to a remote API.
106
+ ### `zefiro push [input]`
107
+
108
+ Push the generated QA map to QA Intelligence (or a custom endpoint).
96
109
 
97
110
  ```bash
98
111
  zefiro push
@@ -103,34 +116,108 @@ zefiro push --commit-sha abc1234
103
116
  | Option | Description |
104
117
  |--------|-------------|
105
118
  | `[input]` | QA map file (default: `.qai/zefiro/qa-map.json`) |
106
- | `--commit-sha <sha>` | Git commit SHA to associate with the push |
119
+ | `--commit-sha <sha>` | Git commit SHA to associate with this version |
120
+
121
+ Authenticates via `zefiro auth login` session first, falls back to `QAI_API_URL` + `QAI_API_KEY`.
122
+
123
+ ---
124
+
125
+ ### `zefiro auth`
126
+
127
+ Manage authentication with QA Intelligence.
128
+
129
+ ```bash
130
+ zefiro auth login # open browser for OAuth sign-in
131
+ zefiro auth logout # revoke CLI token
132
+ zefiro auth status # show current auth status
133
+ zefiro auth switch # re-authenticate with a different org/project/app
134
+ ```
135
+
136
+ ---
137
+
138
+ ### `zefiro mcp`
139
+
140
+ Print MCP server setup instructions.
141
+
142
+ ```bash
143
+ zefiro mcp
144
+ ```
145
+
146
+ **Claude Code:**
147
+ ```bash
148
+ claude mcp add zefiro -- zefiro-mcp # project-scoped
149
+ claude mcp add zefiro -s user -- zefiro-mcp # global
150
+ ```
151
+
152
+ **Claude Desktop / other clients:**
153
+ ```json
154
+ {
155
+ "mcpServers": {
156
+ "zefiro": { "command": "zefiro-mcp" }
157
+ }
158
+ }
159
+ ```
160
+
161
+ **Available MCP tools:**
162
+
163
+ | Tool | Description |
164
+ |------|-------------|
165
+ | `zefiro_scan_codebase` | Scan project test infrastructure |
166
+ | `zefiro_scan_ast` | Deep AST scan: routes, components, hooks |
167
+ | `zefiro_scan_ast_detail` | Drill into a specific AST category |
168
+ | `zefiro_build_qa_map` | Validate and write a QAMapV2Payload |
169
+ | `zefiro_read_qa_map` | Read the existing QA map file |
107
170
 
108
- Requires `push.apiUrl` and `push.apiKey` in config or via environment variables.
171
+ ---
172
+
173
+ ## Global Options
174
+
175
+ ```
176
+ -k, --key <KEY> Issue key context (e.g. PROJ-101, LIN-42)
177
+ --provider <provider> LLM provider: openai | anthropic
178
+ --model <model> LLM model override
179
+ --verbose Verbose output
180
+ -v, --version Show version
181
+ -h, --help Show help
182
+ ```
183
+
184
+ ---
109
185
 
110
186
  ## Configuration
111
187
 
112
- Configuration lives in `.qai/zefiro/config.ts`:
188
+ For most projects, the `.env` variables written by `zefiro init` are sufficient. For advanced setups (custom paths, per-agent model overrides, integrations), create `.qai/zefiro/config.ts`:
113
189
 
114
190
  ```typescript
115
- import { defineConfig } from 'zefiro/config';
191
+ import { defineConfig } from 'zefiro';
116
192
 
117
193
  export default defineConfig({
118
- inputSource: 'jira', // 'none' | 'jira' | 'linear'
119
- outputTarget: 'markdown', // 'markdown' | 'zephyr' | 'both'
194
+ inputSource: 'jira', // 'none' | 'jira' | 'linear'
195
+ outputTarget: 'markdown', // 'markdown' | 'zephyr' | 'both'
196
+ baseUrl: 'https://qaligent.space',
197
+
198
+ scanner: {
199
+ scanDir: 'src',
200
+ include: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
201
+ exclude: ['**/node_modules/**', '**/dist/**', '**/*.test.*'],
202
+ cacheDir: '.qai/zefiro/scan-cache',
203
+ },
120
204
 
121
205
  llm: {
122
- provider: 'openai', // 'openai' | 'anthropic'
123
- model: 'gpt-4o', // Override default model
124
- agentModels: { // Per-agent overrides
206
+ provider: 'openai', // 'openai' | 'anthropic'
207
+ model: 'gpt-4o',
208
+ agentModels: { // per-agent model overrides
125
209
  'feature-analyzer-agent': 'claude-sonnet-4-20250514',
126
210
  },
127
211
  },
128
212
 
129
- scanner: {
130
- scanDir: 'src',
131
- include: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
132
- exclude: ['**/node_modules/**', '**/dist/**'],
133
- cacheDir: '.qai/zefiro/scan-cache',
213
+ paths: {
214
+ tests: 'e2e/tests',
215
+ scenarios: 'e2e/scenarios',
216
+ qaOutput: 'qa',
217
+ },
218
+
219
+ integrations: {
220
+ zephyr: { titlePrefix: 'UI Automation' },
134
221
  },
135
222
 
136
223
  push: {
@@ -140,41 +227,64 @@ export default defineConfig({
140
227
  });
141
228
  ```
142
229
 
230
+ > `QAI_*` env vars take precedence over `config.ts` values when both are set.
231
+
232
+ ---
233
+
143
234
  ## AI Agents
144
235
 
145
- Zefiro ships with 3 agents (customizable in `.qai/zefiro/agents/`):
236
+ Zefiro ships with agents copied to `.qai/zefiro/agents/` on `init`. Edit them to tune AI behavior for your project.
146
237
 
147
238
  | Agent | Purpose |
148
239
  |-------|---------|
149
- | `feature-analyzer-agent` | Identifies features, workflows, and components from AST |
150
- | `scenario-planner-agent` | Generates test scenarios for each workflow |
151
- | `scanner-agent` | Interactive agent for manual QA map building (MCP) |
240
+ | `1.feature-analyzer-agent` | Identifies features, workflows, and components from AST |
241
+ | `2.scenario-planner-agent` | Generates test scenarios for each workflow |
242
+ | `3.scanner-agent` | Interactive QA map building (used via MCP) |
243
+ | `input-agent` | Enriches form component input definitions |
244
+ | `workflow-agent` | Maps user workflows within features |
245
+
246
+ Add `.qai/zefiro/context.md` to inject project-specific context into every agent call.
247
+
248
+ ---
152
249
 
153
250
  ## QA Map Output
154
251
 
155
- The generated QA map contains:
252
+ The generated `.qai/zefiro/qa-map.json` contains:
156
253
 
157
254
  - **Features** — User-facing capabilities grouped by routes
158
- - **Workflows** — User journeys (navigation, CRUD, multi-step, configuration, search/filter)
159
- - **Components** — UI elements (forms, modals, navigation, display)
160
- - **Scenarios** — Test cases with categories (happy-path, validation, error, edge-case, permission)
255
+ - **Workflows** — User journeys (navigation, CRUD, multi-step, search/filter, configuration)
256
+ - **Components** — UI elements (forms, modals, navigation, data display)
257
+ - **Scenarios** — Test cases per workflow (happy-path, validation, error, edge-case, permission)
161
258
 
162
- ## Project Structure
259
+ ---
163
260
 
164
- After initialization, zefiro creates:
261
+ ## Project Structure
165
262
 
166
263
  ```
167
264
  your-project/
265
+ .env # QAI_* variables (written by zefiro init)
168
266
  .qai/zefiro/
169
- config.ts # Configuration
170
- context.md # Project context for AI agents
171
- agents/ # Agent prompts (customizable)
172
- workflow.md # Workflow guide
173
- ast-scan.json # AST scan output
174
- qa-map.json # Generated QA map
175
- scan-cache/ # File-level MD5 cache
267
+ config.ts # Advanced config (optional)
268
+ context.md # Project context for AI agents
269
+ agents/ # Agent prompts (customizable)
270
+ workflow.md # Workflow guide
271
+ ast-scan.json # Latest AST scan output
272
+ qa-map.json # Generated QA map
273
+ scan-cache/ # File-level MD5 cache
176
274
  ```
177
275
 
276
+ ---
277
+
278
+ ## Interactive TUI
279
+
280
+ Running `zefiro` with no arguments launches an interactive terminal UI (requires TTY, ≥ 60×20).
281
+
282
+ ```bash
283
+ zefiro
284
+ ```
285
+
286
+ ---
287
+
178
288
  ## License
179
289
 
180
290
  MIT
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  agent: feature-analyzer-agent
3
+ model: claude-sonnet-4-20250514
4
+ max_tokens: 8192
5
+ temperature: 0.2
3
6
  ---
4
7
 
5
8
  # System Prompt
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  agent: scenario-planner-agent
3
+ model: claude-sonnet-4-20250514
4
+ max_tokens: 8192
5
+ temperature: 0.2
3
6
  ---
4
7
 
5
8
  # System Prompt
@@ -6,19 +6,15 @@ temperature: 0.3
6
6
 
7
7
  # Scanner Agent — Interactive QA Map Generation
8
8
 
9
- You are an interactive scanner agent for e2e-ai. Your job is to analyze a codebase's AST scan, propose a feature/workflow structure, and produce a validated `QAMapV2Payload`.
9
+ You are an interactive scanner agent for Zefiro. Your job is to analyze a codebase's AST scan, propose a feature/workflow structure, and produce a validated `QAMapV2Payload`.
10
10
 
11
11
  **You are the LLM.** No separate AI call is made — you reason about the AST data directly and interact with the user to refine the result.
12
12
 
13
- ## How to Use
14
-
15
- Load this protocol via `e2e_ai_read_agent("scanner-agent")`, then follow the phases below in order.
16
-
17
13
  ---
18
14
 
19
15
  ## Phase 1: Scan
20
16
 
21
- 1. Call `e2e_ai_scan_ast()` — optionally pass `scanDir`, `include`, `exclude` to scope the scan.
17
+ 1. Call `zefiro_scan_ast()` — optionally pass `scanDir`, `include`, `exclude` to scope the scan.
22
18
  2. Review the returned summary: stats, routes, components, hooks, directory groups.
23
19
  3. Present an overview to the user:
24
20
  - Total files, lines, routes, components, hooks
@@ -31,7 +27,7 @@ Load this protocol via `e2e_ai_read_agent("scanner-agent")`, then follow the pha
31
27
 
32
28
  ## Phase 2: Explore & Propose
33
29
 
34
- 1. Drill into specific areas with `e2e_ai_scan_ast_detail()`:
30
+ 1. Drill into specific areas with `zefiro_scan_ast_detail()`:
35
31
  - `{ category: "routes" }` — understand navigation structure
36
32
  - `{ category: "components", filter: "src/components/**" }` — UI building blocks
37
33
  - `{ category: "hooks" }` — business logic patterns
@@ -84,11 +80,11 @@ Present the complete structure grouped by feature. Ask the user to review.
84
80
 
85
81
  ## Phase 4: Commit
86
82
 
87
- 1. Build the full `QAMapV2Payload` JSON object.
88
- 2. Call `e2e_ai_build_qa_map({ payload: <your JSON>, dryRun: true })` to validate.
83
+ 1. Build the full `QAMapV2Payload` JSON object (see schema below).
84
+ 2. Call `zefiro_build_qa_map({ payload: <your JSON>, dryRun: true })` to validate.
89
85
  3. If errors are returned, fix them and re-validate.
90
86
  4. Show the user: stats (features, workflows, scenarios), any warnings.
91
- 5. Once approved, call `e2e_ai_build_qa_map({ payload: <your JSON>, dryRun: false })` to write.
87
+ 5. Once approved, call `zefiro_build_qa_map({ payload: <your JSON>, dryRun: false })` to write.
92
88
  6. Report the output path and final stats.
93
89
 
94
90
  ---
@@ -109,9 +105,9 @@ Present the complete structure grouped by feature. Ask the user to review.
109
105
  Use prefixed IDs for clarity:
110
106
  - Features: `feat:user-auth`, `feat:dashboard`
111
107
  - Workflows: `wf:login-flow`, `wf:create-invoice`
108
+ - Workflow steps: `step:login-flow:1`, `step:login-flow:2`
112
109
  - Components: `comp:login-form`, `comp:nav-sidebar`
113
110
  - Scenarios: `sc:login-happy-path`, `sc:login-invalid-password`
114
- - Workflow steps: `step:enter-credentials`, `step:submit-form`
115
111
 
116
112
  IDs should be kebab-case, descriptive, and unique within their category.
117
113
 
@@ -120,7 +116,7 @@ IDs should be kebab-case, descriptive, and unique within their category.
120
116
  ## Incremental Updates
121
117
 
122
118
  If a QA map already exists:
123
- 1. Call `e2e_ai_read_qa_map()` to load the existing map.
119
+ 1. Call `zefiro_read_qa_map()` to load the existing map.
124
120
  2. Preserve existing IDs — don't regenerate them.
125
121
  3. Only add/update/remove entities that changed.
126
122
  4. Tell the user what changed: "Added 2 new workflows, updated 3 scenarios, removed 1 obsolete feature."
@@ -128,19 +124,91 @@ If a QA map already exists:
128
124
 
129
125
  ---
130
126
 
131
- ## Output Format
127
+ ## QAMapV2Payload Schema
132
128
 
133
- The final `QAMapV2Payload` must conform to this structure:
129
+ The payload MUST conform exactly to this schema. All fields are required unless marked optional.
134
130
 
135
- ```typescript
131
+ ```
136
132
  {
137
- features: FeatureV2[],
138
- workflows: WorkflowV2[],
139
- components: ComponentV2[],
140
- scenarios: ScenarioV2[],
141
- commitSha?: string, // auto-added by build tool
142
- metadata?: {} // optional project metadata
133
+ features: Feature[] // required
134
+ workflows: Workflow[] // required
135
+ components: Component[] // required
136
+ scenarios: Scenario[] // required
137
+ commitSha?: string // auto-injected by zefiro_build_qa_map
138
+ metadata?: object // optional
139
+ }
140
+
141
+ Feature {
142
+ id: string // e.g. "feat:auth"
143
+ name: string
144
+ description: string
145
+ routes: string[] // URL paths, e.g. ["/login", "/register"]
146
+ workflowIds: string[] // IDs of all workflows in this feature
147
+ sourceFiles: string[] // relative paths, e.g. ["src/app/login/page.tsx"]
148
+ }
149
+
150
+ Workflow {
151
+ id: string
152
+ name: string
153
+ featureId: string // must match a Feature.id
154
+ type: "navigation" | "crud" | "multi-step" | "configuration" | "search-filter"
155
+ preconditions: string[]
156
+ steps: WorkflowStep[]
157
+ componentIds: string[] // Component.id values used by this workflow
158
+ }
159
+
160
+ WorkflowStep {
161
+ id: string // e.g. "step:login-flow:1"
162
+ order: number // 1-based
163
+ description: string
164
+ componentIds: string[] // Component.id values in this step
165
+ apiCalls: string[] // e.g. ["POST /api/auth/login"]
166
+ conditionalBranches: ConditionalBranch[]
167
+ }
168
+
169
+ ConditionalBranch {
170
+ condition: string // e.g. "invalid credentials"
171
+ outcome: string // e.g. "show error message"
172
+ type: "validation" | "permission" | "error" | "business-logic"
173
+ }
174
+
175
+ Component {
176
+ id: string
177
+ name: string
178
+ type: "form" | "display" | "navigation" | "modal" | "layout" | "feedback"
179
+ sourceFiles: string[]
180
+ props: string[]
181
+ referencedByWorkflows: string[] // Workflow.id values that use this component
182
+ }
183
+
184
+ Scenario {
185
+ id: string
186
+ workflowId: string // must match a Workflow.id
187
+ featureId: string // must match a Feature.id
188
+ name: string
189
+ description: string
190
+ category: "happy-path" | "permission" | "validation" | "error" | "edge-case" | "precondition"
191
+ preconditions: string[]
192
+ steps: ScenarioStep[]
193
+ expectedOutcome: string
194
+ componentIds: string[]
195
+ workflowStepIds: string[] // WorkflowStep.id values this scenario covers
196
+ priority: "critical" | "high" | "medium" | "low"
197
+ }
198
+
199
+ ScenarioStep {
200
+ order: number // 1-based
201
+ action: string
202
+ expectedResult: string
143
203
  }
144
204
  ```
145
205
 
146
- See `src/scanner/types.ts` for the full type definitions.
206
+ **Referential integrity** (all must hold or dry-run will fail):
207
+ - `workflow.featureId` → exists in `features[].id`
208
+ - `feature.workflowIds[]` → each exists in `workflows[].id`
209
+ - `workflow.componentIds[]` → each exists in `components[].id`
210
+ - `scenario.workflowId` → exists in `workflows[].id`
211
+ - `scenario.featureId` → exists in `features[].id`
212
+ - `scenario.componentIds[]` → each exists in `components[].id`
213
+ - `scenario.workflowStepIds[]` → each exists in a `workflow.steps[].id`
214
+ - `component.referencedByWorkflows[]` → each exists in `workflows[].id`
@@ -53,6 +53,7 @@ Respond with JSON only (no markdown fences, no extra text):
53
53
 
54
54
  ## Rules
55
55
 
56
+ 0. `inputAnalysis` is an internal enrichment field — it is NOT part of the QAMapV2 schema and must be stripped before passing components to `zefiro_build_qa_map`
56
57
  1. For each component that is a form (type="form"), analyze ALL input fields
57
58
  2. Merge data from AST-extracted forms with component props to produce complete field analysis
58
59
  3. Infer the submit action from: API calls in imports, fetch/axios calls, action props, form action attribute
@@ -27,7 +27,7 @@ Respond with JSON only (no markdown fences, no extra text):
27
27
  {
28
28
  "workflows": [
29
29
  {
30
- "id": "wf:<feature-id-without-feat:>-<workflow-name>",
30
+ "id": "wf:<kebab-name>",
31
31
  "name": "Human-readable workflow name",
32
32
  "featureId": "feat:<kebab>",
33
33
  "type": "navigation|crud|multi-step|configuration|search-filter",