@@ -211,6 +211,102 @@ Always structure your responses using clear markdown formatting:
211211 } )
212212} )
213213
214+ describe ( "ConfigMarkdown.shell" , ( ) => {
215+ test ( "extracts shell commands from template" , ( ) => {
216+ const template = "Run !`git status` and then !`npm test`"
217+ const matches = ConfigMarkdown . shell ( template )
218+ expect ( matches . length ) . toBe ( 2 )
219+ expect ( matches [ 0 ] [ 1 ] ) . toBe ( "git status" )
220+ expect ( matches [ 1 ] [ 1 ] ) . toBe ( "npm test" )
221+ } )
222+
223+ test ( "does not match regular backticks without bang" , ( ) => {
224+ const template = "Use `git status` command"
225+ const matches = ConfigMarkdown . shell ( template )
226+ expect ( matches . length ) . toBe ( 0 )
227+ } )
228+
229+ test ( "does not match empty bang-backtick" , ( ) => {
230+ const template = "Empty !`` should not match"
231+ const matches = ConfigMarkdown . shell ( template )
232+ expect ( matches . length ) . toBe ( 0 )
233+ } )
234+
235+ test ( "extracts command with pipes and flags" , ( ) => {
236+ const template = "Run !`cat file.txt | grep error` to find issues"
237+ const matches = ConfigMarkdown . shell ( template )
238+ expect ( matches . length ) . toBe ( 1 )
239+ expect ( matches [ 0 ] [ 1 ] ) . toBe ( "cat file.txt | grep error" )
240+ } )
241+ } )
242+
243+ describe ( "ConfigMarkdown.fallbackSanitization" , ( ) => {
244+ test ( "converts value with colon to block scalar" , ( ) => {
245+ const input = "---\nurl: https://example.com:8080\n---\nContent"
246+ const result = ConfigMarkdown . fallbackSanitization ( input )
247+ expect ( result ) . toContain ( "url: |-" )
248+ expect ( result ) . toContain ( " https://example.com:8080" )
249+ } )
250+
251+ test ( "preserves already double-quoted values with colons" , ( ) => {
252+ const input = '---\nurl: "https://example.com:8080"\n---\nContent'
253+ const result = ConfigMarkdown . fallbackSanitization ( input )
254+ expect ( result ) . toContain ( '"https://example.com:8080"' )
255+ expect ( result ) . not . toContain ( "|-" )
256+ } )
257+
258+ test ( "preserves already single-quoted values with colons" , ( ) => {
259+ const input = "---\nurl: 'https://example.com:8080'\n---\nContent"
260+ const result = ConfigMarkdown . fallbackSanitization ( input )
261+ expect ( result ) . toContain ( "'https://example.com:8080'" )
262+ expect ( result ) . not . toContain ( "|-" )
263+ } )
264+
265+ test ( "passes through content without frontmatter unchanged" , ( ) => {
266+ const input = "Just some content"
267+ expect ( ConfigMarkdown . fallbackSanitization ( input ) ) . toBe ( input )
268+ } )
269+
270+ test ( "preserves comments in frontmatter" , ( ) => {
271+ const input = "---\n# comment\nname: John\n---\nContent"
272+ const result = ConfigMarkdown . fallbackSanitization ( input )
273+ expect ( result ) . toContain ( "# comment" )
274+ expect ( result ) . toContain ( "name: John" )
275+ } )
276+
277+ test ( "preserves indented continuation lines" , ( ) => {
278+ const input = "---\nsummary: >\n This is multiline\n content\n---\nBody"
279+ const result = ConfigMarkdown . fallbackSanitization ( input )
280+ expect ( result ) . toContain ( " This is multiline" )
281+ expect ( result ) . toContain ( " content" )
282+ } )
283+
284+ test ( "preserves block scalar indicators" , ( ) => {
285+ const input = "---\nnotes: |\n line1\n line2\n---\nContent"
286+ const result = ConfigMarkdown . fallbackSanitization ( input )
287+ expect ( result ) . toContain ( "notes: |" )
288+ } )
289+
290+ test ( "handles empty frontmatter values" , ( ) => {
291+ const input = "---\nempty:\n---\nContent"
292+ const result = ConfigMarkdown . fallbackSanitization ( input )
293+ expect ( result ) . toContain ( "empty:" )
294+ } )
295+
296+ test ( "does not modify content after frontmatter" , ( ) => {
297+ const input = "---\nname: John\n---\nContent with url: http://example.com:3000"
298+ const result = ConfigMarkdown . fallbackSanitization ( input )
299+ expect ( result ) . toContain ( "Content with url: http://example.com:3000" )
300+ } )
301+
302+ test ( "handles CRLF line endings in frontmatter regex" , ( ) => {
303+ const input = "---\r\nurl: https://example.com:8080\r\n---\r\nContent"
304+ const result = ConfigMarkdown . fallbackSanitization ( input )
305+ expect ( result ) . toContain ( "url: |-" )
306+ expect ( result ) . toContain ( " https://example.com:8080" )
307+ } )
308+ } )
309+
214310describe ( "ConfigMarkdown: frontmatter has weird model id" , async ( ) => {
215311 const result = await ConfigMarkdown . parse ( import . meta. dir + "/fixtures/weird-model-id.md" )
216312
0 commit comments