oh-my-copilot 5.19.2 → 5.19.4
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +70 -67
- package/agents/planner.md +4 -4
- package/bin/oh-my-copilot.js +5 -1
- package/bridge/claude-md-coordinator.cjs +2 -2
- package/bridge/cli.cjs +3043 -2635
- package/bridge/mcp-server.cjs +969 -867
- package/bridge/runtime-cli.cjs +244 -184
- package/bridge/team-bridge.cjs +17 -1
- package/bridge/team-mcp.cjs +208 -140
- package/bridge/team.js +73 -13
- package/copilot/agents/planner.md +4 -4
- package/dist/__tests__/ci-evidence.test.d.ts +2 -0
- package/dist/__tests__/ci-evidence.test.d.ts.map +1 -0
- package/dist/__tests__/ci-evidence.test.js +210 -0
- package/dist/__tests__/ci-evidence.test.js.map +1 -0
- package/dist/__tests__/copilot-hooks-manifest.test.js +1 -0
- package/dist/__tests__/copilot-hooks-manifest.test.js.map +1 -1
- package/dist/__tests__/doctor-conflicts.test.js +6 -5
- package/dist/__tests__/doctor-conflicts.test.js.map +1 -1
- package/dist/__tests__/hud/cli-diagnostic.test.js +4 -3
- package/dist/__tests__/hud/cli-diagnostic.test.js.map +1 -1
- package/dist/__tests__/mnemosyne/detector.test.js +3 -2
- package/dist/__tests__/mnemosyne/detector.test.js.map +1 -1
- package/dist/__tests__/run-cjs-windows-stdio-contract.test.js +50 -10
- package/dist/__tests__/run-cjs-windows-stdio-contract.test.js.map +1 -1
- package/dist/__tests__/session-end-process-exit.test.js +15 -5
- package/dist/__tests__/session-end-process-exit.test.js.map +1 -1
- package/dist/__tests__/session-start-script-context.test.js +1 -1
- package/dist/__tests__/session-start-script-context.test.js.map +1 -1
- package/dist/__tests__/setup/stub-skill-list-probe.d.ts +2 -0
- package/dist/__tests__/setup/stub-skill-list-probe.d.ts.map +1 -0
- package/dist/__tests__/setup/stub-skill-list-probe.js +11 -0
- package/dist/__tests__/setup/stub-skill-list-probe.js.map +1 -0
- package/dist/__tests__/setup-claude-md-script.test.js +7 -4
- package/dist/__tests__/setup-claude-md-script.test.js.map +1 -1
- package/dist/__tests__/setup-config-script.test.d.ts +2 -0
- package/dist/__tests__/setup-config-script.test.d.ts.map +1 -0
- package/dist/__tests__/setup-config-script.test.js +350 -0
- package/dist/__tests__/setup-config-script.test.js.map +1 -0
- package/dist/__tests__/shipyard-seed-locale.test.js +1 -1
- package/dist/__tests__/shipyard-seed-locale.test.js.map +1 -1
- package/dist/__tests__/shipyard-skills.test.js +9 -9
- package/dist/__tests__/shipyard-skills.test.js.map +1 -1
- package/dist/__tests__/tier0-docs-consistency.test.js +5 -5
- package/dist/__tests__/tier0-docs-consistency.test.js.map +1 -1
- package/dist/__tests__/trusted-publishing-contract.test.js +56 -7
- package/dist/__tests__/trusted-publishing-contract.test.js.map +1 -1
- package/dist/__tests__/visual-verdict-skill.test.js +1 -1
- package/dist/__tests__/visual-verdict-skill.test.js.map +1 -1
- package/dist/cli/__tests__/autoresearch.test.js +3 -2
- package/dist/cli/__tests__/autoresearch.test.js.map +1 -1
- package/dist/cli/autoresearch.d.ts +1 -1
- package/dist/cli/autoresearch.d.ts.map +1 -1
- package/dist/cli/autoresearch.js +2 -1
- package/dist/cli/autoresearch.js.map +1 -1
- package/dist/cli/commands/__tests__/factory-init.test.js +2 -1
- package/dist/cli/commands/__tests__/factory-init.test.js.map +1 -1
- package/dist/cli/commands/__tests__/intake.test.js +26 -4
- package/dist/cli/commands/__tests__/intake.test.js.map +1 -1
- package/dist/cli/commands/doctor-conflicts.d.ts.map +1 -1
- package/dist/cli/commands/doctor-conflicts.js +5 -4
- package/dist/cli/commands/doctor-conflicts.js.map +1 -1
- package/dist/cli/commands/factory.d.ts.map +1 -1
- package/dist/cli/commands/factory.js +4 -3
- package/dist/cli/commands/factory.js.map +1 -1
- package/dist/cli/commands/intake.d.ts.map +1 -1
- package/dist/cli/commands/intake.js +13 -4
- package/dist/cli/commands/intake.js.map +1 -1
- package/dist/cli/commands/release.d.ts.map +1 -1
- package/dist/cli/commands/release.js +11 -2
- package/dist/cli/commands/release.js.map +1 -1
- package/dist/cli/commands/ship.d.ts +1 -1
- package/dist/cli/commands/ship.js +1 -1
- package/dist/copilot-run/job.d.ts.map +1 -1
- package/dist/copilot-run/job.js +4 -1
- package/dist/copilot-run/job.js.map +1 -1
- package/dist/copilot-run/sandbox.d.ts +2 -7
- package/dist/copilot-run/sandbox.d.ts.map +1 -1
- package/dist/copilot-run/sandbox.js +2 -26
- package/dist/copilot-run/sandbox.js.map +1 -1
- package/dist/factory/__tests__/listener.test.js +22 -4
- package/dist/factory/__tests__/listener.test.js.map +1 -1
- package/dist/factory/listener.d.ts +2 -2
- package/dist/factory/listener.d.ts.map +1 -1
- package/dist/factory/listener.js +20 -5
- package/dist/factory/listener.js.map +1 -1
- package/dist/factory/run/__tests__/prepare-gates.test.js +7 -1
- package/dist/factory/run/__tests__/prepare-gates.test.js.map +1 -1
- package/dist/factory/run/engine.d.ts.map +1 -1
- package/dist/factory/run/engine.js +1 -0
- package/dist/factory/run/engine.js.map +1 -1
- package/dist/features/continuation-enforcement.d.ts.map +1 -1
- package/dist/features/continuation-enforcement.js +2 -1
- package/dist/features/continuation-enforcement.js.map +1 -1
- package/dist/features/lookout/__tests__/lookout.test.js +9 -6
- package/dist/features/lookout/__tests__/lookout.test.js.map +1 -1
- package/dist/forge/__tests__/gh-argv-baseline.factory.test.js +7 -1
- package/dist/forge/__tests__/gh-argv-baseline.factory.test.js.map +1 -1
- package/dist/hooks/__tests__/bridge.test.js +10 -2
- package/dist/hooks/__tests__/bridge.test.js.map +1 -1
- package/dist/hooks/autopilot/__tests__/pipeline.test.js +2 -1
- package/dist/hooks/autopilot/__tests__/pipeline.test.js.map +1 -1
- package/dist/hooks/autopilot/adapters/execution-adapter.d.ts.map +1 -1
- package/dist/hooks/autopilot/adapters/execution-adapter.js +3 -2
- package/dist/hooks/autopilot/adapters/execution-adapter.js.map +1 -1
- package/dist/hooks/autopilot/adapters/ralplan-adapter.d.ts.map +1 -1
- package/dist/hooks/autopilot/adapters/ralplan-adapter.js +2 -1
- package/dist/hooks/autopilot/adapters/ralplan-adapter.js.map +1 -1
- package/dist/hooks/learner/detector.d.ts.map +1 -1
- package/dist/hooks/learner/detector.js +2 -6
- package/dist/hooks/learner/detector.js.map +1 -1
- package/dist/hooks/mode-registry/index.d.ts.map +1 -1
- package/dist/hooks/mode-registry/index.js +2 -1
- package/dist/hooks/mode-registry/index.js.map +1 -1
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.js +7 -0
- package/dist/hooks/persistent-mode/__tests__/team-ralplan-stop.test.js.map +1 -1
- package/dist/hooks/persistent-mode/index.d.ts +1 -1
- package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
- package/dist/hooks/persistent-mode/index.js +6 -5
- package/dist/hooks/persistent-mode/index.js.map +1 -1
- package/dist/hooks/persistent-mode/session-isolation.test.js +23 -14
- package/dist/hooks/persistent-mode/session-isolation.test.js.map +1 -1
- package/dist/hooks/ralph/loop.d.ts +1 -1
- package/dist/hooks/ralph/loop.js +1 -1
- package/dist/hooks/ralph/prd.d.ts.map +1 -1
- package/dist/hooks/ralph/prd.js +2 -1
- package/dist/hooks/ralph/prd.js.map +1 -1
- package/dist/hooks/ralph/stale-prd.d.ts +2 -2
- package/dist/hooks/ralph/stale-prd.js +3 -3
- package/dist/hooks/ralph/stale-prd.js.map +1 -1
- package/dist/hooks/ralph/verifier.d.ts +1 -1
- package/dist/hooks/ralph/verifier.d.ts.map +1 -1
- package/dist/hooks/ralph/verifier.js +4 -3
- package/dist/hooks/ralph/verifier.js.map +1 -1
- package/dist/hooks/session-end/__tests__/spawn-next.test.js +31 -4
- package/dist/hooks/session-end/__tests__/spawn-next.test.js.map +1 -1
- package/dist/hooks/session-end/spawn-next.d.ts +6 -3
- package/dist/hooks/session-end/spawn-next.d.ts.map +1 -1
- package/dist/hooks/session-end/spawn-next.js +19 -6
- package/dist/hooks/session-end/spawn-next.js.map +1 -1
- package/dist/hud/index.d.ts.map +1 -1
- package/dist/hud/index.js +3 -2
- package/dist/hud/index.js.map +1 -1
- package/dist/installer/__tests__/hook-templates.test.js +3 -1
- package/dist/installer/__tests__/hook-templates.test.js.map +1 -1
- package/dist/installer/__tests__/session-start-template.test.js +16 -8
- package/dist/installer/__tests__/session-start-template.test.js.map +1 -1
- package/dist/installer/hooks.d.ts +1 -1
- package/dist/installer/hooks.d.ts.map +1 -1
- package/dist/installer/hooks.js +2 -1
- package/dist/installer/hooks.js.map +1 -1
- package/dist/release/__tests__/checks.test.js +39 -1
- package/dist/release/__tests__/checks.test.js.map +1 -1
- package/dist/release/__tests__/engine.test.js +236 -3
- package/dist/release/__tests__/engine.test.js.map +1 -1
- package/dist/release/checks.d.ts +18 -1
- package/dist/release/checks.d.ts.map +1 -1
- package/dist/release/checks.js +40 -1
- package/dist/release/checks.js.map +1 -1
- package/dist/release/engine.d.ts +14 -2
- package/dist/release/engine.d.ts.map +1 -1
- package/dist/release/engine.js +211 -44
- package/dist/release/engine.js.map +1 -1
- package/dist/ship/__tests__/exec-env.test.d.ts +2 -0
- package/dist/ship/__tests__/exec-env.test.d.ts.map +1 -0
- package/dist/ship/__tests__/exec-env.test.js +26 -0
- package/dist/ship/__tests__/exec-env.test.js.map +1 -0
- package/dist/ship/__tests__/exec-plant.test.d.ts +2 -0
- package/dist/ship/__tests__/exec-plant.test.d.ts.map +1 -0
- package/dist/ship/__tests__/exec-plant.test.js +34 -0
- package/dist/ship/__tests__/exec-plant.test.js.map +1 -0
- package/dist/ship/__tests__/gates.test.js +35 -0
- package/dist/ship/__tests__/gates.test.js.map +1 -1
- package/dist/ship/__tests__/workflow-checks.test.js +34 -5
- package/dist/ship/__tests__/workflow-checks.test.js.map +1 -1
- package/dist/ship/config.js +3 -3
- package/dist/ship/config.js.map +1 -1
- package/dist/ship/exec.d.ts.map +1 -1
- package/dist/ship/exec.js +10 -2
- package/dist/ship/exec.js.map +1 -1
- package/dist/ship/gates.d.ts.map +1 -1
- package/dist/ship/gates.js +3 -1
- package/dist/ship/gates.js.map +1 -1
- package/dist/skills/__tests__/mingw-escape.test.js +0 -35
- package/dist/skills/__tests__/mingw-escape.test.js.map +1 -1
- package/dist/skills/__tests__/omc-setup-optout.test.js +4 -3
- package/dist/skills/__tests__/omc-setup-optout.test.js.map +1 -1
- package/dist/smoke/__tests__/copilot-factory-run-scenario.test.js +7 -1
- package/dist/smoke/__tests__/copilot-factory-run-scenario.test.js.map +1 -1
- package/dist/smoke/__tests__/copilot-sdk-driver.test.js +2 -2
- package/dist/smoke/__tests__/copilot-sdk-driver.test.js.map +1 -1
- package/dist/smoke/copilot-sdk-scenarios.d.ts.map +1 -1
- package/dist/smoke/copilot-sdk-scenarios.js +2 -1
- package/dist/smoke/copilot-sdk-scenarios.js.map +1 -1
- package/dist/team/__tests__/git-worktree.test.js +10 -1
- package/dist/team/__tests__/git-worktree.test.js.map +1 -1
- package/dist/team/__tests__/runtime-cli.test.js +4 -4
- package/dist/team/__tests__/runtime-cli.test.js.map +1 -1
- package/dist/team/__tests__/tmux-session.test.js +16 -2
- package/dist/team/__tests__/tmux-session.test.js.map +1 -1
- package/dist/team/__tests__/worker-launch-ack.test.js +14 -0
- package/dist/team/__tests__/worker-launch-ack.test.js.map +1 -1
- package/dist/team/git-worktree.d.ts.map +1 -1
- package/dist/team/git-worktree.js +13 -5
- package/dist/team/git-worktree.js.map +1 -1
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +8 -6
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/ultragoal/goal-record.d.ts.map +1 -1
- package/dist/ultragoal/goal-record.js +2 -1
- package/dist/ultragoal/goal-record.js.map +1 -1
- package/dist/utils/__tests__/skill-slash.test.d.ts +2 -0
- package/dist/utils/__tests__/skill-slash.test.d.ts.map +1 -0
- package/dist/utils/__tests__/skill-slash.test.js +307 -0
- package/dist/utils/__tests__/skill-slash.test.js.map +1 -0
- package/dist/utils/__tests__/windows-search.test.d.ts +2 -0
- package/dist/utils/__tests__/windows-search.test.d.ts.map +1 -0
- package/dist/utils/__tests__/windows-search.test.js +154 -0
- package/dist/utils/__tests__/windows-search.test.js.map +1 -0
- package/dist/utils/skill-registry.d.ts +51 -0
- package/dist/utils/skill-registry.d.ts.map +1 -0
- package/dist/utils/skill-registry.js +168 -0
- package/dist/utils/skill-registry.js.map +1 -0
- package/dist/utils/skill-slash.d.ts +18 -0
- package/dist/utils/skill-slash.d.ts.map +1 -0
- package/dist/utils/skill-slash.js +20 -0
- package/dist/utils/skill-slash.js.map +1 -0
- package/dist/utils/windows-search.d.ts +42 -0
- package/dist/utils/windows-search.d.ts.map +1 -0
- package/dist/utils/windows-search.js +94 -0
- package/dist/utils/windows-search.js.map +1 -0
- package/docs/ARCHITECTURE.md +29 -29
- package/docs/CLAUDE.md +4 -4
- package/docs/FIELD-TESTING.md +563 -0
- package/docs/GETTING-STARTED.md +11 -11
- package/docs/HOOKS.md +8 -8
- package/docs/MIGRATION.md +100 -100
- package/docs/PERFORMANCE-MONITORING.md +2 -2
- package/docs/REFERENCE.md +131 -131
- package/docs/TOOLS.md +1 -1
- package/docs/cancel-skill-active-state-gap.md +2 -2
- package/docs/copilot-instructions.md +3 -3
- package/docs/design/P2-RUN-LEDGER-AND-INTAKE-PLAN.md +1 -1
- package/docs/design/project-session-manager.md +1 -1
- package/docs/field-testing-first-prompt.md +36 -0
- package/docs/shared/features.md +5 -5
- package/docs/shipyard.md +8 -8
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/scripts/build-workflow-stage-prompts.mjs +15 -6
- package/scripts/ci/duration-sequencer.mjs +69 -0
- package/scripts/ci/durations-reporter.mjs +34 -0
- package/scripts/ci/tree-reuse.mjs +166 -0
- package/scripts/ci/update-test-durations.mjs +62 -0
- package/scripts/copilot/dispatch.cjs +3 -0
- package/scripts/find-node.sh +1 -1
- package/scripts/keyword-detector.mjs +5 -4
- package/scripts/lib/copilot-hook-adapter.cjs +3 -0
- package/scripts/lib/hud-wrapper-template.txt +2 -2
- package/scripts/lib/skill-slash.mjs +11 -0
- package/scripts/lib/windows-search.cjs +40 -0
- package/scripts/lib/windows-search.mjs +7 -0
- package/scripts/lib/workflow-stage-prompts.mjs +6 -2
- package/scripts/persistent-mode.cjs +11 -10
- package/scripts/persistent-mode.mjs +16 -11
- package/scripts/plugin-shipping-surface.mjs +1 -0
- package/scripts/pre-tool-enforcer.mjs +1 -1
- package/scripts/session-start.mjs +3 -3
- package/scripts/setup-claude-md.mjs +3 -0
- package/scripts/setup-config.mjs +420 -0
- package/scripts/setup-progress.mjs +3 -0
- package/scripts/shipyard-audit.mjs +2 -1
- package/scripts/stale-run-reporter.mjs +2 -1
- package/skills/AGENTS.md +4 -4
- package/skills/ai-slop-cleaner/SKILL.md +3 -3
- package/skills/ask/SKILL.md +7 -7
- package/skills/ask-navigator/SKILL.md +11 -11
- package/skills/autopilot/SKILL.md +5 -5
- package/skills/cancel/SKILL.md +5 -5
- package/skills/configure-notifications/SKILL.md +10 -10
- package/skills/critique/SKILL.md +1 -1
- package/skills/discover/SKILL.md +1 -1
- package/skills/drydock/SKILL.md +5 -5
- package/skills/external-context/SKILL.md +4 -4
- package/skills/graph/SKILL.md +2 -2
- package/skills/harbor/SKILL.md +7 -7
- package/skills/hud/SKILL.md +10 -10
- package/skills/intent/SKILL.md +1 -1
- package/skills/launch/SKILL.md +13 -13
- package/skills/loft/SKILL.md +2 -2
- package/skills/map/SKILL.md +1 -1
- package/skills/omc-ado-auto-review/SKILL.md +2 -2
- package/skills/omc-ado-review/SKILL.md +2 -2
- package/skills/omc-ado-setup/SKILL.md +1 -1
- package/skills/omc-ado-sprint/SKILL.md +2 -2
- package/skills/omc-ado-triage/SKILL.md +2 -2
- package/skills/omc-doctor/SKILL.md +1 -1
- package/skills/omc-gh-auto-review/SKILL.md +2 -2
- package/skills/omc-gh-project/SKILL.md +2 -2
- package/skills/omc-gh-review/SKILL.md +2 -2
- package/skills/omc-gh-setup/SKILL.md +2 -2
- package/skills/omc-gh-triage/SKILL.md +3 -3
- package/skills/omc-setup/SKILL.md +16 -14
- package/skills/omc-setup/phases/01-install-claude-md.md +1 -18
- package/skills/omc-setup/phases/02-configure.md +10 -30
- package/skills/omc-setup/phases/03-integrations.md +5 -5
- package/skills/omc-setup/phases/04-welcome.md +7 -7
- package/skills/plan/SKILL.md +1 -1
- package/skills/project-session-manager/SKILL.md +1 -1
- package/skills/ralph/SKILL.md +6 -6
- package/skills/ralph-experiment/SKILL.md +3 -3
- package/skills/ralplan/SKILL.md +4 -4
- package/skills/release/SKILL.md +1 -1
- package/skills/self-improve/SKILL.md +1 -1
- package/skills/skill/SKILL.md +12 -12
- package/skills/team/SKILL.md +8 -8
- package/skills/trace/SKILL.md +1 -1
- package/skills/visual-verdict/SKILL.md +1 -1
- package/templates/hooks/keyword-detector.mjs +4 -4
- package/templates/hooks/lib/workflow-stage-prompts.mjs +6 -2
- package/templates/hooks/persistent-mode.mjs +12 -8
- package/templates/hooks/session-start.mjs +1 -1
- package/bridge/__pycache__/gyoshu_bridge.cpython-314.pyc +0 -0
package/bridge/runtime-cli.cjs
CHANGED
|
@@ -8462,6 +8462,19 @@ var init_copilot_session_eval = __esm({
|
|
|
8462
8462
|
}
|
|
8463
8463
|
});
|
|
8464
8464
|
|
|
8465
|
+
// src/utils/skill-slash.ts
|
|
8466
|
+
function skillSlash(name, host = detectHostCliType()) {
|
|
8467
|
+
return host === "copilot" ? `/${name}` : `/${SKILL_NAMESPACE}:${name}`;
|
|
8468
|
+
}
|
|
8469
|
+
var SKILL_NAMESPACE;
|
|
8470
|
+
var init_skill_slash = __esm({
|
|
8471
|
+
"src/utils/skill-slash.ts"() {
|
|
8472
|
+
"use strict";
|
|
8473
|
+
init_host_signal();
|
|
8474
|
+
SKILL_NAMESPACE = "oh-my-copilot";
|
|
8475
|
+
}
|
|
8476
|
+
});
|
|
8477
|
+
|
|
8465
8478
|
// src/smoke/copilot-sdk-scenarios.ts
|
|
8466
8479
|
function samePathKey(p, platform) {
|
|
8467
8480
|
let out = (0, import_path27.resolve)(p);
|
|
@@ -8511,6 +8524,7 @@ var init_copilot_sdk_scenarios = __esm({
|
|
|
8511
8524
|
import_path27 = require("path");
|
|
8512
8525
|
init_ledger();
|
|
8513
8526
|
init_copilot_session_eval();
|
|
8527
|
+
init_skill_slash();
|
|
8514
8528
|
FACTORY_RUN_SCENARIOS = ["factory-run", "factory-run-fix"];
|
|
8515
8529
|
SANDBOX_LANE_SCENARIO = "sandbox-lane";
|
|
8516
8530
|
CLI_SCENARIOS = ["continuation", "prompt-context", "events", "ultragoal"];
|
|
@@ -8569,7 +8583,7 @@ var init_copilot_sdk_scenarios = __esm({
|
|
|
8569
8583
|
},
|
|
8570
8584
|
skill: {
|
|
8571
8585
|
name: "skill",
|
|
8572
|
-
prompt:
|
|
8586
|
+
prompt: `Use the ${skillSlash("omc-plan", "copilot")} skill to outline a two-step plan for adding a README. Keep it under 5 lines.`,
|
|
8573
8587
|
excludedTools: [...NO_SHELL_OR_WRITE_TOOLS],
|
|
8574
8588
|
permit: permitScopedRead
|
|
8575
8589
|
// loading SKILL.md is a read request
|
|
@@ -12420,11 +12434,11 @@ function buildWorkerStartCommand(config) {
|
|
|
12420
12434
|
windowsEnvVars.OMC_RECOVERY_GATE_SPEC_B64 = Buffer.from(windowsEnvVars.OMC_RECOVERY_GATE_SPEC, "utf8").toString("base64");
|
|
12421
12435
|
delete windowsEnvVars.OMC_RECOVERY_GATE_SPEC;
|
|
12422
12436
|
}
|
|
12423
|
-
const envPrefix = Object.entries(windowsEnvVars).map(([key, value]) => {
|
|
12437
|
+
const envPrefix = ['set "NoDefaultCurrentDirectoryInExePath=1"', ...Object.entries(windowsEnvVars).filter(([key]) => key.toUpperCase() !== "NODEFAULTCURRENTDIRECTORYINEXEPATH").map(([key, value]) => {
|
|
12424
12438
|
assertSafeEnvKey(key);
|
|
12425
12439
|
assertSafeCmdValue2(value);
|
|
12426
12440
|
return `set "${key}=${escapeForCmdSet(value)}"`;
|
|
12427
|
-
}).join(" && ");
|
|
12441
|
+
})].join(" && ");
|
|
12428
12442
|
const launch = launchWords.map((part) => {
|
|
12429
12443
|
assertSafeCmdValue2(part);
|
|
12430
12444
|
return `"${escapeForCmdSet(part)}"`;
|
|
@@ -16295,12 +16309,50 @@ var init_mcp_comm = __esm({
|
|
|
16295
16309
|
}
|
|
16296
16310
|
});
|
|
16297
16311
|
|
|
16312
|
+
// src/utils/windows-search.ts
|
|
16313
|
+
function envValue(env, name) {
|
|
16314
|
+
const key = Object.keys(env).find((k) => k.toUpperCase() === name);
|
|
16315
|
+
const value = key === void 0 ? void 0 : env[key];
|
|
16316
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
16317
|
+
}
|
|
16318
|
+
function findOnPath(name, env, platform, exists = isFile) {
|
|
16319
|
+
const P = platform === "win32" ? import_node_path8.win32 : import_node_path8.posix;
|
|
16320
|
+
const exts = platform === "win32" ? (envValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
|
|
16321
|
+
const inNodeModules = platform === "win32" ? /(^|[\\/])node_modules([\\/]|$)/i : /(^|\/)node_modules(\/|$)/;
|
|
16322
|
+
for (const raw of (envValue(env, "PATH") ?? "").split(P.delimiter)) {
|
|
16323
|
+
const dir = raw.trim().replace(/^"(.*)"$/, "$1");
|
|
16324
|
+
if (!dir || !P.isAbsolute(dir) || inNodeModules.test(dir)) continue;
|
|
16325
|
+
for (const ext of exts) if (exists(P.join(dir, name + ext))) return P.join(dir, name + ext);
|
|
16326
|
+
}
|
|
16327
|
+
return null;
|
|
16328
|
+
}
|
|
16329
|
+
function resolveBareExe(cmd, env = process.env) {
|
|
16330
|
+
if (process.platform !== "win32" || /[\\/:]/.test(cmd)) return cmd;
|
|
16331
|
+
const pathext = (envValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((e) => e && !/^\.(cmd|bat)$/i.test(e)).join(";") || ".COM;.EXE";
|
|
16332
|
+
return findOnPath(cmd, { ...env, PATHEXT: pathext }, "win32");
|
|
16333
|
+
}
|
|
16334
|
+
var import_node_fs7, import_node_path8, isFile;
|
|
16335
|
+
var init_windows_search = __esm({
|
|
16336
|
+
"src/utils/windows-search.ts"() {
|
|
16337
|
+
"use strict";
|
|
16338
|
+
import_node_fs7 = require("node:fs");
|
|
16339
|
+
import_node_path8 = require("node:path");
|
|
16340
|
+
isFile = (p) => {
|
|
16341
|
+
try {
|
|
16342
|
+
return (0, import_node_fs7.statSync)(p).isFile();
|
|
16343
|
+
} catch {
|
|
16344
|
+
return false;
|
|
16345
|
+
}
|
|
16346
|
+
};
|
|
16347
|
+
}
|
|
16348
|
+
});
|
|
16349
|
+
|
|
16298
16350
|
// src/lib/worktree-cleanup-safety.ts
|
|
16299
16351
|
function realpathOrResolve(path5) {
|
|
16300
16352
|
try {
|
|
16301
|
-
return (0,
|
|
16353
|
+
return (0, import_node_fs8.realpathSync)(path5);
|
|
16302
16354
|
} catch {
|
|
16303
|
-
return (0,
|
|
16355
|
+
return (0, import_node_path9.resolve)(path5);
|
|
16304
16356
|
}
|
|
16305
16357
|
}
|
|
16306
16358
|
function assertSafeBoundary(path5, label) {
|
|
@@ -16312,7 +16364,7 @@ function assertSafeBoundary(path5, label) {
|
|
|
16312
16364
|
throw new Error(`${label}_contains_nul`);
|
|
16313
16365
|
}
|
|
16314
16366
|
const resolved = realpathOrResolve(trimmed);
|
|
16315
|
-
const root = (0,
|
|
16367
|
+
const root = (0, import_node_path9.parse)(resolved).root;
|
|
16316
16368
|
const home = realpathOrResolve((0, import_node_os2.homedir)());
|
|
16317
16369
|
if (resolved === root) {
|
|
16318
16370
|
throw new Error(`${label}_is_filesystem_root:${resolved}`);
|
|
@@ -16323,8 +16375,8 @@ function assertSafeBoundary(path5, label) {
|
|
|
16323
16375
|
return resolved;
|
|
16324
16376
|
}
|
|
16325
16377
|
function isInside(parent, child) {
|
|
16326
|
-
const rel = (0,
|
|
16327
|
-
return rel.length > 0 && !rel.startsWith("..") && !(0,
|
|
16378
|
+
const rel = (0, import_node_path9.relative)(parent, child);
|
|
16379
|
+
return rel.length > 0 && !rel.startsWith("..") && !(0, import_node_path9.isAbsolute)(rel);
|
|
16328
16380
|
}
|
|
16329
16381
|
function validateWorktreeRemovalTarget(options) {
|
|
16330
16382
|
const { candidatePath, expectedRoots, mainRepoRoots = [], requireExisting = true } = options;
|
|
@@ -16341,13 +16393,13 @@ function validateWorktreeRemovalTarget(options) {
|
|
|
16341
16393
|
if (rawCandidate === "." || rawCandidate === ".." || rawCandidate === "~") {
|
|
16342
16394
|
throw new Error(`worktree_path_suspicious:${rawCandidate}`);
|
|
16343
16395
|
}
|
|
16344
|
-
const lexicalPath = (0,
|
|
16345
|
-
if (!(0,
|
|
16396
|
+
const lexicalPath = (0, import_node_path9.resolve)(rawCandidate);
|
|
16397
|
+
if (!(0, import_node_fs8.existsSync)(lexicalPath)) {
|
|
16346
16398
|
if (requireExisting) {
|
|
16347
16399
|
throw new Error(`worktree_path_missing:${lexicalPath}`);
|
|
16348
16400
|
}
|
|
16349
16401
|
} else {
|
|
16350
|
-
const stat2 = (0,
|
|
16402
|
+
const stat2 = (0, import_node_fs8.lstatSync)(lexicalPath);
|
|
16351
16403
|
if (stat2.isSymbolicLink()) {
|
|
16352
16404
|
throw new Error(`worktree_path_is_symlink:${lexicalPath}`);
|
|
16353
16405
|
}
|
|
@@ -16367,37 +16419,37 @@ function validateWorktreeRemovalTarget(options) {
|
|
|
16367
16419
|
throw new Error(`worktree_path_is_main_repo:${resolvedPath}`);
|
|
16368
16420
|
}
|
|
16369
16421
|
}
|
|
16370
|
-
if ((0,
|
|
16371
|
-
const gitStat = (0,
|
|
16422
|
+
if ((0, import_node_fs8.existsSync)((0, import_node_path9.join)(resolvedPath, ".git"))) {
|
|
16423
|
+
const gitStat = (0, import_node_fs8.lstatSync)((0, import_node_path9.join)(resolvedPath, ".git"));
|
|
16372
16424
|
if (gitStat.isDirectory()) {
|
|
16373
16425
|
throw new Error(`worktree_path_is_main_repo:${resolvedPath}`);
|
|
16374
16426
|
}
|
|
16375
16427
|
}
|
|
16376
16428
|
return { resolvedPath, matchedRoot };
|
|
16377
16429
|
}
|
|
16378
|
-
var
|
|
16430
|
+
var import_node_fs8, import_node_os2, import_node_path9;
|
|
16379
16431
|
var init_worktree_cleanup_safety = __esm({
|
|
16380
16432
|
"src/lib/worktree-cleanup-safety.ts"() {
|
|
16381
16433
|
"use strict";
|
|
16382
|
-
|
|
16434
|
+
import_node_fs8 = require("node:fs");
|
|
16383
16435
|
import_node_os2 = require("node:os");
|
|
16384
|
-
|
|
16436
|
+
import_node_path9 = require("node:path");
|
|
16385
16437
|
}
|
|
16386
16438
|
});
|
|
16387
16439
|
|
|
16388
16440
|
// src/team/git-worktree.ts
|
|
16389
16441
|
function getWorktreePath(repoRoot, teamName, workerName) {
|
|
16390
|
-
return (0,
|
|
16442
|
+
return (0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees", sanitizeName(workerName));
|
|
16391
16443
|
}
|
|
16392
16444
|
function getBranchName(teamName, workerName) {
|
|
16393
16445
|
return `omc-team/${sanitizeName(teamName)}/${sanitizeName(workerName)}`;
|
|
16394
16446
|
}
|
|
16395
16447
|
function hostHooksDir() {
|
|
16396
16448
|
try {
|
|
16397
|
-
if (emptyHooksDir && (0,
|
|
16449
|
+
if (emptyHooksDir && (0, import_node_fs9.readdirSync)(emptyHooksDir).length === 0) return emptyHooksDir;
|
|
16398
16450
|
} catch {
|
|
16399
16451
|
}
|
|
16400
|
-
emptyHooksDir = (0,
|
|
16452
|
+
emptyHooksDir = (0, import_node_fs9.mkdtempSync)((0, import_node_path10.join)((0, import_node_os3.tmpdir)(), "omg-host-git-nohooks-"));
|
|
16401
16453
|
return emptyHooksDir;
|
|
16402
16454
|
}
|
|
16403
16455
|
function hostGitHardeningArgs() {
|
|
@@ -16409,11 +16461,11 @@ function hostGitHardeningArgs() {
|
|
|
16409
16461
|
}
|
|
16410
16462
|
function hostAttributesFile() {
|
|
16411
16463
|
try {
|
|
16412
|
-
if (emptyAttributesFile && (0,
|
|
16464
|
+
if (emptyAttributesFile && (0, import_node_fs9.readFileSync)(emptyAttributesFile, "utf-8") === "") return emptyAttributesFile;
|
|
16413
16465
|
} catch {
|
|
16414
16466
|
}
|
|
16415
|
-
emptyAttributesFile = (0,
|
|
16416
|
-
(0,
|
|
16467
|
+
emptyAttributesFile = (0, import_node_path10.join)((0, import_node_fs9.mkdtempSync)((0, import_node_path10.join)((0, import_node_os3.tmpdir)(), "omg-host-git-noattrs-")), "attributes");
|
|
16468
|
+
(0, import_node_fs9.writeFileSync)(emptyAttributesFile, "");
|
|
16417
16469
|
return emptyAttributesFile;
|
|
16418
16470
|
}
|
|
16419
16471
|
function gitSubcommandIndex(args) {
|
|
@@ -16430,16 +16482,16 @@ function hostGitEnv(args, base = process.env) {
|
|
|
16430
16482
|
};
|
|
16431
16483
|
const gitDir = valueOf("--git-dir");
|
|
16432
16484
|
if (!gitDir) return { ...base, GIT_LFS_SKIP_SMUDGE: "1" };
|
|
16433
|
-
const env = { ...base, GIT_DIR: (0,
|
|
16485
|
+
const env = { ...base, GIT_DIR: (0, import_node_path10.resolve)(gitDir), GIT_LFS_SKIP_SMUDGE: "1" };
|
|
16434
16486
|
const workTree = valueOf("--work-tree");
|
|
16435
|
-
if (workTree) env.GIT_WORK_TREE = (0,
|
|
16436
|
-
if ((0,
|
|
16487
|
+
if (workTree) env.GIT_WORK_TREE = (0, import_node_path10.resolve)(workTree);
|
|
16488
|
+
if ((0, import_node_path10.basename)((0, import_node_path10.dirname)((0, import_node_path10.resolve)(gitDir))) === "worktrees") env.GIT_COMMON_DIR = (0, import_node_path10.dirname)((0, import_node_path10.dirname)((0, import_node_path10.resolve)(gitDir)));
|
|
16437
16489
|
return env;
|
|
16438
16490
|
}
|
|
16439
16491
|
function hostGitDriverOverrides(cwd, env, timeout) {
|
|
16440
16492
|
let out;
|
|
16441
16493
|
try {
|
|
16442
|
-
out = (0, import_node_child_process3.execFileSync)(
|
|
16494
|
+
out = (0, import_node_child_process3.execFileSync)(hostGitExe(), [...hostGitHardeningArgs(), "config", "--null", "--show-scope", "--name-only", "--get-regexp", "^(filter|diff)\\."], { cwd, env, encoding: "utf8", stdio: "pipe", windowsHide: true, timeout });
|
|
16443
16495
|
} catch (err) {
|
|
16444
16496
|
return err.status === 1 ? [] : null;
|
|
16445
16497
|
}
|
|
@@ -16464,6 +16516,11 @@ function hostGitDriverOverrides(cwd, env, timeout) {
|
|
|
16464
16516
|
...[...diffs].flatMap((n) => ["textconv=", "command="].flatMap((kv) => ["-c", `diff.${n}.${kv}`]))
|
|
16465
16517
|
];
|
|
16466
16518
|
}
|
|
16519
|
+
function hostGitExe() {
|
|
16520
|
+
const git2 = resolveBareExe("git");
|
|
16521
|
+
if (git2 === null) throw new Error("host git: git is not on PATH");
|
|
16522
|
+
return git2;
|
|
16523
|
+
}
|
|
16467
16524
|
function runHostGit(cwd, args, timeout, baseEnv = process.env) {
|
|
16468
16525
|
const env = hostGitEnv(args, baseEnv);
|
|
16469
16526
|
const recorded = env.GIT_DIR ? recordedGitDirs.get(env.GIT_DIR) : void 0;
|
|
@@ -16484,38 +16541,38 @@ function runHostGit(cwd, args, timeout, baseEnv = process.env) {
|
|
|
16484
16541
|
tree = [...tree, ...LANE_SUBMODULE_OVERRIDES.flatMap((kv) => ["-c", kv])];
|
|
16485
16542
|
if (IGNORE_SUBMODULES_SUBCOMMANDS.has(subcommand)) finalArgs = [...args.slice(0, at + 1), "--ignore-submodules=all", ...args.slice(at + 1)];
|
|
16486
16543
|
}
|
|
16487
|
-
return (0, import_node_child_process3.execFileSync)(
|
|
16544
|
+
return (0, import_node_child_process3.execFileSync)(hostGitExe(), [...hostGitHardeningArgs(), ...tree, ...finalArgs], { cwd, env, encoding: "utf-8", stdio: "pipe", windowsHide: true, timeout });
|
|
16488
16545
|
}
|
|
16489
16546
|
function git(repoRoot, args, cwd = repoRoot) {
|
|
16490
16547
|
return runHostGit(cwd, args).trim();
|
|
16491
16548
|
}
|
|
16492
16549
|
function readPlainFile(path5) {
|
|
16493
16550
|
try {
|
|
16494
|
-
return (0,
|
|
16551
|
+
return (0, import_node_fs9.lstatSync)(path5).isFile() ? (0, import_node_fs9.readFileSync)(path5, "utf-8") : null;
|
|
16495
16552
|
} catch {
|
|
16496
16553
|
return null;
|
|
16497
16554
|
}
|
|
16498
16555
|
}
|
|
16499
16556
|
function readWorktreeGitLinks(wtPath) {
|
|
16500
|
-
const dotGit = readPlainFile((0,
|
|
16557
|
+
const dotGit = readPlainFile((0, import_node_path10.join)(wtPath, ".git"));
|
|
16501
16558
|
const match = dotGit === null ? null : /^gitdir: (.+?)\r?\n?$/.exec(dotGit);
|
|
16502
16559
|
if (!dotGit || !match) return null;
|
|
16503
|
-
const adminDir = (0,
|
|
16560
|
+
const adminDir = (0, import_node_path10.resolve)(wtPath, match[1]);
|
|
16504
16561
|
try {
|
|
16505
|
-
if (!(0,
|
|
16562
|
+
if (!(0, import_node_fs9.lstatSync)(adminDir).isDirectory()) return null;
|
|
16506
16563
|
} catch {
|
|
16507
16564
|
return null;
|
|
16508
16565
|
}
|
|
16509
|
-
const gitdir = readPlainFile((0,
|
|
16510
|
-
const commondir = readPlainFile((0,
|
|
16566
|
+
const gitdir = readPlainFile((0, import_node_path10.join)(adminDir, "gitdir"));
|
|
16567
|
+
const commondir = readPlainFile((0, import_node_path10.join)(adminDir, "commondir"));
|
|
16511
16568
|
const configWorktree = configWorktreeState(adminDir);
|
|
16512
16569
|
if (gitdir === null || commondir === null || configWorktree === null) return null;
|
|
16513
16570
|
return { adminDir, dotGit, gitdir, commondir, configWorktree };
|
|
16514
16571
|
}
|
|
16515
16572
|
function configWorktreeState(adminDir) {
|
|
16516
|
-
const path5 = (0,
|
|
16573
|
+
const path5 = (0, import_node_path10.join)(adminDir, "config.worktree");
|
|
16517
16574
|
try {
|
|
16518
|
-
return (0,
|
|
16575
|
+
return (0, import_node_fs9.lstatSync)(path5).isFile() ? (0, import_node_crypto8.createHash)("sha256").update((0, import_node_fs9.readFileSync)(path5)).digest("hex") : null;
|
|
16519
16576
|
} catch (err) {
|
|
16520
16577
|
return err.code === "ENOENT" ? "absent" : null;
|
|
16521
16578
|
}
|
|
@@ -16527,24 +16584,24 @@ function recordedEntry(wtPath) {
|
|
|
16527
16584
|
return [...recordedGitDirs.values()].find((e) => pathKey(e.wtPath) === pathKey(wtPath));
|
|
16528
16585
|
}
|
|
16529
16586
|
function recordWorktreeGitLinks(wtPath, links) {
|
|
16530
|
-
const existing = recordedEntry(wtPath) ?? recordedGitDirs.get((0,
|
|
16587
|
+
const existing = recordedEntry(wtPath) ?? recordedGitDirs.get((0, import_node_path10.resolve)(links.adminDir));
|
|
16531
16588
|
if (existing) {
|
|
16532
16589
|
if (pathKey(existing.wtPath) === pathKey(wtPath) && sameGitLinks(existing.links, links)) return;
|
|
16533
16590
|
throw new Error(`sandbox-escaped: other git links are already recorded for ${wtPath}; the record is never replaced`);
|
|
16534
16591
|
}
|
|
16535
16592
|
const args = ["--git-dir", links.adminDir, "--work-tree", wtPath];
|
|
16536
|
-
const format = (0, import_node_child_process3.execFileSync)(
|
|
16593
|
+
const format = (0, import_node_child_process3.execFileSync)(hostGitExe(), [...hostGitHardeningArgs(), ...args, "rev-parse", "--show-object-format"], { cwd: wtPath, env: hostGitEnv(args), encoding: "utf-8", stdio: "pipe", windowsHide: true }).trim();
|
|
16537
16594
|
const emptyTree = EMPTY_TREE[format];
|
|
16538
16595
|
if (!emptyTree) throw new Error(`host git: unknown object format ${JSON.stringify(format)} in ${wtPath}`);
|
|
16539
|
-
recordedGitDirs.set((0,
|
|
16596
|
+
recordedGitDirs.set((0, import_node_path10.resolve)(links.adminDir), { wtPath, links, emptyTree });
|
|
16540
16597
|
}
|
|
16541
16598
|
function forgetWorktreeGitLinks(wtPath) {
|
|
16542
16599
|
const entry = recordedEntry(wtPath);
|
|
16543
|
-
if (entry) recordedGitDirs.delete((0,
|
|
16600
|
+
if (entry) recordedGitDirs.delete((0, import_node_path10.resolve)(entry.links.adminDir));
|
|
16544
16601
|
}
|
|
16545
16602
|
function isAdminDirOf(commonGitDir, adminDir) {
|
|
16546
|
-
const rel = (0,
|
|
16547
|
-
return rel !== "" && !rel.startsWith("..") && !(0,
|
|
16603
|
+
const rel = (0, import_node_path10.relative)((0, import_node_path10.resolve)(commonGitDir, "worktrees"), adminDir);
|
|
16604
|
+
return rel !== "" && !rel.startsWith("..") && !(0, import_node_path10.isAbsolute)(rel) && !rel.includes(import_node_path10.sep);
|
|
16548
16605
|
}
|
|
16549
16606
|
function worktreeGitLinksIntact(wtPath, expected, commonGitDir) {
|
|
16550
16607
|
return isAdminDirOf(commonGitDir, expected.adminDir) && sameGitLinks(readWorktreeGitLinks(wtPath), expected);
|
|
@@ -16571,20 +16628,20 @@ function assertCleanLeaderWorktree(repoRoot) {
|
|
|
16571
16628
|
}
|
|
16572
16629
|
}
|
|
16573
16630
|
function canonicalPathForComparison(path5) {
|
|
16574
|
-
let existing = (0,
|
|
16631
|
+
let existing = (0, import_node_path10.resolve)(path5);
|
|
16575
16632
|
const missingTail = [];
|
|
16576
16633
|
let canonical;
|
|
16577
16634
|
for (; ; ) {
|
|
16578
16635
|
try {
|
|
16579
|
-
canonical = (0,
|
|
16636
|
+
canonical = (0, import_node_path10.join)(import_node_fs9.realpathSync.native(existing), ...missingTail);
|
|
16580
16637
|
break;
|
|
16581
16638
|
} catch {
|
|
16582
|
-
const parent = (0,
|
|
16639
|
+
const parent = (0, import_node_path10.dirname)(existing);
|
|
16583
16640
|
if (parent === existing) {
|
|
16584
|
-
canonical = (0,
|
|
16641
|
+
canonical = (0, import_node_path10.resolve)(path5);
|
|
16585
16642
|
break;
|
|
16586
16643
|
}
|
|
16587
|
-
missingTail.unshift((0,
|
|
16644
|
+
missingTail.unshift((0, import_node_path10.basename)(existing));
|
|
16588
16645
|
existing = parent;
|
|
16589
16646
|
}
|
|
16590
16647
|
}
|
|
@@ -16660,10 +16717,10 @@ function statusEntryPath(line) {
|
|
|
16660
16717
|
return normalizeStatusPath(renameIndex >= 0 ? payload.slice(renameIndex + renameSeparator.length) : payload);
|
|
16661
16718
|
}
|
|
16662
16719
|
function worktreeRuntimeStatePrefixes(wtPath) {
|
|
16663
|
-
const root = (0,
|
|
16664
|
-
const omcRel = (0,
|
|
16665
|
-
if (!omcRel || omcRel.startsWith("..") || (0,
|
|
16666
|
-
return WORKTREE_RUNTIME_STATE_DIRS.map(([dir, rest]) => [`${(0,
|
|
16720
|
+
const root = (0, import_node_path10.resolve)(wtPath);
|
|
16721
|
+
const omcRel = (0, import_node_path10.relative)(root, (0, import_node_path10.resolve)(getOmcRoot(wtPath))).split(import_node_path10.sep).join("/");
|
|
16722
|
+
if (!omcRel || omcRel.startsWith("..") || (0, import_node_path10.isAbsolute)(omcRel) || omcRel.includes("/")) return [];
|
|
16723
|
+
return WORKTREE_RUNTIME_STATE_DIRS.map(([dir, rest]) => [`${(0, import_node_path10.relative)(root, resolveOmcPath(dir, wtPath)).split(import_node_path10.sep).join("/")}/`, rest]);
|
|
16667
16724
|
}
|
|
16668
16725
|
function isWorktreeDirtyExcept(wtPath, ignoredRootPaths = [], gitDirArgs = []) {
|
|
16669
16726
|
try {
|
|
@@ -16687,7 +16744,7 @@ function removeRuntimeLeftover(wtPath, retryMs = RUNTIME_LEFTOVER_RETRY_MS) {
|
|
|
16687
16744
|
const deadline = Date.now() + retryMs;
|
|
16688
16745
|
for (; ; ) {
|
|
16689
16746
|
try {
|
|
16690
|
-
(0,
|
|
16747
|
+
(0, import_node_fs9.rmSync)(wtPath, { recursive: true, force: true });
|
|
16691
16748
|
return;
|
|
16692
16749
|
} catch (err) {
|
|
16693
16750
|
if (Date.now() >= deadline) {
|
|
@@ -16701,33 +16758,33 @@ function removeRuntimeLeftover(wtPath, retryMs = RUNTIME_LEFTOVER_RETRY_MS) {
|
|
|
16701
16758
|
}
|
|
16702
16759
|
function unlinkUntrackedWorktreeLinks(wtPath, gitDirArgs = [], keepTracked = true) {
|
|
16703
16760
|
const tracked = new Set(
|
|
16704
|
-
(keepTracked ? gitOrNull([...gitDirArgs, "ls-files", "-z", "--stage"], wtPath) ?? "" : "").split("\0").filter((entry) => entry.startsWith("120000 ")).map((entry) => (0,
|
|
16761
|
+
(keepTracked ? gitOrNull([...gitDirArgs, "ls-files", "-z", "--stage"], wtPath) ?? "" : "").split("\0").filter((entry) => entry.startsWith("120000 ")).map((entry) => (0, import_node_path10.resolve)(wtPath, entry.slice(entry.indexOf(" ") + 1)))
|
|
16705
16762
|
);
|
|
16706
16763
|
const pending = [wtPath];
|
|
16707
16764
|
while (pending.length > 0) {
|
|
16708
16765
|
const dir = pending.pop();
|
|
16709
16766
|
let entries;
|
|
16710
16767
|
try {
|
|
16711
|
-
entries = (0,
|
|
16768
|
+
entries = (0, import_node_fs9.readdirSync)(dir, { withFileTypes: true });
|
|
16712
16769
|
} catch {
|
|
16713
16770
|
continue;
|
|
16714
16771
|
}
|
|
16715
16772
|
for (const entry of entries) {
|
|
16716
|
-
const path5 = (0,
|
|
16773
|
+
const path5 = (0, import_node_path10.join)(dir, entry.name);
|
|
16717
16774
|
if (keepTracked && dir === wtPath && entry.name === ".git") continue;
|
|
16718
16775
|
let stat2;
|
|
16719
16776
|
try {
|
|
16720
|
-
stat2 = (0,
|
|
16777
|
+
stat2 = (0, import_node_fs9.lstatSync)(path5);
|
|
16721
16778
|
} catch {
|
|
16722
16779
|
continue;
|
|
16723
16780
|
}
|
|
16724
16781
|
if (stat2.isSymbolicLink()) {
|
|
16725
|
-
if (tracked.has((0,
|
|
16782
|
+
if (tracked.has((0, import_node_path10.resolve)(path5))) continue;
|
|
16726
16783
|
try {
|
|
16727
|
-
(0,
|
|
16784
|
+
(0, import_node_fs9.unlinkSync)(path5);
|
|
16728
16785
|
} catch {
|
|
16729
16786
|
try {
|
|
16730
|
-
(0,
|
|
16787
|
+
(0, import_node_fs9.rmdirSync)(path5);
|
|
16731
16788
|
} catch (err) {
|
|
16732
16789
|
const error = new Error(`worktree_link_unremovable: preserving worker worktree at ${wtPath}; cannot unlink ${path5}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16733
16790
|
error.code = "worktree_link_unremovable";
|
|
@@ -16758,10 +16815,10 @@ function commitCheckFailedError(message) {
|
|
|
16758
16815
|
function branchRefStored(repoRoot, branch) {
|
|
16759
16816
|
const commonDir = gitOrNull(["rev-parse", "--git-common-dir"], repoRoot);
|
|
16760
16817
|
if (!commonDir) throw commitCheckFailedError(`keeping worker branch ${branch} (cannot locate the git directory)`);
|
|
16761
|
-
const gitDir = (0,
|
|
16762
|
-
if ((0,
|
|
16818
|
+
const gitDir = (0, import_node_path10.resolve)(repoRoot, commonDir);
|
|
16819
|
+
if ((0, import_node_fs9.existsSync)((0, import_node_path10.join)(gitDir, "refs", "heads", ...branch.split("/")))) return true;
|
|
16763
16820
|
try {
|
|
16764
|
-
return (0,
|
|
16821
|
+
return (0, import_node_fs9.readFileSync)((0, import_node_path10.join)(gitDir, "packed-refs"), "utf-8").split("\n").some((line) => line.trimEnd().endsWith(` refs/heads/${branch}`));
|
|
16765
16822
|
} catch (err) {
|
|
16766
16823
|
if (err.code === "ENOENT") return false;
|
|
16767
16824
|
throw commitCheckFailedError(`keeping worker branch ${branch} (cannot read packed-refs)`);
|
|
@@ -16805,16 +16862,16 @@ function countUnmergedCommits(repoRoot, head, baseCommit, contained = []) {
|
|
|
16805
16862
|
}
|
|
16806
16863
|
function hasInitializedSubmodules(wtPath, gitDirArgs = []) {
|
|
16807
16864
|
const modulesDir = gitOrNull([...gitDirArgs, "rev-parse", "--git-path", "modules"], wtPath);
|
|
16808
|
-
if (modulesDir && (0,
|
|
16865
|
+
if (modulesDir && (0, import_node_fs9.existsSync)((0, import_node_path10.resolve)(wtPath, modulesDir))) return true;
|
|
16809
16866
|
const staged = gitOrNull([...gitDirArgs, "ls-files", "--stage"], wtPath) ?? "";
|
|
16810
16867
|
return staged.split("\n").some((line) => {
|
|
16811
16868
|
if (!line.startsWith("160000 ")) return false;
|
|
16812
16869
|
const tab = line.indexOf(" ");
|
|
16813
|
-
return tab >= 0 && (0,
|
|
16870
|
+
return tab >= 0 && (0, import_node_fs9.existsSync)((0, import_node_path10.join)(wtPath, normalizeStatusPath(line.slice(tab + 1)), ".git"));
|
|
16814
16871
|
});
|
|
16815
16872
|
}
|
|
16816
16873
|
function unmergedCommitsError(info) {
|
|
16817
|
-
const what = (0,
|
|
16874
|
+
const what = (0, import_node_fs9.existsSync)(info.path) ? `worker worktree at ${info.path}` : `worker branch of the removed worktree ${info.path}`;
|
|
16818
16875
|
const error = new Error(
|
|
16819
16876
|
`worktree_unmerged_commits: preserving ${what} with ${info.commits} commit(s) not merged into the leader HEAD${info.branch ? ` (branch ${info.branch})` : " (detached)"}`
|
|
16820
16877
|
);
|
|
@@ -16822,34 +16879,34 @@ function unmergedCommitsError(info) {
|
|
|
16822
16879
|
return error;
|
|
16823
16880
|
}
|
|
16824
16881
|
function getPreservedWorktreesRecordPath(repoRoot, teamName) {
|
|
16825
|
-
return (0,
|
|
16882
|
+
return (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team-preserved-worktrees", `${sanitizeName(teamName)}.json`);
|
|
16826
16883
|
}
|
|
16827
16884
|
function writePreservedWorktreesRecord(repoRoot, teamName, preserved) {
|
|
16828
16885
|
const recordPath = getPreservedWorktreesRecordPath(repoRoot, teamName);
|
|
16829
16886
|
if (preserved.length === 0) {
|
|
16830
|
-
(0,
|
|
16887
|
+
(0, import_node_fs9.rmSync)(recordPath, { force: true });
|
|
16831
16888
|
return;
|
|
16832
16889
|
}
|
|
16833
|
-
ensureDirWithMode((0,
|
|
16890
|
+
ensureDirWithMode((0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team-preserved-worktrees"));
|
|
16834
16891
|
atomicWriteJson2(recordPath, { team: teamName, recorded_at: (/* @__PURE__ */ new Date()).toISOString(), preserved_worktrees: preserved });
|
|
16835
16892
|
}
|
|
16836
16893
|
function getMetadataPath(repoRoot, teamName) {
|
|
16837
|
-
return (0,
|
|
16894
|
+
return (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team", sanitizeName(teamName), "worktrees.json");
|
|
16838
16895
|
}
|
|
16839
16896
|
function getLegacyMetadataPath(repoRoot, teamName) {
|
|
16840
|
-
return (0,
|
|
16897
|
+
return (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team-bridge", sanitizeName(teamName), "worktrees.json");
|
|
16841
16898
|
}
|
|
16842
16899
|
function getWorkerStateDir(repoRoot, teamName, workerName) {
|
|
16843
|
-
return (0,
|
|
16900
|
+
return (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team", sanitizeName(teamName), "workers", sanitizeName(workerName));
|
|
16844
16901
|
}
|
|
16845
16902
|
function getRootAgentsBackupPath(repoRoot, teamName, workerName) {
|
|
16846
|
-
return (0,
|
|
16903
|
+
return (0, import_node_path10.join)(getWorkerStateDir(repoRoot, teamName, workerName), "worktree-root-agents.json");
|
|
16847
16904
|
}
|
|
16848
16905
|
function readRootAgentsBackup(repoRoot, teamName, workerName) {
|
|
16849
16906
|
const backupPath = getRootAgentsBackupPath(repoRoot, teamName, workerName);
|
|
16850
|
-
if (!(0,
|
|
16907
|
+
if (!(0, import_node_fs9.existsSync)(backupPath)) return null;
|
|
16851
16908
|
try {
|
|
16852
|
-
return JSON.parse((0,
|
|
16909
|
+
return JSON.parse((0, import_node_fs9.readFileSync)(backupPath, "utf-8"));
|
|
16853
16910
|
} catch (err) {
|
|
16854
16911
|
const msg = err instanceof Error ? err.message : String(err);
|
|
16855
16912
|
process.stderr.write(`[omc] warning: worktree root AGENTS backup parse error: ${msg}
|
|
@@ -16862,13 +16919,13 @@ function readRootAgentsBackup(repoRoot, teamName, workerName) {
|
|
|
16862
16919
|
function installWorktreeRootAgents(teamName, workerName, repoRoot, worktreePath, overlayContent) {
|
|
16863
16920
|
const omcRoot = getOmcRoot(repoRoot);
|
|
16864
16921
|
validateResolvedPath(worktreePath, omcRoot);
|
|
16865
|
-
const agentsPath = (0,
|
|
16922
|
+
const agentsPath = (0, import_node_path10.join)(worktreePath, "AGENTS.md");
|
|
16866
16923
|
validateResolvedPath(agentsPath, worktreePath);
|
|
16867
16924
|
const backupPath = getRootAgentsBackupPath(repoRoot, teamName, workerName);
|
|
16868
16925
|
validateResolvedPath(backupPath, omcRoot);
|
|
16869
16926
|
ensureDirWithMode(getWorkerStateDir(repoRoot, teamName, workerName));
|
|
16870
16927
|
const previous = readRootAgentsBackup(repoRoot, teamName, workerName);
|
|
16871
|
-
const currentContent = (0,
|
|
16928
|
+
const currentContent = (0, import_node_fs9.existsSync)(agentsPath) ? (0, import_node_fs9.readFileSync)(agentsPath, "utf-8") : void 0;
|
|
16872
16929
|
if (previous && currentContent !== void 0 && currentContent !== previous.installedContent) {
|
|
16873
16930
|
const error = new Error(`agents_dirty: preserving modified worktree root AGENTS.md at ${agentsPath}`);
|
|
16874
16931
|
error.code = "agents_dirty";
|
|
@@ -16882,7 +16939,7 @@ function installWorktreeRootAgents(teamName, workerName, repoRoot, worktreePath,
|
|
|
16882
16939
|
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16883
16940
|
};
|
|
16884
16941
|
atomicWriteJson2(backupPath, backup);
|
|
16885
|
-
(0,
|
|
16942
|
+
(0, import_node_fs9.writeFileSync)(agentsPath, overlayContent, "utf-8");
|
|
16886
16943
|
}
|
|
16887
16944
|
function restoreWorktreeRootAgents(teamName, workerName, repoRoot, worktreePath) {
|
|
16888
16945
|
const omcRoot = getOmcRoot(repoRoot);
|
|
@@ -16892,27 +16949,27 @@ function restoreWorktreeRootAgents(teamName, workerName, repoRoot, worktreePath)
|
|
|
16892
16949
|
if (!backup) return { restored: false, reason: "no_backup" };
|
|
16893
16950
|
const resolvedWorktreePath = worktreePath ?? backup.worktreePath;
|
|
16894
16951
|
validateResolvedPath(resolvedWorktreePath, omcRoot);
|
|
16895
|
-
if (!(0,
|
|
16952
|
+
if (!(0, import_node_fs9.existsSync)(resolvedWorktreePath)) {
|
|
16896
16953
|
try {
|
|
16897
|
-
(0,
|
|
16954
|
+
(0, import_node_fs9.unlinkSync)(backupPath);
|
|
16898
16955
|
} catch {
|
|
16899
16956
|
}
|
|
16900
16957
|
return { restored: false, reason: "worktree_missing" };
|
|
16901
16958
|
}
|
|
16902
|
-
const agentsPath = (0,
|
|
16959
|
+
const agentsPath = (0, import_node_path10.join)(resolvedWorktreePath, "AGENTS.md");
|
|
16903
16960
|
validateResolvedPath(agentsPath, resolvedWorktreePath);
|
|
16904
|
-
const currentContent = (0,
|
|
16961
|
+
const currentContent = (0, import_node_fs9.existsSync)(agentsPath) ? (0, import_node_fs9.readFileSync)(agentsPath, "utf-8") : void 0;
|
|
16905
16962
|
const isPartialInstallOriginal = backup.hadOriginal && currentContent === (backup.originalContent ?? "");
|
|
16906
16963
|
if (currentContent !== void 0 && currentContent !== backup.installedContent && !isPartialInstallOriginal) {
|
|
16907
16964
|
return { restored: false, reason: "agents_dirty" };
|
|
16908
16965
|
}
|
|
16909
16966
|
if (backup.hadOriginal) {
|
|
16910
|
-
(0,
|
|
16911
|
-
} else if ((0,
|
|
16912
|
-
(0,
|
|
16967
|
+
(0, import_node_fs9.writeFileSync)(agentsPath, backup.originalContent ?? "", "utf-8");
|
|
16968
|
+
} else if ((0, import_node_fs9.existsSync)(agentsPath)) {
|
|
16969
|
+
(0, import_node_fs9.unlinkSync)(agentsPath);
|
|
16913
16970
|
}
|
|
16914
16971
|
try {
|
|
16915
|
-
(0,
|
|
16972
|
+
(0, import_node_fs9.unlinkSync)(backupPath);
|
|
16916
16973
|
} catch {
|
|
16917
16974
|
}
|
|
16918
16975
|
return { restored: true };
|
|
@@ -16922,9 +16979,9 @@ function readMetadataResult(repoRoot, teamName) {
|
|
|
16922
16979
|
const byWorker = /* @__PURE__ */ new Map();
|
|
16923
16980
|
const issues = [];
|
|
16924
16981
|
for (const metaPath of paths) {
|
|
16925
|
-
if (!(0,
|
|
16982
|
+
if (!(0, import_node_fs9.existsSync)(metaPath)) continue;
|
|
16926
16983
|
try {
|
|
16927
|
-
const entries = JSON.parse((0,
|
|
16984
|
+
const entries = JSON.parse((0, import_node_fs9.readFileSync)(metaPath, "utf-8"));
|
|
16928
16985
|
for (const entry of entries) byWorker.set(entry.workerName, entry);
|
|
16929
16986
|
} catch (err) {
|
|
16930
16987
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -16939,15 +16996,15 @@ function readMetadata(repoRoot, teamName) {
|
|
|
16939
16996
|
return readMetadataResult(repoRoot, teamName).entries;
|
|
16940
16997
|
}
|
|
16941
16998
|
function listRootAgentsBackupIssues(repoRoot, teamName, entries) {
|
|
16942
|
-
const workersDir = (0,
|
|
16943
|
-
if (!(0,
|
|
16999
|
+
const workersDir = (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team", sanitizeName(teamName), "workers");
|
|
17000
|
+
if (!(0, import_node_fs9.existsSync)(workersDir)) return [];
|
|
16944
17001
|
const knownWorkers = new Set(entries.map((entry) => sanitizeName(entry.workerName)));
|
|
16945
17002
|
const issues = [];
|
|
16946
|
-
for (const workerName of (0,
|
|
16947
|
-
const backupPath = (0,
|
|
16948
|
-
if (!(0,
|
|
17003
|
+
for (const workerName of (0, import_node_fs9.readdirSync)(workersDir)) {
|
|
17004
|
+
const backupPath = (0, import_node_path10.join)(workersDir, workerName, "worktree-root-agents.json");
|
|
17005
|
+
if (!(0, import_node_fs9.existsSync)(backupPath)) continue;
|
|
16949
17006
|
try {
|
|
16950
|
-
JSON.parse((0,
|
|
17007
|
+
JSON.parse((0, import_node_fs9.readFileSync)(backupPath, "utf-8"));
|
|
16951
17008
|
} catch (error) {
|
|
16952
17009
|
const message = error instanceof Error ? error.message : String(error);
|
|
16953
17010
|
issues.push({ path: backupPath, message: `worktree_root_agents_backup_unreadable:${workerName}:${message}` });
|
|
@@ -16964,8 +17021,8 @@ function listRootAgentsBackupIssues(repoRoot, teamName, entries) {
|
|
|
16964
17021
|
}
|
|
16965
17022
|
function writeMetadata(repoRoot, teamName, entries) {
|
|
16966
17023
|
const metaPath = getMetadataPath(repoRoot, teamName);
|
|
16967
|
-
validateResolvedPath(metaPath, (0,
|
|
16968
|
-
ensureDirWithMode((0,
|
|
17024
|
+
validateResolvedPath(metaPath, (0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team"));
|
|
17025
|
+
ensureDirWithMode((0, import_node_path10.join)(getOmcRoot(repoRoot), "state", "team", sanitizeName(teamName)));
|
|
16969
17026
|
atomicWriteJson2(metaPath, entries);
|
|
16970
17027
|
}
|
|
16971
17028
|
function recordMetadata(repoRoot, teamName, info) {
|
|
@@ -17020,12 +17077,12 @@ function ensureWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17020
17077
|
}
|
|
17021
17078
|
const wtPath = getWorktreePath(repoRoot, teamName, workerName);
|
|
17022
17079
|
const branch = mode === "named" ? getBranchName(teamName, workerName) : "HEAD";
|
|
17023
|
-
validateResolvedPath(wtPath, (0,
|
|
17080
|
+
validateResolvedPath(wtPath, (0, import_node_path10.join)(getOmcRoot(repoRoot), "team"));
|
|
17024
17081
|
try {
|
|
17025
17082
|
runHostGit(repoRoot, ["worktree", "prune"]);
|
|
17026
17083
|
} catch {
|
|
17027
17084
|
}
|
|
17028
|
-
if ((0,
|
|
17085
|
+
if ((0, import_node_fs9.existsSync)(wtPath)) {
|
|
17029
17086
|
assertCompatibleExistingWorktree(repoRoot, wtPath, branch, mode);
|
|
17030
17087
|
const previousBase = readMetadata(repoRoot, teamName).find((entry) => entry.workerName === workerName)?.baseCommit;
|
|
17031
17088
|
const info2 = {
|
|
@@ -17044,10 +17101,10 @@ function ensureWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17044
17101
|
recordMetadata(repoRoot, teamName, info2);
|
|
17045
17102
|
return info2;
|
|
17046
17103
|
}
|
|
17047
|
-
const wtDir = (0,
|
|
17104
|
+
const wtDir = (0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees");
|
|
17048
17105
|
ensureDirWithMode(wtDir);
|
|
17049
17106
|
const args = mode === "named" ? ["worktree", "add", "-b", branch, wtPath, options.baseRef ?? "HEAD"] : ["worktree", "add", "--detach", wtPath, options.baseRef ?? "HEAD"];
|
|
17050
|
-
(0, import_node_child_process3.execFileSync)(
|
|
17107
|
+
(0, import_node_child_process3.execFileSync)(hostGitExe(), args, { cwd: repoRoot, stdio: "pipe", windowsHide: true });
|
|
17051
17108
|
const baseCommit = gitOrNull(["rev-parse", "HEAD"], wtPath);
|
|
17052
17109
|
const info = {
|
|
17053
17110
|
...baseCommit ? { baseCommit } : {},
|
|
@@ -17068,17 +17125,17 @@ function ensureWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17068
17125
|
function checkWorkerWorktreeRemovalSafety(teamName, workerName, repoRoot, worktreePath, gitDirArgs = []) {
|
|
17069
17126
|
const wtPath = worktreePath ?? getWorktreePath(repoRoot, teamName, workerName);
|
|
17070
17127
|
const backup = readRootAgentsBackup(repoRoot, teamName, workerName);
|
|
17071
|
-
if (!(0,
|
|
17128
|
+
if (!(0, import_node_fs9.existsSync)(wtPath)) return;
|
|
17072
17129
|
validateWorktreeRemovalTarget({
|
|
17073
17130
|
candidatePath: wtPath,
|
|
17074
|
-
expectedRoots: [(0,
|
|
17131
|
+
expectedRoots: [(0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees")],
|
|
17075
17132
|
mainRepoRoots: [repoRoot]
|
|
17076
17133
|
});
|
|
17077
17134
|
let ignoreRootAgents = false;
|
|
17078
17135
|
if (backup) {
|
|
17079
|
-
const agentsPath = (0,
|
|
17136
|
+
const agentsPath = (0, import_node_path10.join)(wtPath, "AGENTS.md");
|
|
17080
17137
|
validateResolvedPath(agentsPath, wtPath);
|
|
17081
|
-
const currentContent = (0,
|
|
17138
|
+
const currentContent = (0, import_node_fs9.existsSync)(agentsPath) ? (0, import_node_fs9.readFileSync)(agentsPath, "utf-8") : void 0;
|
|
17082
17139
|
const isPartialInstallOriginal = backup.hadOriginal && currentContent === (backup.originalContent ?? "");
|
|
17083
17140
|
if (currentContent !== void 0 && currentContent !== backup.installedContent && !isPartialInstallOriginal) {
|
|
17084
17141
|
const error = new Error(`agents_dirty: preserving modified worktree root AGENTS.md at ${agentsPath}`);
|
|
@@ -17099,7 +17156,7 @@ function prepareWorkerWorktreeForRemoval(teamName, workerName, repoRoot, worktre
|
|
|
17099
17156
|
checkWorkerWorktreeRemovalSafety(teamName, workerName, repoRoot, wtPath, gitDirArgs);
|
|
17100
17157
|
const agentsRestore = restoreWorktreeRootAgents(teamName, workerName, repoRoot, wtPath);
|
|
17101
17158
|
if (agentsRestore.reason === "agents_dirty") {
|
|
17102
|
-
const error = new Error(`agents_dirty: preserving modified worktree root AGENTS.md at ${(0,
|
|
17159
|
+
const error = new Error(`agents_dirty: preserving modified worktree root AGENTS.md at ${(0, import_node_path10.join)(wtPath, "AGENTS.md")}`);
|
|
17103
17160
|
error.code = "agents_dirty";
|
|
17104
17161
|
throw error;
|
|
17105
17162
|
}
|
|
@@ -17134,7 +17191,7 @@ function removeWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17134
17191
|
throw commitCheckFailedError(`preserving worker worktree at ${wtPath} (cannot list git worktrees)`);
|
|
17135
17192
|
}
|
|
17136
17193
|
const wasRegisteredWorktree = registered !== null;
|
|
17137
|
-
if (registered && (0,
|
|
17194
|
+
if (registered && (0, import_node_fs9.existsSync)(wtPath)) {
|
|
17138
17195
|
const toplevel = gitOrNull([...gitDirArgs, "rev-parse", "--show-toplevel"], wtPath);
|
|
17139
17196
|
if (!toplevel || canonicalPathForComparison(toplevel) !== canonicalPathForComparison(wtPath)) {
|
|
17140
17197
|
throw commitCheckFailedError(`preserving worker worktree at ${wtPath} (git does not resolve it to its own worktree)`);
|
|
@@ -17153,21 +17210,21 @@ function removeWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17153
17210
|
if (commits === null) throw commitCheckFailedError(`keeping worker branch ${branch} (cannot count its commits against the leader HEAD)`);
|
|
17154
17211
|
if (commits > 0) throw unmergedCommitsError({ workerName, path: wtPath, branch, commits });
|
|
17155
17212
|
}
|
|
17156
|
-
const runtimeOnly = (0,
|
|
17157
|
-
const submodules = (0,
|
|
17213
|
+
const runtimeOnly = (0, import_node_fs9.existsSync)(wtPath) && isWorktreeDirtyExcept(wtPath, ["AGENTS.md"], gitDirArgs).runtimeState;
|
|
17214
|
+
const submodules = (0, import_node_fs9.existsSync)(wtPath) && hasInitializedSubmodules(wtPath, gitDirArgs);
|
|
17158
17215
|
const force = runtimeOnly && !submodules;
|
|
17159
17216
|
if (wasRegisteredWorktree && submodules) {
|
|
17160
17217
|
const error = new Error(`worktree_remove_failed: preserving metadata for registered worker worktree at ${wtPath}: initialized submodules`);
|
|
17161
17218
|
error.code = "worktree_remove_failed";
|
|
17162
17219
|
throw error;
|
|
17163
17220
|
}
|
|
17164
|
-
if ((0,
|
|
17221
|
+
if ((0, import_node_fs9.existsSync)(wtPath)) unlinkUntrackedWorktreeLinks(wtPath, gitDirArgs);
|
|
17165
17222
|
try {
|
|
17166
17223
|
if (options.gitLinks && laneCommonDir) {
|
|
17167
|
-
if ((0,
|
|
17224
|
+
if ((0, import_node_fs9.existsSync)(wtPath)) {
|
|
17168
17225
|
validateWorktreeRemovalTarget({
|
|
17169
17226
|
candidatePath: wtPath,
|
|
17170
|
-
expectedRoots: [(0,
|
|
17227
|
+
expectedRoots: [(0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees")],
|
|
17171
17228
|
mainRepoRoots: [repoRoot]
|
|
17172
17229
|
});
|
|
17173
17230
|
}
|
|
@@ -17194,14 +17251,14 @@ function removeWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17194
17251
|
} catch {
|
|
17195
17252
|
}
|
|
17196
17253
|
if (branchHead) deleteWorkerBranchAt(repoRoot, branch, branchHead);
|
|
17197
|
-
if ((0,
|
|
17254
|
+
if ((0, import_node_fs9.existsSync)(wtPath) && !isRegisteredWorktreePath(repoRoot, wtPath)) {
|
|
17198
17255
|
validateWorktreeRemovalTarget({
|
|
17199
17256
|
candidatePath: wtPath,
|
|
17200
|
-
expectedRoots: [(0,
|
|
17257
|
+
expectedRoots: [(0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees")],
|
|
17201
17258
|
mainRepoRoots: [repoRoot]
|
|
17202
17259
|
});
|
|
17203
17260
|
if (force) removeRuntimeLeftover(wtPath);
|
|
17204
|
-
else (0,
|
|
17261
|
+
else (0, import_node_fs9.rmSync)(wtPath, { recursive: true, force: true });
|
|
17205
17262
|
}
|
|
17206
17263
|
forgetMetadataUnlocked(repoRoot, teamName, workerName);
|
|
17207
17264
|
forgetWorktreeGitLinks(wtPath);
|
|
@@ -17211,27 +17268,27 @@ function removeWorkerWorktree(teamName, workerName, repoRoot, options = {}) {
|
|
|
17211
17268
|
function removeTreeByPath(dir) {
|
|
17212
17269
|
let stat2;
|
|
17213
17270
|
try {
|
|
17214
|
-
stat2 = (0,
|
|
17271
|
+
stat2 = (0, import_node_fs9.lstatSync)(dir);
|
|
17215
17272
|
} catch {
|
|
17216
17273
|
return;
|
|
17217
17274
|
}
|
|
17218
17275
|
if (stat2.isSymbolicLink()) {
|
|
17219
17276
|
try {
|
|
17220
|
-
(0,
|
|
17277
|
+
(0, import_node_fs9.unlinkSync)(dir);
|
|
17221
17278
|
} catch {
|
|
17222
|
-
(0,
|
|
17279
|
+
(0, import_node_fs9.rmdirSync)(dir);
|
|
17223
17280
|
}
|
|
17224
17281
|
return;
|
|
17225
17282
|
}
|
|
17226
17283
|
unlinkUntrackedWorktreeLinks(dir, [], false);
|
|
17227
|
-
(0,
|
|
17284
|
+
(0, import_node_fs9.rmSync)(dir, { recursive: true, force: true });
|
|
17228
17285
|
}
|
|
17229
17286
|
function removeTamperedWorktree(repoRoot, teamName, workerName, wtPath, links, commonDir) {
|
|
17230
17287
|
const removeTree = removeTreeByPath;
|
|
17231
|
-
if ((0,
|
|
17288
|
+
if ((0, import_node_fs9.existsSync)(wtPath)) {
|
|
17232
17289
|
validateWorktreeRemovalTarget({
|
|
17233
17290
|
candidatePath: wtPath,
|
|
17234
|
-
expectedRoots: [(0,
|
|
17291
|
+
expectedRoots: [(0, import_node_path10.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "worktrees")],
|
|
17235
17292
|
mainRepoRoots: [repoRoot]
|
|
17236
17293
|
});
|
|
17237
17294
|
}
|
|
@@ -17291,15 +17348,16 @@ function cleanupTeamWorktrees(teamName, repoRoot) {
|
|
|
17291
17348
|
}
|
|
17292
17349
|
return { removed, preserved, retained };
|
|
17293
17350
|
}
|
|
17294
|
-
var
|
|
17351
|
+
var import_node_fs9, import_node_os3, import_node_path10, import_node_child_process3, import_node_crypto8, emptyHooksDir, EXEC_KEY_OVERRIDES, emptyAttributesFile, WORK_TREE_SUBCOMMANDS, GLOBAL_OPTIONS_WITH_VALUE, LANE_SUBMODULE_OVERRIDES, IGNORE_SUBMODULES_SUBCOMMANDS, EMPTY_TREE, recordedGitDirs, pathKey, UNTRACKED_OMC_STATE, WORKTREE_RUNTIME_STATE_DIRS, RUNTIME_LEFTOVER_RETRY_MS;
|
|
17295
17352
|
var init_git_worktree = __esm({
|
|
17296
17353
|
"src/team/git-worktree.ts"() {
|
|
17297
17354
|
"use strict";
|
|
17298
|
-
|
|
17355
|
+
import_node_fs9 = require("node:fs");
|
|
17299
17356
|
import_node_os3 = require("node:os");
|
|
17300
|
-
|
|
17357
|
+
import_node_path10 = require("node:path");
|
|
17301
17358
|
import_node_child_process3 = require("node:child_process");
|
|
17302
17359
|
import_node_crypto8 = require("node:crypto");
|
|
17360
|
+
init_windows_search();
|
|
17303
17361
|
init_fs_utils();
|
|
17304
17362
|
init_worktree_cleanup_safety();
|
|
17305
17363
|
init_tmux_session();
|
|
@@ -17350,7 +17408,7 @@ var init_git_worktree = __esm({
|
|
|
17350
17408
|
sha256: "6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321"
|
|
17351
17409
|
};
|
|
17352
17410
|
recordedGitDirs = /* @__PURE__ */ new Map();
|
|
17353
|
-
pathKey = (path5) => process.platform === "win32" ? (0,
|
|
17411
|
+
pathKey = (path5) => process.platform === "win32" ? (0, import_node_path10.resolve)(path5).toLowerCase() : (0, import_node_path10.resolve)(path5);
|
|
17354
17412
|
UNTRACKED_OMC_STATE = new RegExp(
|
|
17355
17413
|
`^\\?\\? ${OmcPaths.ROOT.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:/|$)`
|
|
17356
17414
|
);
|
|
@@ -17856,13 +17914,13 @@ function configureHarnessMergeAttributes(repoRoot) {
|
|
|
17856
17914
|
stdio: "pipe",
|
|
17857
17915
|
windowsHide: true
|
|
17858
17916
|
}).trim();
|
|
17859
|
-
const resolvedCommonDir = (0,
|
|
17860
|
-
const infoDir = (0,
|
|
17861
|
-
(0,
|
|
17862
|
-
const attrPath = (0,
|
|
17917
|
+
const resolvedCommonDir = (0, import_node_path11.isAbsolute)(commonDir) ? commonDir : (0, import_node_path11.join)(repoRoot, commonDir);
|
|
17918
|
+
const infoDir = (0, import_node_path11.join)(resolvedCommonDir, "info");
|
|
17919
|
+
(0, import_node_fs10.mkdirSync)(infoDir, { recursive: true });
|
|
17920
|
+
const attrPath = (0, import_node_path11.join)(infoDir, "attributes");
|
|
17863
17921
|
let existing = "";
|
|
17864
17922
|
try {
|
|
17865
|
-
existing = (0,
|
|
17923
|
+
existing = (0, import_node_fs10.readFileSync)(attrPath, "utf-8");
|
|
17866
17924
|
} catch {
|
|
17867
17925
|
}
|
|
17868
17926
|
const existingLines = new Set(existing.split("\n").map((l) => l.trim()));
|
|
@@ -17871,7 +17929,7 @@ function configureHarnessMergeAttributes(repoRoot) {
|
|
|
17871
17929
|
);
|
|
17872
17930
|
if (missing.length === 0) return;
|
|
17873
17931
|
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
17874
|
-
(0,
|
|
17932
|
+
(0, import_node_fs10.appendFileSync)(attrPath, `${prefix}${missing.join("\n")}
|
|
17875
17933
|
`, "utf-8");
|
|
17876
17934
|
}
|
|
17877
17935
|
function checkMergeConflicts(workerBranch, baseBranch, repoRoot) {
|
|
@@ -17971,13 +18029,13 @@ function mergeWorkerBranch(workerBranch, baseBranch, repoRoot) {
|
|
|
17971
18029
|
};
|
|
17972
18030
|
}
|
|
17973
18031
|
}
|
|
17974
|
-
var import_node_child_process4,
|
|
18032
|
+
var import_node_child_process4, import_node_fs10, import_node_path11, BRANCH_NAME_RE, HARNESS_MERGE_PATHS;
|
|
17975
18033
|
var init_merge_coordinator = __esm({
|
|
17976
18034
|
"src/team/merge-coordinator.ts"() {
|
|
17977
18035
|
"use strict";
|
|
17978
18036
|
import_node_child_process4 = require("node:child_process");
|
|
17979
|
-
|
|
17980
|
-
|
|
18037
|
+
import_node_fs10 = require("node:fs");
|
|
18038
|
+
import_node_path11 = require("node:path");
|
|
17981
18039
|
init_git_worktree();
|
|
17982
18040
|
BRANCH_NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9/_.-]*$/;
|
|
17983
18041
|
HARNESS_MERGE_PATHS = ["AGENTS.md", ".claude/**"];
|
|
@@ -18270,10 +18328,10 @@ var init_worker_commit_cadence = __esm({
|
|
|
18270
18328
|
|
|
18271
18329
|
// src/team/merge-orchestrator.ts
|
|
18272
18330
|
function mergerWorktreePathFor(repoRoot, teamName) {
|
|
18273
|
-
return (0,
|
|
18331
|
+
return (0, import_node_path12.join)(getOmcRoot(repoRoot), "team", sanitizeName(teamName), "merger");
|
|
18274
18332
|
}
|
|
18275
18333
|
function persistedStatePath(repoRoot, teamName) {
|
|
18276
|
-
return (0,
|
|
18334
|
+
return (0, import_node_path12.join)(
|
|
18277
18335
|
getOmcRoot(repoRoot),
|
|
18278
18336
|
"state",
|
|
18279
18337
|
"team",
|
|
@@ -18282,7 +18340,7 @@ function persistedStatePath(repoRoot, teamName) {
|
|
|
18282
18340
|
);
|
|
18283
18341
|
}
|
|
18284
18342
|
function teardownAuditPath(repoRoot, teamName) {
|
|
18285
|
-
return (0,
|
|
18343
|
+
return (0, import_node_path12.join)(
|
|
18286
18344
|
getOmcRoot(repoRoot),
|
|
18287
18345
|
"state",
|
|
18288
18346
|
"team",
|
|
@@ -18291,7 +18349,7 @@ function teardownAuditPath(repoRoot, teamName) {
|
|
|
18291
18349
|
);
|
|
18292
18350
|
}
|
|
18293
18351
|
function orchestratorEventLogPath(repoRoot, teamName) {
|
|
18294
|
-
return (0,
|
|
18352
|
+
return (0, import_node_path12.join)(
|
|
18295
18353
|
getOmcRoot(repoRoot),
|
|
18296
18354
|
"state",
|
|
18297
18355
|
"team",
|
|
@@ -18312,7 +18370,7 @@ function assertRuntimeV2Gate() {
|
|
|
18312
18370
|
}
|
|
18313
18371
|
async function appendEvent(repoRoot, teamName, event) {
|
|
18314
18372
|
const path5 = orchestratorEventLogPath(repoRoot, teamName);
|
|
18315
|
-
await (0, import_promises16.mkdir)((0,
|
|
18373
|
+
await (0, import_promises16.mkdir)((0, import_node_path12.dirname)(path5), { recursive: true });
|
|
18316
18374
|
const full = {
|
|
18317
18375
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18318
18376
|
team: teamName,
|
|
@@ -18348,10 +18406,10 @@ function gitPath(worktreePath, gitPathName) {
|
|
|
18348
18406
|
if (resolved) return resolved;
|
|
18349
18407
|
} catch {
|
|
18350
18408
|
}
|
|
18351
|
-
return (0,
|
|
18409
|
+
return (0, import_node_path12.join)(worktreePath, ".git", gitPathName);
|
|
18352
18410
|
}
|
|
18353
18411
|
function isRebaseInProgress(worktreePath) {
|
|
18354
|
-
return (0,
|
|
18412
|
+
return (0, import_node_fs11.existsSync)(gitPath(worktreePath, "rebase-merge"));
|
|
18355
18413
|
}
|
|
18356
18414
|
function isWorktreeRegistered(repoRoot, wtPath) {
|
|
18357
18415
|
try {
|
|
@@ -18371,8 +18429,8 @@ function isWorktreeRegistered(repoRoot, wtPath) {
|
|
|
18371
18429
|
return false;
|
|
18372
18430
|
}
|
|
18373
18431
|
function ensureMergerWorktree(repoRoot, mergerPath, leaderBranch) {
|
|
18374
|
-
ensureDirWithMode((0,
|
|
18375
|
-
if ((0,
|
|
18432
|
+
ensureDirWithMode((0, import_node_path12.dirname)(mergerPath));
|
|
18433
|
+
if ((0, import_node_fs11.existsSync)(mergerPath) && isWorktreeRegistered(repoRoot, mergerPath)) {
|
|
18376
18434
|
return;
|
|
18377
18435
|
}
|
|
18378
18436
|
(0, import_node_child_process5.execFileSync)("git", ["worktree", "add", "--force", mergerPath, leaderBranch], {
|
|
@@ -18412,13 +18470,13 @@ async function startMergeOrchestrator(config) {
|
|
|
18412
18470
|
const pollIntervalMs = config.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS2;
|
|
18413
18471
|
const drainTimeoutMs = config.drainTimeoutMs ?? DEFAULT_DRAIN_TIMEOUT_MS;
|
|
18414
18472
|
const mergerPath = mergerWorktreePathFor(config.repoRoot, config.teamName);
|
|
18415
|
-
validateResolvedPath(mergerPath, (0,
|
|
18473
|
+
validateResolvedPath(mergerPath, (0, import_node_path12.join)(getOmcRoot(config.repoRoot), "team"));
|
|
18416
18474
|
ensureMergerWorktree(config.repoRoot, mergerPath, config.leaderBranch);
|
|
18417
18475
|
await ensureLeaderInbox(config.teamName, config.cwd);
|
|
18418
18476
|
configureHarnessMergeAttributes(config.repoRoot);
|
|
18419
18477
|
const persistedPath = persistedStatePath(config.repoRoot, config.teamName);
|
|
18420
18478
|
let persisted = { lastShas: {} };
|
|
18421
|
-
if ((0,
|
|
18479
|
+
if ((0, import_node_fs11.existsSync)(persistedPath)) {
|
|
18422
18480
|
try {
|
|
18423
18481
|
const { readFileSync: readFileSync31 } = await import("node:fs");
|
|
18424
18482
|
persisted = JSON.parse(readFileSync31(persistedPath, "utf-8"));
|
|
@@ -18824,7 +18882,7 @@ ${dirtyFiles.map((f) => `- \`${f}\``).join("\n")}`;
|
|
|
18824
18882
|
} catch {
|
|
18825
18883
|
}
|
|
18826
18884
|
const auditPath = teardownAuditPath(config.repoRoot, config.teamName);
|
|
18827
|
-
await (0, import_promises16.mkdir)((0,
|
|
18885
|
+
await (0, import_promises16.mkdir)((0, import_node_path12.dirname)(auditPath), { recursive: true });
|
|
18828
18886
|
for (const u of unmerged) {
|
|
18829
18887
|
const row = JSON.stringify({
|
|
18830
18888
|
type: "unmerged_at_shutdown",
|
|
@@ -18864,7 +18922,7 @@ ${unmerged.map((u) => `- ${u.workerName}: ${u.reason}`).join("\n")}`;
|
|
|
18864
18922
|
async function recoverFromRestart(config) {
|
|
18865
18923
|
const persistedPath = persistedStatePath(config.repoRoot, config.teamName);
|
|
18866
18924
|
let persistedShasLoaded = 0;
|
|
18867
|
-
if ((0,
|
|
18925
|
+
if ((0, import_node_fs11.existsSync)(persistedPath)) {
|
|
18868
18926
|
try {
|
|
18869
18927
|
const { readFileSync: readFileSync31 } = await import("node:fs");
|
|
18870
18928
|
const persisted = JSON.parse(readFileSync31(persistedPath, "utf-8"));
|
|
@@ -18910,14 +18968,14 @@ Cadence resumes once the git rebase state is gone.`;
|
|
|
18910
18968
|
}
|
|
18911
18969
|
return { orphanedRebases, persistedShasLoaded };
|
|
18912
18970
|
}
|
|
18913
|
-
var import_node_child_process5,
|
|
18971
|
+
var import_node_child_process5, import_node_fs11, import_promises16, import_node_path12, liveServiceOwners, DEFAULT_POLL_INTERVAL_MS2, DEFAULT_DRAIN_TIMEOUT_MS, UNMERGED_STATUS;
|
|
18914
18972
|
var init_merge_orchestrator = __esm({
|
|
18915
18973
|
"src/team/merge-orchestrator.ts"() {
|
|
18916
18974
|
"use strict";
|
|
18917
18975
|
import_node_child_process5 = require("node:child_process");
|
|
18918
|
-
|
|
18976
|
+
import_node_fs11 = require("node:fs");
|
|
18919
18977
|
import_promises16 = require("node:fs/promises");
|
|
18920
|
-
|
|
18978
|
+
import_node_path12 = require("node:path");
|
|
18921
18979
|
init_fs_utils();
|
|
18922
18980
|
init_worktree_paths();
|
|
18923
18981
|
init_runtime_flags();
|
|
@@ -18946,32 +19004,32 @@ function sdkPaneId(workerName) {
|
|
|
18946
19004
|
return `${SDK_TARGET_PREFIX}${workerName}`;
|
|
18947
19005
|
}
|
|
18948
19006
|
function sdkWorkerFiles(stateRoot, workerName) {
|
|
18949
|
-
const dir = (0,
|
|
19007
|
+
const dir = (0, import_node_path13.join)(stateRoot, "workers", workerName);
|
|
18950
19008
|
return {
|
|
18951
19009
|
dir,
|
|
18952
|
-
spec: (0,
|
|
18953
|
-
doorbell: (0,
|
|
18954
|
-
session: (0,
|
|
18955
|
-
probe: (0,
|
|
18956
|
-
events: (0,
|
|
18957
|
-
log: (0,
|
|
18958
|
-
home: (0,
|
|
18959
|
-
bin: (0,
|
|
18960
|
-
shutdownAck: (0,
|
|
19010
|
+
spec: (0, import_node_path13.join)(dir, "sdk-host-spec.json"),
|
|
19011
|
+
doorbell: (0, import_node_path13.join)(dir, "sdk-doorbell.jsonl"),
|
|
19012
|
+
session: (0, import_node_path13.join)(dir, "sdk-session.json"),
|
|
19013
|
+
probe: (0, import_node_path13.join)(dir, "sdk-probe.json"),
|
|
19014
|
+
events: (0, import_node_path13.join)(dir, "sdk-events.jsonl"),
|
|
19015
|
+
log: (0, import_node_path13.join)(dir, "sdk-host.log"),
|
|
19016
|
+
home: (0, import_node_path13.join)(dir, "copilot-home"),
|
|
19017
|
+
bin: (0, import_node_path13.join)(dir, "bin"),
|
|
19018
|
+
shutdownAck: (0, import_node_path13.join)(dir, "shutdown-ack.json")
|
|
18961
19019
|
};
|
|
18962
19020
|
}
|
|
18963
19021
|
function ringDoorbell(stateRoot, workerName, entry) {
|
|
18964
19022
|
const files = sdkWorkerFiles(stateRoot, workerName);
|
|
18965
|
-
(0,
|
|
19023
|
+
(0, import_node_fs12.mkdirSync)(files.dir, { recursive: true });
|
|
18966
19024
|
const id = entry.id ?? (0, import_node_crypto9.randomUUID)();
|
|
18967
19025
|
const line = { ...entry, id, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18968
|
-
(0,
|
|
19026
|
+
(0, import_node_fs12.appendFileSync)(files.doorbell, `${JSON.stringify(line)}
|
|
18969
19027
|
`);
|
|
18970
19028
|
return id;
|
|
18971
19029
|
}
|
|
18972
19030
|
function readSdkSession(stateRoot, workerName) {
|
|
18973
19031
|
try {
|
|
18974
|
-
const parsed = JSON.parse((0,
|
|
19032
|
+
const parsed = JSON.parse((0, import_node_fs12.readFileSync)(sdkWorkerFiles(stateRoot, workerName).session, "utf8"));
|
|
18975
19033
|
return parsed && parsed.schema_version === 1 ? parsed : null;
|
|
18976
19034
|
} catch {
|
|
18977
19035
|
return null;
|
|
@@ -18990,8 +19048,8 @@ function hostCredentialHandoff(env) {
|
|
|
18990
19048
|
`;
|
|
18991
19049
|
}
|
|
18992
19050
|
function spawnDetachedHost(cliPath, specPath, logPath, cwd, env = process.env) {
|
|
18993
|
-
(0,
|
|
18994
|
-
const fd = (0,
|
|
19051
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path13.dirname)(logPath), { recursive: true });
|
|
19052
|
+
const fd = (0, import_node_fs12.openSync)(logPath, "a");
|
|
18995
19053
|
try {
|
|
18996
19054
|
const child = (0, import_node_child_process6.spawn)(process.execPath, [cliPath, "team", "sdk-host", "--spec", specPath], {
|
|
18997
19055
|
cwd,
|
|
@@ -19005,7 +19063,7 @@ function spawnDetachedHost(cliPath, specPath, logPath, cwd, env = process.env) {
|
|
|
19005
19063
|
child.unref();
|
|
19006
19064
|
return child.pid;
|
|
19007
19065
|
} finally {
|
|
19008
|
-
(0,
|
|
19066
|
+
(0, import_node_fs12.closeSync)(fd);
|
|
19009
19067
|
}
|
|
19010
19068
|
}
|
|
19011
19069
|
async function launchSdkHost(input) {
|
|
@@ -19022,8 +19080,8 @@ async function launchSdkHost(input) {
|
|
|
19022
19080
|
context: { kind: "initial" }
|
|
19023
19081
|
});
|
|
19024
19082
|
const files = sdkWorkerFiles(input.stateRoot, input.workerName);
|
|
19025
|
-
(0,
|
|
19026
|
-
const cliPath = (0,
|
|
19083
|
+
(0, import_node_fs12.mkdirSync)(files.dir, { recursive: true });
|
|
19084
|
+
const cliPath = (0, import_node_path13.join)((0, import_node_path13.dirname)(runtimeCliPath), "cli.cjs");
|
|
19027
19085
|
const spec = {
|
|
19028
19086
|
schema_version: 1,
|
|
19029
19087
|
leader_cwd: input.leaderCwd,
|
|
@@ -19048,9 +19106,9 @@ async function launchSdkHost(input) {
|
|
|
19048
19106
|
user_config_dir: input.userConfigDir,
|
|
19049
19107
|
...input.inProcessTools ? { in_process_tools: true } : {}
|
|
19050
19108
|
};
|
|
19051
|
-
(0,
|
|
19109
|
+
(0, import_node_fs12.writeFileSync)(files.spec, `${JSON.stringify(spec, null, 2)}
|
|
19052
19110
|
`);
|
|
19053
|
-
(0,
|
|
19111
|
+
(0, import_node_fs12.writeFileSync)(files.doorbell, "");
|
|
19054
19112
|
const hostPid = (input.spawnHost ?? spawnDetachedHost)(cliPath, files.spec, files.log, input.workerCwd);
|
|
19055
19113
|
const kill = async () => {
|
|
19056
19114
|
if (hostPid && isProcessAlive(hostPid)) await killProcessTree(hostPid, "SIGKILL").catch(() => void 0);
|
|
@@ -19065,7 +19123,7 @@ async function launchSdkHost(input) {
|
|
|
19065
19123
|
for (; ; ) {
|
|
19066
19124
|
const sliceMs = Math.max(1, Math.min(1e3, startDeadline - Date.now()));
|
|
19067
19125
|
if (await awaitWorkerLaunchProviderStarted(attempt, { timeoutMs: sliceMs })) break;
|
|
19068
|
-
const exited = (0,
|
|
19126
|
+
const exited = (0, import_node_fs12.existsSync)(`${attempt.startedPath}.terminal`) || (0, import_node_fs12.existsSync)(`${attempt.decisionPath}.retired`) || hostPid !== void 0 && !isProcessAlive(hostPid);
|
|
19069
19127
|
if (exited || failedThisAttempt(attempt, input.stateRoot)) {
|
|
19070
19128
|
const graceUntil = Date.now() + SDK_LAUNCH_FAILURE_GRACE_MS;
|
|
19071
19129
|
while (!failedThisAttempt(attempt, input.stateRoot) && Date.now() < graceUntil) {
|
|
@@ -19073,7 +19131,7 @@ async function launchSdkHost(input) {
|
|
|
19073
19131
|
}
|
|
19074
19132
|
await kill();
|
|
19075
19133
|
const error = (failedThisAttempt(attempt, input.stateRoot) ? readSdkSession(input.stateRoot, input.workerName)?.last_error : null) ?? "unknown";
|
|
19076
|
-
const phase = (0,
|
|
19134
|
+
const phase = (0, import_node_fs12.existsSync)(attempt.startedPath) ? "at_start" : "before_start";
|
|
19077
19135
|
return { ok: false, attempt, reason: `sdk_host_failed_${phase}:${error}`, ...hostPid ? { hostPid } : {} };
|
|
19078
19136
|
}
|
|
19079
19137
|
if (Date.now() >= startDeadline) {
|
|
@@ -19090,7 +19148,7 @@ async function isTargetGone(target) {
|
|
|
19090
19148
|
return liveness === "dead" || liveness === "mismatch";
|
|
19091
19149
|
}
|
|
19092
19150
|
function failedBeforeProviderStarted(attempt, stateRoot) {
|
|
19093
|
-
return !(0,
|
|
19151
|
+
return !(0, import_node_fs12.existsSync)(attempt.startedPath) && failedThisAttempt(attempt, stateRoot);
|
|
19094
19152
|
}
|
|
19095
19153
|
function failedThisAttempt(attempt, stateRoot) {
|
|
19096
19154
|
const session = readSdkSession(stateRoot, attempt.worker_name);
|
|
@@ -19130,7 +19188,7 @@ async function stopSdkHost(attempt, stateRoot, opts = {}) {
|
|
|
19130
19188
|
}
|
|
19131
19189
|
function readStartedRecord(attempt) {
|
|
19132
19190
|
try {
|
|
19133
|
-
const record = JSON.parse((0,
|
|
19191
|
+
const record = JSON.parse((0, import_node_fs12.readFileSync)(attempt.startedPath, "utf8"));
|
|
19134
19192
|
return typeof record.pid === "number" && record.pid > 0 && typeof record.process_start_identity === "string" ? { pid: record.pid, process_start_identity: record.process_start_identity } : null;
|
|
19135
19193
|
} catch {
|
|
19136
19194
|
return null;
|
|
@@ -19138,9 +19196,9 @@ function readStartedRecord(attempt) {
|
|
|
19138
19196
|
}
|
|
19139
19197
|
function writeTerminationComplete(attempt, pid, startIdentity) {
|
|
19140
19198
|
const path5 = `${attempt.startedPath}.termination-complete`;
|
|
19141
|
-
if ((0,
|
|
19199
|
+
if ((0, import_node_fs12.existsSync)(path5)) return;
|
|
19142
19200
|
try {
|
|
19143
|
-
(0,
|
|
19201
|
+
(0, import_node_fs12.writeFileSync)(path5, JSON.stringify({
|
|
19144
19202
|
schema_version: attempt.schema_version,
|
|
19145
19203
|
attempt_id: attempt.attempt_id,
|
|
19146
19204
|
nonce: attempt.nonce,
|
|
@@ -19160,14 +19218,14 @@ function writeTerminationComplete(attempt, pid, startIdentity) {
|
|
|
19160
19218
|
} catch {
|
|
19161
19219
|
}
|
|
19162
19220
|
}
|
|
19163
|
-
var import_node_child_process6, import_node_crypto9,
|
|
19221
|
+
var import_node_child_process6, import_node_crypto9, import_node_fs12, import_node_path13, SDK_TARGET_PREFIX, SDK_LAUNCH_POLL_MS, SDK_LAUNCH_FAILURE_GRACE_MS, HOST_CREDENTIAL_ENV, SDK_HOST_STOP_FLOOR_MS;
|
|
19164
19222
|
var init_sdk_transport = __esm({
|
|
19165
19223
|
"src/team/sdk-transport.ts"() {
|
|
19166
19224
|
"use strict";
|
|
19167
19225
|
import_node_child_process6 = require("node:child_process");
|
|
19168
19226
|
import_node_crypto9 = require("node:crypto");
|
|
19169
|
-
|
|
19170
|
-
|
|
19227
|
+
import_node_fs12 = require("node:fs");
|
|
19228
|
+
import_node_path13 = require("node:path");
|
|
19171
19229
|
init_process_utils();
|
|
19172
19230
|
init_copilot_session_env();
|
|
19173
19231
|
init_runtime_owner_client();
|
|
@@ -19312,7 +19370,7 @@ var init_recovery_saga = __esm({
|
|
|
19312
19370
|
|
|
19313
19371
|
// src/team/worker-activation-gate.ts
|
|
19314
19372
|
async function writeAtomic3(path5, value) {
|
|
19315
|
-
await (0, import_promises18.mkdir)((0,
|
|
19373
|
+
await (0, import_promises18.mkdir)((0, import_node_path14.dirname)(path5), { recursive: true });
|
|
19316
19374
|
const temporary = `${path5}.tmp.${process.pid}.${Date.now()}`;
|
|
19317
19375
|
await (0, import_promises18.writeFile)(temporary, JSON.stringify(value), "utf8");
|
|
19318
19376
|
await (0, import_promises18.rename)(temporary, path5);
|
|
@@ -19570,13 +19628,13 @@ async function runWorkerActivationGate(gate) {
|
|
|
19570
19628
|
}
|
|
19571
19629
|
return fenced.value;
|
|
19572
19630
|
}
|
|
19573
|
-
var import_node_child_process7, import_promises18,
|
|
19631
|
+
var import_node_child_process7, import_promises18, import_node_path14;
|
|
19574
19632
|
var init_worker_activation_gate = __esm({
|
|
19575
19633
|
"src/team/worker-activation-gate.ts"() {
|
|
19576
19634
|
"use strict";
|
|
19577
19635
|
import_node_child_process7 = require("node:child_process");
|
|
19578
19636
|
import_promises18 = require("node:fs/promises");
|
|
19579
|
-
|
|
19637
|
+
import_node_path14 = require("node:path");
|
|
19580
19638
|
init_worker_launch_ack();
|
|
19581
19639
|
init_process_utils();
|
|
19582
19640
|
}
|
|
@@ -19863,6 +19921,7 @@ var init_exec = __esm({
|
|
|
19863
19921
|
"use strict";
|
|
19864
19922
|
import_child_process9 = require("child_process");
|
|
19865
19923
|
init_guard();
|
|
19924
|
+
init_windows_search();
|
|
19866
19925
|
TRUSTED_READ_ENV = Object.freeze({ GIT_NO_REPLACE_OBJECTS: "1" });
|
|
19867
19926
|
}
|
|
19868
19927
|
});
|
|
@@ -19891,9 +19950,9 @@ var init_config2 = __esm({
|
|
|
19891
19950
|
"Socket Security: Pull Request Alerts",
|
|
19892
19951
|
"Socket Security: Project Report"
|
|
19893
19952
|
],
|
|
19894
|
-
// Every check this repo's CI reports on a PR to dev (ci.yml, pr-check.yml
|
|
19895
|
-
//
|
|
19896
|
-
// ci.yml
|
|
19953
|
+
// Every check this repo's CI reports on a PR to dev (ci.yml, pr-check.yml);
|
|
19954
|
+
// the jobs that consume the Build output start late (`needs: [build]`).
|
|
19955
|
+
// ci.yml runs only for PRs to main / dev
|
|
19897
19956
|
// (`pull_request.branches`): on a PR to another base their checks never
|
|
19898
19957
|
// report and stay pending, so such a base needs its own requiredChecks in
|
|
19899
19958
|
// the user config.
|
|
@@ -19985,6 +20044,7 @@ var init_sandbox = __esm({
|
|
|
19985
20044
|
init_copilot_session_env();
|
|
19986
20045
|
init_sdk_policy();
|
|
19987
20046
|
init_jsonc();
|
|
20047
|
+
init_windows_search();
|
|
19988
20048
|
DEFAULT_SANDBOX_SETTINGS = Object.freeze({
|
|
19989
20049
|
enabled: true,
|
|
19990
20050
|
reviewUnsandboxed: "no-shell",
|
|
@@ -20045,7 +20105,7 @@ var init_version = __esm({
|
|
|
20045
20105
|
});
|
|
20046
20106
|
|
|
20047
20107
|
// src/smoke/replay/redact.ts
|
|
20048
|
-
function userHomePatterns(win, pct,
|
|
20108
|
+
function userHomePatterns(win, pct, posix2, posixFlags) {
|
|
20049
20109
|
return [
|
|
20050
20110
|
// The separator spelling is captured once, so `\n` after an escaped `\\` is not taken for a tail separator.
|
|
20051
20111
|
// `\` doubles per JSON level, so any run of backslashes is a separator. The one after `Users` may be either
|
|
@@ -20054,7 +20114,7 @@ function userHomePatterns(win, pct, posix, posixFlags) {
|
|
|
20054
20114
|
// Percent-encoded (`file:///c%3A/Users/...`, `C%3A%5CUsers%5C...`, `%2Fhome%2Fname`).
|
|
20055
20115
|
new RegExp(String.raw`(?<head>(?:\b[A-Za-z]%3A${PCT_SEP}Users|%2F(?:home|Users))${PCT_SEP}(?!<user>)${pct})(?:${PCT_SEP}${PCT_SEG})*`, "gi"),
|
|
20056
20116
|
// POSIX, Git Bash (`/c/Users/...`) and WSL (`/mnt/c/Users/...`).
|
|
20057
|
-
new RegExp(String.raw`(?<head>(?<![\w.$}-])\/(?:home|Users|(?:mnt\/)?[A-Za-z]\/Users)\/(?!<user>)${
|
|
20117
|
+
new RegExp(String.raw`(?<head>(?<![\w.$}-])\/(?:home|Users|(?:mnt\/)?[A-Za-z]\/Users)\/(?!<user>)${posix2})(?:\/${POSIX_SEG})*`, posixFlags)
|
|
20058
20118
|
];
|
|
20059
20119
|
}
|
|
20060
20120
|
function knownUserHomePatterns(user) {
|