featureparity 0.0.35 → 0.0.36
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.
- checksums.yaml +4 -4
- data/lib/fp/commands/doctor.rb +1 -1
- data/lib/fp/commands/list.rb +6 -0
- data/lib/fp/commands/mark.rb +40 -2
- data/lib/fp/commands/matrix.rb +1 -0
- data/lib/fp/commands/report.rb +15 -3
- data/lib/fp/commands/run.rb +12 -0
- data/lib/fp/commands/surfaces.rb +138 -104
- data/lib/fp/repo_detector.rb +8 -2
- data/lib/fp/version.rb +1 -1
- data/skills/fp/SKILL.md +17 -0
- data/skills/fp/references/cli.md +17 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f2ed0718caaa1c3c2ceb9cb158d0c2a5a7718ad2d8d42d63f9e1e6056b89cd2
|
|
4
|
+
data.tar.gz: a383fe678a4c083d61f2477c4777eb7992153206e8caba98c39e7443f581635b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 01ae66612f6481088a79f7d33a101ab27d49bf07cc4484fd59c5f8cebf5588c9e2790b9b2ac7098d8861dd60ecdd6d9003c91bfcf0c248ace3dde7bb56ac9755
|
|
7
|
+
data.tar.gz: f9554935e264053682bf4fb6d720662a0d6815f03aceadf11385995cb9cca7a5be27a8c4c0462b771fdf131c71f2afb7a06c67c13ea05626851d721511dfca3b
|
data/lib/fp/commands/doctor.rb
CHANGED
data/lib/fp/commands/list.rb
CHANGED
|
@@ -263,6 +263,12 @@ module Fp
|
|
|
263
263
|
puts "Note: #{unscoped} requirement(s) name no surface this project has, " \
|
|
264
264
|
'so nothing can cover them.'
|
|
265
265
|
end
|
|
266
|
+
# Gaps are counted on approved requirements. A project that is all drafts has
|
|
267
|
+
# none of those, which is not the same as having nothing left to test.
|
|
268
|
+
if filter_desc.empty? && (report['summary'] || {})['requirements'].to_i.zero?
|
|
269
|
+
puts 'No requirement has been approved yet, so there is nothing to measure. ' \
|
|
270
|
+
'Drafts with no test: fp list --status draft --gaps, or fp coverage.'
|
|
271
|
+
end
|
|
266
272
|
next
|
|
267
273
|
end
|
|
268
274
|
|
data/lib/fp/commands/mark.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'timeout'
|
|
4
|
+
|
|
3
5
|
require 'digest'
|
|
4
6
|
require 'fileutils'
|
|
5
7
|
require 'json'
|
|
@@ -77,6 +79,9 @@ module Fp
|
|
|
77
79
|
# number from a later, fresh read is rarely second-guessed.
|
|
78
80
|
JOURNAL_TTL = 30 * 60
|
|
79
81
|
|
|
82
|
+
# How long the check that a slug names a requirement may take before it is skipped.
|
|
83
|
+
SLUG_LOOKUP_SECONDS = 3
|
|
84
|
+
|
|
80
85
|
def run(args)
|
|
81
86
|
opts, positional = parse_flags(args, KNOWN_FLAGS)
|
|
82
87
|
slug, *locations = positional
|
|
@@ -112,11 +117,42 @@ module Fp
|
|
|
112
117
|
mark_file(path, files[path], file_targets, slug, marker, opts, earlier[path])
|
|
113
118
|
end
|
|
114
119
|
|
|
115
|
-
report(results)
|
|
120
|
+
report(results, unknown_slug_warning(slug))
|
|
116
121
|
end
|
|
117
122
|
|
|
118
123
|
private
|
|
119
124
|
|
|
125
|
+
# A marker whose slug names no requirement binds nothing, and a typo here is silent
|
|
126
|
+
# until someone wonders why a test never showed up as evidence (Fizzy #2040). So
|
|
127
|
+
# when fp can ask, it says. It only asks from a checkout whose .featureparity.yml
|
|
128
|
+
# names the project and with a key configured; `fp mark` needs neither, and marking
|
|
129
|
+
# before the requirement is proposed is fine, so this warns and never refuses.
|
|
130
|
+
def unknown_slug_warning(slug)
|
|
131
|
+
return nil unless config&.valid?
|
|
132
|
+
|
|
133
|
+
project = ProjectConfig.discover(Dir.pwd).project
|
|
134
|
+
return nil unless project
|
|
135
|
+
|
|
136
|
+
api = client || Client.new(config)
|
|
137
|
+
# Marking is a local edit; a slow API must not make it wait.
|
|
138
|
+
requirements = Timeout.timeout(SLUG_LOOKUP_SECONDS) do
|
|
139
|
+
projects = api.list_projects
|
|
140
|
+
return nil unless projects[:ok]
|
|
141
|
+
|
|
142
|
+
found = (projects[:data]['projects'] || []).find { |p| p['slug'] == project || p['id'] == project }
|
|
143
|
+
return nil unless found
|
|
144
|
+
|
|
145
|
+
api.list_requirements(project_id: found['id'])
|
|
146
|
+
end
|
|
147
|
+
return nil unless requirements[:ok]
|
|
148
|
+
return nil if (requirements[:data]['requirements'] || []).any? { |r| r['slug'] == slug }
|
|
149
|
+
|
|
150
|
+
"No requirement '#{slug}' in project '#{project}'. The marker is written, but it binds nothing until " \
|
|
151
|
+
"that requirement exists: check the slug against `fp list` and `fp list --status draft`, or propose it."
|
|
152
|
+
rescue StandardError, Timeout::Error
|
|
153
|
+
nil
|
|
154
|
+
end
|
|
155
|
+
|
|
120
156
|
# Insert the marker above each target in one file. Targets go in from the bottom up,
|
|
121
157
|
# so every line number still means what it meant when the command started; each
|
|
122
158
|
# result's `line` is then where its marker sits in the file as written.
|
|
@@ -317,7 +353,9 @@ module Fp
|
|
|
317
353
|
s
|
|
318
354
|
end
|
|
319
355
|
|
|
320
|
-
def report(results)
|
|
356
|
+
def report(results, warning = nil)
|
|
357
|
+
# On stderr, so --json output stays one parseable document.
|
|
358
|
+
warn "Warning: #{warning}" if warning
|
|
321
359
|
data = results.map do |r|
|
|
322
360
|
{ file: r[:file], line: r[:line], marker: r[:marker], already_marked: r[:already] || false,
|
|
323
361
|
dry_run: r[:dry_run] || false, binds_to: r[:found] && r[:found][:title] }.compact
|
data/lib/fp/commands/matrix.rb
CHANGED
|
@@ -56,6 +56,7 @@ module Fp
|
|
|
56
56
|
if requirements.empty?
|
|
57
57
|
output.success(report.merge('project' => project_slug)) do
|
|
58
58
|
puts 'No active requirements. The matrix is empty.'
|
|
59
|
+
puts 'Drafts join it once a human approves them. Until then, see them with: fp coverage'
|
|
59
60
|
puts "Surfaces: #{surfaces.join(', ')}" unless surfaces.empty?
|
|
60
61
|
end
|
|
61
62
|
return
|
data/lib/fp/commands/report.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Fp
|
|
|
29
29
|
help_flag :test_type, "Kind of test (project's vocabulary, e.g. unit, integration, e2e)"
|
|
30
30
|
help_flag :file, 'Path to the test file (single-requirement mode)', required: true
|
|
31
31
|
help_flag :line, 'Line number of the test within the file'
|
|
32
|
-
help_flag :repo,
|
|
32
|
+
help_flag :repo, "Repository the test lives in (org/repo). Defaults to the checkout's git origin remote"
|
|
33
33
|
help_flag :pr, 'Pull request URL'
|
|
34
34
|
help_flag :sha, 'Commit SHA the evidence was observed at'
|
|
35
35
|
help_flag :work_item, 'Work-item URL (card/issue) that prompted the work'
|
|
@@ -69,6 +69,11 @@ module Fp
|
|
|
69
69
|
|
|
70
70
|
VALID_STATES = %w[present stub].freeze
|
|
71
71
|
|
|
72
|
+
# "org/repo" from the git origin remote of the checkout at `dir`, or nil.
|
|
73
|
+
def self.inferred_repo(dir = Dir.pwd)
|
|
74
|
+
RepoDetector.new(dir).git_remote_repo
|
|
75
|
+
end
|
|
76
|
+
|
|
72
77
|
def run(args)
|
|
73
78
|
opts, positional = parse_flags(args, KNOWN_FLAGS)
|
|
74
79
|
|
|
@@ -83,7 +88,7 @@ module Fp
|
|
|
83
88
|
require_project!(opts)
|
|
84
89
|
require_flag(opts, :surface)
|
|
85
90
|
require_flag(opts, :file)
|
|
86
|
-
|
|
91
|
+
resolve_repo!(opts)
|
|
87
92
|
|
|
88
93
|
# Validate state
|
|
89
94
|
state = opts[:state] || 'present'
|
|
@@ -207,13 +212,20 @@ module Fp
|
|
|
207
212
|
stored_source == 'ci' && CI_STATUSES.include?(stored_status) && stored_status != requested_state
|
|
208
213
|
end
|
|
209
214
|
|
|
215
|
+
# --repo, or the checkout's own origin remote when it wasn't given: an agent working
|
|
216
|
+
# in a clone shouldn't have to retype what git already knows (Fizzy #2040).
|
|
217
|
+
def resolve_repo!(opts)
|
|
218
|
+
opts[:repo] ||= self.class.inferred_repo
|
|
219
|
+
require_flag(opts, :repo, '--repo is required (org/repo): this checkout has no git origin remote to read it from')
|
|
220
|
+
end
|
|
221
|
+
|
|
210
222
|
# Batch-upload evidence from a JUnit XML report.
|
|
211
223
|
def run_junit(opts)
|
|
212
224
|
# The report's own checkout says which project it is: discovering from the
|
|
213
225
|
# report's directory (and up) means `fp report --junit hexhaven/junit.xml` run
|
|
214
226
|
# from a parent folder reads hexhaven's .featureparity.yml, not the parent's.
|
|
215
227
|
require_project!(opts, ProjectConfig.discover(File.dirname(File.expand_path(opts[:junit].to_s))))
|
|
216
|
-
|
|
228
|
+
resolve_repo!(opts)
|
|
217
229
|
# --surface is the default for markers that don't pin their own surface
|
|
218
230
|
# (e.g. `fp:slug@api,web`). It's only strictly required when at least one
|
|
219
231
|
# matched marker omits a surface — validated below once we know.
|
data/lib/fp/commands/run.rb
CHANGED
|
@@ -62,6 +62,18 @@ module Fp
|
|
|
62
62
|
exit 1
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# The report needs a repo. Settle it before the suite runs, so a missing one costs
|
|
66
|
+
# a second rather than the whole run (Fizzy #2040).
|
|
67
|
+
unless report_args.include?('--repo') || report_args.any? { |a| a.start_with?('--repo=') }
|
|
68
|
+
repo = Report.inferred_repo
|
|
69
|
+
unless repo
|
|
70
|
+
output.error('--repo is required (org/repo): this checkout has no git origin remote to read it from. ' \
|
|
71
|
+
'Nothing was run.')
|
|
72
|
+
exit 1
|
|
73
|
+
end
|
|
74
|
+
report_args += ['--repo', repo]
|
|
75
|
+
end
|
|
76
|
+
|
|
65
77
|
tmp = Dir.mktmpdir('fp-run-')
|
|
66
78
|
begin
|
|
67
79
|
report_path, argv, env = self.class.inject(runner, command, tmp)
|
data/lib/fp/commands/surfaces.rb
CHANGED
|
@@ -80,7 +80,7 @@ module Fp
|
|
|
80
80
|
help_flag :repo, 'Repository the surface maps to (org/repo)'
|
|
81
81
|
help_flag :default_branch, 'Default branch for the repo'
|
|
82
82
|
help_flag :from, 'Source surface to copy requirements from (drafts them for the new surface)'
|
|
83
|
-
help_flag :evaluate, 'With --from:
|
|
83
|
+
help_flag :evaluate, 'With --from: ask AI which of the source requirements apply to the new surface (paid plans; returns data, drafts nothing)'
|
|
84
84
|
help_flag :showroom_url, 'Client showroom card: the http(s) link a client opens (edit; empty clears)'
|
|
85
85
|
help_flag :showroom_label, 'Client showroom card: the button text for that link (edit)'
|
|
86
86
|
help_flag :showroom_instructions, 'Client showroom card: how to sign in and try the surface (edit)'
|
|
@@ -186,8 +186,13 @@ module Fp
|
|
|
186
186
|
|
|
187
187
|
project_id = resolve_project_id(opts[:project])
|
|
188
188
|
|
|
189
|
-
#
|
|
189
|
+
# With --from, everything that can refuse is checked before the surface is created:
|
|
190
|
+
# the source surface, the new key, that there is something to carry over, and (for
|
|
191
|
+
# --evaluate) that the project may use AI. A run that can't do its job leaves
|
|
192
|
+
# nothing behind (Fizzy #2040).
|
|
190
193
|
source_surface = nil
|
|
194
|
+
candidates = []
|
|
195
|
+
evaluations = []
|
|
191
196
|
if opts[:from]
|
|
192
197
|
source_result = client.find_surface_by_key(project_id, opts[:from])
|
|
193
198
|
unless source_result[:ok]
|
|
@@ -195,6 +200,14 @@ module Fp
|
|
|
195
200
|
exit 1
|
|
196
201
|
end
|
|
197
202
|
source_surface = source_result[:data]['surface']
|
|
203
|
+
|
|
204
|
+
surface_exists!(key, opts[:project]) if client.find_surface_by_key(project_id, key)[:ok]
|
|
205
|
+
|
|
206
|
+
candidates = carry_over_candidates!(project_id, opts, key)
|
|
207
|
+
evaluations = evaluate_requirements_for_surface!(candidates, opts[:from], key) if opts[:evaluate]
|
|
208
|
+
elsif opts[:evaluate]
|
|
209
|
+
output.error('--evaluate needs --from <source surface>: it asks which of that surface\'s requirements apply to the new one.')
|
|
210
|
+
exit 1
|
|
198
211
|
end
|
|
199
212
|
|
|
200
213
|
# The API derives key from name and defaults kind/audience/default_branch, but we
|
|
@@ -208,14 +221,7 @@ module Fp
|
|
|
208
221
|
|
|
209
222
|
result = client.create_surface(project_id, params)
|
|
210
223
|
|
|
211
|
-
if !result[:ok] && result[:status] == 409
|
|
212
|
-
output.error(
|
|
213
|
-
"Surface '#{key}' already exists in project '#{opts[:project]}'. " \
|
|
214
|
-
"Change it with: fp surfaces edit #{key} --project #{opts[:project]} [--name ...] [--kind ...] [--repo ...]",
|
|
215
|
-
status: 409
|
|
216
|
-
)
|
|
217
|
-
exit 1
|
|
218
|
-
end
|
|
224
|
+
surface_exists!(key, opts[:project]) if !result[:ok] && result[:status] == 409
|
|
219
225
|
|
|
220
226
|
unless result[:ok]
|
|
221
227
|
output.error(result[:error], status: result[:status])
|
|
@@ -224,21 +230,17 @@ module Fp
|
|
|
224
230
|
|
|
225
231
|
surface = result[:data]['surface'] || {}
|
|
226
232
|
|
|
227
|
-
#
|
|
233
|
+
# Without --evaluate, propose the new surface on every candidate.
|
|
228
234
|
drafted = []
|
|
229
235
|
gaps = []
|
|
230
|
-
|
|
231
|
-
if source_surface
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
evaluations = evaluate_requirements_for_surface(project_id, opts[:project], source_surface, key)
|
|
235
|
-
else
|
|
236
|
-
# No --evaluate: draft all requirements from the source surface
|
|
237
|
-
drafted, gaps = draft_requirements_from_surface(project_id, opts[:project], source_surface, key)
|
|
238
|
-
end
|
|
236
|
+
skipped = []
|
|
237
|
+
if source_surface && !opts[:evaluate]
|
|
238
|
+
drafted, gaps, skipped = draft_requirements_from_surface(project_id, opts[:project], surface, candidates,
|
|
239
|
+
opts[:from], key)
|
|
239
240
|
end
|
|
240
241
|
|
|
241
242
|
response_data = result[:data].merge('drafted' => drafted, 'gaps' => gaps)
|
|
243
|
+
response_data['skipped'] = skipped unless skipped.empty?
|
|
242
244
|
response_data['evaluations'] = evaluations unless evaluations.empty?
|
|
243
245
|
|
|
244
246
|
output.success(response_data) do
|
|
@@ -255,6 +257,7 @@ module Fp
|
|
|
255
257
|
print_evaluations(evaluations, opts[:from], key)
|
|
256
258
|
else
|
|
257
259
|
print_drafted_requirements(drafted, opts[:from], key)
|
|
260
|
+
print_skipped_requirements(skipped)
|
|
258
261
|
print_gap_list(gaps, key) unless gaps.empty?
|
|
259
262
|
end
|
|
260
263
|
end
|
|
@@ -679,61 +682,98 @@ module Fp
|
|
|
679
682
|
|
|
680
683
|
# --- --from: draft requirements from a source surface ---
|
|
681
684
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
685
|
+
def surface_exists!(key, project_slug)
|
|
686
|
+
output.error(
|
|
687
|
+
"Surface '#{key}' already exists in project '#{project_slug}'. " \
|
|
688
|
+
"Change it with: fp surfaces edit #{key} --project #{project_slug} [--name ...] [--kind ...] [--repo ...]",
|
|
689
|
+
status: 409
|
|
690
|
+
)
|
|
691
|
+
exit 1
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
# The requirements --from carries over: active ones and drafts that name the source
|
|
695
|
+
# surface and not yet the new one. Drafts count because a project an agent has just
|
|
696
|
+
# onboarded has nothing else, and `fp surfaces batch-draft` takes them too. Parents
|
|
697
|
+
# come before their children, since a child can't require a surface its parent
|
|
698
|
+
# doesn't. Exits before anything is created when the list can't be read or is empty.
|
|
699
|
+
def carry_over_candidates!(project_id, opts, new_surface_key)
|
|
700
|
+
source_key = opts[:from]
|
|
687
701
|
result = client.list_requirements(project_id: project_id)
|
|
688
702
|
unless result[:ok]
|
|
689
|
-
|
|
690
|
-
|
|
703
|
+
output.error("Could not list requirements to carry over from '#{source_key}': #{result[:error]}. " \
|
|
704
|
+
'Nothing was created.', status: result[:status])
|
|
705
|
+
exit 1
|
|
691
706
|
end
|
|
692
707
|
|
|
693
708
|
requirements = result[:data]['requirements'] || []
|
|
694
|
-
source_key = source_surface['key']
|
|
695
|
-
|
|
696
|
-
# Find active requirements that include the source surface
|
|
697
709
|
candidates = requirements.select do |req|
|
|
698
|
-
|
|
710
|
+
surfaces = req['required_surfaces'] || []
|
|
711
|
+
%w[active draft].include?(req['status']) && surfaces.include?(source_key) && !surfaces.include?(new_surface_key)
|
|
699
712
|
end
|
|
700
713
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
candidates.each do |req|
|
|
707
|
-
current_surfaces = req['required_surfaces'] || []
|
|
708
|
-
next if current_surfaces.include?(new_surface_key) # Already has this surface
|
|
709
|
-
|
|
710
|
-
new_surfaces = current_surfaces + [new_surface_key]
|
|
711
|
-
change_result = client.propose_requirement_change(
|
|
712
|
-
req['id'],
|
|
713
|
-
required_surfaces: new_surfaces,
|
|
714
|
-
reason: "Adding '#{new_surface_key}' surface (from 'fp surfaces add --from #{source_key}')",
|
|
715
|
-
source_type: 'manual'
|
|
714
|
+
if candidates.empty?
|
|
715
|
+
output.error(
|
|
716
|
+
"No active or draft requirement names '#{source_key}' without already naming '#{new_surface_key}', " \
|
|
717
|
+
"so there is nothing to carry over. Nothing was created. To add the surface on its own: " \
|
|
718
|
+
"fp surfaces add #{new_surface_key} --project #{opts[:project]}"
|
|
716
719
|
)
|
|
720
|
+
exit 1
|
|
721
|
+
end
|
|
717
722
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
723
|
+
by_id = requirements.to_h { |req| [req['id'], req] }
|
|
724
|
+
candidates.sort_by.with_index { |req, index| [requirement_depth(req, by_id), index] }
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
def requirement_depth(requirement, by_id)
|
|
728
|
+
depth = 0
|
|
729
|
+
seen = {}
|
|
730
|
+
parent = by_id[requirement['parent_id']]
|
|
731
|
+
while parent && !seen[parent['id']]
|
|
732
|
+
seen[parent['id']] = true
|
|
733
|
+
depth += 1
|
|
734
|
+
parent = by_id[parent['parent_id']]
|
|
735
|
+
end
|
|
736
|
+
depth
|
|
737
|
+
end
|
|
738
|
+
|
|
739
|
+
# Propose the new surface on every candidate, through the same endpoint as
|
|
740
|
+
# `fp surfaces batch-draft` so the two can't disagree about what gets drafted or
|
|
741
|
+
# skipped. Returns [drafted, gaps, skipped].
|
|
742
|
+
def draft_requirements_from_surface(project_id, project_slug, surface, candidates, source_key, new_surface_key)
|
|
743
|
+
result = client.batch_draft_surface_requirements(
|
|
744
|
+
project_id,
|
|
745
|
+
surface['id'],
|
|
746
|
+
slugs: candidates.map { |req| req['slug'] },
|
|
747
|
+
reason: "Adding '#{new_surface_key}' surface (from 'fp surfaces add --from #{source_key}')",
|
|
748
|
+
source_type: 'manual'
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
unless result[:ok]
|
|
752
|
+
output.error(
|
|
753
|
+
"Created surface '#{new_surface_key}', but could not draft requirements for it: #{result[:error]}. " \
|
|
754
|
+
"Retry with: fp surfaces batch-draft #{new_surface_key} --project #{project_slug} " \
|
|
755
|
+
"--slugs #{candidates.map { |req| req['slug'] }.join(',')}",
|
|
756
|
+
status: result[:status]
|
|
757
|
+
)
|
|
758
|
+
exit 1
|
|
730
759
|
end
|
|
731
760
|
|
|
732
|
-
|
|
733
|
-
|
|
761
|
+
data = result[:data]
|
|
762
|
+
by_slug = candidates.to_h { |req| [req['slug'], req] }
|
|
763
|
+
|
|
764
|
+
(data['errors'] || []).each do |err|
|
|
734
765
|
warn "Warning: could not draft '#{err['slug']}': #{err['error']}"
|
|
735
766
|
end
|
|
736
767
|
|
|
768
|
+
drafted = (data['drafted'] || []).map do |row|
|
|
769
|
+
req = by_slug[row['slug']] || {}
|
|
770
|
+
{
|
|
771
|
+
'slug' => row['slug'],
|
|
772
|
+
'title' => row['title'] || req['title'],
|
|
773
|
+
'surfaces' => (req['required_surfaces'] || []) + [new_surface_key]
|
|
774
|
+
}
|
|
775
|
+
end
|
|
776
|
+
|
|
737
777
|
# The gap list is every requirement we just drafted — they all need evidence on
|
|
738
778
|
# the new surface. Format matches what `fp list --gaps` returns.
|
|
739
779
|
gaps = drafted.map do |req|
|
|
@@ -744,48 +784,28 @@ module Fp
|
|
|
744
784
|
}
|
|
745
785
|
end
|
|
746
786
|
|
|
747
|
-
[drafted, gaps]
|
|
787
|
+
[drafted, gaps, data['skipped'] || []]
|
|
748
788
|
end
|
|
749
789
|
|
|
750
790
|
# --- --from --evaluate: evaluate requirements for applicability ---
|
|
751
791
|
|
|
752
|
-
#
|
|
753
|
-
#
|
|
754
|
-
|
|
755
|
-
# applicability verdicts and reasoning for agent decision-making.
|
|
756
|
-
def evaluate_requirements_for_surface(project_id, project_slug, source_surface, new_surface_key)
|
|
757
|
-
result = client.list_requirements(project_id: project_id)
|
|
758
|
-
unless result[:ok]
|
|
759
|
-
warn "Warning: could not list requirements to evaluate from '#{source_surface['key']}': #{result[:error]}"
|
|
760
|
-
return []
|
|
761
|
-
end
|
|
762
|
-
|
|
763
|
-
requirements = result[:data]['requirements'] || []
|
|
764
|
-
source_key = source_surface['key']
|
|
765
|
-
|
|
766
|
-
# Find active requirements that include the source surface
|
|
767
|
-
candidates = requirements.select do |req|
|
|
768
|
-
req['status'] == 'active' && (req['required_surfaces'] || []).include?(source_key)
|
|
769
|
-
end
|
|
770
|
-
|
|
771
|
-
return [] if candidates.empty?
|
|
772
|
-
|
|
773
|
-
evaluations = []
|
|
774
|
-
candidates.each do |req|
|
|
775
|
-
current_surfaces = req['required_surfaces'] || []
|
|
776
|
-
next if current_surfaces.include?(new_surface_key) # Already has this surface
|
|
792
|
+
# A refusal that will be the same for every requirement: no AI access for this
|
|
793
|
+
# project (402), a key that can't reach it, or the analyzer being unavailable.
|
|
794
|
+
EVALUATION_BLOCKED = [401, 402, 403, 503].freeze
|
|
777
795
|
|
|
796
|
+
# Ask, for each candidate, whether it applies to the new surface. Returns a list of
|
|
797
|
+
# evaluations with applicability verdicts and reasoning for agent decision-making.
|
|
798
|
+
# Runs before the surface is created: a project without AI access is told once and
|
|
799
|
+
# the command exits 1 with nothing made, as `fp analyze` does.
|
|
800
|
+
def evaluate_requirements_for_surface!(candidates, source_key, new_surface_key)
|
|
801
|
+
candidates.map do |req|
|
|
778
802
|
progress("Evaluating #{req['slug']} ...")
|
|
779
803
|
|
|
780
|
-
eval_result = client.evaluate_surface_applicability(
|
|
781
|
-
req['id'],
|
|
782
|
-
new_surface_key,
|
|
783
|
-
source_key
|
|
784
|
-
)
|
|
804
|
+
eval_result = client.evaluate_surface_applicability(req['id'], new_surface_key, source_key)
|
|
785
805
|
|
|
786
806
|
if eval_result[:ok]
|
|
787
807
|
evaluation = eval_result[:data]['evaluation'] || {}
|
|
788
|
-
|
|
808
|
+
{
|
|
789
809
|
'slug' => req['slug'],
|
|
790
810
|
'title' => req['title'],
|
|
791
811
|
'applies' => evaluation['applies'],
|
|
@@ -793,9 +813,16 @@ module Fp
|
|
|
793
813
|
'confidence' => evaluation['confidence'],
|
|
794
814
|
'reason' => evaluation['reason']
|
|
795
815
|
}
|
|
816
|
+
elsif EVALUATION_BLOCKED.include?(eval_result[:status])
|
|
817
|
+
output.error(
|
|
818
|
+
"#{eval_result[:error]} Nothing was created. Without --evaluate, " \
|
|
819
|
+
"fp surfaces add #{new_surface_key} --from #{source_key} drafts every requirement on '#{source_key}' for review.",
|
|
820
|
+
status: eval_result[:status]
|
|
821
|
+
)
|
|
822
|
+
exit 1
|
|
796
823
|
else
|
|
797
|
-
#
|
|
798
|
-
|
|
824
|
+
# One requirement failed for a reason of its own; the rest still get an answer.
|
|
825
|
+
{
|
|
799
826
|
'slug' => req['slug'],
|
|
800
827
|
'title' => req['title'],
|
|
801
828
|
'applies' => nil,
|
|
@@ -806,16 +833,9 @@ module Fp
|
|
|
806
833
|
}
|
|
807
834
|
end
|
|
808
835
|
end
|
|
809
|
-
|
|
810
|
-
evaluations
|
|
811
836
|
end
|
|
812
837
|
|
|
813
838
|
def print_evaluations(evaluations, source_key, new_key)
|
|
814
|
-
if evaluations.empty?
|
|
815
|
-
puts "No requirements on '#{source_key}' to evaluate for '#{new_key}'."
|
|
816
|
-
return
|
|
817
|
-
end
|
|
818
|
-
|
|
819
839
|
applies = evaluations.select { |e| e['applies'] == true }
|
|
820
840
|
does_not_apply = evaluations.select { |e| e['applies'] == false }
|
|
821
841
|
errors = evaluations.select { |e| e['error'] }
|
|
@@ -844,8 +864,8 @@ module Fp
|
|
|
844
864
|
end
|
|
845
865
|
|
|
846
866
|
puts
|
|
847
|
-
puts 'Nothing was drafted.
|
|
848
|
-
puts
|
|
867
|
+
puts 'Nothing was drafted. Draft the ones you decide apply with:'
|
|
868
|
+
puts " fp surfaces batch-draft #{new_key} --slugs slug1,slug2"
|
|
849
869
|
end
|
|
850
870
|
|
|
851
871
|
def progress(message)
|
|
@@ -854,7 +874,7 @@ module Fp
|
|
|
854
874
|
|
|
855
875
|
def print_drafted_requirements(drafted, source_key, new_key)
|
|
856
876
|
if drafted.empty?
|
|
857
|
-
puts "No
|
|
877
|
+
puts "No requirement on '#{source_key}' was drafted for '#{new_key}'."
|
|
858
878
|
return
|
|
859
879
|
end
|
|
860
880
|
|
|
@@ -865,6 +885,20 @@ module Fp
|
|
|
865
885
|
puts ' A human must approve each change in the web app before the surface is measured.'
|
|
866
886
|
end
|
|
867
887
|
|
|
888
|
+
SKIP_REASONS = {
|
|
889
|
+
'has_pending_change' => 'already has a change awaiting review',
|
|
890
|
+
'already_includes_surface' => 'already names this surface',
|
|
891
|
+
'archived' => 'archived'
|
|
892
|
+
}.freeze
|
|
893
|
+
|
|
894
|
+
def print_skipped_requirements(skipped)
|
|
895
|
+
return if skipped.empty?
|
|
896
|
+
|
|
897
|
+
puts
|
|
898
|
+
puts "Skipped (#{skipped.size}):"
|
|
899
|
+
skipped.each { |row| puts " - #{row['slug']}: #{SKIP_REASONS[row['reason']] || row['reason']}" }
|
|
900
|
+
end
|
|
901
|
+
|
|
868
902
|
def print_gap_list(gaps, new_key)
|
|
869
903
|
puts
|
|
870
904
|
puts "Gap list for '#{new_key}' (#{gaps.size} requirement(s) need coverage):"
|
data/lib/fp/repo_detector.rb
CHANGED
|
@@ -101,9 +101,15 @@ module Fp
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
# Human-readable summary of #detect, printed by `fp doctor` and `fp init --detect`.
|
|
104
|
-
|
|
104
|
+
# `project` is the slug the repo's .featureparity.yml already names; with one there is
|
|
105
|
+
# nothing left to suggest.
|
|
106
|
+
def self.print_summary(repo, out: $stdout, project: nil)
|
|
105
107
|
out.puts 'Repo'
|
|
106
|
-
|
|
108
|
+
if project
|
|
109
|
+
out.puts " Project: #{project} (from the project file)"
|
|
110
|
+
else
|
|
111
|
+
out.puts " Suggested slug: #{repo['slug']}#{repo['repo'] ? " (from git remote #{repo['repo']})" : ' (from the directory name)'}"
|
|
112
|
+
end
|
|
107
113
|
frameworks = repo['frameworks'].map { |f| f['dir'] == '.' ? f['name'] : "#{f['name']} (#{f['dir']})" }
|
|
108
114
|
out.puts " Frameworks: #{frameworks.empty? ? '(none recognised)' : frameworks.uniq.join(', ')}"
|
|
109
115
|
|
data/lib/fp/version.rb
CHANGED
data/skills/fp/SKILL.md
CHANGED
|
@@ -516,6 +516,23 @@ media remove <id> --yes` takes one down. A surface with media but no link is sti
|
|
|
516
516
|
Feedback and the share link are human-only, so after writing the content tell a person
|
|
517
517
|
it's ready.
|
|
518
518
|
|
|
519
|
+
### 10. Add a platform the product now ships on
|
|
520
|
+
|
|
521
|
+
When the product gains a surface (Android when it already has web), carry the catalog
|
|
522
|
+
over instead of re-typing it:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
fp surfaces add android --from web # create android, propose it on every requirement that names web
|
|
526
|
+
fp surfaces add android --from web --evaluate --json > eval.json # or ask AI which ones apply first (paid plans)
|
|
527
|
+
fp surfaces batch-draft android --slugs login,checkout # then propose it on the ones you chose
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
`--from` takes active and draft requirements, and creates nothing when it has nothing to
|
|
531
|
+
carry over or `--evaluate` isn't available on the project's plan. Each proposal waits for
|
|
532
|
+
a human: until it is approved the new surface isn't required, the existing tests keep
|
|
533
|
+
their verdicts, and `fp check` is unchanged. After approval, `fp list --gaps --surface
|
|
534
|
+
android` is the list of tests to write.
|
|
535
|
+
|
|
519
536
|
### Repo-local config (`.featureparity.yml`)
|
|
520
537
|
|
|
521
538
|
If a repo has a `.featureparity.yml`, `--project` is optional — `fp` reads the slug from
|
data/skills/fp/references/cli.md
CHANGED
|
@@ -74,16 +74,26 @@ create --surfaces` made with defaults. `edit` only sends the flags you pass. `de
|
|
|
74
74
|
asks you to type the key back in a terminal and refuses without `--yes` otherwise.
|
|
75
75
|
|
|
76
76
|
**`--from`**: When adding a platform that mirrors an existing one (Android when you
|
|
77
|
-
have web), `--from web` finds every active requirement
|
|
78
|
-
new surface to each, and returns a
|
|
77
|
+
have web), `--from web` finds every active or draft requirement that names `web`,
|
|
78
|
+
proposes adding the new surface to each (parents before their children), and returns a
|
|
79
|
+
gap list. The proposals await human review. It goes through the same endpoint as `fp
|
|
80
|
+
surfaces batch-draft`, so a requirement that already has a change awaiting review is
|
|
81
|
+
skipped and named. Everything is checked first: if the source surface doesn't exist, the
|
|
82
|
+
new key is taken, or no requirement names the source, the command exits 1 and creates
|
|
83
|
+
nothing.
|
|
79
84
|
|
|
80
85
|
**`--from --evaluate`**: Instead of mass-drafting, asks the AI whether each source
|
|
81
86
|
requirement applies to the target platform. Returns applicability verdicts with
|
|
82
87
|
reasoning — which requirements apply (✅), which don't (❌), and why. Nothing is
|
|
83
|
-
drafted; the
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
drafted; send the slugs you decide apply to `fp surfaces batch-draft`. Useful for
|
|
89
|
+
filtering the ~10% that are platform-specific (browser resize, web-only APIs) from the
|
|
90
|
+
90% that transfer to any client. Requires a Pro plan or a project owner with AI access:
|
|
91
|
+
without it the command says so once, exits 1, and creates nothing.
|
|
92
|
+
|
|
93
|
+
**While a new surface awaits review, nothing else moves.** A proposal that only adds a
|
|
94
|
+
required surface leaves the existing tests' verdicts as they were, and the gate keeps
|
|
95
|
+
measuring the requirement on the surfaces it already had. The new surface is required
|
|
96
|
+
(and its cells `missing`) only once a human approves it.
|
|
87
97
|
|
|
88
98
|
A surface that requirements still require can't be deleted or re-keyed — the server
|
|
89
99
|
refuses and names them. Taking a surface off a requirement is a human's call, so ask
|
|
@@ -1067,7 +1077,7 @@ fp repos unset customer_android --project acme
|
|
|
1067
1077
|
fp is a Ruby gem, so any of these installs the newest version:
|
|
1068
1078
|
|
|
1069
1079
|
```bash
|
|
1070
|
-
fp update #
|
|
1080
|
+
fp update # fp 0.0.34 and newer
|
|
1071
1081
|
gem update featureparity
|
|
1072
1082
|
curl -fsSL https://api.featureparity.dev/api/cli/install | bash # the installer again
|
|
1073
1083
|
```
|