The 1+ Metagolf Challenge I'm letting this one out of the sandbox. Hopefully it is well-written and make sense, feel free to improve.
So in order to make 1+ more popular (and ease the creation of golfed 1+ text-printing programs) here comes the metagolf challenge:
The 1+ Language
1+ is a fun deque-based esolang where 1 is the only literal, and other numbers are constructed with operators
It is also &quot;monotonic&quot;, that is, it only has the + and * operators, and not - or /
The deque is often referred to as a &quot;stack&quot;, and one end of the deques is often referred to as the &quot;top&quot;
Here are the commands:

1 pushes 1
+ and * pop 2 numbers, and push their sum and product respectively
&quot; duplicates the top number
/ and \ rotate the stack upwards and downwards respectively. That is, / moves the top number to the bottom and \ does the exact reverse
^ swaps the top two numbers
&lt; is the only comparison operator (although it probably won't do much in Kolmogorov-complexity challenges)
. and , input an integer and a Unicode character respectively, and push it onto the stack. You are not allowed to take input here
: and ; output an integer and a Unicode character respectively. In the original interpreter, the : command outputs with a trailing newline, but here we allow both with a trailing newline and without a trailing newline
# is a goto-command that pops the top value n, and sends program flow to immediately after the nth # in the current line of execution (where numbering starts from 0)
Functions are defined with (name|code) and are called with (name). The name can be empty and the point where they are defined causes their execution too. They are separate lines of execution, so the numbering of #'s in them starts from 0

Original interpreter
Slightly modified interpreter to remove integer output trailing newline
Challenge
Your challenge is to write a program that inputs some text and outputs a 1+ program that outputs the text. The program can be in any language (lesser-known ones preferably), but it must output valid programs for any text.
Do not golf the test cases manually, otherwise I'll change them.
Winning criteria
Your score for a particular test case is your output length divided by the input length. The total score is the sum of the scores of all test cases. The lower, the better.
The test cases are:

&quot;Hello, World!&quot;
We're no strangers to code golf, you know the rules, and so do I
A keyboard so real you can almost TASTE it
Pascal's Tree-angle
JavaScript (Node.js),  16.26 ... 12.30  12.19
8.31 + 1.13 + 0.91 + 1.84
Saved 1.69 by optimizing the initial code, as suggested by @JoKing
Saved 1.31 by using a precomputed table of code snippets, as suggested by @Mukundan314
Saved 0.11 by counting the patterns more accurately, as suggested by @JoKing
Source
const CHAR_SET =
  &quot; !\&quot;#$%&amp;'*+,-./0123456789:;&lt;=&gt;?@&quot; +
  &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`&quot; +
  &quot;abcdefghijklmnopqrstuvwxyz{}&quot;;

const CHAR_MAP = {
  10 : '11+1+&quot;*1+',
  32 : '11+&quot;*&quot;*&quot;+',
  33 : '11+&quot;*&quot;*&quot;+1+',
  34 : '11+&quot;*&quot;*1+&quot;+',
  35 : '11+&quot;*1+&quot;1+1+*',
  36 : '11+1+&quot;+&quot;*',
  37 : '11+1+&quot;+&quot;*1+',
  38 : '11+&quot;1+&quot;+&quot;*+',
  39 : '11+1+&quot;&quot;+&quot;*+',
  40 : '11+&quot;*&quot;1+*&quot;+',
  41 : '11+&quot;*1+&quot;1+&quot;*+',
  42 : '11+1+&quot;+&quot;1+*',
  43 : '11+1+&quot;+&quot;1+*1+',
  44 : '11+&quot;*&quot;1+&quot;+1+*',
  45 : '11+1+&quot;&quot;1+1+**',
  46 : '11+1+&quot;&quot;1+1+**1+',
  47 : '11+&quot;*1+&quot;1+&quot;1+*+',
  48 : '11+1+&quot;1+&quot;**',
  49 : '11+1+&quot;+1+&quot;*',
  50 : '11+&quot;*1+&quot;*&quot;+',
  51 : '11+1+&quot;1+&quot;*1+*',
  52 : '11+1+&quot;&quot;+1+&quot;*+',
  53 : '11+1+&quot;1+1+&quot;*&quot;++',
  54 : '11+1+&quot;&quot;**&quot;+',
  55 : '11+1+&quot;+&quot;1+&quot;*+',
  56 : '11+1+&quot;+1+&quot;1+*',
  57 : '11+1+&quot;&quot;*&quot;+1+*',
  58 : '11+&quot;*&quot;1+&quot;*+&quot;+',
  59 : '11+1+&quot;&quot;+1+&quot;1+*+',
  60 : '11+1+&quot;1+&quot;1+**',
  61 : '11+1+&quot;1+&quot;1+**1+',
  62 : '11+1+&quot;+&quot;1+&quot;1+*+',
  63 : '11+1+&quot;&quot;&quot;+1+**',
  64 : '11+&quot;*&quot;+&quot;*',
  65 : '11+&quot;*&quot;+&quot;*1+',
  66 : '11+&quot;&quot;*&quot;+&quot;*+',
  67 : '11+1+&quot;1+&quot;+&quot;*+',
  68 : '11+&quot;*&quot;&quot;*1+*',
  69 : '11+&quot;*&quot;&quot;*1+*1+',
  70 : '11+&quot;&quot;*&quot;&quot;*1+*+',
  71 : '11+1+&quot;+1+&quot;1+&quot;*+',
  72 : '11+1+&quot;+&quot;*&quot;+',
  73 : '11+1+&quot;+&quot;*&quot;+1+',
  74 : '11+1+&quot;+&quot;*1+&quot;+',
  75 : '11+1+&quot;1+1+&quot;**',
  76 : '11+&quot;*&quot;&quot;+&quot;1+*+',
  77 : '11+&quot;1+&quot;1+1+&quot;**+',
  78 : '11+1+&quot;+&quot;&quot;+1+*',
  79 : '11+1+&quot;+&quot;&quot;+1+*1+',
  80 : '11+&quot;*&quot;&quot;1+**',
  81 : '11+1+&quot;*&quot;*',
  82 : '11+1+&quot;*&quot;*1+',
  83 : '11+&quot;1+&quot;*&quot;*+',
  84 : '11+1+&quot;&quot;*&quot;*+',
  85 : '11+1+&quot;&quot;*&quot;*+1+',
  86 : '11+&quot;1+&quot;&quot;*&quot;*++',
  87 : '11+1+&quot;&quot;&quot;*&quot;*++',
  88 : '11+&quot;*&quot;+&quot;1+1+1+*',
  89 : '11+&quot;*&quot;+&quot;1+&quot;*+',
  90 : '11+1+&quot;*&quot;1+*',
  91 : '11+1+&quot;*&quot;1+*1+',
  92 : '11+&quot;1+&quot;*&quot;1+*+',
  93 : '11+1+&quot;&quot;*&quot;1+*+',
  94 : '11+1+&quot;&quot;*&quot;1+*+1+',
  95 : '11+&quot;1+&quot;&quot;*&quot;1+*++',
  96 : '11+1+&quot;1+&quot;**&quot;+',
  97 : '11+1+&quot;1+&quot;**&quot;+1+',
  98 : '11+1+&quot;+1+&quot;*&quot;+',
  99 : '11+1+&quot;*&quot;1+1+*',
  100: '11+1+&quot;*1+&quot;*',
  101: '11+1+&quot;*1+&quot;*1+',
  102: '11+&quot;1+&quot;*1+&quot;*+',
  103: '11+1+&quot;&quot;*1+&quot;*+',
  104: '11+&quot;*&quot;1+&quot;*1+*',
  105: '11+&quot;*1+&quot;&quot;+&quot;*+',
  106: '11+1+&quot;&quot;&quot;*1+&quot;*++',
  107: '11+&quot;&quot;*1+&quot;&quot;+&quot;*++',
  108: '11+1+&quot;&quot;+&quot;**',
  109: '11+1+&quot;*&quot;1+&quot;*+',
  110: '11+1+&quot;*1+&quot;1+*',
  111: '11+1+&quot;&quot;+&quot;*1+*',
  112: '11+1+&quot;+1+&quot;1+*&quot;+',
  113: '11+1+&quot;&quot;*1+&quot;1+*+',
  114: '11+1+&quot;&quot;+&quot;*1+1+*',
  115: '11+&quot;*1+&quot;&quot;+&quot;1+*+',
  116: '11+&quot;*&quot;&quot;1+&quot;*+*',
  117: '11+1+&quot;&quot;&quot;+&quot;*+*',
  118: '11+1+&quot;*&quot;&quot;1+&quot;*++',
  119: '11+1+&quot;*&quot;1+&quot;1+*+',
  120: '11+&quot;*&quot;1+&quot;1+**',
  121: '11+&quot;1+&quot;*+&quot;*',
  122: '11+&quot;1+&quot;*+&quot;*1+',
  123: '11+&quot;&quot;1+&quot;*+&quot;*+',
  124: '11+1+&quot;&quot;*1+1+&quot;*+',
  125: '11+&quot;*1+&quot;&quot;**',
  126: '11+1+&quot;&quot;+&quot;1+**'
}

const MAX_WINDOW = 100;

function encode(str) {
  let out = '', cmd = [], stk = [], pos = [];

  Buffer.from(str).forEach((c, i) =&gt; {
    let j = stk.indexOf(c);

    if(~j) {
      cmd[pos[j]] = cmd[pos[j]].replace(/;/, '&quot;;');
      cmd.push(';');
      stk = stk.slice(0, j);
      pos = pos.slice(0, j);
    }
    else {
      cmd.push(CHAR_MAP[c] + ';');
    }
    stk.push(c);
    pos.push(i);
  });

  out += cmd.join('');

  for(let n = 0;; n++) {
    let id = (function genId(n) {
      return n ? CHAR_SET[n % CHAR_SET.length] + genId(n / CHAR_SET.length | 0) : ''
    })(n);

    let max = 0, best = null, stat = {};

    for(let i = 0; i &lt; out.length; i++) {
      let sub = '', p = 0, c;

      for(let w = 0; w &lt; MAX_WINDOW &amp;&amp; (c = out[i + w]); w++) {
        sub += c;
        p += (c == '(') - (c == ')');

        if(p &lt; 0 || c == '|') break;

        if(!p) {
          (stat[sub] = stat[sub] || []).push(i);
        }
      }
    }

    let A = Object.keys(stat).map(sub =&gt; {
      let w = sub.length,
          b = ~w,
          cnt = stat[sub].reduce((t, a) =&gt; a &lt; b + w ? t : (b = a, t + 1), 0),
          saved = cnt * w - ((cnt - 1) * (id.length + 2) + w + id.length + 3);

      return [ saved, sub, w ];
    })
    .sort((a, b) =&gt; b[0] - a[0]);

    if(!A.length) break;

    let [ saved, sub ] = A[0];

    if(saved &lt; 1) break;

    if(saved &gt; max) {
      max = saved;
      best = sub;
    }

    if(best === null) break;

    out =
      out.split(best).map((s, i) =&gt;
        i ? i == 1 ? `(${id}|` + best + ')' + s : `(${id})` + s : s
      ).join('');
  }

  return out;
}

Try it online!
Outputs

&quot;Hello, World!&quot;
We're no strangers to code golf, you know the rules, and so do I
A keyboard so real you can almost TASTE it
Pascal's Tree-angle

How?
Building the code snippets
The table of code snippets CHAR_MAP was built with the following program. This is a brute-force search that keeps the shortest snippet for each character, or the one that contains the most 1's in case of a tie. The idea behind this last rule is to use similar building strategies whenever possible to improve the final compression.
let snippet = {};

(function search(stk, cmd) {
  let n = stk[0];

  if(stk.length == 1 &amp;&amp; n &lt; 127) {
    snippet[n] =
      !snippet[n] || (
        snippet[n].length &gt; cmd.length || (
          snippet[n].length == cmd.length &amp;&amp;
          snippet[n].split('1').length &lt; cmd.split('1').length
        )
      ) ?
        cmd
      :
        snippet[n];
  }
  if(cmd.length &lt; 15) {
    if(stk.length &gt;= 2) {
      let a = stk[stk.length - 2], b = stk[stk.length - 1];

      search([...stk.slice(0, -2), a * b], cmd + '*');
      search([...stk.slice(0, -2), a + b], cmd + '+');
    }
    search([...stk, 1], cmd + '1');
    search([...stk, stk[stk.length - 1]], cmd + '&quot;');
  }
})([1, 1], '11');

console.log(snippet);

Try it online!
Optimizing the initial code
The initial code is first optimized by re-using characters that were previously generated whenever possible. For instance, Hello, World! is optimized as:
[H];[e];[l]&quot;;&quot;;[o]&quot;;[,];[ ];[W];;[r];;[d];[!];

where each character within brackets is one of the code snippets generated above.
Compressing the code with functions
We then iteratively look for the sub-string in the code that leads to the highest savings when replaced with a function call.
We make sure that the selected sub-strings have balanced parentheses and do not contain a |.
Below are all the compression steps for &quot;Hello, World!&quot;.
Initial code:
11+1+&quot;+&quot;*&quot;+;11+1+&quot;*1+&quot;*1+;11+1+&quot;&quot;+&quot;**&quot;;&quot;;11+1+&quot;&quot;+&quot;*1+*&quot;;11+&quot;*&quot;1+&quot;+1+*;11+&quot;*&quot;*&quot;+;11+1+&quot;&quot;&quot;
*&quot;*++;;11+1+&quot;&quot;+&quot;*1+1+*;;11+1+&quot;*1+&quot;*;11+&quot;*&quot;*&quot;+1+;

We replace ;11+1+&quot; with a function with an empty name:
11+1+&quot;+&quot;*&quot;+(|;11+1+&quot;)*1+&quot;*1+()&quot;+&quot;**&quot;;&quot;()&quot;+&quot;*1+*&quot;;11+&quot;*&quot;1+&quot;+1+*;11+&quot;*&quot;*&quot;+()&quot;&quot;*&quot;*++;()&quot;+&quot;*
1+1+*;()*1+&quot;*;11+&quot;*&quot;*&quot;+1+;

We replace ;11+&quot;*&quot; with a function named !:
11+1+&quot;+&quot;*&quot;+(|;11+1+&quot;)*1+&quot;*1+()&quot;+&quot;**&quot;;&quot;()&quot;+&quot;*1+*&quot;(!|;11+&quot;*&quot;)1+&quot;+1+*(!)*&quot;+()&quot;&quot;*&quot;*++;()&quot;+&quot;*
1+1+*;()*1+&quot;*(!)*&quot;+1+;

We replace ()&quot;+&quot;* with a function named &quot;:
11+1+&quot;+&quot;*&quot;+(|;11+1+&quot;)*1+&quot;*1+(&quot;|()&quot;+&quot;*)*&quot;;&quot;(&quot;)1+*&quot;(!|;11+&quot;*&quot;)1+&quot;+1+*(!)*&quot;+()&quot;&quot;*&quot;*++;(&quot;)1+
1+*;()*1+&quot;*(!)*&quot;+1+;