featureparity 0.0.33 → 0.0.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed664952f7dd1c088b3d534868eb06023a3dcdfe5783417288745560217ab1ee
4
- data.tar.gz: de7931594143ee7c9324a6b29968b77f60435c51af0f935ec01ea9f8347aebdc
3
+ metadata.gz: 312f91d87b5afc777f045b11dd38db0660bfc55aaa7faa523f2cd4ca464c348b
4
+ data.tar.gz: 3c8b90e1c24911b17751e1574555fc9e5692cf4eacc94c5d27af262dcf6e7328
5
5
  SHA512:
6
- metadata.gz: 73231f3b48feda8c832eaedaa25c58d637ffecc436be1f2518da1089c9e9747517a08b53765a1f44b9faf92174a4711f1eb371abac522a64d6a3c292ed7ac98a
7
- data.tar.gz: f7fb9b80fe7d7236523279c13d1e42b1d80cd89bd3bdf8163015abe88cbb33f13b14acb35ca95a9de9bcbddbc6d15ade21a1cb362537038c8e6b4e3ce731b5f5
6
+ metadata.gz: 803c8fc5b8586ea9d62a3eaa171f04373308c67d13e2f66aa7cf82213f4ba65f95f840c60596c145790d32e39e8116570a48074431c03727930a9085dc85dcf9
7
+ data.tar.gz: ca6aa9b65707f0bcf5c839672135c1419918760df4027e414acfc7a20854ae697cd58be43cbc381841863869f136e69a8e825a575f8d634550d28c20e057c13a
data/lib/fp/cli.rb CHANGED
@@ -40,6 +40,7 @@ module Fp
40
40
  'whoami' => Commands::Whoami,
41
41
  'skill' => Commands::Skill,
42
42
  'version' => Commands::Version,
43
+ 'update' => Commands::Update,
43
44
  'help' => Commands::Help,
44
45
  'attach' => Commands::Attach,
45
46
  'attachments' => Commands::Attachments,
@@ -84,7 +85,7 @@ module Fp
84
85
 
85
86
  # Profile/config commands don't need auth. `init` is here too: it only writes
86
87
  # files into the repo, and onboarding a repo must work before anyone has a key.
87
- needs_auth = !%w[init doctor profile config repos setup whoami skill version help mark tutorial].include?(command_name)
88
+ needs_auth = !%w[init doctor profile config repos setup whoami skill version update help mark tutorial].include?(command_name)
88
89
 
89
90
  if needs_auth
90
91
  config = Config.new(profile: global_opts[:profile], api_url: global_opts[:api_url])
@@ -103,6 +104,7 @@ module Fp
103
104
  output = Output.new(json: global_opts[:json])
104
105
  command = command_class.new(client: client, output: output, config: config)
105
106
  command.run(args + passthrough)
107
+ announce_update(config, command_name, json: global_opts[:json])
106
108
  rescue Interrupt
107
109
  warn "\nAborted."
108
110
  exit 130
@@ -114,6 +116,15 @@ module Fp
114
116
 
115
117
  private
116
118
 
119
+ # At most once a day, say on stderr that a newer fp is published (Fizzy #1993).
120
+ # Never with --json: a caller reading that stream gets the envelope and nothing else.
121
+ def announce_update(config, command_name, json:)
122
+ return if json
123
+
124
+ notice = UpdateCheck.daily_notice(config.api_url, command: command_name)
125
+ warn "\n#{notice}" if notice
126
+ end
127
+
117
128
  # True when the remaining args ask for help on the command: `--help` or `-h`
118
129
  # anywhere in the args. We don't treat a lone `help` positional specially here —
119
130
  # that's a real subcommand for some commands.
data/lib/fp/client.rb CHANGED
@@ -87,6 +87,22 @@ module Fp
87
87
  delete("/api/projects/#{project_id}/surfaces/#{surface_id}")
88
88
  end
89
89
 
90
+ # POST /projects/:id/surfaces/:surface_id/batch_draft
91
+ #
92
+ # Batch-draft requirements for a surface (Fizzy #2009). Takes a list of requirement
93
+ # slugs and proposes adding this surface to each one's required_surfaces. Used after
94
+ # `fp surfaces add --from --evaluate` to draft only the requirements the agent
95
+ # decides apply.
96
+ def batch_draft_surface_requirements(project_id, surface_id, slugs:, reason: nil, source_type: nil,
97
+ source_url: nil, source_context: nil)
98
+ body = { slugs: slugs }
99
+ body[:reason] = reason if reason
100
+ body[:source_type] = source_type if source_type
101
+ body[:source_url] = source_url if source_url
102
+ body[:source_context] = source_context if source_context
103
+ post("/api/projects/#{project_id}/surfaces/#{surface_id}/batch_draft", body)
104
+ end
105
+
90
106
  # GET /projects/:id/showroom
91
107
  # The client showroom as a client would see it (Fizzy #1479). Open to the team and
92
108
  # their agents; the response carries only what a client is shown.
@@ -219,6 +235,16 @@ module Fp
219
235
  post("/api/requirements/#{requirement_id}/test_review", { tests: tests })
220
236
  end
221
237
 
238
+ # POST /requirements/:id/surface_applicability — Jev's evaluation of whether a
239
+ # requirement applies to a different surface (`fp surfaces add --from --evaluate`,
240
+ # Fizzy #2009). Paid plans only (402 otherwise).
241
+ def evaluate_surface_applicability(requirement_id, target_surface, source_surface)
242
+ post("/api/requirements/#{requirement_id}/surface_applicability", {
243
+ target_surface: target_surface,
244
+ source_surface: source_surface
245
+ })
246
+ end
247
+
222
248
  # GET /requirements/:id/changes
223
249
  #
224
250
  # A requirement's change history: what it was, what changed, who changed it, and
@@ -42,7 +42,11 @@ module Fp
42
42
  project_config = ProjectConfig.discover
43
43
  project_slug = require_project!(opts, project_config)
44
44
  project_id = resolve_project_id(project_slug)
45
- surface = opts[:surface] || project_config.surface
45
+ # Unlike fp check and fp matrix, draft coverage shows the full picture by default.
46
+ # The pinned surface from .featureparity.yml is ignored unless --surface is explicit;
47
+ # on a new project with only drafts you want to see every surface's column, not just
48
+ # the one this repo happens to ship (Fizzy #2008).
49
+ surface = opts[:surface]
46
50
 
47
51
  result = client.get_parity_with_drafts(project_id, surface: surface)
48
52
  unless result[:ok]
@@ -7,13 +7,15 @@ module Fp
7
7
  # fp doctor [--dir PATH] [--json]
8
8
  #
9
9
  # Says whether fp will work here, and what this repo needs before its tests can report
10
- # (Fizzy #1786). Purely local: no API calls, no key needed.
10
+ # (Fizzy #1786). No key needed. Everything is read locally except the newest published
11
+ # version (Fizzy #1993), one unauthenticated lookup that is skipped when it can't be made.
11
12
  #
12
13
  # Ruby which Ruby is running fp, where the gem lives, and whether this directory
13
14
  # pins a different Ruby (.ruby-version, .tool-versions, mise.toml). A
14
15
  # version-manager shim resolves `fp` against the *pinned* Ruby, so a gem
15
16
  # installed under another one fails inside the repo with
16
17
  # `mise ERROR No version is set for shim: fp` and works from /tmp.
18
+ # Also whether a newer fp is published, and the command that installs it.
17
19
  # Config the API environment (warning off production), whether a key resolved,
18
20
  # and which .featureparity.yml applies.
19
21
  # Repo RepoDetector's summary: test runners and the command that makes each emit
@@ -28,7 +30,7 @@ module Fp
28
30
  help_flag :dir, 'Directory to check (defaults to the working directory)'
29
31
  help_example 'fp doctor'
30
32
  help_example 'fp doctor --json', 'Machine-readable, for an agent to act on'
31
- help_note "Purely local; makes no API calls, so it works without a key.\n" \
33
+ help_note "Works without a key and offline. Its one network call asks the API for the newest fp version.\n" \
32
34
  "If `fp` itself fails with `mise ERROR No version is set for shim: fp`, the shim stopped it\n" \
33
35
  'before fp could run: install the gem under the pinned Ruby (`gem install featureparity` in the repo).'
34
36
 
@@ -51,6 +53,7 @@ module Fp
51
53
  repo: RepoDetector.new(repo_root(dir)).detect
52
54
  }
53
55
  report[:agents_section] = agents_section_report(repo_root(dir))
56
+ report[:update] = UpdateCheck.status(config.api_url) unless UpdateCheck.disabled?
54
57
 
55
58
  output.success(report) { print_report(report) }
56
59
  end
@@ -187,6 +190,18 @@ module Fp
187
190
  end
188
191
  end
189
192
 
193
+ def print_update(update)
194
+ line = if update[:latest_version].nil?
195
+ 'could not check (offline, or the API is unreachable)'
196
+ elsif update[:update_available]
197
+ "#{update[:latest_version]} — newer than this one. Run `#{update[:update_command]}` " \
198
+ "(or `#{UpdateCheck::GEM_COMMAND}`)."
199
+ else
200
+ "#{update[:latest_version]} (up to date)"
201
+ end
202
+ puts " Latest fp: #{line}"
203
+ end
204
+
190
205
  def print_report(report)
191
206
  ruby = report[:ruby]
192
207
  cfg = report[:config]
@@ -195,6 +210,7 @@ module Fp
195
210
  puts "fp #{ruby[:fp_version]} on Ruby #{ruby[:version]} (#{ruby[:ruby]})"
196
211
  puts " Gem: #{ruby[:gem_path]}"
197
212
  puts " fp on PATH: #{ruby[:fp_on_path] || '(not found)'}#{ruby[:fp_on_path_is_shim] ? ' [version-manager shim]' : ''}"
213
+ print_update(report[:update]) if report[:update]
198
214
  if ruby[:pinned]
199
215
  state = ruby[:mismatch] ? '⚠ differs from the Ruby running fp' : 'matches'
200
216
  puts " Ruby pin: #{ruby[:pinned]} (#{ruby[:pinned_by]}) — #{state}"
@@ -112,6 +112,7 @@ module Fp
112
112
  repos set|get|list|unset Map surfaces to local repo paths
113
113
  setup Interactive first-time setup
114
114
  version Show version (also: fp --version, fp -v)
115
+ update [--check] Install the newest fp, or check whether one is available
115
116
  help Show this help
116
117
 
117
118
  GLOBAL FLAGS
@@ -35,10 +35,14 @@ module Fp
35
35
  project_slug = require_project!(opts, project_config)
36
36
  project_id = resolve_project_id(project_slug)
37
37
 
38
+ # The matrix shows the full grid by default. The pinned surface from
39
+ # .featureparity.yml is ignored unless --surface is explicit; a team reviewing
40
+ # parity wants to see every surface's column, not just the one this repo ships.
41
+ # (fp check keeps using the pinned surface because it gates that surface's CI.)
38
42
  result = client.get_parity(
39
43
  project_id,
40
44
  level: opts[:level] || project_config.enforcement,
41
- surface: opts[:surface] || project_config.surface
45
+ surface: opts[:surface]
42
46
  )
43
47
  unless result[:ok]
44
48
  output.error(result[:error], status: result[:status])
@@ -32,7 +32,19 @@ module Fp
32
32
  kind: :string,
33
33
  audience: :string,
34
34
  repo: :string,
35
- default_branch: :string
35
+ default_branch: :string,
36
+ from: :string,
37
+ evaluate: :boolean
38
+ }.freeze
39
+
40
+ BATCH_DRAFT_FLAGS = {
41
+ project: :string,
42
+ slugs: :string,
43
+ slugs_file: :string,
44
+ reason: :string,
45
+ source_type: :string,
46
+ source_url: :string,
47
+ source_context: :string
36
48
  }.freeze
37
49
 
38
50
  SHOWROOM_FLAGS = {
@@ -57,22 +69,32 @@ module Fp
57
69
  help_usage 'fp surfaces --project <slug>',
58
70
  'fp surfaces show <key> --project <slug>',
59
71
  'fp surfaces add <key> --project <slug> [--name ...] [--kind K] [--repo org/repo]',
72
+ 'fp surfaces add <key> --project <slug> --from <source_key>',
60
73
  'fp surfaces edit <key> --project <slug> [flags]',
61
- 'fp surfaces delete <key> --project <slug> [--yes]'
74
+ 'fp surfaces delete <key> --project <slug> [--yes]',
75
+ 'fp surfaces batch-draft <key> --project <slug> --slugs slug1,slug2 | --slugs-file file.json'
62
76
  help_flag :project, 'Project slug (falls back to .featureparity.yml)'
63
77
  help_flag :name, 'Human-readable surface name'
64
78
  help_flag :kind, "Surface kind: #{VALID_KINDS.join(', ')}"
65
79
  help_flag :audience, "Audience: #{VALID_AUDIENCES.join(', ')}"
66
80
  help_flag :repo, 'Repository the surface maps to (org/repo)'
67
81
  help_flag :default_branch, 'Default branch for the repo'
82
+ help_flag :from, 'Source surface to copy requirements from (drafts them for the new surface)'
83
+ help_flag :evaluate, 'With --from: run each requirement through Jev to evaluate applicability (returns data; does not auto-draft)'
68
84
  help_flag :showroom_url, 'Client showroom card: the http(s) link a client opens (edit; empty clears)'
69
85
  help_flag :showroom_label, 'Client showroom card: the button text for that link (edit)'
70
86
  help_flag :showroom_instructions, 'Client showroom card: how to sign in and try the surface (edit)'
71
87
  help_flag :showroom_instructions_file, 'Read --showroom-instructions from a file (multi-line)'
72
88
  help_flag :showroom_position, 'Client showroom order: 1 is first; empty clears (unplaced surfaces follow, A-Z) (edit)'
73
89
  help_flag :yes, 'Skip the typed-key confirmation on delete'
90
+ help_flag :slugs, 'Comma-separated requirement slugs to draft (batch-draft)'
91
+ help_flag :slugs_file, 'JSON file with slugs to draft: array of strings or objects with "slug" keys (batch-draft)'
74
92
  help_example 'fp surfaces --project acme'
75
93
  help_example 'fp surfaces add customer_android --project acme --kind android --repo acme/customer-android'
94
+ help_example 'fp surfaces add android --project acme --from web', 'Create android, drafting requirements that apply to web'
95
+ help_example 'fp surfaces add android --project acme --from web --evaluate', 'Create android, evaluate which web requirements apply (agent workflow)'
96
+ help_example 'fp surfaces batch-draft android --project acme --slugs login,checkout', 'Draft specific requirements for the android surface'
97
+ help_example 'fp surfaces batch-draft android --project acme --slugs-file /tmp/applying.json', 'Draft from a JSON file (output of --evaluate filtered by agent)'
76
98
  help_example 'fp surfaces delete web --project acme --yes'
77
99
  help_example 'fp surfaces edit web --project acme --showroom-url https://dev.example.com --showroom-instructions-file docs/showroom/web.txt'
78
100
  help_example 'fp surfaces edit web --project acme --showroom-position 1'
@@ -89,6 +111,8 @@ module Fp
89
111
  edit(args[1..])
90
112
  when 'delete'
91
113
  delete(args[1..])
114
+ when 'batch-draft'
115
+ batch_draft(args[1..])
92
116
  else
93
117
  list(args)
94
118
  end
@@ -162,6 +186,17 @@ module Fp
162
186
 
163
187
  project_id = resolve_project_id(opts[:project])
164
188
 
189
+ # Validate --from surface exists before creating anything
190
+ source_surface = nil
191
+ if opts[:from]
192
+ source_result = client.find_surface_by_key(project_id, opts[:from])
193
+ unless source_result[:ok]
194
+ output.error("Source surface '#{opts[:from]}' not found in project '#{opts[:project]}'")
195
+ exit 1
196
+ end
197
+ source_surface = source_result[:data]['surface']
198
+ end
199
+
165
200
  # The API derives key from name and defaults kind/audience/default_branch, but we
166
201
  # send the key explicitly because here the key is what the caller actually typed —
167
202
  # `add api --name "Backend API"` must produce `api`, not `backend_api`.
@@ -189,13 +224,40 @@ module Fp
189
224
 
190
225
  surface = result[:data]['surface'] || {}
191
226
 
192
- output.success(result[:data]) do
227
+ # If --from was given, either evaluate or draft requirements from the source surface
228
+ drafted = []
229
+ gaps = []
230
+ evaluations = []
231
+ if source_surface
232
+ if opts[:evaluate]
233
+ # --evaluate: run each through Jev and return applicability data (no drafting)
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
239
+ end
240
+
241
+ response_data = result[:data].merge('drafted' => drafted, 'gaps' => gaps)
242
+ response_data['evaluations'] = evaluations unless evaluations.empty?
243
+
244
+ output.success(response_data) do
193
245
  puts "Created surface '#{surface['key'] || key}' in project '#{opts[:project]}'."
194
246
  puts
195
247
  puts " Name: #{surface['name']}"
196
248
  puts " Kind: #{surface['kind']}"
197
249
  puts " Audience: #{surface['audience']}"
198
250
  puts " Repo: #{surface['repo'] || '(none)'}"
251
+
252
+ if source_surface
253
+ puts
254
+ if opts[:evaluate]
255
+ print_evaluations(evaluations, opts[:from], key)
256
+ else
257
+ print_drafted_requirements(drafted, opts[:from], key)
258
+ print_gap_list(gaps, key) unless gaps.empty?
259
+ end
260
+ end
199
261
  end
200
262
  end
201
263
 
@@ -347,6 +409,149 @@ module Fp
347
409
  end
348
410
  end
349
411
 
412
+ # POST /projects/:id/surfaces/:surface_id/batch_draft
413
+ #
414
+ # Batch-draft requirements for a surface (Fizzy #2009). Takes a list of requirement
415
+ # slugs and proposes adding this surface to each one's required_surfaces. Used after
416
+ # `fp surfaces add --from --evaluate` to draft only the requirements the agent
417
+ # decides apply.
418
+ def batch_draft(args)
419
+ opts, positional = parse_flags(args, BATCH_DRAFT_FLAGS)
420
+
421
+ # Check mutually exclusive flags before doing any API calls
422
+ if opts[:slugs] && opts[:slugs_file]
423
+ output.error('Pass --slugs or --slugs-file, not both.')
424
+ exit 1
425
+ end
426
+
427
+ require_project!(opts)
428
+
429
+ key = positional.first
430
+ if key.nil? || key.strip.empty?
431
+ output.error('Usage: fp surfaces batch-draft <key> --project <slug> --slugs slug1,slug2 | --slugs-file file.json')
432
+ exit 1
433
+ end
434
+
435
+ project_id = resolve_project_id(opts[:project])
436
+ surface = find_surface!(project_id, key)
437
+
438
+ slugs = resolve_batch_draft_slugs(opts)
439
+ if slugs.empty?
440
+ output.error('No slugs provided. Use --slugs slug1,slug2 or --slugs-file file.json')
441
+ exit 1
442
+ end
443
+
444
+ result = client.batch_draft_surface_requirements(
445
+ project_id,
446
+ surface['id'],
447
+ slugs: slugs,
448
+ reason: opts[:reason],
449
+ source_type: opts[:source_type],
450
+ source_url: opts[:source_url],
451
+ source_context: opts[:source_context]
452
+ )
453
+
454
+ unless result[:ok]
455
+ output.error(result[:error], status: result[:status])
456
+ exit 1
457
+ end
458
+
459
+ data = result[:data]
460
+ output.success(data) do
461
+ print_batch_draft_result(data, key, opts[:project])
462
+ end
463
+ end
464
+
465
+ # Resolve slugs from --slugs or --slugs-file. Accepts:
466
+ # - --slugs as comma-separated: "login,checkout,profile"
467
+ # - --slugs-file as JSON: ["login", "checkout"] or [{"slug": "login"}, ...]
468
+ def resolve_batch_draft_slugs(opts)
469
+ # Mutual exclusion already checked in batch_draft before API calls
470
+
471
+ if opts[:slugs]
472
+ return opts[:slugs].to_s.split(',').map(&:strip).reject(&:empty?)
473
+ end
474
+
475
+ if opts[:slugs_file]
476
+ return read_slugs_file(opts[:slugs_file])
477
+ end
478
+
479
+ []
480
+ end
481
+
482
+ # Read slugs from a JSON file. Accepts:
483
+ # - Array of strings: ["login", "checkout"]
484
+ # - Array of objects with "slug" key: [{"slug": "login", "applies": true}, ...]
485
+ # (the output format of --evaluate, filtered)
486
+ def read_slugs_file(path)
487
+ unless File.file?(path)
488
+ output.error("--slugs-file: no such file '#{path}'")
489
+ exit 1
490
+ end
491
+
492
+ content = File.read(path).strip
493
+ begin
494
+ data = JSON.parse(content)
495
+ rescue JSON::ParserError => e
496
+ output.error("--slugs-file: invalid JSON (#{e.message})")
497
+ exit 1
498
+ end
499
+
500
+ unless data.is_a?(Array)
501
+ output.error("--slugs-file: expected a JSON array of slugs or objects with 'slug' key")
502
+ exit 1
503
+ end
504
+
505
+ data.map do |item|
506
+ case item
507
+ when String
508
+ item.strip
509
+ when Hash
510
+ item['slug']&.to_s&.strip
511
+ else
512
+ nil
513
+ end
514
+ end.compact.reject(&:empty?)
515
+ end
516
+
517
+ def print_batch_draft_result(data, surface_key, project_slug)
518
+ summary = data['summary'] || {}
519
+ drafted = data['drafted'] || []
520
+ skipped = data['skipped'] || []
521
+ errors = data['errors'] || []
522
+
523
+ puts "Batch draft for surface '#{surface_key}' in project '#{project_slug}':"
524
+ puts
525
+ puts " Requested: #{summary['requested'] || 0}"
526
+ puts " Drafted: #{summary['drafted'] || 0}"
527
+ puts " Skipped: #{summary['skipped'] || 0}"
528
+ puts " Errors: #{summary['errors'] || 0}"
529
+
530
+ if drafted.any?
531
+ puts
532
+ puts "Drafted (#{drafted.size}):"
533
+ drafted.each { |d| puts " ✅ #{d['slug']}: #{truncate(d['title'], 50)}" }
534
+ end
535
+
536
+ if skipped.any?
537
+ puts
538
+ puts "Skipped (#{skipped.size}):"
539
+ skipped.each { |s| puts " ⏭️ #{s['slug']}: #{s['reason']}" }
540
+ end
541
+
542
+ if errors.any?
543
+ puts
544
+ puts "Errors (#{errors.size}):"
545
+ errors.each { |e| puts " ❌ #{e['slug']}: #{e['error']}" }
546
+ end
547
+
548
+ return unless drafted.any?
549
+
550
+ puts
551
+ puts '⚠️ These are now DRAFTS awaiting human review.'
552
+ puts ' A human must approve each change in the web app before the surface is measured.'
553
+ end
554
+
350
555
  # Same guard as `fp projects delete`: --yes skips the prompt, an interactive
351
556
  # terminal types the key back, and anything else is refused.
352
557
  def confirm_delete!(surface, opts)
@@ -471,6 +676,205 @@ module Fp
471
676
  []
472
677
  end
473
678
  end
679
+
680
+ # --- --from: draft requirements from a source surface ---
681
+
682
+ # Draft requirements from a source surface for the newly created surface. For each
683
+ # active requirement that includes the source surface, propose adding the new
684
+ # surface to its required_surfaces. Returns the list of drafted requirements and
685
+ # the gap list for the new surface.
686
+ def draft_requirements_from_surface(project_id, project_slug, source_surface, new_surface_key)
687
+ result = client.list_requirements(project_id: project_id)
688
+ unless result[:ok]
689
+ warn "Warning: could not list requirements to draft from '#{source_surface['key']}': #{result[:error]}"
690
+ return [[], []]
691
+ end
692
+
693
+ requirements = result[:data]['requirements'] || []
694
+ source_key = source_surface['key']
695
+
696
+ # Find active requirements that include the source surface
697
+ candidates = requirements.select do |req|
698
+ req['status'] == 'active' && (req['required_surfaces'] || []).include?(source_key)
699
+ end
700
+
701
+ return [[], []] if candidates.empty?
702
+
703
+ drafted = []
704
+ errors = []
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'
716
+ )
717
+
718
+ if change_result[:ok]
719
+ drafted << {
720
+ 'slug' => req['slug'],
721
+ 'title' => req['title'],
722
+ 'surfaces' => new_surfaces
723
+ }
724
+ else
725
+ errors << {
726
+ 'slug' => req['slug'],
727
+ 'error' => change_result[:error]
728
+ }
729
+ end
730
+ end
731
+
732
+ # Warn about errors but don't fail the whole operation
733
+ errors.each do |err|
734
+ warn "Warning: could not draft '#{err['slug']}': #{err['error']}"
735
+ end
736
+
737
+ # The gap list is every requirement we just drafted — they all need evidence on
738
+ # the new surface. Format matches what `fp list --gaps` returns.
739
+ gaps = drafted.map do |req|
740
+ {
741
+ 'slug' => req['slug'],
742
+ 'title' => req['title'],
743
+ 'surfaces' => [{ 'surface' => new_surface_key, 'state' => 'missing' }]
744
+ }
745
+ end
746
+
747
+ [drafted, gaps]
748
+ end
749
+
750
+ # --- --from --evaluate: evaluate requirements for applicability ---
751
+
752
+ # Evaluate requirements from a source surface to determine which apply to a new
753
+ # surface. For each active requirement that includes the source surface, ask Jev
754
+ # whether it applies to the target surface. Returns a list of evaluations with
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
777
+
778
+ progress("Evaluating #{req['slug']} ...")
779
+
780
+ eval_result = client.evaluate_surface_applicability(
781
+ req['id'],
782
+ new_surface_key,
783
+ source_key
784
+ )
785
+
786
+ if eval_result[:ok]
787
+ evaluation = eval_result[:data]['evaluation'] || {}
788
+ evaluations << {
789
+ 'slug' => req['slug'],
790
+ 'title' => req['title'],
791
+ 'applies' => evaluation['applies'],
792
+ 'probability' => evaluation['probability'],
793
+ 'confidence' => evaluation['confidence'],
794
+ 'reason' => evaluation['reason']
795
+ }
796
+ else
797
+ # Evaluation failed (likely 402 for no AI access) — include as an error entry
798
+ evaluations << {
799
+ 'slug' => req['slug'],
800
+ 'title' => req['title'],
801
+ 'applies' => nil,
802
+ 'probability' => nil,
803
+ 'confidence' => nil,
804
+ 'reason' => nil,
805
+ 'error' => eval_result[:error]
806
+ }
807
+ end
808
+ end
809
+
810
+ evaluations
811
+ end
812
+
813
+ 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
+ applies = evaluations.select { |e| e['applies'] == true }
820
+ does_not_apply = evaluations.select { |e| e['applies'] == false }
821
+ errors = evaluations.select { |e| e['error'] }
822
+
823
+ puts "Evaluated #{evaluations.size} requirement(s) from '#{source_key}' for '#{new_key}':"
824
+ puts
825
+ puts " ✅ Applies (#{applies.size}):"
826
+ applies.each do |e|
827
+ puts " #{e['slug']}: #{truncate(e['title'], 50)}"
828
+ puts " #{e['reason']}" if e['reason']
829
+ end
830
+
831
+ puts
832
+ puts " ❌ Does not apply (#{does_not_apply.size}):"
833
+ does_not_apply.each do |e|
834
+ puts " #{e['slug']}: #{truncate(e['title'], 50)}"
835
+ puts " #{e['reason']}" if e['reason']
836
+ end
837
+
838
+ unless errors.empty?
839
+ puts
840
+ puts " ⚠️ Evaluation failed (#{errors.size}):"
841
+ errors.each do |e|
842
+ puts " #{e['slug']}: #{e['error']}"
843
+ end
844
+ end
845
+
846
+ puts
847
+ puts 'Nothing was drafted. Use the evaluation data above to decide which requirements to'
848
+ puts 'add manually, or re-run without --evaluate to draft all requirements at once.'
849
+ end
850
+
851
+ def progress(message)
852
+ warn message unless output.json?
853
+ end
854
+
855
+ def print_drafted_requirements(drafted, source_key, new_key)
856
+ if drafted.empty?
857
+ puts "No requirements on '#{source_key}' to draft for '#{new_key}'."
858
+ return
859
+ end
860
+
861
+ puts "Drafted #{drafted.size} requirement(s) from '#{source_key}' to include '#{new_key}':"
862
+ drafted.each { |req| puts " - #{req['slug']}: #{truncate(req['title'], 50)}" }
863
+ puts
864
+ puts '⚠️ These are now DRAFTS awaiting human review.'
865
+ puts ' A human must approve each change in the web app before the surface is measured.'
866
+ end
867
+
868
+ def print_gap_list(gaps, new_key)
869
+ puts
870
+ puts "Gap list for '#{new_key}' (#{gaps.size} requirement(s) need coverage):"
871
+ headers = %w[SLUG TITLE STATE]
872
+ rows = gaps.map do |gap|
873
+ state = gap['surfaces'].first
874
+ [gap['slug'], truncate(gap['title'], 40), state ? "#{state['surface']} (#{state['state']})" : '-']
875
+ end
876
+ output.table(headers, rows)
877
+ end
474
878
  end
475
879
  end
476
880
  end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Fp
6
+ module Commands
7
+ # fp update [--check]
8
+ #
9
+ # Installs the newest published fp (Fizzy #1993). There was no way to update from
10
+ # inside fp and nothing said one was due; `gem update featureparity` was mentioned
11
+ # once, in the changed-test upgrade notes.
12
+ #
13
+ # The latest version comes from the API's public `GET /cli/version`, so this needs no
14
+ # key. The install runs RubyGems under the Ruby that is running fp, which is the one
15
+ # whose `fp` the person just typed: in a repo that pins a Ruby, that is the pinned one.
16
+ class Update < Base
17
+ help_summary 'Install the newest fp, or check whether one is available'
18
+ help_usage 'fp update [--check]'
19
+ help_flag :check, 'Only say whether a newer fp exists; install nothing'
20
+ help_example 'fp update', 'Install the newest fp under the Ruby running this one'
21
+ help_example 'fp update --check', 'Is a newer fp published?'
22
+ help_note "Needs no API key. Same as `gem update featureparity`, or re-running the installer.\n" \
23
+ 'After an update, run `fp skill install` and `fp init --force` in each repo that uses fp, ' \
24
+ "to refresh the agent skill and the AGENTS.md section.\n" \
25
+ 'fp also says when a newer version exists, at most once a day; FP_NO_UPDATE_CHECK=1 turns that off.'
26
+
27
+ KNOWN_FLAGS = { check: :boolean }.freeze
28
+
29
+ AFTER_UPDATE = [
30
+ ['fp skill install', "refresh the agent skill in a repo that has it"],
31
+ ['fp init --force', "refresh the FeatureParity section of a repo's AGENTS.md"]
32
+ ].freeze
33
+
34
+ class << self
35
+ # Runs the install and returns [combined output, success?]. Swapped in tests.
36
+ attr_writer :installer
37
+
38
+ def installer
39
+ @installer ||= lambda do
40
+ out, status = Open3.capture2e(
41
+ Gem.ruby, '-e', 'require "rubygems/gem_runner"; Gem::GemRunner.new.run(ARGV)',
42
+ 'install', 'featureparity'
43
+ )
44
+ [out, status.success?]
45
+ end
46
+ end
47
+ end
48
+
49
+ def run(args)
50
+ opts, = parse_flags(args, KNOWN_FLAGS)
51
+ status = UpdateCheck.status(config.api_url)
52
+ latest = status[:latest_version]
53
+
54
+ unless latest
55
+ output.error("Could not read the latest fp version from #{config.api_url}. " \
56
+ "To update anyway, run `#{UpdateCheck::GEM_COMMAND}`.")
57
+ exit 1
58
+ end
59
+
60
+ unless status[:update_available]
61
+ return output.success(status.merge(updated: false)) { puts "fp #{Fp::VERSION} is the latest version." }
62
+ end
63
+
64
+ if opts[:check]
65
+ return output.success(status.merge(updated: false)) { puts UpdateCheck.message(latest) }
66
+ end
67
+
68
+ install(status)
69
+ end
70
+
71
+ private
72
+
73
+ def install(status)
74
+ puts "Installing fp #{status[:latest_version]} (you have #{Fp::VERSION})..." unless output.json?
75
+ log, ok = self.class.installer.call
76
+
77
+ unless ok
78
+ output.error("The update failed. Run `#{UpdateCheck::GEM_COMMAND}` to see why.\n#{log.to_s.lines.last(5).join}".strip)
79
+ exit 1
80
+ end
81
+
82
+ output.success(status.merge(updated: true, next_steps: AFTER_UPDATE.map(&:first))) do
83
+ puts "✓ fp is updated. `fp version` shows what's installed."
84
+ puts
85
+ puts 'Next, in each repo that uses fp:'
86
+ AFTER_UPDATE.each { |command, why| puts " #{command.ljust(18)} # #{why}" }
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
data/lib/fp/commands.rb CHANGED
@@ -35,6 +35,7 @@ require_relative 'commands/setup'
35
35
  require_relative 'commands/whoami'
36
36
  require_relative 'commands/skill'
37
37
  require_relative 'commands/version'
38
+ require_relative 'commands/update'
38
39
  require_relative 'commands/help'
39
40
  require_relative 'commands/attach'
40
41
  require_relative 'commands/attachments'
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'time'
7
+ require 'fileutils'
8
+
9
+ module Fp
10
+ # Says when a newer fp has been published (Fizzy #1993). Nothing told a person or an
11
+ # agent that the gem they had was behind: `GET /api/cli/version` had the answer and
12
+ # nothing read it.
13
+ #
14
+ # The lookup is one unauthenticated GET with a short timeout, and every failure is
15
+ # silent: being offline or behind must never break or slow the command someone ran.
16
+ # FP_NO_UPDATE_CHECK=1 turns all of it off.
17
+ module UpdateCheck
18
+ INTERVAL = 24 * 60 * 60
19
+ TIMEOUT = 2
20
+ CACHE_NAME = 'update_check.json'
21
+ UPDATE_COMMAND = 'fp update'
22
+ GEM_COMMAND = 'gem update featureparity'
23
+
24
+ # Commands that say it themselves, or that are about the version already.
25
+ QUIET_COMMANDS = %w[update doctor version help].freeze
26
+
27
+ module_function
28
+
29
+ def disabled?
30
+ !['', '0', 'false'].include?(ENV.fetch('FP_NO_UPDATE_CHECK', '').strip.downcase)
31
+ end
32
+
33
+ # The version the API says is published, or nil when it can't be read.
34
+ def latest_version(api_url)
35
+ uri = URI.parse("#{api_url.to_s.chomp('/')}/api/cli/version")
36
+ http = Net::HTTP.new(uri.host, uri.port)
37
+ http.use_ssl = uri.scheme == 'https'
38
+ http.open_timeout = TIMEOUT
39
+ http.read_timeout = TIMEOUT
40
+ response = http.request(Net::HTTP::Get.new(uri))
41
+ return nil unless response.code.to_i == 200
42
+
43
+ version = JSON.parse(response.body).dig('cli', 'version').to_s
44
+ Gem::Version.correct?(version) ? version : nil
45
+ rescue StandardError
46
+ nil
47
+ end
48
+
49
+ def newer?(latest, current = Fp::VERSION)
50
+ Gem::Version.new(latest) > Gem::Version.new(current)
51
+ rescue ArgumentError, TypeError
52
+ false
53
+ end
54
+
55
+ # A live answer, for `fp doctor` and `fp update`.
56
+ def status(api_url)
57
+ latest = latest_version(api_url)
58
+ {
59
+ current_version: Fp::VERSION,
60
+ latest_version: latest,
61
+ update_available: latest ? newer?(latest) : false,
62
+ update_command: UPDATE_COMMAND
63
+ }
64
+ end
65
+
66
+ def message(latest)
67
+ "fp #{latest} is available (you have #{Fp::VERSION}). Run `#{UPDATE_COMMAND}` to install it."
68
+ end
69
+
70
+ # The line to show after a command, at most once a day: nil when the last look was
71
+ # under a day ago, when CI is running fp, or when there is nothing newer. A failed
72
+ # look still counts as today's, so an offline machine waits out the timeout once.
73
+ def daily_notice(api_url, command: nil, now: Time.now)
74
+ return nil if disabled? || QUIET_COMMANDS.include?(command.to_s)
75
+ return nil unless ENV['CI'].to_s.empty?
76
+ return nil if checked_recently?(now)
77
+
78
+ latest = latest_version(api_url)
79
+ remember(now, latest)
80
+ latest && newer?(latest) ? message(latest) : nil
81
+ rescue StandardError
82
+ nil
83
+ end
84
+
85
+ def cache_file
86
+ File.join(Fp::Config::CONFIG_DIR, CACHE_NAME)
87
+ end
88
+
89
+ def checked_recently?(now)
90
+ checked_at = Time.parse(JSON.parse(File.read(cache_file))['checked_at'].to_s)
91
+ now - checked_at < INTERVAL
92
+ rescue StandardError
93
+ false
94
+ end
95
+
96
+ def remember(now, latest)
97
+ FileUtils.mkdir_p(File.dirname(cache_file))
98
+ File.write(cache_file, JSON.generate('checked_at' => now.utc.iso8601, 'latest' => latest))
99
+ rescue SystemCallError
100
+ nil
101
+ end
102
+ end
103
+ end
data/lib/fp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fp
4
- VERSION = '0.0.33'
4
+ VERSION = '0.0.35'
5
5
  end
data/lib/fp.rb CHANGED
@@ -9,6 +9,7 @@ require_relative 'fp/source_fingerprint'
9
9
  require_relative 'fp/junit'
10
10
  require_relative 'fp/repo_detector'
11
11
  require_relative 'fp/output'
12
+ require_relative 'fp/update_check'
12
13
  require_relative 'fp/commands'
13
14
  require_relative 'fp/cli'
14
15
 
data/skills/fp/SKILL.md CHANGED
@@ -17,6 +17,8 @@ command -v fp && fp --version
17
17
  ```
18
18
 
19
19
  If missing: `gem install featureparity` (or `bundle exec fp` inside an app that already depends on the gem).
20
+ To update fp, run `fp update` (or `gem update featureparity`); fp says on stderr, at most once
21
+ a day, when a newer version is published, and `fp doctor` shows it.
20
22
  This skill ships inside the gem; `fp skill install` refreshes an installed copy after an upgrade.
21
23
  `fp doctor` checks the install, the config and the repo without an API key. If `fp` fails
22
24
  inside a repo but works elsewhere, see Troubleshooting.
@@ -61,6 +61,8 @@ fp surfaces --project acme
61
61
  fp surfaces --project acme --json
62
62
  fp surfaces show <key> --project acme
63
63
  fp surfaces add <key> --project acme [--name "..."] [--kind api|web|android|ios|other] [--audience ...] [--repo org/repo] [--default-branch main]
64
+ fp surfaces add <key> --project acme --from <source> # Create and draft requirements from the source surface
65
+ fp surfaces add <key> --project acme --from <source> --evaluate # Create, evaluate applicability, return data (no drafting)
64
66
  fp surfaces edit <key> --project acme [--name "..."] [--kind ...] [--audience ...] [--repo ...] [--default-branch ...] [--key new_key]
65
67
  fp surfaces edit <key> --project acme [--showroom-url URL] [--showroom-label "..."] [--showroom-instructions "..." | --showroom-instructions-file PATH] [--showroom-position N]
66
68
  fp surfaces delete <key> --project acme [--yes]
@@ -71,6 +73,18 @@ you at `edit` — use `edit` to fill in the kind or repo of a surface that `fp p
71
73
  create --surfaces` made with defaults. `edit` only sends the flags you pass. `delete`
72
74
  asks you to type the key back in a terminal and refuses without `--yes` otherwise.
73
75
 
76
+ **`--from`**: When adding a platform that mirrors an existing one (Android when you
77
+ have web), `--from web` finds every active requirement on `web`, proposes adding the
78
+ new surface to each, and returns a gap list. The drafts await human review.
79
+
80
+ **`--from --evaluate`**: Instead of mass-drafting, asks the AI whether each source
81
+ requirement applies to the target platform. Returns applicability verdicts with
82
+ reasoning — which requirements apply (✅), which don't (❌), and why. Nothing is
83
+ drafted; the agent uses the evaluation data to decide which requirements to add
84
+ manually. Useful for filtering the ~10% that are platform-specific (browser resize,
85
+ web-only APIs) from the 90% that transfer to any client. Requires a Pro plan or a
86
+ project owner with AI access.
87
+
74
88
  A surface that requirements still require can't be deleted or re-keyed — the server
75
89
  refuses and names them. Taking a surface off a requirement is a human's call, so ask
76
90
  one rather than working around it.
@@ -937,7 +951,8 @@ secret exists is fine: the gate skips with an explanation and stays green.
937
951
 
938
952
  ### fp doctor
939
953
 
940
- Check that fp works here, with no API key and no API calls.
954
+ Check that fp works here, with no API key. It reads everything locally except the newest
955
+ published fp version, one lookup that is skipped when the API can't be reached.
941
956
 
942
957
  ```bash
943
958
  fp doctor
@@ -951,6 +966,8 @@ fp doctor --json
951
966
  the fix: install the gem under the pinned Ruby (`mise exec ruby@<pinned> -- gem install
952
967
  featureparity`, or `gem install featureparity` in the repo), or put the running Ruby's bin
953
968
  directory first on `PATH`.
969
+ - **Latest fp:** the newest published version. When it's newer than the one running, doctor
970
+ names `fp update` (and `gem update featureparity`) to install it.
954
971
  - **Config:** the API environment (warning when it isn't production), whether a key is
955
972
  present, which `.featureparity.yml` applies, and which fp wrote the `AGENTS.md` section.
956
973
  - **Repo:** the same summary as `fp init --detect`.
@@ -1022,6 +1039,18 @@ fp skill install --path ~/my-agent/skills # any skills directory (writes <path>/
1022
1039
  fp skill path # where the bundled skill lives
1023
1040
  ```
1024
1041
 
1042
+ ### fp update
1043
+
1044
+ Install the newest fp, or check whether one is published. Needs no API key.
1045
+
1046
+ ```bash
1047
+ fp update # install the newest fp under the Ruby running this one
1048
+ fp update --check # only say whether a newer one exists
1049
+ fp update --json
1050
+ ```
1051
+
1052
+ See [Updating fp](#updating-fp) for what to do afterwards.
1053
+
1025
1054
  ### fp repos
1026
1055
 
1027
1056
  Map surfaces to local repo paths (stored locally, not in the web app).
@@ -1033,6 +1062,30 @@ fp repos get customer_android --project acme
1033
1062
  fp repos unset customer_android --project acme
1034
1063
  ```
1035
1064
 
1065
+ ## Updating fp
1066
+
1067
+ fp is a Ruby gem, so any of these installs the newest version:
1068
+
1069
+ ```bash
1070
+ fp update # from fp 0.0.35
1071
+ gem update featureparity
1072
+ curl -fsSL https://api.featureparity.dev/api/cli/install | bash # the installer again
1073
+ ```
1074
+
1075
+ Then, in each repo that uses fp:
1076
+
1077
+ ```bash
1078
+ fp skill install # refresh the agent skill, if the repo has it installed
1079
+ fp init --force # refresh the FeatureParity section of AGENTS.md
1080
+ ```
1081
+
1082
+ `fp version` shows what's installed and `fp update --check` whether a newer one exists.
1083
+ `fp doctor` shows the newest published version and, when the one running is behind, the
1084
+ command that installs it. At most once a day, an fp command that finds a newer version
1085
+ says so on stderr after its own output. It stays quiet with `--json`, when `CI` is set,
1086
+ and when `FP_NO_UPDATE_CHECK=1`. A repo that pins a Ruby has its own copy of the gem: run
1087
+ the update inside that repo so the pinned Ruby's copy is the one that changes.
1088
+
1036
1089
  ## Exit codes
1037
1090
 
1038
1091
  | Code | Meaning |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: featureparity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-14 00:00:00.000000000 Z
11
+ date: 2026-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -131,6 +131,7 @@ files:
131
131
  - lib/fp/commands/spot_check.rb
132
132
  - lib/fp/commands/surfaces.rb
133
133
  - lib/fp/commands/tutorial.rb
134
+ - lib/fp/commands/update.rb
134
135
  - lib/fp/commands/version.rb
135
136
  - lib/fp/commands/whoami.rb
136
137
  - lib/fp/config.rb
@@ -148,6 +149,7 @@ files:
148
149
  - lib/fp/tutorial/hexhaven/test/junit_reporter.rb
149
150
  - lib/fp/tutorial/hexhaven/test/rules_test.rb
150
151
  - lib/fp/tutorial/hexhaven/test/test_helper.rb
152
+ - lib/fp/update_check.rb
151
153
  - lib/fp/version.rb
152
154
  - skills/fp/SKILL.md
153
155
  - skills/fp/references/cli.md