@themoltnet/legreffier 0.26.2 → 0.28.0

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -18
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -2631,9 +2631,9 @@ function invert$1(number, modulo) {
2631
2631
  let b = modulo;
2632
2632
  let x = _0n$2, u = _1n$3;
2633
2633
  while (a !== _0n$2) {
2634
- const q = b / a;
2634
+ const q2 = b / a;
2635
2635
  const r = b % a;
2636
- const m = x - u * q;
2636
+ const m = x - u * q2;
2637
2637
  b = a, a = r, x = u, u = m;
2638
2638
  }
2639
2639
  const gcd = b;
@@ -3738,8 +3738,8 @@ const invert = (num, md) => {
3738
3738
  err("no inverse n=" + num + " mod=" + md);
3739
3739
  let a = M(num, md), b = md, x = 0n, u = 1n;
3740
3740
  while (a !== 0n) {
3741
- const q = b / a, r = b % a;
3742
- const m = x - u * q;
3741
+ const q2 = b / a, r = b % a;
3742
+ const m = x - u * q2;
3743
3743
  b = a, a = r, x = u, u = m;
3744
3744
  }
3745
3745
  return b === 1n ? M(x, md) : err("no inverse");
@@ -5718,21 +5718,10 @@ class CodexAdapter {
5718
5718
  await downloadSkills(repoDir, ".agents/skills");
5719
5719
  }
5720
5720
  /**
5721
- * Write a sourceable env file at `.moltnet/<name>/env` with the OAuth2
5722
- * credentials that Codex needs in the shell environment.
5721
+ * Env file generation moved to shared writeEnvFile in the agentSetup phase.
5722
+ * Codex has no additional settings beyond the env file.
5723
5723
  */
5724
- async writeSettings(opts) {
5725
- const envDir = join(opts.repoDir, ".moltnet", opts.agentName);
5726
- await mkdir(envDir, { recursive: true });
5727
- const q = (v) => `'${v.replace(/'/g, "'\\''")}'`;
5728
- const lines = [
5729
- `${opts.prefix}_CLIENT_ID=${q(opts.clientId)}`,
5730
- `${opts.prefix}_CLIENT_SECRET=${q(opts.clientSecret)}`,
5731
- `${opts.prefix}_GITHUB_APP_ID=${q(opts.appSlug)}`,
5732
- `${opts.prefix}_GITHUB_APP_PRIVATE_KEY_PATH=${q(opts.pemPath)}`,
5733
- `${opts.prefix}_GITHUB_APP_INSTALLATION_ID=${q(opts.installationId)}`
5734
- ];
5735
- await writeFile(join(envDir, "env"), lines.join("\n") + "\n", "utf-8");
5724
+ async writeSettings(_opts) {
5736
5725
  }
5737
5726
  async writeRules(opts) {
5738
5727
  const dir2 = join(opts.repoDir, ".codex", "rules");
@@ -5748,6 +5737,54 @@ const adapters = {
5748
5737
  claude: new ClaudeAdapter(),
5749
5738
  codex: new CodexAdapter()
5750
5739
  };
5740
+ function q(v) {
5741
+ return `'${v.replace(/'/g, "'\\''")}'`;
5742
+ }
5743
+ async function writeEnvFile(opts) {
5744
+ await mkdir(opts.envDir, { recursive: true });
5745
+ const envPath = join(opts.envDir, "env");
5746
+ const managedEntries = [
5747
+ [`${opts.prefix}_CLIENT_ID`, q(opts.clientId)],
5748
+ [`${opts.prefix}_CLIENT_SECRET`, q(opts.clientSecret)],
5749
+ [`${opts.prefix}_GITHUB_APP_ID`, q(opts.appSlug)],
5750
+ [`${opts.prefix}_GITHUB_APP_PRIVATE_KEY_PATH`, q(opts.pemPath)],
5751
+ [`${opts.prefix}_GITHUB_APP_INSTALLATION_ID`, q(opts.installationId)],
5752
+ ["GIT_CONFIG_GLOBAL", q(`.moltnet/${opts.agentName}/gitconfig`)]
5753
+ ];
5754
+ const managedKeys = new Set(managedEntries.map(([k]) => k));
5755
+ let existingLines = [];
5756
+ try {
5757
+ const existing = await readFile(envPath, "utf-8");
5758
+ existingLines = existing.split("\n");
5759
+ } catch {
5760
+ }
5761
+ const outputLines = [];
5762
+ for (const [key, val] of managedEntries) {
5763
+ outputLines.push(`${key}=${val}`);
5764
+ }
5765
+ let seenUserContent = false;
5766
+ for (const line of existingLines) {
5767
+ const trimmed = line.trim();
5768
+ if (trimmed === "") {
5769
+ if (seenUserContent) outputLines.push(line);
5770
+ continue;
5771
+ }
5772
+ if (trimmed.startsWith("#")) {
5773
+ if (!seenUserContent) outputLines.push("");
5774
+ seenUserContent = true;
5775
+ outputLines.push(line);
5776
+ continue;
5777
+ }
5778
+ const eqIdx = trimmed.indexOf("=");
5779
+ if (eqIdx < 1) continue;
5780
+ const key = trimmed.slice(0, eqIdx);
5781
+ if (managedKeys.has(key)) continue;
5782
+ if (!seenUserContent) outputLines.push("");
5783
+ seenUserContent = true;
5784
+ outputLines.push(line);
5785
+ }
5786
+ await writeFile(envPath, outputLines.join("\n") + "\n", "utf-8");
5787
+ }
5751
5788
  function getStatePath(configDir) {
5752
5789
  return join(configDir, "legreffier-init.state.json");
5753
5790
  }
@@ -5842,6 +5879,16 @@ async function runAgentSetupPhase(opts) {
5842
5879
  await adapter.writeSettings(adapterOpts);
5843
5880
  }
5844
5881
  dispatch({ type: "step", key: "settings", status: "done" });
5882
+ await writeEnvFile({
5883
+ envDir: configDir,
5884
+ agentName,
5885
+ prefix,
5886
+ clientId,
5887
+ clientSecret,
5888
+ appSlug,
5889
+ pemPath,
5890
+ installationId
5891
+ });
5845
5892
  await clearState(configDir);
5846
5893
  }
5847
5894
  async function exchangeManifestCode(code) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/legreffier",
3
- "version": "0.26.2",
3
+ "version": "0.28.0",
4
4
  "description": "LeGreffier — one-command accountable AI agent setup",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -34,9 +34,9 @@
34
34
  "vite": "^6.0.0",
35
35
  "vitest": "^3.0.0",
36
36
  "@moltnet/api-client": "0.1.0",
37
- "@moltnet/crypto-service": "0.1.0",
38
- "@themoltnet/design-system": "0.3.0",
39
- "@themoltnet/sdk": "0.83.1"
37
+ "@themoltnet/design-system": "0.3.1",
38
+ "@themoltnet/sdk": "0.83.2",
39
+ "@moltnet/crypto-service": "0.1.0"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "vite build --watch",
@@ -44,6 +44,6 @@
44
44
  "typecheck": "tsc -b --emitDeclarationOnly && tsc -b tsconfig.test.json --force",
45
45
  "test": "vitest run --passWithNoTests",
46
46
  "lint": "eslint src/",
47
- "check:pack": "tsx ../../scripts/check-pack.ts --package ."
47
+ "check:pack": "tsx ../../tools/src/check-pack.ts --package ."
48
48
  }
49
49
  }