The styling you’re going for here specifically would be a duplicate of How to display "Chapter X" above level 1 heading name?.
Since the excluded headings all appear at the start, you could simply have the show rule below them in the code:
= Foreword
...
// The `show` rule goes here
= Lorem
...
Alternatively, don’t change the show rule’s positions in the code, but instead add #set heading(numbering: ...) where necessary, especially for more alterations:
#show heading.where(level: 1).and(heading.where(numbering: "1")): set text(red)
= Black
#set heading(numbering: "1")
= Red
#set heading(numbering: none)
= Black
Notice the added and.
Otherwise, I believe you would need to distinguish the headings through labels.
That’s how the numbering is detected. You would need to pass a function, for example Package subpar0.2.2 - #2 by hpcfzl.