@joshuafolkken/kit 1.1383.0 → 1.1435.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/epic-commands/SKILL.md +1 -1
- package/.claude/skills/epic-commands/epic-bundle.md +5 -0
- package/.claude/skills/workflow-commands/backlogrun-lanes.md +5 -3
- package/.claude/skills/workflow-commands/backlogrun-steps.md +4 -3
- package/.claude/skills/workflow-commands/backlogrun.md +1 -0
- package/.claude/skills/workflow-commands/chain-rule.md +4 -2
- package/.claude/skills/workflow-commands/issue-comments.md +6 -0
- package/.claude/skills/workflow-commands/observation-ledger.md +3 -2
- package/.claude/skills/workflow-commands/pre-gate-cut.md +5 -3
- package/README.md +25 -0
- package/dist/hooks/audit-provision.js +2 -2
- package/dist/hooks/batch-guard.js +7 -7
- package/dist/hooks/{chunk-LOJTBU5V.js → chunk-2G5F2YCD.js} +3 -3
- package/dist/hooks/{chunk-4MGHBTOM.js → chunk-3LE6VLSR.js} +25 -8
- package/dist/hooks/{chunk-Y5R47QHU.js → chunk-4BHUPFKF.js} +1 -1
- package/dist/hooks/{chunk-KC6LUZZ2.js → chunk-5SJSSCJG.js} +1 -1
- package/dist/hooks/{chunk-FZ6FUSBM.js → chunk-723HKZO5.js} +1 -1
- package/dist/hooks/{chunk-RYP3TSUJ.js → chunk-7KMN5QB5.js} +3 -3
- package/dist/hooks/{chunk-NEC4AT4Z.js → chunk-DGT54IH5.js} +4 -0
- package/dist/hooks/{chunk-YKUITFT7.js → chunk-EMB55BDF.js} +4 -4
- package/dist/hooks/{chunk-JBBMAPC4.js → chunk-IX6TTTI6.js} +4 -0
- package/dist/hooks/{chunk-6MAW7BCM.js → chunk-JXQBK323.js} +2677 -190
- package/dist/hooks/{chunk-KCF2YE7O.js → chunk-MSYSUSY6.js} +5 -5
- package/dist/hooks/{chunk-LC56R53A.js → chunk-MU4LJFIV.js} +4 -4
- package/dist/hooks/{chunk-7VSZ2N4B.js → chunk-QL6QTPWN.js} +3 -3
- package/dist/hooks/{chunk-TT742SIO.js → chunk-XER6SSIB.js} +92 -19
- package/dist/hooks/{chunk-2X2ART5G.js → chunk-YW452ZAX.js} +500 -29
- package/dist/hooks/{chunk-6AC4C2IO.js → chunk-YZXYOAZ3.js} +187 -443
- package/dist/hooks/codex-hook-adapter.js +15 -15
- package/dist/hooks/duplicate-read-guard.js +8 -8
- package/dist/hooks/format-edited.js +5 -5
- package/dist/hooks/inputs.json +262 -201
- package/dist/hooks/investigation-guard.js +8 -8
- package/dist/hooks/pretool-guard.js +14 -14
- package/dist/hooks/session-lang.js +124 -15
- package/dist/hooks/stop-guard.js +98 -55
- package/dist/josh.js +63 -10
- package/package.json +4 -3
- package/prompts/review.md +22 -0
- package/scripts/agent/claude-agent-argv.ts +13 -1
- package/scripts/auth/auth-setup-cli.ts +101 -0
- package/scripts/auth/claude-token-output.ts +78 -0
- package/scripts/auth/claude-token.ts +68 -0
- package/scripts/backlog/backlog-drive-cli.ts +2 -4
- package/scripts/backlog/backlog-drive-epic.ts +24 -8
- package/scripts/backlog/backlog-drive-launch.ts +5 -0
- package/scripts/backlog/backlog-drive-named-offer.ts +7 -2
- package/scripts/backlog/backlog-drive-named.ts +4 -2
- package/scripts/backlog/backlog-drive-owner.ts +72 -5
- package/scripts/backlog/backlog-drive-unread.ts +56 -0
- package/scripts/backlog/backlog-drive.ts +16 -8
- package/scripts/backlog/backlog-overlap.ts +22 -5
- package/scripts/backlog/backlog-ready.ts +1 -3
- package/scripts/backlog/backlogrun-args.ts +13 -2
- package/scripts/backlog/backlogrun-cli.ts +91 -19
- package/scripts/backlog/backlogrun-launch.ts +80 -5
- package/scripts/backlog/backlogrun-replace.ts +166 -0
- package/scripts/backlog/backlogrun-stop.ts +178 -0
- package/scripts/behavior/behavior-cli.ts +6 -1
- package/scripts/doctor/doctor-io.ts +60 -9
- package/scripts/doctor/doctor.ts +20 -1
- package/scripts/document/document-byte-budget.ts +3 -3
- package/scripts/epic/epic-bundle-cli.ts +8 -8
- package/scripts/epic/epic-bundle-referenced.ts +2 -5
- package/scripts/epic/epic-bundle.ts +39 -4
- package/scripts/exports/unused-members-cli.ts +2 -1
- package/scripts/followup/followup-checks-event.ts +82 -0
- package/scripts/followup/git-followup-finish.ts +16 -2
- package/scripts/followup/git-followup-workflow.ts +5 -2
- package/scripts/followup/git-pr-followup-checks.ts +18 -4
- package/scripts/followup/git-pr-followup-wrapup.ts +5 -0
- package/scripts/followup/git-pr-followup.ts +4 -1
- package/scripts/fresh-machine/fresh-machine-cli.ts +204 -0
- package/scripts/fresh-machine/fresh-machine-docker.ts +65 -0
- package/scripts/fresh-machine/fresh-machine-image.ts +62 -0
- package/scripts/fresh-machine/fresh-machine-log.ts +61 -0
- package/scripts/fresh-machine/fresh-machine-patterns.ts +130 -0
- package/scripts/fresh-machine/fresh-machine-run.ts +215 -0
- package/scripts/fresh-machine/fresh-machine-script.ts +45 -0
- package/scripts/fresh-machine/fresh-machine-spec.ts +57 -0
- package/scripts/fresh-machine/specs/kit-test-backlogrun-python.json +34 -0
- package/scripts/fresh-machine/specs/kit-test-backlogrun.json +31 -0
- package/scripts/gate/gate-report.ts +70 -15
- package/scripts/gate/project-checks.ts +13 -2
- package/scripts/gate/scoped-green.ts +2 -1
- package/scripts/gate/verification-gate.ts +4 -3
- package/scripts/gh/gh-author-association.ts +14 -0
- package/scripts/gh/git-gh-conditional.ts +66 -0
- package/scripts/gh/git-gh-exec.ts +1 -1
- package/scripts/gh/git-gh-issue-read.ts +6 -3
- package/scripts/gh/git-gh-issue-write.ts +5 -1
- package/scripts/gh/git-gh-issue.ts +4 -1
- package/scripts/gh/git-pr-checks-eval.ts +13 -0
- package/scripts/gh/git-pr-checks-parse.ts +8 -1
- package/scripts/gh/git-pr-checks-watch.ts +11 -4
- package/scripts/gh/git-pr-checks.ts +36 -2
- package/scripts/git/git-command.ts +16 -4
- package/scripts/git/git-schemas.ts +1 -0
- package/scripts/git/git-spawn-sync.ts +1 -1
- package/scripts/hooks/pretool-guard.ts +3 -1
- package/scripts/init/hook-command-rewrite.ts +31 -0
- package/scripts/init/init-actions.ts +4 -1
- package/scripts/init/init-ai-copy.ts +33 -10
- package/scripts/init/init-basic.ts +8 -3
- package/scripts/init/init-logic-toolchain.ts +76 -0
- package/scripts/init/init-logic.ts +2 -0
- package/scripts/init/init.ts +5 -23
- package/scripts/init/project-profile.ts +36 -7
- package/scripts/init/start-exec.ts +27 -1
- package/scripts/init/start-plan.ts +30 -4
- package/scripts/init/start-steps.ts +77 -3
- package/scripts/init/start.ts +21 -13
- package/scripts/init/workflow-mark.ts +35 -0
- package/scripts/issue/issue-ack-cli.ts +84 -0
- package/scripts/issue/issue-labels.ts +40 -8
- package/scripts/issue/issue-state-cli.ts +14 -4
- package/scripts/issue/issue-watch-diff.ts +152 -0
- package/scripts/issue/issue-watch-gate.ts +81 -0
- package/scripts/issue/issue-watch-hook.ts +54 -0
- package/scripts/issue/issue-watch.ts +240 -0
- package/scripts/issue/measure-rerun-cli.ts +3 -4
- package/scripts/josh/josh-command-map.ts +4 -0
- package/scripts/josh/josh-commands-backlog.ts +2 -2
- package/scripts/josh/josh-commands-development.ts +1 -1
- package/scripts/josh/josh-commands-issue.ts +7 -0
- package/scripts/josh/josh-commands-lane.ts +11 -2
- package/scripts/josh/josh-commands-project.ts +25 -1
- package/scripts/josh/josh-verdict.ts +33 -4
- package/scripts/lane/claude-lane-broker.ts +142 -0
- package/scripts/lane/lane-await.ts +6 -2
- package/scripts/lane/lane-cache.ts +37 -7
- package/scripts/lane/lane-capacity.ts +8 -6
- package/scripts/lane/lane-child-invocation.ts +1 -0
- package/scripts/lane/lane-cli.ts +15 -1
- package/scripts/lane/lane-close.ts +15 -6
- package/scripts/lane/lane-dispatch.ts +36 -10
- package/scripts/lane/lane-environment.ts +1 -1
- package/scripts/lane/lane-launch-cli.ts +13 -4
- package/scripts/lane/lane-ledger.ts +21 -3
- package/scripts/lane/lane-measure-cli.ts +10 -2
- package/scripts/lane/lane-open.ts +9 -1
- package/scripts/lane/lane-preserve.ts +49 -0
- package/scripts/lane/lane-reap.ts +20 -5
- package/scripts/lane/lane-registry.ts +6 -0
- package/scripts/lane/lane-restart-cli.ts +51 -0
- package/scripts/lane/lane-restart.ts +175 -0
- package/scripts/lane/{openai-review-broker.ts → lane-session-broker.ts} +106 -28
- package/scripts/lane/lane-spent.ts +195 -0
- package/scripts/lane/lane-stage-stats.ts +27 -3
- package/scripts/lane/lane-stop-stats.ts +96 -0
- package/scripts/lane/openai-lane-supervisor.ts +2 -2
- package/scripts/lane/process-tools.ts +31 -0
- package/scripts/lib/buffered-process.ts +36 -2
- package/scripts/lib/pnpm-reach.ts +27 -0
- package/scripts/lib/status-icons.ts +5 -1
- package/scripts/lint/lint-parallel.ts +19 -2
- package/scripts/observations/observation-ledger-home.ts +1 -0
- package/scripts/review/review-attest-cli.ts +21 -6
- package/scripts/review/review-brief-cli.ts +2 -2
- package/scripts/review/review-comment-round.ts +114 -0
- package/scripts/review/review-record-cli.ts +39 -17
- package/scripts/rules/implementation-cut.ts +3 -3
- package/scripts/rules/pre-gate-cut.ts +1 -1
- package/scripts/run/board/run-board-checks.ts +42 -0
- package/scripts/run/board/run-board-cli.ts +2 -0
- package/scripts/run/board/run-board-every.ts +3 -1
- package/scripts/run/board/run-board-fit.ts +16 -5
- package/scripts/run/board/run-board-fresh.ts +64 -0
- package/scripts/run/board/run-board-header.ts +139 -37
- package/scripts/run/board/run-board-labels.ts +47 -4
- package/scripts/run/board/run-board-lane-event.ts +66 -0
- package/scripts/run/board/run-board-layout.ts +57 -9
- package/scripts/run/board/run-board-now.ts +234 -0
- package/scripts/run/board/run-board-operation-read.ts +75 -0
- package/scripts/run/board/run-board-operation.ts +150 -0
- package/scripts/run/board/run-board-phase.ts +26 -1
- package/scripts/run/board/run-board-plan.ts +4 -6
- package/scripts/run/board/run-board-read.ts +58 -5
- package/scripts/run/board/run-board-reason.ts +124 -0
- package/scripts/run/board/run-board-render-checks.ts +55 -0
- package/scripts/run/board/run-board-render-legend.ts +12 -3
- package/scripts/run/board/run-board-render-slot.ts +2 -2
- package/scripts/run/board/run-board-render-tail.ts +128 -0
- package/scripts/run/board/run-board-render-thanks.ts +50 -0
- package/scripts/run/board/run-board-render-title.ts +58 -0
- package/scripts/run/board/run-board-render.ts +96 -80
- package/scripts/run/board/run-board-row-yield.ts +32 -0
- package/scripts/run/board/run-board-setup.ts +121 -0
- package/scripts/run/board/run-board-span.ts +49 -7
- package/scripts/run/board/run-board-state.ts +10 -0
- package/scripts/run/board/run-board-status.ts +76 -13
- package/scripts/run/board/run-board-thanks-csv.ts +71 -0
- package/scripts/run/board/run-board-thanks-read.ts +112 -0
- package/scripts/run/board/run-board-thanks.ts +53 -0
- package/scripts/run/board/run-board-tick.ts +53 -16
- package/scripts/run/board/run-board-usual.ts +44 -0
- package/scripts/run/carry/run-carry-added.ts +1 -1
- package/scripts/run/carry/run-carry-args.ts +9 -1
- package/scripts/run/carry/run-carry-change.ts +1 -1
- package/scripts/run/carry/run-carry-cli.ts +39 -52
- package/scripts/run/carry/run-carry-end.ts +73 -0
- package/scripts/run/carry/run-carry-ended.ts +9 -1
- package/scripts/run/carry/run-carry.ts +24 -1
- package/scripts/run/entry/run-entry-cli.ts +5 -0
- package/scripts/run/event/run-event-checks.ts +54 -0
- package/scripts/run/event/run-event-render.ts +3 -0
- package/scripts/run/event/run-event-scope.ts +1 -0
- package/scripts/run/event/run-event-setup.ts +91 -0
- package/scripts/run/event/run-event-stream.ts +46 -9
- package/scripts/run/merge/run-merge-cli.ts +7 -4
- package/scripts/run/merge/run-merge-ship.ts +61 -0
- package/scripts/run/merge/run-merge-steps.ts +7 -14
- package/scripts/run/merge/run-merge-token.ts +16 -2
- package/scripts/run/run-headless.ts +1 -0
- package/scripts/run/run-step.ts +2 -0
- package/scripts/run/run-stranded-detect.ts +58 -12
- package/scripts/run/ship/run-ship-cli.ts +22 -2
- package/scripts/run/ship/run-ship-return.ts +31 -13
- package/scripts/run/ship/run-ship-review-steps.ts +17 -4
- package/scripts/run/ship/run-ship-stage.ts +1 -0
- package/scripts/run/wake/run-wake-await.ts +130 -0
- package/scripts/run/wake/run-wake-cli.ts +108 -74
- package/scripts/run/wake/run-wake-describe.ts +36 -2
- package/scripts/run/wake/run-wake-driver.ts +21 -5
- package/scripts/run/wake/run-wake-handoff.ts +1 -1
- package/scripts/run/wake/run-wake-session.ts +20 -3
- package/scripts/run/wake/run-wake-stop.ts +37 -0
- package/scripts/run/wake/run-wake-supervise.ts +44 -0
- package/scripts/sync/claude-settings-merge.ts +144 -0
- package/scripts/sync/sync-ai-files.ts +28 -3
- package/scripts/sync/sync.ts +15 -0
- package/scripts/test/project-test-script.ts +73 -0
- package/scripts/test/skip-marker.ts +14 -1
- package/scripts/test/test-related.ts +3 -2
- package/scripts/test/test-unit-guard.ts +78 -14
- package/scripts/time-runtime/time-reported-failure.ts +11 -3
- package/scripts/uninstall/distributed-files.ts +92 -0
- package/scripts/uninstall/uninstall-plan.ts +119 -0
- package/scripts/uninstall/uninstall-report.ts +61 -0
- package/scripts/uninstall/uninstall.ts +206 -0
- package/templates/AGENTS.basic.md +4 -0
- package/templates/GEMINI.basic.md +6 -0
- package/dist/hooks/chunk-6V5OPIUU.js +0 -13
- package/scripts/run/board/run-board-track.ts +0 -22
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
error_text
|
|
3
|
+
} from "./chunk-CDY4NFQG.js";
|
|
1
4
|
import {
|
|
2
5
|
lane_child_marker
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4BHUPFKF.js";
|
|
4
7
|
import {
|
|
5
8
|
ENV_FILE_NAME,
|
|
6
9
|
GIT_LOCATION_VARIABLES,
|
|
@@ -20,14 +23,14 @@ import {
|
|
|
20
23
|
process_identity,
|
|
21
24
|
process_owner_schema,
|
|
22
25
|
run_carry
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3LE6VLSR.js";
|
|
24
27
|
import {
|
|
25
28
|
INSTALL_TIMEOUT_MS,
|
|
26
29
|
PLATFORM_TEMP_ROOT,
|
|
27
30
|
PROBE_TIMEOUT_MS,
|
|
28
31
|
SUITE_TIMEOUT_MS,
|
|
29
32
|
stamp_file
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-DGT54IH5.js";
|
|
31
34
|
|
|
32
35
|
// scripts/agent/agent-headless.ts
|
|
33
36
|
var KEY = "JOSH_AGENT_HEADLESS";
|
|
@@ -40,6 +43,16 @@ function is_headless(source = process.env) {
|
|
|
40
43
|
}
|
|
41
44
|
var agent_headless = { KEY, environment, is_headless };
|
|
42
45
|
|
|
46
|
+
// scripts/josh/session-language.ts
|
|
47
|
+
var ENV_KEY = "JOSH_SESSION_LANG";
|
|
48
|
+
var DEFAULT_SESSION_LANG = "ja";
|
|
49
|
+
function resolve_session_lang() {
|
|
50
|
+
const value = process.env[ENV_KEY]?.trim();
|
|
51
|
+
if (value) return { lang: value, is_default: false };
|
|
52
|
+
return { lang: DEFAULT_SESSION_LANG, is_default: true };
|
|
53
|
+
}
|
|
54
|
+
var session_language = { DEFAULT_SESSION_LANG, ENV_KEY, resolve_session_lang };
|
|
55
|
+
|
|
43
56
|
// scripts/lane/lane-reap.ts
|
|
44
57
|
import { execFileSync } from "node:child_process";
|
|
45
58
|
|
|
@@ -213,6 +226,7 @@ function stop_reason(stage, conflicts = []) {
|
|
|
213
226
|
return conflicts.length > 0 ? CONFLICT : stage;
|
|
214
227
|
}
|
|
215
228
|
var run_ship_stage = {
|
|
229
|
+
CONFLICT,
|
|
216
230
|
PHASE,
|
|
217
231
|
STAGE,
|
|
218
232
|
clear,
|
|
@@ -316,6 +330,21 @@ var lane_child_invocation = {
|
|
|
316
330
|
ship_stop_invocation
|
|
317
331
|
};
|
|
318
332
|
|
|
333
|
+
// scripts/lane/process-tools.ts
|
|
334
|
+
import path from "node:path";
|
|
335
|
+
var NOT_FOUND_CODE = "ENOENT";
|
|
336
|
+
var PACKAGE_HINT = "install the package that provides it (procps on Debian/Ubuntu: `apt-get install procps`)";
|
|
337
|
+
function is_not_found(error) {
|
|
338
|
+
return error instanceof Error && "code" in error && error.code === NOT_FOUND_CODE;
|
|
339
|
+
}
|
|
340
|
+
function missing_notice(command) {
|
|
341
|
+
return `\`${path.basename(command)}\` is not installed \u2014 kit's lane commands read processes with ps and pgrep; ${PACKAGE_HINT}`;
|
|
342
|
+
}
|
|
343
|
+
function throw_if_missing(command, error) {
|
|
344
|
+
if (is_not_found(error)) throw new Error(missing_notice(command), { cause: error });
|
|
345
|
+
}
|
|
346
|
+
var process_tools = { missing_notice, throw_if_missing };
|
|
347
|
+
|
|
319
348
|
// scripts/lane/lane-reap.ts
|
|
320
349
|
var PGREP_COMMAND = "pgrep";
|
|
321
350
|
var MATCH_FULL_COMMAND_LINE = "-f";
|
|
@@ -334,7 +363,8 @@ function run_probe(command, args) {
|
|
|
334
363
|
timeout: PROBE_TIMEOUT_MS,
|
|
335
364
|
stdio: ["ignore", "pipe", "ignore"]
|
|
336
365
|
});
|
|
337
|
-
} catch {
|
|
366
|
+
} catch (error) {
|
|
367
|
+
process_tools.throw_if_missing(command, error);
|
|
338
368
|
return "";
|
|
339
369
|
}
|
|
340
370
|
}
|
|
@@ -380,14 +410,20 @@ function tree_of(roots, probes) {
|
|
|
380
410
|
}
|
|
381
411
|
return tree;
|
|
382
412
|
}
|
|
413
|
+
function roots_of(issue, own2, probes) {
|
|
414
|
+
const pattern = lane_child_invocation.process_pattern(issue);
|
|
415
|
+
return probes.matching(pattern).filter((pid) => !own2.has(pid));
|
|
416
|
+
}
|
|
383
417
|
function reap_child(issue, probes = SYSTEM_PROBES) {
|
|
384
418
|
const own2 = own_ancestry(probes);
|
|
385
|
-
const
|
|
386
|
-
const roots = probes.matching(pattern).filter((pid) => !own2.has(pid));
|
|
387
|
-
const doomed = tree_of(roots, probes).filter((pid) => !own2.has(pid));
|
|
419
|
+
const doomed = tree_of(roots_of(issue, own2, probes), probes).filter((pid) => !own2.has(pid));
|
|
388
420
|
return doomed.filter((pid) => probes.terminate(pid));
|
|
389
421
|
}
|
|
422
|
+
function is_child_running(issue, probes = SYSTEM_PROBES) {
|
|
423
|
+
return roots_of(issue, own_ancestry(probes), probes).length > 0;
|
|
424
|
+
}
|
|
390
425
|
var lane_reap = {
|
|
426
|
+
is_child_running,
|
|
391
427
|
own_ancestry,
|
|
392
428
|
parse_pids,
|
|
393
429
|
reap_child
|
|
@@ -395,11 +431,11 @@ var lane_reap = {
|
|
|
395
431
|
|
|
396
432
|
// scripts/lane/lane-registry.ts
|
|
397
433
|
import { existsSync as existsSync2 } from "node:fs";
|
|
398
|
-
import
|
|
434
|
+
import path3 from "node:path";
|
|
399
435
|
|
|
400
436
|
// scripts/discovery/repo-discovery.ts
|
|
401
437
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
402
|
-
import
|
|
438
|
+
import path2 from "node:path";
|
|
403
439
|
|
|
404
440
|
// scripts/discovery/repo-origin.ts
|
|
405
441
|
var GITHUB_HOST = "github.com";
|
|
@@ -546,10 +582,10 @@ var GITDIR_PREFIX = "gitdir:";
|
|
|
546
582
|
var COMMON_DIRECTORY_FILE = "commondir";
|
|
547
583
|
var OVERRIDE_ENV_KEY = "JOSH_REPO_PATHS";
|
|
548
584
|
function resolve_common_directory(git_directory) {
|
|
549
|
-
const pointer =
|
|
585
|
+
const pointer = path2.join(git_directory, COMMON_DIRECTORY_FILE);
|
|
550
586
|
if (!existsSync(pointer)) return git_directory;
|
|
551
587
|
try {
|
|
552
|
-
return
|
|
588
|
+
return path2.resolve(git_directory, readFileSync(pointer, "utf8").trim());
|
|
553
589
|
} catch {
|
|
554
590
|
return git_directory;
|
|
555
591
|
}
|
|
@@ -557,10 +593,10 @@ function resolve_common_directory(git_directory) {
|
|
|
557
593
|
function follow_git_file(repository_path, git_file) {
|
|
558
594
|
const pointer = readFileSync(git_file, "utf8").trim();
|
|
559
595
|
if (!pointer.startsWith(GITDIR_PREFIX)) return void 0;
|
|
560
|
-
return
|
|
596
|
+
return path2.resolve(repository_path, pointer.slice(GITDIR_PREFIX.length).trim());
|
|
561
597
|
}
|
|
562
598
|
function resolve_git_directory(repository_path) {
|
|
563
|
-
const candidate =
|
|
599
|
+
const candidate = path2.join(repository_path, GIT_DIRECTORY);
|
|
564
600
|
if (!existsSync(candidate)) return void 0;
|
|
565
601
|
try {
|
|
566
602
|
if (statSync(candidate).isDirectory()) return candidate;
|
|
@@ -574,7 +610,7 @@ function read_config(repository_path) {
|
|
|
574
610
|
const git_directory = resolve_git_directory(repository_path);
|
|
575
611
|
if (git_directory === void 0) return void 0;
|
|
576
612
|
try {
|
|
577
|
-
return readFileSync(
|
|
613
|
+
return readFileSync(path2.join(git_directory, GIT_CONFIG), "utf8");
|
|
578
614
|
} catch {
|
|
579
615
|
return void 0;
|
|
580
616
|
}
|
|
@@ -589,7 +625,7 @@ function read_remote_urls(repository_path) {
|
|
|
589
625
|
}
|
|
590
626
|
function sibling_directories(parent) {
|
|
591
627
|
try {
|
|
592
|
-
return readdirSync(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
628
|
+
return readdirSync(parent, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path2.join(parent, entry.name)).toSorted((left, right) => left.localeCompare(right));
|
|
593
629
|
} catch {
|
|
594
630
|
return [];
|
|
595
631
|
}
|
|
@@ -608,15 +644,15 @@ function resolve_current_owner(repository_path) {
|
|
|
608
644
|
function main_worktree(repository_path) {
|
|
609
645
|
const git_directory = resolve_git_directory(repository_path);
|
|
610
646
|
if (git_directory === void 0) return repository_path;
|
|
611
|
-
if (
|
|
612
|
-
return
|
|
647
|
+
if (path2.basename(git_directory) !== GIT_DIRECTORY) return repository_path;
|
|
648
|
+
return path2.dirname(git_directory);
|
|
613
649
|
}
|
|
614
650
|
function discover_repositories(repository_path, environment3 = process.env) {
|
|
615
651
|
const main = main_worktree(repository_path);
|
|
616
652
|
const current_owner = resolve_current_owner(main);
|
|
617
653
|
if (current_owner === void 0) return /* @__PURE__ */ new Map();
|
|
618
654
|
return repo_map_logic.build_repository_map(
|
|
619
|
-
scan_siblings(
|
|
655
|
+
scan_siblings(path2.dirname(main)),
|
|
620
656
|
current_owner,
|
|
621
657
|
environment3[OVERRIDE_ENV_KEY]
|
|
622
658
|
);
|
|
@@ -1182,7 +1218,7 @@ function held_seat(content) {
|
|
|
1182
1218
|
return seat_from_content(content) ?? EMPTY_SEAT;
|
|
1183
1219
|
}
|
|
1184
1220
|
function read_environment(directory) {
|
|
1185
|
-
return file_reader.read_if_readable(
|
|
1221
|
+
return file_reader.read_if_readable(path3.join(directory, ENV_FILE_NAME));
|
|
1186
1222
|
}
|
|
1187
1223
|
function branch_issue(branch) {
|
|
1188
1224
|
if (!branch?.endsWith(lane_paths.LANE_BRANCH_SUFFIX)) return void 0;
|
|
@@ -1245,6 +1281,9 @@ async function has_lanes_in_flight() {
|
|
|
1245
1281
|
const lanes = await list_lanes();
|
|
1246
1282
|
return lanes.some((lane) => !lane.is_stranded);
|
|
1247
1283
|
}
|
|
1284
|
+
function live_count(lanes) {
|
|
1285
|
+
return lanes.filter((lane) => !lane.is_stranded).length;
|
|
1286
|
+
}
|
|
1248
1287
|
function used_seats(lanes) {
|
|
1249
1288
|
return lanes.map((lane) => lane.seat).filter((seat) => seat !== void 0);
|
|
1250
1289
|
}
|
|
@@ -1262,6 +1301,7 @@ var lane_registry = {
|
|
|
1262
1301
|
find_open_lane,
|
|
1263
1302
|
has_lanes_in_flight,
|
|
1264
1303
|
list_lanes,
|
|
1304
|
+
live_count,
|
|
1265
1305
|
main_repository_root,
|
|
1266
1306
|
parse_block,
|
|
1267
1307
|
read_environment,
|
|
@@ -1323,17 +1363,446 @@ var run_headless = {
|
|
|
1323
1363
|
is_backlog_parent,
|
|
1324
1364
|
is_cut_capped,
|
|
1325
1365
|
is_headless: is_headless2,
|
|
1366
|
+
is_headless_parent,
|
|
1326
1367
|
is_owned_here,
|
|
1327
1368
|
must_keep_waiting
|
|
1328
1369
|
};
|
|
1329
1370
|
|
|
1371
|
+
// scripts/run/event/run-event-stream.ts
|
|
1372
|
+
import { z as z3 } from "zod";
|
|
1373
|
+
var EVENT_PREFIX = "josh-run-events-";
|
|
1374
|
+
var EVENT_SUFFIX = ".jsonl";
|
|
1375
|
+
var EVENT_CAP = 500;
|
|
1376
|
+
var FIRST_POSITION = 0;
|
|
1377
|
+
var POSITION_INCREMENT = 1;
|
|
1378
|
+
var LINE_SEPARATOR = "\n";
|
|
1379
|
+
var WORD_SEPARATOR2 = " ";
|
|
1380
|
+
var STAGE_PHASE_INDEX = 2;
|
|
1381
|
+
var LOCK_SUFFIX = ".lock";
|
|
1382
|
+
var LOCK_WAIT_MS = 5e3;
|
|
1383
|
+
var EVENT_KIND = {
|
|
1384
|
+
PLAN: "plan",
|
|
1385
|
+
CHILD_LAUNCH: "child-launch",
|
|
1386
|
+
MERGE: "merge",
|
|
1387
|
+
PARK: "park",
|
|
1388
|
+
SPLIT: "split",
|
|
1389
|
+
OUTAGE: "outage",
|
|
1390
|
+
CUT: "cut",
|
|
1391
|
+
// A fresh session adopted an implementation cut — `run:cut --resume` answered `resume-impl`. The
|
|
1392
|
+
// resume clears the cut record, so without this the `cut` would stay the newest position and
|
|
1393
|
+
// `run:step` would keep answering the resume command it had just run.
|
|
1394
|
+
RESUME: "resume",
|
|
1395
|
+
// A person stopped a running lane child and re-dispatched its issue in a fresh session
|
|
1396
|
+
// (`lane:restart`). It follows the fresh dispatch's `CHILD_LAUNCH`, so it is a launch to the parent and
|
|
1397
|
+
// the board, and — like that launch — a batch record a lane child never reads as its own position.
|
|
1398
|
+
RESTART: "restart",
|
|
1399
|
+
// The backlog emptied while nothing of the run's own was in flight — the drain. It marks the position
|
|
1400
|
+
// at which the end-of-run retrospective is owed, *before* the idle watch opens, so `run:step` fires
|
|
1401
|
+
// the retrospective at the drain rather than after the watch runs its course. It is not itself a
|
|
1402
|
+
// stop: the run watches on once the retrospective has run, and the real `STOP` follows when the watch
|
|
1403
|
+
// expires.
|
|
1404
|
+
DRAIN: "drain",
|
|
1405
|
+
STOP: "stop",
|
|
1406
|
+
PR_OPENED: "pr-opened",
|
|
1407
|
+
REVIEW_ROUND: "review-round",
|
|
1408
|
+
// The end-of-run retrospective's result, recorded when the run marks the retrospective done. A
|
|
1409
|
+
// retrospective that files zero improvements and one that never ran look
|
|
1410
|
+
// the same from outside — no new Issue either way — so the result is put on the stream the report is
|
|
1411
|
+
// generated from: the issues filed (or that none were), and the candidates dropped with why. It is
|
|
1412
|
+
// emitted from the `run:carry --retrospective` close, so marking the retrospective done and recording
|
|
1413
|
+
// what it found are one action rather than two the run could do only one of.
|
|
1414
|
+
RETROSPECTIVE: "retrospective",
|
|
1415
|
+
// Ready backlog work is sitting undispatched while a lane is free and nothing has dispatched for a
|
|
1416
|
+
// while. Emitted once per stall episode by the stop-time detector, it is both the dedup marker —
|
|
1417
|
+
// `emit_once_since` refuses a second until a `CHILD_LAUNCH` intervenes — and the line a terminal
|
|
1418
|
+
// reader following the stream sees. `run:step` reads it as `backlog:next`, so a run that
|
|
1419
|
+
// stalled is pointed straight at dispatching the work rather than left waiting.
|
|
1420
|
+
STALL: "stall",
|
|
1421
|
+
// The run's own driver is gone: the cut handed the budget off, the owner has died, and no supervisor
|
|
1422
|
+
// is watching. Emitted once per strand episode by the stop-time detector — or by the `run:wake`
|
|
1423
|
+
// supervisor as it fails, leaves that state behind and has warned of it —
|
|
1424
|
+
// exactly as `STALL` is — the newest-event dedup keeps a run polled every stop from notifying more
|
|
1425
|
+
// than once, and a terminal reader following the stream sees the line. The strand is the step before
|
|
1426
|
+
// the stall: a stalled run still has a driver that could dispatch, a stranded one has none.
|
|
1427
|
+
STRANDED: "stranded",
|
|
1428
|
+
// One `josh ship` stage starting, succeeding or failing. It is a trace of the
|
|
1429
|
+
// composite's progress rather than a position the run is at — the positions a ship leaves behind are
|
|
1430
|
+
// the closed issue its `followup` merges, or a detached supervisor's `SHIP_LAUNCH` / `SHIP_STOP` below
|
|
1431
|
+
// — so it is one of the `TRACE_KINDS` the last-event read skips.
|
|
1432
|
+
SHIP_STAGE: "ship-stage",
|
|
1433
|
+
// One progress watcher line — the `at … / next …` heartbeat `run:progress` prints. Printed only to
|
|
1434
|
+
// the watcher's own output, a headless successor's heartbeat would be buried in its log after a cut;
|
|
1435
|
+
// on the stream it reaches the attached session's relay. It says
|
|
1436
|
+
// the run is alive rather than where it is, so it is a trace kind like `SHIP_STAGE`.
|
|
1437
|
+
HEARTBEAT: "heartbeat",
|
|
1438
|
+
// The post-implementation region handed to a detached `josh ship --detach` supervisor. Unlike a stage
|
|
1439
|
+
// trace it is a position: the agent has ended and the
|
|
1440
|
+
// supervisor carries the run, so `run:step` answers `wait` until it stops or the issue closes.
|
|
1441
|
+
SHIP_LAUNCH: "ship-launch",
|
|
1442
|
+
// The supervisor stopped at a failed stage — a red gate, a High/Medium review, a failed push, red CI
|
|
1443
|
+
// The position that hands control back: `run:step` prints the command that
|
|
1444
|
+
// shows the stopped report, so the agent fixes it and relaunches rather than rebuilding the context.
|
|
1445
|
+
SHIP_STOP: "ship-stop",
|
|
1446
|
+
// An Issue the run filed on its way, written by `issue:file`, so a run started from the command line
|
|
1447
|
+
// still surfaces what it found — `run:board`'s findings section reads it.
|
|
1448
|
+
FILED: "filed",
|
|
1449
|
+
// A one-line observation short of an Issue, written with `run:event --append note` and shown in the
|
|
1450
|
+
// same section.
|
|
1451
|
+
NOTE: "note",
|
|
1452
|
+
// A lane child reached a phase no other event marks — its first implementation edit, written by the
|
|
1453
|
+
// PreToolUse hook — so `run:board` draws how far the child has got. A trace,
|
|
1454
|
+
// like `SHIP_STAGE`: it says where the child's work is, not where the run is.
|
|
1455
|
+
LANE_PHASE: "lane-phase",
|
|
1456
|
+
// An issue `run:add` put into the live run. The parent's `--wait` watcher
|
|
1457
|
+
// ends on it, so the issue takes the next free lane without waiting out the arrival probe's minute. A
|
|
1458
|
+
// trace: it says what the run was handed, not where the run is.
|
|
1459
|
+
ADD: "add",
|
|
1460
|
+
// `josh lane:limit` raised a live run's lane limit. The `--wait` watcher's
|
|
1461
|
+
// arrival probe reads it as a wake: the lanes a raise frees are new room for a pool its baseline
|
|
1462
|
+
// already holds. A trace: it says the run gained room, not where the run is.
|
|
1463
|
+
LANE_LIMIT: "lane-limit",
|
|
1464
|
+
// One stage of the run's start — the session starting, the plan, the hand-off to the supervisor, a
|
|
1465
|
+
// lane opening (`run-event-setup.ts`). `run:board` draws it while the run stands at it, so the
|
|
1466
|
+
// minutes before one read as work rather than as a run that has stopped. A trace: it says the run is
|
|
1467
|
+
// getting ready, not where the run is.
|
|
1468
|
+
SETUP: "setup",
|
|
1469
|
+
// A child's pull request checks as `josh followup` last polled them — the CI counts and CodeRabbit's
|
|
1470
|
+
// state (`run-event-checks.ts`), written only when they change, so `run:board` draws a child waiting
|
|
1471
|
+
// in followup without asking GitHub (joshuafolkken/kit#3770). A trace: it says how the checks stand,
|
|
1472
|
+
// not where the run is.
|
|
1473
|
+
PR_CHECKS: "pr-checks"
|
|
1474
|
+
};
|
|
1475
|
+
var EVENT_KINDS = Object.values(EVENT_KIND);
|
|
1476
|
+
var TRACE_KINDS = /* @__PURE__ */ new Set([
|
|
1477
|
+
EVENT_KIND.SHIP_STAGE,
|
|
1478
|
+
EVENT_KIND.HEARTBEAT,
|
|
1479
|
+
EVENT_KIND.FILED,
|
|
1480
|
+
EVENT_KIND.NOTE,
|
|
1481
|
+
EVENT_KIND.LANE_PHASE,
|
|
1482
|
+
EVENT_KIND.ADD,
|
|
1483
|
+
EVENT_KIND.LANE_LIMIT,
|
|
1484
|
+
EVENT_KIND.SETUP,
|
|
1485
|
+
EVENT_KIND.PR_CHECKS
|
|
1486
|
+
]);
|
|
1487
|
+
var DISPOSABLE_KINDS = /* @__PURE__ */ new Set([
|
|
1488
|
+
EVENT_KIND.SHIP_STAGE,
|
|
1489
|
+
EVENT_KIND.HEARTBEAT,
|
|
1490
|
+
EVENT_KIND.SETUP,
|
|
1491
|
+
EVENT_KIND.PR_CHECKS
|
|
1492
|
+
]);
|
|
1493
|
+
var event_schema = z3.object({
|
|
1494
|
+
pos: z3.number(),
|
|
1495
|
+
at: z3.string(),
|
|
1496
|
+
kind: z3.string(),
|
|
1497
|
+
text: z3.string()
|
|
1498
|
+
});
|
|
1499
|
+
function is_event_kind(value) {
|
|
1500
|
+
return EVENT_KINDS.includes(value);
|
|
1501
|
+
}
|
|
1502
|
+
function target_of(repository2) {
|
|
1503
|
+
return stamp_file.stamp_path(EVENT_PREFIX, repository2, EVENT_SUFFIX);
|
|
1504
|
+
}
|
|
1505
|
+
function is_present(event) {
|
|
1506
|
+
return event !== void 0;
|
|
1507
|
+
}
|
|
1508
|
+
function parse_line(line) {
|
|
1509
|
+
return event_schema.safeParse(json_value.parse_or_undefined(line)).data;
|
|
1510
|
+
}
|
|
1511
|
+
function read_lines(target) {
|
|
1512
|
+
const raw = stamp_file.read_stamp_text(target);
|
|
1513
|
+
if (raw === void 0) return [];
|
|
1514
|
+
return raw.split(LINE_SEPARATOR).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => parse_line(line)).filter(is_present);
|
|
1515
|
+
}
|
|
1516
|
+
function read_events(target) {
|
|
1517
|
+
return read_lines(target).filter((event) => is_event_kind(event.kind));
|
|
1518
|
+
}
|
|
1519
|
+
function last_position(events) {
|
|
1520
|
+
return events[events.length - POSITION_INCREMENT]?.pos ?? FIRST_POSITION;
|
|
1521
|
+
}
|
|
1522
|
+
function issue_of(event) {
|
|
1523
|
+
return event.text.split(WORD_SEPARATOR2)[FIRST_POSITION] ?? "";
|
|
1524
|
+
}
|
|
1525
|
+
function newest_by_issue(events, kind) {
|
|
1526
|
+
const newest = /* @__PURE__ */ new Map();
|
|
1527
|
+
for (const event of events) {
|
|
1528
|
+
if (event.kind === kind) newest.set(issue_of(event), event);
|
|
1529
|
+
}
|
|
1530
|
+
return new Set(newest.values());
|
|
1531
|
+
}
|
|
1532
|
+
function is_stage_start(event) {
|
|
1533
|
+
if (event.kind !== EVENT_KIND.SHIP_STAGE) return false;
|
|
1534
|
+
return event.text.split(WORD_SEPARATOR2)[STAGE_PHASE_INDEX] === run_ship_stage.PHASE.START;
|
|
1535
|
+
}
|
|
1536
|
+
function drawn_lines(events) {
|
|
1537
|
+
const setup = events.findLast((event) => event.kind === EVENT_KIND.SETUP);
|
|
1538
|
+
return /* @__PURE__ */ new Set([
|
|
1539
|
+
...newest_by_issue(events, EVENT_KIND.SHIP_STAGE),
|
|
1540
|
+
...newest_by_issue(events, EVENT_KIND.PR_CHECKS),
|
|
1541
|
+
...setup === void 0 ? [] : [setup]
|
|
1542
|
+
]);
|
|
1543
|
+
}
|
|
1544
|
+
function droppable(events) {
|
|
1545
|
+
const kept = drawn_lines(events);
|
|
1546
|
+
const disposable = events.filter((event) => DISPOSABLE_KINDS.has(event.kind) && !kept.has(event));
|
|
1547
|
+
return [
|
|
1548
|
+
...disposable.filter((event) => !is_stage_start(event)),
|
|
1549
|
+
...disposable.filter((event) => is_stage_start(event))
|
|
1550
|
+
];
|
|
1551
|
+
}
|
|
1552
|
+
function bounded(events) {
|
|
1553
|
+
const excess = events.length - EVENT_CAP;
|
|
1554
|
+
if (excess <= 0) return events;
|
|
1555
|
+
const dropped = new Set(droppable(events).slice(0, excess));
|
|
1556
|
+
return events.filter((event) => !dropped.has(event)).slice(-EVENT_CAP);
|
|
1557
|
+
}
|
|
1558
|
+
function serialize(events) {
|
|
1559
|
+
return `${events.map((event) => JSON.stringify(event)).join(LINE_SEPARATOR)}${LINE_SEPARATOR}`;
|
|
1560
|
+
}
|
|
1561
|
+
function append_held(target, event) {
|
|
1562
|
+
const position = last_position(read_lines(target)) + POSITION_INCREMENT;
|
|
1563
|
+
const events = bounded([...read_events(target), { pos: position, ...event }]);
|
|
1564
|
+
stamp_file.replace_text_stamp(target, serialize(events));
|
|
1565
|
+
return position;
|
|
1566
|
+
}
|
|
1567
|
+
function append(target, kind, text, at) {
|
|
1568
|
+
if (!is_event_kind(kind)) return { appended: false, position: FIRST_POSITION };
|
|
1569
|
+
const lock = `${target}${LOCK_SUFFIX}`;
|
|
1570
|
+
const position = repository_lock.with_lock_sync(
|
|
1571
|
+
() => append_held(target, { at, kind, text }),
|
|
1572
|
+
lock,
|
|
1573
|
+
LOCK_WAIT_MS
|
|
1574
|
+
);
|
|
1575
|
+
if (position === void 0) {
|
|
1576
|
+
const message = `run event stream: gave up waiting for the lock at ${lock}`;
|
|
1577
|
+
process.stderr.write(`${message}
|
|
1578
|
+
`);
|
|
1579
|
+
throw new Error(message);
|
|
1580
|
+
}
|
|
1581
|
+
return { appended: true, position };
|
|
1582
|
+
}
|
|
1583
|
+
function read_from(target, position) {
|
|
1584
|
+
const events = read_events(target);
|
|
1585
|
+
return {
|
|
1586
|
+
events: events.filter((event) => event.pos > position),
|
|
1587
|
+
next_position: last_position(events)
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function read_last(target) {
|
|
1591
|
+
return read_events(target).findLast((event) => !TRACE_KINDS.has(event.kind));
|
|
1592
|
+
}
|
|
1593
|
+
function has_since(events, kind, reset_kind) {
|
|
1594
|
+
const reset_at = events.findLastIndex((event) => event.kind === reset_kind);
|
|
1595
|
+
return events.slice(reset_at + POSITION_INCREMENT).some((event) => event.kind === kind);
|
|
1596
|
+
}
|
|
1597
|
+
var FIELD_SEPARATOR = " \xB7 ";
|
|
1598
|
+
function format_event(event) {
|
|
1599
|
+
return [event.at, event.kind, event.text].join(FIELD_SEPARATOR);
|
|
1600
|
+
}
|
|
1601
|
+
var run_event_stream = {
|
|
1602
|
+
EVENT_CAP,
|
|
1603
|
+
EVENT_KIND,
|
|
1604
|
+
EVENT_KINDS,
|
|
1605
|
+
TRACE_KINDS,
|
|
1606
|
+
append,
|
|
1607
|
+
format_event,
|
|
1608
|
+
has_since,
|
|
1609
|
+
is_stage_start,
|
|
1610
|
+
read_events,
|
|
1611
|
+
read_from,
|
|
1612
|
+
read_last,
|
|
1613
|
+
target_of
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
// scripts/run/event/run-event-scope.ts
|
|
1617
|
+
var SINCE_SCOPE = "since";
|
|
1618
|
+
var UNKNOWN_SCOPE = "unknown";
|
|
1619
|
+
var UNKNOWN_EVENT_SCOPE = { kind: UNKNOWN_SCOPE };
|
|
1620
|
+
function moment_of(at) {
|
|
1621
|
+
const parsed = Date.parse(at);
|
|
1622
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
1623
|
+
}
|
|
1624
|
+
function is_within(event, floor) {
|
|
1625
|
+
const at = moment_of(event.at);
|
|
1626
|
+
return at !== void 0 && at >= floor;
|
|
1627
|
+
}
|
|
1628
|
+
function scoped_events(events, scope) {
|
|
1629
|
+
if (scope.kind === UNKNOWN_SCOPE) return void 0;
|
|
1630
|
+
const floor = moment_of(scope.started_at);
|
|
1631
|
+
if (floor === void 0) return void 0;
|
|
1632
|
+
return events.filter((event) => is_within(event, floor));
|
|
1633
|
+
}
|
|
1634
|
+
function scope_of(read) {
|
|
1635
|
+
if (read.kind !== "carried") return UNKNOWN_EVENT_SCOPE;
|
|
1636
|
+
return { kind: SINCE_SCOPE, started_at: read.carry.started_at };
|
|
1637
|
+
}
|
|
1638
|
+
function last_scoped_event(events, scope) {
|
|
1639
|
+
return scoped_events(events, scope)?.findLast(
|
|
1640
|
+
(event) => !run_event_stream.TRACE_KINDS.has(event.kind)
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
var SHIP_POSITION_KINDS = /* @__PURE__ */ new Set([
|
|
1644
|
+
run_event_stream.EVENT_KIND.SHIP_LAUNCH,
|
|
1645
|
+
run_event_stream.EVENT_KIND.SHIP_STOP
|
|
1646
|
+
]);
|
|
1647
|
+
var KIND = run_event_stream.EVENT_KIND;
|
|
1648
|
+
var BATCH_RECORD_KINDS = /* @__PURE__ */ new Set([
|
|
1649
|
+
KIND.CHILD_LAUNCH,
|
|
1650
|
+
KIND.RESTART,
|
|
1651
|
+
KIND.PARK,
|
|
1652
|
+
KIND.SPLIT,
|
|
1653
|
+
KIND.RETROSPECTIVE,
|
|
1654
|
+
KIND.STRANDED
|
|
1655
|
+
]);
|
|
1656
|
+
var ISSUE_REFERENCE = /#(\d+)/u;
|
|
1657
|
+
function is_foreign_ship_event(event, issue) {
|
|
1658
|
+
return SHIP_POSITION_KINDS.has(event.kind) && !event.text.startsWith(`${issue_cite.plain(issue)} `);
|
|
1659
|
+
}
|
|
1660
|
+
function is_own_ship_event(event, issue) {
|
|
1661
|
+
return SHIP_POSITION_KINDS.has(event.kind) && !is_foreign_ship_event(event, issue);
|
|
1662
|
+
}
|
|
1663
|
+
function issue_named(event) {
|
|
1664
|
+
return ISSUE_REFERENCE.exec(event.text)?.[1];
|
|
1665
|
+
}
|
|
1666
|
+
function names_issue(event, issue) {
|
|
1667
|
+
return issue_named(event) === issue;
|
|
1668
|
+
}
|
|
1669
|
+
function is_lane_position(event, issue) {
|
|
1670
|
+
return !BATCH_RECORD_KINDS.has(event.kind) && names_issue(event, issue);
|
|
1671
|
+
}
|
|
1672
|
+
function since_own_launch(events, issue) {
|
|
1673
|
+
const launch2 = events.findLastIndex(
|
|
1674
|
+
(event) => event.kind === KIND.CHILD_LAUNCH && names_issue(event, issue)
|
|
1675
|
+
);
|
|
1676
|
+
return events.slice(launch2 + 1);
|
|
1677
|
+
}
|
|
1678
|
+
function is_foreign_event(event, issue, is_lane_child) {
|
|
1679
|
+
if (is_lane_child) return !is_lane_position(event, issue);
|
|
1680
|
+
return is_foreign_ship_event(event, issue);
|
|
1681
|
+
}
|
|
1682
|
+
function last_issue_event(events, scope, issue, is_lane_child) {
|
|
1683
|
+
const attempt = is_lane_child ? since_own_launch(events, issue) : events;
|
|
1684
|
+
const own2 = attempt.filter((event) => !is_foreign_event(event, issue, is_lane_child));
|
|
1685
|
+
if (scope.kind === SINCE_SCOPE) return last_scoped_event(own2, scope);
|
|
1686
|
+
return own2.findLast((event) => is_own_ship_event(event, issue));
|
|
1687
|
+
}
|
|
1688
|
+
var LAUNCH_OR_SETTLE_KINDS = /* @__PURE__ */ new Set([
|
|
1689
|
+
KIND.CHILD_LAUNCH,
|
|
1690
|
+
KIND.MERGE,
|
|
1691
|
+
KIND.PARK,
|
|
1692
|
+
KIND.SPLIT
|
|
1693
|
+
]);
|
|
1694
|
+
function is_merge_owed(events, scope, issue) {
|
|
1695
|
+
const newest = (scoped_events(events, scope) ?? []).findLast(
|
|
1696
|
+
(event) => LAUNCH_OR_SETTLE_KINDS.has(event.kind) && names_issue(event, issue)
|
|
1697
|
+
);
|
|
1698
|
+
return newest?.kind === KIND.CHILD_LAUNCH;
|
|
1699
|
+
}
|
|
1700
|
+
var run_event_scope = {
|
|
1701
|
+
UNKNOWN_EVENT_SCOPE,
|
|
1702
|
+
is_merge_owed,
|
|
1703
|
+
issue_named,
|
|
1704
|
+
last_issue_event,
|
|
1705
|
+
last_scoped_event,
|
|
1706
|
+
moment_of,
|
|
1707
|
+
scope_of,
|
|
1708
|
+
scoped_events,
|
|
1709
|
+
since_own_launch
|
|
1710
|
+
};
|
|
1711
|
+
|
|
1712
|
+
// scripts/run/event/run-event-stream-emit.ts
|
|
1713
|
+
function now_iso() {
|
|
1714
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1715
|
+
}
|
|
1716
|
+
async function stream_target() {
|
|
1717
|
+
const repository2 = await run_carry.repository_directory();
|
|
1718
|
+
return repository2 === void 0 ? void 0 : run_event_stream.target_of(repository2);
|
|
1719
|
+
}
|
|
1720
|
+
async function emit(kind, text) {
|
|
1721
|
+
try {
|
|
1722
|
+
const target = await stream_target();
|
|
1723
|
+
if (target === void 0) return;
|
|
1724
|
+
run_event_stream.append(target, kind, text, now_iso());
|
|
1725
|
+
} catch {
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
async function emit_once(kind, text) {
|
|
1729
|
+
try {
|
|
1730
|
+
const target = await stream_target();
|
|
1731
|
+
if (target === void 0 || run_event_stream.read_last(target)?.kind === kind) return false;
|
|
1732
|
+
return run_event_stream.append(target, kind, text, now_iso()).appended;
|
|
1733
|
+
} catch (error) {
|
|
1734
|
+
error_text.trace_swallowed("run_event_stream_emit.emit_once", error);
|
|
1735
|
+
return false;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
function invocation_events(repository2, target) {
|
|
1739
|
+
const events = run_event_stream.read_events(target);
|
|
1740
|
+
const scope = run_event_scope.scope_of(run_carry.read_carry(run_carry.carry_path(repository2)));
|
|
1741
|
+
return run_event_scope.scoped_events(events, scope) ?? events;
|
|
1742
|
+
}
|
|
1743
|
+
async function emit_once_since(kind, text, reset_kind) {
|
|
1744
|
+
try {
|
|
1745
|
+
const repository2 = await run_carry.repository_directory();
|
|
1746
|
+
if (repository2 === void 0) return false;
|
|
1747
|
+
const target = run_event_stream.target_of(repository2);
|
|
1748
|
+
if (run_event_stream.has_since(invocation_events(repository2, target), kind, reset_kind)) {
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
return run_event_stream.append(target, kind, text, now_iso()).appended;
|
|
1752
|
+
} catch (error) {
|
|
1753
|
+
error_text.trace_swallowed("run_event_stream_emit.emit_once_since", error);
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
async function emit_heartbeat(line) {
|
|
1758
|
+
await emit(run_event_stream.EVENT_KIND.HEARTBEAT, line);
|
|
1759
|
+
}
|
|
1760
|
+
async function current_events() {
|
|
1761
|
+
try {
|
|
1762
|
+
const repository2 = await run_carry.repository_directory();
|
|
1763
|
+
if (repository2 === void 0) return [];
|
|
1764
|
+
const read = run_carry.read_carry(run_carry.carry_path(repository2));
|
|
1765
|
+
const scope = run_event_scope.scope_of(read);
|
|
1766
|
+
const events = run_event_stream.read_events(run_event_stream.target_of(repository2));
|
|
1767
|
+
return run_event_scope.scoped_events(events, scope) ?? [];
|
|
1768
|
+
} catch {
|
|
1769
|
+
return [];
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
async function invocation_or_all_events() {
|
|
1773
|
+
try {
|
|
1774
|
+
const repository2 = await run_carry.repository_directory();
|
|
1775
|
+
return repository2 === void 0 ? [] : invocation_events(repository2, run_event_stream.target_of(repository2));
|
|
1776
|
+
} catch {
|
|
1777
|
+
return [];
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
async function all_events() {
|
|
1781
|
+
try {
|
|
1782
|
+
const target = await stream_target();
|
|
1783
|
+
return target === void 0 ? [] : run_event_stream.read_events(target);
|
|
1784
|
+
} catch {
|
|
1785
|
+
return [];
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
var run_event_stream_emit = {
|
|
1789
|
+
all_events,
|
|
1790
|
+
current_events,
|
|
1791
|
+
emit,
|
|
1792
|
+
emit_heartbeat,
|
|
1793
|
+
emit_once,
|
|
1794
|
+
emit_once_since,
|
|
1795
|
+
invocation_or_all_events,
|
|
1796
|
+
stream_target
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1330
1799
|
// scripts/run/detached-launch.ts
|
|
1331
1800
|
import { spawn } from "node:child_process";
|
|
1332
1801
|
import { closeSync, constants, openSync, writeSync } from "node:fs";
|
|
1333
1802
|
|
|
1334
1803
|
// scripts/agent/agent-launch-environment.ts
|
|
1335
1804
|
import { existsSync as existsSync3, lstatSync, mkdirSync, readlinkSync, symlinkSync, unlinkSync } from "node:fs";
|
|
1336
|
-
import
|
|
1805
|
+
import path5 from "node:path";
|
|
1337
1806
|
|
|
1338
1807
|
// scripts/gh/gh-cli-token.ts
|
|
1339
1808
|
import { execaSync } from "execa";
|
|
@@ -1361,9 +1830,9 @@ var agent_session_role = { KEY: KEY2, env_for: environment_for, is_reviewer };
|
|
|
1361
1830
|
|
|
1362
1831
|
// scripts/agent/codex-home-source.ts
|
|
1363
1832
|
import os from "node:os";
|
|
1364
|
-
import
|
|
1833
|
+
import path4 from "node:path";
|
|
1365
1834
|
function default_home() {
|
|
1366
|
-
return
|
|
1835
|
+
return path4.join(os.homedir(), ".codex");
|
|
1367
1836
|
}
|
|
1368
1837
|
var codex_home_source = { default_home };
|
|
1369
1838
|
|
|
@@ -1385,13 +1854,13 @@ function remove_old_home_link(source, target) {
|
|
|
1385
1854
|
return false;
|
|
1386
1855
|
}
|
|
1387
1856
|
function link_home_file(source_home, target_home, name) {
|
|
1388
|
-
const source =
|
|
1389
|
-
const target =
|
|
1857
|
+
const source = path5.join(source_home, name);
|
|
1858
|
+
const target = path5.join(target_home, name);
|
|
1390
1859
|
if (!remove_old_home_link(source, target) && existsSync3(source)) symlinkSync(source, target);
|
|
1391
1860
|
}
|
|
1392
1861
|
function reviewer_home(cwd, environment3) {
|
|
1393
1862
|
const source = environment3["CODEX_HOME"] ?? process.env["CODEX_HOME"] ?? codex_home_source.default_home();
|
|
1394
|
-
const target =
|
|
1863
|
+
const target = path5.resolve(cwd, ...REVIEWER_HOME);
|
|
1395
1864
|
mkdirSync(target, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });
|
|
1396
1865
|
for (const name of HOME_FILES) link_home_file(source, target, name);
|
|
1397
1866
|
return target;
|
|
@@ -1545,17 +2014,19 @@ var detached_launch = {
|
|
|
1545
2014
|
};
|
|
1546
2015
|
|
|
1547
2016
|
export {
|
|
2017
|
+
repo_origin,
|
|
2018
|
+
repo_discovery,
|
|
1548
2019
|
issue_cite,
|
|
1549
2020
|
git_common_directory,
|
|
1550
|
-
|
|
1551
|
-
|
|
2021
|
+
run_event_stream,
|
|
2022
|
+
run_event_scope,
|
|
2023
|
+
run_event_stream_emit,
|
|
1552
2024
|
agent_role_profile,
|
|
1553
2025
|
agent_session_role,
|
|
1554
2026
|
lane_child_invocation,
|
|
1555
|
-
repo_origin,
|
|
1556
|
-
repo_discovery,
|
|
1557
2027
|
agent_headless,
|
|
1558
2028
|
detached_launch,
|
|
2029
|
+
session_language,
|
|
1559
2030
|
lane_registry,
|
|
1560
2031
|
run_headless
|
|
1561
2032
|
};
|