@outerlayer/cli 0.40.0-next.20261115195301 → 0.40.0-next.20261116030824

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 (91) hide show
  1. package/README.md +8 -0
  2. package/dist/{agent-setup-URENTDUL.js → agent-setup-KUOWKHAG.js} +3 -3
  3. package/dist/build-info.json +1 -1
  4. package/dist/{caller-FJUWGSNN.js → caller-YHE7IHC7.js} +2 -2
  5. package/dist/{check-RNYNJLPD.js → check-APZ57YHI.js} +21 -21
  6. package/dist/{chunk-IQRYAAOG.js → chunk-2Q5OMKDK.js} +1 -1
  7. package/dist/{chunk-UOP4OSVB.js → chunk-2YKSBXWU.js} +1 -1
  8. package/dist/{chunk-LHL666SD.js → chunk-4SAXGCD2.js} +2 -2
  9. package/dist/{init-cmd-3IGM4ME7.js → chunk-53CDP7AH.js} +2 -44
  10. package/dist/{chunk-ZBZAJ63M.js → chunk-5XQAADM3.js} +4 -4
  11. package/dist/{chunk-F7AOOV5N.js → chunk-BAPRSDUR.js} +2 -2
  12. package/dist/{chunk-NQDJRUCT.js → chunk-DGCF5LVP.js} +5 -5
  13. package/dist/{chunk-4TVL4E53.js → chunk-DHB3M244.js} +88 -16
  14. package/dist/{chunk-TY54GMUZ.js → chunk-E54LIYIR.js} +16 -16
  15. package/dist/{chunk-VQ57S72O.js → chunk-EGYZGB2P.js} +1 -1
  16. package/dist/{chunk-XTUTQVBU.js → chunk-EVMSDUK7.js} +2 -2
  17. package/dist/{chunk-L6B4O4UB.js → chunk-GODZ6QAN.js} +1 -1
  18. package/dist/{chunk-AEAKGO6N.js → chunk-HFVTLCI7.js} +1 -1
  19. package/dist/{chunk-73ZVFELN.js → chunk-HG7RVRAY.js} +9 -9
  20. package/dist/{chunk-EX37FUSI.js → chunk-IIMASDNH.js} +1 -1
  21. package/dist/{chunk-IGVOCKAC.js → chunk-IQWBUZ75.js} +23 -2
  22. package/dist/{chunk-F4HSDGFO.js → chunk-IZHE3WOW.js} +1 -1
  23. package/dist/{chunk-4FD6PCB5.js → chunk-L7GUBTCP.js} +2 -2
  24. package/dist/{chunk-R34OLRY7.js → chunk-LCZGMJXD.js} +1 -1
  25. package/dist/{chunk-SPCYPIND.js → chunk-LFYNOKS5.js} +4 -4
  26. package/dist/{chunk-V2O6KLTQ.js → chunk-PIXDSHVH.js} +1 -1
  27. package/dist/{chunk-VQLOZLLC.js → chunk-PSKNTGC3.js} +1 -1
  28. package/dist/{chunk-5EQ2B6UE.js → chunk-QFAH525L.js} +1 -1
  29. package/dist/{chunk-556K7WAT.js → chunk-RGG4J24Z.js} +5 -5
  30. package/dist/{chunk-4L3WCEOI.js → chunk-RRRW2M4B.js} +1 -1
  31. package/dist/{chunk-IXZG7OJ6.js → chunk-SEKJKOOB.js} +1 -1
  32. package/dist/chunk-SYFVCV2V.js +124 -0
  33. package/dist/{chunk-BAE5M4N3.js → chunk-TQ3PXYPJ.js} +1 -1
  34. package/dist/{chunk-ASHPKDV4.js → chunk-WKPOKOUQ.js} +1 -1
  35. package/dist/{chunk-HEJ4UYSX.js → chunk-WMXJ3XBP.js} +1 -1
  36. package/dist/{chunk-VL3IS7S2.js → chunk-YDB72T5Z.js} +1 -1
  37. package/dist/{chunk-QW7T7OMV.js → chunk-YYSW7OKI.js} +1 -1
  38. package/dist/{cli-WUOM4FLZ.js → cli-EUICZJBA.js} +150 -109
  39. package/dist/{command-C7NHLA5X.js → command-PBWQFU4B.js} +19 -19
  40. package/dist/{config-ME2W5VIX.js → config-TGFG7IID.js} +1 -1
  41. package/dist/{connect-cmd-QX7WJ65U.js → connect-cmd-UYJV435V.js} +2 -2
  42. package/dist/{container-start-FUY7HBID.js → container-start-6INDSNAE.js} +17 -17
  43. package/dist/{context-show-cmd-2ABJ5B66.js → context-show-cmd-XIPY7JXC.js} +3 -3
  44. package/dist/{demo-voice-cmd-ZGT6ZKH4.js → demo-voice-cmd-ABTYSDTU.js} +7 -7
  45. package/dist/{doctor-V7PL73TB.js → doctor-KQ7J5GPF.js} +17 -17
  46. package/dist/{emit-artifact-cmd-2KQYKVRF.js → emit-artifact-cmd-R5BOINKV.js} +6 -6
  47. package/dist/{emit-criteria-cmd-JOYI5L6K.js → emit-criteria-cmd-VWCPZ3TV.js} +4 -4
  48. package/dist/{emit-demo-cmd-J4N2P7MS.js → emit-demo-cmd-QPF3MGY3.js} +7 -7
  49. package/dist/{emit-finding-cmd-QPSTTD7U.js → emit-finding-cmd-O2HNKNSU.js} +4 -4
  50. package/dist/{emit-result-cmd-KPAS6BS4.js → emit-result-cmd-CFS2YAS5.js} +5 -5
  51. package/dist/{emit-step-cmd-GQDRQ6JS.js → emit-step-cmd-Q43ESQ5J.js} +4 -4
  52. package/dist/{find-unit-AFBSWEOE.js → find-unit-HKCVRS7L.js} +3 -3
  53. package/dist/{findings-cmd-57E6BXM2.js → findings-cmd-ZWNSAECA.js} +4 -4
  54. package/dist/{governing-source-O6VIHNZG.js → governing-source-MIRABOUE.js} +5 -5
  55. package/dist/{host-checks-34JJBDZN.js → host-checks-34OYY7KX.js} +15 -15
  56. package/dist/index.js +1 -1
  57. package/dist/{init-N2CJRONT.js → init-BIQTMVLH.js} +15 -15
  58. package/dist/{init-NP7ZEMF6.js → init-RNXF64MR.js} +15 -15
  59. package/dist/{init-agent-WCYO3FDV.js → init-agent-E3PLU6R4.js} +15 -15
  60. package/dist/init-cmd-DAZPTELN.js +53 -0
  61. package/dist/{init-update-W3CNPIEJ.js → init-update-GHLRW7BP.js} +3 -3
  62. package/dist/{install-cmd-2BZYH77S.js → install-cmd-PEFKMYGU.js} +2 -2
  63. package/dist/{launch-agent-S5ZCDOJR.js → launch-agent-P5KMBBB5.js} +3 -3
  64. package/dist/{login-browser-KJPWH65X.js → login-browser-OA4R4PEQ.js} +1 -1
  65. package/dist/{loop-PBB2C6OX.js → loop-PE7QDWJA.js} +20 -20
  66. package/dist/{machine-OHIDQF5L.js → machine-G3I6CXMA.js} +15 -15
  67. package/dist/{run-cmd-NEZVPFFG.js → run-cmd-W2XIBU2G.js} +4 -4
  68. package/dist/{runner-env-RYMF4YVJ.js → runner-env-TJE5WGPK.js} +3 -3
  69. package/dist/{runner-key-7FSETEPG.js → runner-key-PAF6N4RJ.js} +15 -15
  70. package/dist/{session-sender-6HKSOFQ2.js → session-sender-NDP6HVSG.js} +6 -6
  71. package/dist/setup-cmd-PQTTUAXH.js +214 -0
  72. package/dist/setup-wiring-65IDNFAW.js +200 -0
  73. package/dist/{spec-cmd-53UFNXNH.js → spec-cmd-LEU2PGWP.js} +5 -5
  74. package/dist/{status-2KUO23YX.js → status-6IF7APSQ.js} +15 -15
  75. package/dist/{sync-cmd-5FAB4CAX.js → sync-cmd-Q3FERZNI.js} +5 -5
  76. package/dist/{update-steps-UNCWB35F.js → update-steps-GERKPJ5C.js} +16 -16
  77. package/dist/{watch-GKQOIY7F.js → watch-2Z2HFUIL.js} +5 -5
  78. package/dist/{work-claim-cmd-PZFPD3NS.js → work-claim-cmd-Q4EXZDXE.js} +6 -6
  79. package/dist/{work-cmd-JANDUCNE.js → work-cmd-JNSI6X5D.js} +4 -4
  80. package/dist/{work-comment-cmd-ZIDXYWNH.js → work-comment-cmd-4AD66BWL.js} +5 -5
  81. package/dist/{work-demo-cmd-7OKBQG37.js → work-demo-cmd-BBNNMB4P.js} +4 -4
  82. package/dist/{work-logs-cmd-2XDRIBM2.js → work-logs-cmd-EU2Z2P2F.js} +4 -4
  83. package/dist/{work-mock-cmd-RFBGDQST.js → work-mock-cmd-5W52S7J5.js} +4 -4
  84. package/dist/{work-needs-attention-cmd-EY5FLR35.js → work-needs-attention-cmd-6X3DMFB3.js} +4 -4
  85. package/dist/{work-no-change-cmd-UOLGPCI2.js → work-no-change-cmd-JS5GWIV5.js} +4 -4
  86. package/dist/{work-open-pr-cmd-WBWODWGY.js → work-open-pr-cmd-3KHOY5KT.js} +5 -5
  87. package/dist/{work-pr-cmd-6733KSPR.js → work-pr-cmd-LJDDDQS4.js} +4 -4
  88. package/dist/{work-proofs-cmd-MWS4XRCK.js → work-proofs-cmd-WZHU6KBF.js} +5 -5
  89. package/dist/{work-proofs-record-UBXMJY6N.js → work-proofs-record-FMFNCZZV.js} +10 -10
  90. package/dist/{work-stop-cmd-A32J3PL7.js → work-stop-cmd-WTKUFCEF.js} +4 -4
  91. package/package.json +2 -2
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { sanitizeTerminal } from './chunk-DV44KCM6.js';
4
4
  import { mcpFiles, skillLinkFolders, isAgentsMdLayout } from './chunk-XDBHRWPQ.js';
5
- import { DEFAULT_DASHBOARD } from './chunk-4TVL4E53.js';
5
+ import { DEFAULT_DASHBOARD } from './chunk-DHB3M244.js';
6
6
  import { cliFetch, resolveGatewayCredentials } from './chunk-N7PG5JAD.js';
7
7
  import { readCloudConfig } from './chunk-HWVMRETT.js';
8
8
  import { findGitDirs, writeRepoConnection, readRepoConnection } from './chunk-BJ3KTMDH.js';
@@ -43,6 +43,24 @@ async function isRepositoryLinked(fetchImpl, gatewayUrl, token, appId, repositor
43
43
  if (!Array.isArray(listed)) return null;
44
44
  return listed.some((entry) => isLinkedRepository(repository, entry ?? {}));
45
45
  }
46
+ async function linkedBranches(fetchImpl, gatewayUrl, token, appId, repository) {
47
+ let res;
48
+ try {
49
+ res = await fetchImpl(`${gatewayUrl.replace(/\/+$/, "")}/v1/apps/${encodeURIComponent(appId)}/git/links`, {
50
+ method: "GET",
51
+ headers: { authorization: `Bearer ${token}`, "x-outerlayer-app-id": appId },
52
+ signal: AbortSignal.timeout(LINKS_TIMEOUT_MS)
53
+ });
54
+ } catch {
55
+ return null;
56
+ }
57
+ if (!res.ok) return null;
58
+ const listed = (await res.json().catch(() => void 0))?.data;
59
+ if (!Array.isArray(listed)) return null;
60
+ const entry = listed.find((e) => isLinkedRepository(repository, e ?? {}));
61
+ if (entry === void 0 || !Array.isArray(entry.branches)) return null;
62
+ return entry.branches.filter((b) => typeof b === "string" && b !== "");
63
+ }
46
64
  function dashboardBase(home) {
47
65
  const saved = readCloudConfig(home).dashboard;
48
66
  const base = typeof saved === "string" && saved.trim() !== "" ? saved : DEFAULT_DASHBOARD;
@@ -106,6 +124,9 @@ function existsOnDisk(path) {
106
124
  return false;
107
125
  }
108
126
  }
127
+ function setupCommitPaths(repoRoot) {
128
+ return setupPathsFor(repoRoot).filter((path) => existsOnDisk(join(repoRoot, path)) && !isGitIgnored(repoRoot, path));
129
+ }
109
130
  function commitCommandsFor(cwd) {
110
131
  const dirs = findGitDirs(cwd);
111
132
  if (dirs === void 0) return commitLineFor(cwd);
@@ -416,4 +437,4 @@ ${commitLineFor(deps.cwd)}
416
437
  return r.code;
417
438
  }
418
439
 
419
- export { COMMIT_LINE, agentsLayoutCommitLine, autoConnectedLine, commitCommandsFor, commitLineFor, dashboardBase, fetchFactories, findNamedFactory, hasUncommittedPolicy, isLinkedRepository, listText, listWithAnd, promptOnTerminal, realConnectDeps, runConnect, runConnectCommand, saveFactoryConnection, selectFactory, slug, workPageUrl };
440
+ export { COMMIT_LINE, agentsLayoutCommitLine, autoConnectedLine, commitCommandsFor, commitLineFor, dashboardBase, fetchFactories, findNamedFactory, hasUncommittedPolicy, isLinkedRepository, linkedBranches, listText, listWithAnd, ownerAndName, promptOnTerminal, realConnectDeps, runConnect, runConnectCommand, saveFactoryConnection, selectFactory, setupCommitPaths, slug, workPageUrl };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { keyRunnerFactory, RunnerConfigError } from './chunk-V2O6KLTQ.js';
3
+ import { keyRunnerFactory, RunnerConfigError } from './chunk-PIXDSHVH.js';
4
4
  import { orgHomeDir } from './chunk-DYV2OC4S.js';
5
5
 
6
6
  createRequire(import.meta.url);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { helperSocketPath } from './chunk-73ZVFELN.js';
4
- import { UNIT_MARKER } from './chunk-4L3WCEOI.js';
3
+ import { helperSocketPath } from './chunk-HG7RVRAY.js';
4
+ import { UNIT_MARKER } from './chunk-RRRW2M4B.js';
5
5
  import { runnerDir } from './chunk-DYV2OC4S.js';
6
6
  import { createHash } from 'crypto';
7
7
  import { join } from 'path';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { LiveUploader } from './chunk-BAE5M4N3.js';
3
+ import { LiveUploader } from './chunk-TQ3PXYPJ.js';
4
4
  import { spoolDir } from './chunk-E5PWV6H2.js';
5
5
  import { parseRunEnv, parseWorkItemEnv } from './chunk-LGJ56FCM.js';
6
6
  import { sessionFolderIn, legacyAgent } from './chunk-LPQJ5LXP.js';
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { scrubReason, stripTerminalControls } from './chunk-73ZVFELN.js';
4
- import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-4L3WCEOI.js';
3
+ import { scrubReason, stripTerminalControls } from './chunk-HG7RVRAY.js';
4
+ import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-RRRW2M4B.js';
5
5
  import { RunnerAlreadyRunningError, readPidFile } from './chunk-MGN525G6.js';
6
6
  import { isSameProcess } from './chunk-JBJTC3UU.js';
7
- import { isSignatureRefusal, postJson } from './chunk-F7AOOV5N.js';
8
- import { keyRunnerFactory } from './chunk-V2O6KLTQ.js';
7
+ import { isSignatureRefusal, postJson } from './chunk-BAPRSDUR.js';
8
+ import { keyRunnerFactory } from './chunk-PIXDSHVH.js';
9
9
  import { signerFor } from './chunk-NDDXBJMX.js';
10
10
  import { pidFilePath } from './chunk-DYV2OC4S.js';
11
11
  import { readFileSync } from 'fs';
@@ -108,7 +108,7 @@ var MAX_IMAGE_LENGTH = 200;
108
108
  var KEYS = ["provider", "machine", "snapshot", "image", "allowHosts", "idleMinutes", "docker"];
109
109
  var MANAGED_SNAPSHOT = "outerlayer";
110
110
  function machineSizeOf(machine) {
111
- const { vcpus, memoryGiB, diskGB } = machine === "large" ? { vcpus: 4, memoryGiB: 16, diskGB: 30 } : { vcpus: 2, memoryGiB: 8, diskGB: 20 };
111
+ const { vcpus, memoryGiB, diskGB } = machine === "large" ? { vcpus: 8, memoryGiB: 32, diskGB: 30 } : { vcpus: 4, memoryGiB: 16, diskGB: 20 };
112
112
  return { vcpu: vcpus, memoryMib: memoryGiB * 1024, diskGib: Math.ceil(diskGB * 1e9 / GIB) };
113
113
  }
114
114
  function sandboxSizeOf(build) {
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { LAUNCH_AGENT_ENV } from './chunk-TXKHD4Q6.js';
4
4
  import { execStartArgv } from './chunk-PT3DOY6P.js';
5
- import { DEFAULT_UNIT_NAME } from './chunk-4L3WCEOI.js';
5
+ import { DEFAULT_UNIT_NAME } from './chunk-RRRW2M4B.js';
6
6
  import { runnerDir } from './chunk-DYV2OC4S.js';
7
7
  import { join, dirname } from 'path';
8
8
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { fetchFactories, selectFactory, saveFactoryConnection, autoConnectedLine } from './chunk-IGVOCKAC.js';
3
+ import { fetchFactories, selectFactory, saveFactoryConnection, autoConnectedLine } from './chunk-IQWBUZ75.js';
4
4
  import { resolveGatewayCredentials } from './chunk-N7PG5JAD.js';
5
5
  import { readCloudConfig } from './chunk-HWVMRETT.js';
6
6
  import { findGitDirs, readRepoConnection } from './chunk-BJ3KTMDH.js';
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { placeholderQueues, placeholderProblem } from './chunk-73ZVFELN.js';
4
- import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-4L3WCEOI.js';
5
- import { getJson, WorkCommandError } from './chunk-F7AOOV5N.js';
6
- import { isBuiltinVm, isBuiltinSandbox, builtinKind, EGRESS_SWITCHABLE_KEYS, imageBuildOf, keepsHostBuilder } from './chunk-V2O6KLTQ.js';
3
+ import { placeholderQueues, placeholderProblem } from './chunk-HG7RVRAY.js';
4
+ import { checkFit, RUNNER_RESERVE_BYTES } from './chunk-RRRW2M4B.js';
5
+ import { getJson, WorkCommandError } from './chunk-BAPRSDUR.js';
6
+ import { isBuiltinVm, isBuiltinSandbox, builtinKind, EGRESS_SWITCHABLE_KEYS, imageBuildOf, keepsHostBuilder } from './chunk-PIXDSHVH.js';
7
7
  import { realBuildDiskProbe, checkDiskFit, DEFAULT_CACHE_DISK, DEFAULT_BUILD_DISK } from './chunk-OC3BSNNE.js';
8
8
  import { ensureHostKey } from './chunk-NDDXBJMX.js';
9
9
  import { sandboxSettingsFrom } from './chunk-VXU5IAEQ.js';
@@ -224,7 +224,7 @@ function checkBlockedWithSlots(config, probes, agents = defaultAgents()) {
224
224
  }
225
225
  var GIB = 1024 ** 3;
226
226
  function largeBuildMemoryBytes() {
227
- return 16 * GIB;
227
+ return 32 * GIB;
228
228
  }
229
229
  var LARGE_BUILD_DISK_BYTES = 3e10;
230
230
  function checkManagedRoom(input) {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { builtinKind, keepsHostBuilder } from './chunk-V2O6KLTQ.js';
3
+ import { builtinKind, keepsHostBuilder } from './chunk-PIXDSHVH.js';
4
4
  import { parseSize } from './chunk-TCPWJBH5.js';
5
5
  import { runnerDir } from './chunk-DYV2OC4S.js';
6
6
  import { FD_SLOTS_PER_BUILD, FD_STORE_ENV, BUILD_SLICE_MEMORY_ENV, credentialLineIn, withoutCredentialLines } from './chunk-XOJRFV3U.js';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { detectActiveSession } from './chunk-IKGAVS5X.js';
4
- import { autoConnect } from './chunk-5EQ2B6UE.js';
4
+ import { autoConnect } from './chunk-QFAH525L.js';
5
5
  import { C } from './chunk-2AM6Z5BP.js';
6
6
  import { defaultFetch, unauthorizedMessage, resolveGatewayCredentials } from './chunk-N7PG5JAD.js';
7
7
  import { parseWorkItemEnv } from './chunk-LGJ56FCM.js';
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'node:module';
3
+ import { linkedBranches, setupCommitPaths, commitCommandsFor, ownerAndName } from './chunk-IQWBUZ75.js';
4
+ import { resolveGatewayCredentials } from './chunk-N7PG5JAD.js';
5
+ import { findGitDirs } from './chunk-BJ3KTMDH.js';
6
+ import { execFileSync } from 'child_process';
7
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
8
+ import { join, dirname } from 'path';
9
+
10
+ createRequire(import.meta.url);
11
+ var SETUP_BRANCH = "outerlayer-setup";
12
+ var SETUP_MARKER = ".outerlayer/config.json";
13
+ var GIT_TIMEOUT_MS = 6e4;
14
+ var PR_TITLE = "Add OuterLayer setup";
15
+ var PR_BODY = "Adds the OuterLayer setup that `outerlayer setup` wrote: the policy in `.outerlayer/`, the agent instructions and skills, and the MCP server entries. Checks run on a pull request only once the policy is on the branch it targets.";
16
+ function run(command, args, cwd) {
17
+ try {
18
+ const stdout = execFileSync(command, args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: GIT_TIMEOUT_MS });
19
+ return { ok: true, stdout: stdout.trim(), stderr: "" };
20
+ } catch (err) {
21
+ const e = err;
22
+ return { ok: false, stdout: String(e.stdout ?? "").trim(), stderr: String(e.stderr ?? e.message ?? "").trim() };
23
+ }
24
+ }
25
+ var git = (cwd, args) => run("git", args, cwd);
26
+ var realGh = (args, cwd) => run("gh", args, cwd);
27
+ async function setupBaseBranch(cwd, home, repository, fetchImpl = fetch) {
28
+ const resolved = resolveGatewayCredentials({ cwd, home });
29
+ const linked = resolved.ok && repository !== void 0 ? await linkedBranches(fetchImpl, resolved.url, resolved.credential, resolved.appId, repository) : null;
30
+ return linked?.[0] ?? originDefaultBranch(cwd) ?? "main";
31
+ }
32
+ function originDefaultBranch(cwd) {
33
+ const ref = git(cwd, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]);
34
+ return ref.ok && ref.stdout.startsWith("origin/") ? ref.stdout.slice("origin/".length) : void 0;
35
+ }
36
+ function currentBranch(cwd) {
37
+ const ref = git(cwd, ["symbolic-ref", "--short", "-q", "HEAD"]);
38
+ return ref.ok && ref.stdout !== "" ? ref.stdout : void 0;
39
+ }
40
+ function setupMerged(cwd, base) {
41
+ if (!git(cwd, ["fetch", "--quiet", "origin", `refs/heads/${base}:refs/remotes/origin/${base}`]).ok) return null;
42
+ return git(cwd, ["cat-file", "-e", `refs/remotes/origin/${base}:${SETUP_MARKER}`]).ok;
43
+ }
44
+ function setupBranchPushed(cwd) {
45
+ const heads = git(cwd, ["ls-remote", "--heads", "origin", SETUP_BRANCH]);
46
+ return heads.ok && heads.stdout !== "";
47
+ }
48
+ function compareUrl(repository, base) {
49
+ if (repository === void 0 || !repository.toLowerCase().startsWith("github.com/")) return void 0;
50
+ return `https://github.com/${ownerAndName(repository)}/compare/${encodeURIComponent(base)}...${SETUP_BRANCH}?expand=1`;
51
+ }
52
+ function ghReady(gh, cwd) {
53
+ return gh(["auth", "status"], cwd).ok;
54
+ }
55
+ function setupPullRequestUrl(cwd, base, repository, gh = realGh) {
56
+ if (compareUrl(repository, base) !== void 0 && ghReady(gh, cwd)) {
57
+ const open = gh(["pr", "view", SETUP_BRANCH, "--json", "url", "--jq", ".url"], cwd);
58
+ if (open.ok && open.stdout.startsWith("https://")) return open.stdout;
59
+ }
60
+ return compareUrl(repository, base);
61
+ }
62
+ function openSetupPullRequest(cwd, base, repository, gh = realGh) {
63
+ const dirs = findGitDirs(cwd);
64
+ if (dirs === void 0) return { ok: false, message: "this directory is not in a git repository." };
65
+ const paths = setupCommitPaths(dirs.repoRoot);
66
+ if (paths.length === 0) return { ok: false, message: "there are no setup files to commit. Run `outerlayer setup` without --open-pr first." };
67
+ return pushSetupBranch({ root: dirs.repoRoot, paths, base, repository, commitCommands: commitCommandsFor(cwd) }, git, gh);
68
+ }
69
+ function pushSetupBranch(plan, runGit, gh) {
70
+ const { root, paths, base, repository } = plan;
71
+ const instead = (why) => ({
72
+ ok: false,
73
+ message: `${why} Commit the setup yourself instead, then open a pull request into ${base}:
74
+ ${plan.commitCommands}`
75
+ });
76
+ const head = runGit(root, ["symbolic-ref", "--short", "-q", "HEAD"]);
77
+ const branch = head.ok && head.stdout !== "" ? head.stdout : void 0;
78
+ if (branch !== SETUP_BRANCH) {
79
+ if (branch !== base) return instead(`this checkout is on ${branch ?? "a detached HEAD"}, not ${base}, so a branch from it could carry other work.`);
80
+ runGit(root, ["fetch", "--quiet", "origin", `refs/heads/${base}:refs/remotes/origin/${base}`]);
81
+ const ahead = runGit(root, ["rev-list", "--count", `refs/remotes/origin/${base}..HEAD`]);
82
+ if (!ahead.ok) return instead(`git could not compare ${base} with origin/${base}.`);
83
+ if (ahead.stdout !== "0") return instead(`${base} has ${ahead.stdout} commits that origin does not have, and the pull request would carry them.`);
84
+ if (runGit(root, ["rev-parse", "--verify", "--quiet", `refs/heads/${SETUP_BRANCH}`]).ok) {
85
+ return instead(`a branch named ${SETUP_BRANCH} already exists here.`);
86
+ }
87
+ const created2 = runGit(root, ["switch", "--quiet", "-c", SETUP_BRANCH]);
88
+ if (!created2.ok) return { ok: false, message: `could not create the ${SETUP_BRANCH} branch: ${created2.stderr}` };
89
+ }
90
+ const added = runGit(root, ["add", "--", ...paths]);
91
+ if (!added.ok) return { ok: false, message: `git add failed: ${added.stderr}` };
92
+ const staged = runGit(root, ["diff", "--cached", "--quiet", "--", ...paths]);
93
+ if (!staged.ok) {
94
+ const committed = runGit(root, ["commit", "--quiet", "-m", PR_TITLE, "--", ...paths]);
95
+ if (!committed.ok) return { ok: false, message: `git commit failed: ${committed.stderr || committed.stdout}` };
96
+ }
97
+ const pushed = runGit(root, ["push", "--quiet", "-u", "origin", SETUP_BRANCH]);
98
+ if (!pushed.ok) return { ok: false, message: `git push failed: ${pushed.stderr}` };
99
+ const page = compareUrl(repository, base);
100
+ if (page === void 0 || !ghReady(gh, root)) return { ok: true, url: page, opened: false };
101
+ const existing = gh(["pr", "view", SETUP_BRANCH, "--json", "url", "--jq", ".url"], root);
102
+ if (existing.ok && existing.stdout.startsWith("https://")) return { ok: true, url: existing.stdout, opened: true };
103
+ const created = gh(["pr", "create", "--base", base, "--head", SETUP_BRANCH, "--title", PR_TITLE, "--body", PR_BODY], root);
104
+ const url = created.stdout.split("\n").reverse().find((line) => line.startsWith("https://"));
105
+ return created.ok && url !== void 0 ? { ok: true, url, opened: true } : { ok: true, url: page, opened: false };
106
+ }
107
+ function installedPath(cwd) {
108
+ const dirs = findGitDirs(cwd);
109
+ return dirs === void 0 ? void 0 : join(dirs.gitCommonDir, "outerlayer", "setup.json");
110
+ }
111
+ function setupInstalled(cwd) {
112
+ const path = installedPath(cwd);
113
+ const dirs = findGitDirs(cwd);
114
+ return path !== void 0 && dirs !== void 0 && existsSync(path) && existsSync(join(dirs.repoRoot, SETUP_MARKER));
115
+ }
116
+ function markSetupInstalled(cwd, now) {
117
+ const path = installedPath(cwd);
118
+ if (path === void 0) return;
119
+ mkdirSync(dirname(path), { recursive: true });
120
+ writeFileSync(path, `${JSON.stringify({ installedAt: now.toISOString() })}
121
+ `);
122
+ }
123
+
124
+ export { SETUP_BRANCH, currentBranch, markSetupInstalled, openSetupPullRequest, setupBaseBranch, setupBranchPushed, setupInstalled, setupMerged, setupPullRequestUrl };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { uploadSpooledSteps } from './chunk-VQ57S72O.js';
3
+ import { uploadSpooledSteps } from './chunk-EGYZGB2P.js';
4
4
  import { LaunchFilter } from './chunk-C2PZOLN7.js';
5
5
  import { migrateLegacyArtifactSidecars, planArtifactUpload, artifactsStatePath, sanitizeTerminal, acquireArtifactSpoolLock, artifactBlobsDir, resolveArtifactTurnIndex, isArtifactTombstoned, ARTIFACT_RETRY_MAX_AGE_MS, writeArtifactSpoolState, reclaimUnneededArtifactBlobs, neededArtifactShas } from './chunk-DV44KCM6.js';
6
6
  import { C } from './chunk-2AM6Z5BP.js';
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';
3
3
  import { runEmit } from './chunk-BFZDVD7T.js';
4
4
  import { addStdioMcpEntryIfAbsent, addDocsMcpEntryIfAbsent, DOCS_MCP_SERVER_NAME } from './chunk-7PFRNOSF.js';
5
5
  import { installStarterPack } from './chunk-TQPFWWND.js';
6
- import { listWithAnd } from './chunk-IGVOCKAC.js';
6
+ import { listWithAnd } from './chunk-IQWBUZ75.js';
7
7
  import { AGENTS_MD_LAYOUT, mcpFiles, declareAgentsMdLayout, linkAgentSkills, describeSkillsLink, isAgentsMdLayout, holdsTodaysLayoutSources, discoverOuterlayerPaths } from './chunk-XDBHRWPQ.js';
8
8
  import { C } from './chunk-2AM6Z5BP.js';
9
9
  import { resolveGitCommonDir, defaultGitRunner } from './chunk-ISRMDI2H.js';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { escapeUnitPath, UNIT_MARKER, DEFAULT_UNIT_NAME } from './chunk-4L3WCEOI.js';
3
+ import { escapeUnitPath, UNIT_MARKER, DEFAULT_UNIT_NAME } from './chunk-RRRW2M4B.js';
4
4
  import { inspectService, realInspectProbes } from './chunk-XOJRFV3U.js';
5
5
  import { realpathSync, readFileSync, readdirSync } from 'fs';
6
6
  import { resolve, dirname, join } from 'path';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { newTokenRetry } from './chunk-FJGYU2EK.js';
4
- import { WorkCommandError, postJson } from './chunk-F7AOOV5N.js';
4
+ import { WorkCommandError, postJson } from './chunk-BAPRSDUR.js';
5
5
  import { defaultGitRunner, materializeContext, fetchControlPlaneCommit, lookupGoverningSource } from './chunk-ISRMDI2H.js';
6
6
  import { buildRefusalReason } from './chunk-ZCOIE7ZJ.js';
7
7
  import { unsupportedLayout, layoutRefusalReason, composeDelivery } from './chunk-IIYDYHS5.js';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { resolveCredentials, postBytes, RateLimitedError, postJson, getJson, getBytes } from './chunk-F7AOOV5N.js';
3
+ import { resolveCredentials, postBytes, RateLimitedError, postJson, getJson, getBytes } from './chunk-BAPRSDUR.js';
4
4
  import { detectActiveSession } from './chunk-IKGAVS5X.js';
5
5
  import { sanitizeTerminal } from './chunk-DV44KCM6.js';
6
6
  import { C } from './chunk-2AM6Z5BP.js';