1717require_relative "build"
1818require_relative "sync"
1919require_relative "artifact_targets"
20+ require_relative "instruction_marker"
2021
2122module Status
2223 CONTRACT_VERSION = 2
@@ -72,6 +73,7 @@ def injection_outcome(findings)
7273 end
7374
7475 # generated artifacts の数と、source より古い (build_id 不一致) artifact の数。
76+ # skill (directory) と instruction (単一ファイル) の両方を数える。
7577 def generated_state
7678 sources = Assets . sources_by_name ( @root )
7779 total = 0
@@ -83,6 +85,12 @@ def generated_state
8385 total += 1
8486 stale += 1 unless fresh? ( artifact , sources )
8587 end
88+ Dir . glob ( File . join ( @root , "generated" , tool , "instructions" , "*" ) ) . sort . each do |artifact |
89+ next unless File . file? ( artifact )
90+
91+ total += 1
92+ stale += 1 unless fresh_instruction? ( artifact , sources )
93+ end
8694 end
8795 [ total , stale ]
8896 end
@@ -102,6 +110,17 @@ def fresh?(artifact, sources)
102110 false
103111 end
104112
113+ # instruction (ファイル内コメント marker) の鮮度判定。
114+ def fresh_instruction? ( path , sources )
115+ marker = InstructionMarker . parse ( File . read ( path ) )
116+ return false unless marker
117+
118+ source = sources [ marker [ "name" ] ]
119+ return false unless source
120+
121+ marker [ "build_id" ] == Build . build_id_for ( @root , source [ "path" ] , source [ "format" ] )
122+ end
123+
105124 # catalog (docs/register-catalog.md) の register summary。
106125 def register_summary
107126 catalog_path = File . join ( @root , "generated" , "catalog.json" )
0 commit comments