@joshuafolkken/kit 1.1136.0 → 1.1178.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/settings.json +4 -4
- package/.claude/skills/epic-commands/SKILL.md +27 -239
- package/.claude/skills/epic-commands/epic-bundle.md +115 -0
- package/.claude/skills/epic-commands/execution-waves.md +126 -0
- package/.claude/skills/workflow-commands/SKILL.md +48 -194
- package/.claude/skills/workflow-commands/background-commands.md +1 -1
- package/.claude/skills/workflow-commands/backlogrun-child.md +12 -123
- package/.claude/skills/workflow-commands/backlogrun-lanes.md +14 -63
- package/.claude/skills/workflow-commands/backlogrun-park.md +16 -15
- package/.claude/skills/workflow-commands/backlogrun-progress.md +17 -173
- package/.claude/skills/workflow-commands/backlogrun-recovery.md +155 -0
- package/.claude/skills/workflow-commands/backlogrun-steps.md +65 -144
- package/.claude/skills/workflow-commands/backlogrun.md +5 -4
- package/.claude/skills/workflow-commands/chain-rule.md +3 -2
- package/.claude/skills/workflow-commands/delegation.md +2 -2
- package/.claude/skills/workflow-commands/entry-sequence.md +62 -0
- package/.claude/skills/workflow-commands/followup.md +104 -181
- package/.claude/skills/workflow-commands/fullrun-steps.md +8 -9
- package/.claude/skills/workflow-commands/fullrun.md +16 -73
- package/.claude/skills/workflow-commands/halfrun.md +10 -36
- package/.claude/skills/workflow-commands/into-target.md +4 -4
- package/.claude/skills/workflow-commands/issue-comments.md +7 -8
- package/.claude/skills/workflow-commands/issue-scout.md +6 -6
- package/.claude/skills/workflow-commands/kickoff.md +6 -6
- package/.claude/skills/workflow-commands/needs-human-review.md +6 -6
- package/.claude/skills/workflow-commands/observation-filing.md +21 -172
- package/.claude/skills/workflow-commands/observation-ledger.md +150 -0
- package/.claude/skills/workflow-commands/pre-gate-cut.md +35 -95
- package/.claude/skills/workflow-commands/prerequisite.md +6 -6
- package/.claude/skills/workflow-commands/progress-watcher.md +90 -0
- package/.claude/skills/workflow-commands/prrun.md +5 -5
- package/.claude/skills/workflow-commands/retrospective.md +9 -9
- package/.claude/skills/workflow-commands/split-assessment.md +2 -2
- package/.claude/skills/workflow-commands/target-repository.md +2 -2
- package/.claude/skills/workflow-commands/working-tree-hold.md +7 -5
- package/.codex/hooks.json +4 -4
- package/.github/workflows/ci.yml +15 -2
- package/AGENTS.md +1 -6
- package/CLAUDE.md +58 -120
- package/GEMINI.md +1 -6
- package/dist/CLAUDE.md +58 -120
- package/dist/hooks/batch-guard.js +4 -4
- package/dist/hooks/{chunk-NFZGFGOR.js → chunk-32GQTL4F.js} +14 -1
- package/dist/hooks/{chunk-HBKZLITF.js → chunk-DO6NWWHU.js} +4 -4
- package/dist/hooks/{chunk-KBXZLMRH.js → chunk-G6KRCKEC.js} +216 -76
- package/dist/hooks/{chunk-JKKTVDAG.js → chunk-GDS5N2KB.js} +186 -309
- package/dist/hooks/chunk-I4XSL4TT.js +56 -0
- package/dist/hooks/{chunk-GDU26K3J.js → chunk-S6X6WYKR.js} +886 -174
- package/dist/hooks/{chunk-FO2I7UT7.js → chunk-UAGLLIGZ.js} +1 -1
- package/dist/hooks/{chunk-RFWWUI5F.js → chunk-VESKRQOF.js} +3 -3
- package/dist/hooks/{chunk-KOKOAV6D.js → chunk-VQLLNFNT.js} +6 -4
- package/dist/hooks/{chunk-LJBLGHEH.js → chunk-ZAL3NRGL.js} +4 -6
- package/dist/hooks/codex-hook-adapter.js +10 -10
- package/dist/hooks/duplicate-read-guard.js +5 -5
- package/dist/hooks/format-edited.js +2 -2
- package/dist/hooks/inputs.json +178 -177
- package/dist/hooks/investigation-guard.js +5 -5
- package/dist/hooks/pretool-guard.js +11 -10
- package/dist/hooks/stop-guard.js +20 -6
- package/dist/josh.js +29 -3
- package/dist/version/index.js +5 -1
- package/package.json +2 -1
- package/prompts/collaboration-workflow/file-edits.md +11 -10
- package/prompts/collaboration-workflow/gh-rest.md +2 -4
- package/prompts/collaboration-workflow/glossary.md +1 -1
- package/prompts/collaboration-workflow/issue-citation.md +5 -9
- package/prompts/collaboration-workflow/issue-template.md +40 -115
- package/prompts/collaboration-workflow/operating-rules.md +4 -5
- package/prompts/collaboration-workflow/output-bounds.md +12 -78
- package/prompts/collaboration-workflow/overview.md +7 -13
- package/prompts/collaboration-workflow/plan-comment.md +11 -39
- package/prompts/collaboration-workflow/principles.md +3 -4
- package/prompts/collaboration-workflow/report-format.md +28 -74
- package/prompts/collaboration-workflow/residency.md +12 -109
- package/prompts/collaboration-workflow/rule-delivery.md +98 -97
- package/prompts/collaboration-workflow/shell-body.md +3 -13
- package/prompts/collaboration-workflow/turn-batching.md +14 -88
- package/prompts/collaboration-workflow/upstream-interrupt.md +12 -14
- package/prompts/collaboration-workflow/wip-cap.md +6 -45
- package/prompts/collaboration-workflow.md +1 -13
- package/prompts/review-rubric.md +8 -71
- package/prompts/review.md +25 -55
- package/prompts/testing-guide.md +18 -67
- package/scripts/agent/agent-role-profile.ts +1 -1
- package/scripts/agent/codex-hooks.ts +3 -12
- package/scripts/backlog/backlog-budget.ts +1 -1
- package/scripts/backlog/backlog-drive-cli.ts +4 -3
- package/scripts/backlog/backlog-drive-offer-argv.ts +10 -1
- package/scripts/backlog/backlog-next.ts +15 -4
- package/scripts/backlog/backlog-offer.ts +6 -6
- package/scripts/backlog/backlog-plan-cli.ts +6 -5
- package/scripts/backlog/backlog-rank.ts +18 -9
- package/scripts/backlog/backlog-restructure.ts +152 -0
- package/scripts/backlog/backlog-waves.ts +15 -17
- package/scripts/behavior/behavior-rules.ts +11 -4
- package/scripts/cost-runtime/context-cut-threshold.ts +1 -9
- package/scripts/cost-runtime/cost-verdict.ts +15 -28
- package/scripts/delegation/investigation-reads.ts +5 -5
- package/scripts/discovery/repo-discovery.ts +21 -7
- package/scripts/discovery/repo-origin.ts +26 -0
- package/scripts/discovery/repo-party.ts +42 -1
- package/scripts/document/backlogrun-parent-read-set.ts +14 -15
- package/scripts/document/document-byte-budget.ts +34 -20
- package/scripts/document/entry-read-budget.ts +21 -9
- package/scripts/document/lane-child-read-set.ts +12 -14
- package/scripts/document/read-set-cli.ts +4 -4
- package/scripts/document/read-set-point-of-use.ts +10 -2
- package/scripts/document/resident-budget.ts +47 -0
- package/scripts/epic/epic-shape.ts +10 -13
- package/scripts/epic/epic-solo.ts +1 -1
- package/scripts/exports/unused-members-cli.ts +7 -3
- package/scripts/followup/git-followup-stages.ts +9 -0
- package/scripts/followup/git-pr-followup.ts +1 -1
- package/scripts/gh/git-gh-api-path.ts +7 -0
- package/scripts/gh/git-gh-issue.ts +5 -3
- package/scripts/gh/git-gh-pr-read.ts +4 -0
- package/scripts/gh/git-pr-checks-eval.ts +8 -0
- package/scripts/gh/git-pr-checks.ts +11 -1
- package/scripts/git/constants.ts +10 -0
- package/scripts/git/main-merge.ts +57 -21
- package/scripts/git/schemas.ts +2 -0
- package/scripts/hooks/pretool-guard-cli.ts +2 -2
- package/scripts/hooks/pretool-guard.ts +45 -2
- package/scripts/hooks/run-hook.sh +41 -0
- package/scripts/init/hook-command-rewrite.ts +18 -35
- package/scripts/init/hook-launch.ts +21 -32
- package/scripts/issue/issue-auto-ok.ts +95 -0
- package/scripts/issue/issue-file-cli.ts +53 -7
- package/scripts/issue/issue-file.ts +28 -5
- package/scripts/issue/issue-labels.ts +12 -12
- package/scripts/issue/issue-rank.ts +1 -1
- package/scripts/issue/issue-read-cli.ts +3 -3
- package/scripts/issue/issue-read.ts +2 -2
- package/scripts/issue/issue-scout-cli.ts +2 -2
- package/scripts/issue/issue-state-cli.ts +1 -1
- package/scripts/issue/issue-state.ts +2 -2
- package/scripts/issue/issue-wip.ts +70 -0
- package/scripts/josh/hook-decision.ts +17 -0
- package/scripts/josh/josh-commands-development.ts +11 -1
- package/scripts/josh/josh-commands-issue.ts +2 -2
- package/scripts/lane/lane-launch-cli.ts +21 -3
- package/scripts/lines/bytes-command.ts +29 -6
- package/scripts/notify/telegram-notify.ts +26 -1
- package/scripts/observations/observation-ledger-line.ts +1 -1
- package/scripts/release/release-progress.ts +167 -0
- package/scripts/release/release-publish.ts +19 -8
- package/scripts/release/release-tag.ts +22 -8
- package/scripts/rules/decision-oracle-stage.ts +1 -1
- package/scripts/rules/decision-oracle.ts +6 -6
- package/scripts/rules/delivered-rules.ts +11 -11
- package/scripts/rules/direct-pr-create.ts +110 -0
- package/scripts/rules/file-body.ts +98 -42
- package/scripts/rules/filing-cap.ts +2 -2
- package/scripts/rules/filing-offer.ts +1 -1
- package/scripts/rules/gh-api.ts +18 -1
- package/scripts/rules/implementation-cut.ts +3 -1
- package/scripts/rules/lane-background.ts +67 -10
- package/scripts/rules/permission-guards.ts +10 -2
- package/scripts/rules/pre-gate-cut.ts +2 -2
- package/scripts/rules/stop-rules.ts +4 -4
- package/scripts/rules/test-declared-commit.ts +1 -1
- package/scripts/rules/third-party-write.ts +56 -12
- package/scripts/run/run-carry.ts +11 -5
- package/scripts/run/run-cut-cli.ts +1 -1
- package/scripts/run/run-cut-handoff.ts +21 -1
- package/scripts/run/run-cut-report.ts +2 -2
- package/scripts/run/run-entry-cli.ts +11 -3
- package/scripts/run/run-hold-cli.ts +16 -2
- package/scripts/run/run-label.ts +50 -0
- package/scripts/run/run-merge-steps.ts +8 -3
- package/scripts/run/run-merge.ts +1 -1
- package/scripts/run/run-prep-cli.ts +6 -2
- package/scripts/run/run-prep.ts +17 -0
- package/scripts/run/run-ship-cli.ts +27 -6
- package/scripts/run/run-ship-next.ts +13 -0
- package/scripts/run/run-ship-pre-detach.ts +66 -0
- package/scripts/run/run-ship-preflight.ts +34 -3
- package/scripts/run/run-ship-return.ts +7 -4
- package/scripts/run/run-ship-review-steps.ts +1 -1
- package/scripts/run/run-ship-review.ts +26 -5
- package/scripts/run/run-ship-stage.ts +13 -0
- package/scripts/run/run-ship-steps.ts +10 -2
- package/scripts/run/run-ship-sync.ts +114 -0
- package/scripts/run/run-ship.ts +6 -0
- package/scripts/run/run-step-cli.ts +20 -7
- package/scripts/run/run-wake-cli.ts +8 -1
- package/scripts/run/run-wake-driver.ts +62 -8
- package/scripts/run/run-wake-session.ts +2 -1
- package/scripts/test/test-declared-logic.ts +1 -1
- package/scripts/test/test-red-logic.ts +17 -2
- package/scripts/test/test-red.ts +8 -7
- package/scripts/time-runtime/time-batch-guard.ts +52 -16
- package/scripts/time-runtime/time-density-hook.ts +20 -2
- package/scripts/time-runtime/time-density.ts +4 -3
- package/scripts/time-runtime/time-markers.ts +15 -4
- package/scripts/time-runtime/time-transcript-line.ts +27 -1
- package/scripts/version/npm-registry.ts +11 -1
- package/templates/workflows/ci.yml +9 -1
- package/.claude/skills/workflow-commands/followup-reference.md +0 -118
- package/dist/hooks/chunk-HANSKHES.js +0 -464
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
NEEDS_DECISION_LABEL,
|
|
6
6
|
NEEDS_HUMAN_REVIEW_LABEL,
|
|
7
7
|
PORCELAIN_FLAG,
|
|
8
|
-
RECENT_REQUEST_WINDOW,
|
|
9
8
|
agent_role_profile,
|
|
10
9
|
bash_triggers,
|
|
11
10
|
cli_flags,
|
|
@@ -22,7 +21,6 @@ import {
|
|
|
22
21
|
lane_background,
|
|
23
22
|
lane_park,
|
|
24
23
|
lane_registry,
|
|
25
|
-
open_issue_schema,
|
|
26
24
|
own_session,
|
|
27
25
|
parse_json_object_safe,
|
|
28
26
|
read_json_listing,
|
|
@@ -30,36 +28,36 @@ import {
|
|
|
30
28
|
repo_party,
|
|
31
29
|
run_carry,
|
|
32
30
|
run_cut,
|
|
31
|
+
run_cut_handoff,
|
|
33
32
|
run_headless,
|
|
34
33
|
run_hold,
|
|
35
34
|
run_tail,
|
|
36
35
|
shell_segments,
|
|
37
36
|
tail_commands
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-GDS5N2KB.js";
|
|
39
38
|
import {
|
|
40
39
|
find_local_bin_upwards
|
|
41
40
|
} from "./chunk-3V37IID6.js";
|
|
42
41
|
import {
|
|
43
42
|
batch_outcome
|
|
44
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-VQLLNFNT.js";
|
|
45
44
|
import {
|
|
46
45
|
investigation_refusal
|
|
47
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-VESKRQOF.js";
|
|
48
47
|
import {
|
|
49
48
|
duplicate_read_outcome
|
|
50
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-DO6NWWHU.js";
|
|
51
50
|
import {
|
|
52
51
|
investigation_reads
|
|
53
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-ZAL3NRGL.js";
|
|
54
53
|
import {
|
|
55
|
-
lane_guard_policy
|
|
56
|
-
|
|
57
|
-
} from "./chunk-HANSKHES.js";
|
|
54
|
+
lane_guard_policy
|
|
55
|
+
} from "./chunk-I4XSL4TT.js";
|
|
58
56
|
import {
|
|
59
57
|
hook_decision,
|
|
60
58
|
lane_child_marker,
|
|
61
59
|
run_issue_number
|
|
62
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-32GQTL4F.js";
|
|
63
61
|
import {
|
|
64
62
|
PLATFORM_TEMP_ROOT,
|
|
65
63
|
cost_attribute,
|
|
@@ -69,9 +67,11 @@ import {
|
|
|
69
67
|
file_reader,
|
|
70
68
|
json_value,
|
|
71
69
|
lane_paths,
|
|
70
|
+
open_issue_schema,
|
|
72
71
|
stamp_file,
|
|
72
|
+
time_batch_guard,
|
|
73
73
|
time_shell
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-S6X6WYKR.js";
|
|
75
75
|
|
|
76
76
|
// scripts/rules/direct-filing.ts
|
|
77
77
|
var DIRECT_FILING_REASON = '\u26D4 direct filing: an Issue is filed with `pnpm josh issue:file "<title>" --body-file <path> --depth <0|1|2> [--route <route>] [--label <name>] [--repo <owner/repo>]`, never with `gh api \u2026/issues` or `gh issue create`. The command runs every filing step in order \u2014 the duplicate scout, the body lint and its classification labels, the depth and `route:` labels, the `## Origin` check when filing into another repository, and `epic:bundle` after the create \u2014 so none of them is a step to remember. When the scout prints candidates it holds the filing: read each, then reissue with `--distinct <N,\u2026>` for the ones that are separate deliverables. Reference: `docs/josh-commands-automation.md` \u2192 "`josh issue:file`". **This rule fires on every occurrence, not once per run.**';
|
|
@@ -466,15 +466,28 @@ var early_heartbeat = {
|
|
|
466
466
|
|
|
467
467
|
// scripts/rules/file-body.ts
|
|
468
468
|
import { existsSync } from "node:fs";
|
|
469
|
-
var HEREDOC =
|
|
469
|
+
var HEREDOC = /(?<!<)<<(?!<)-?\s*['"]?([A-Z_a-z]\w*)/u;
|
|
470
470
|
var LINE_BREAK = "\n";
|
|
471
|
-
function first_line(command) {
|
|
472
|
-
const [line] = command.split(LINE_BREAK);
|
|
473
|
-
return line ?? "";
|
|
474
|
-
}
|
|
475
471
|
function has_heredoc(command) {
|
|
476
472
|
return HEREDOC.test(command);
|
|
477
473
|
}
|
|
474
|
+
function with_body_line(lines, line) {
|
|
475
|
+
const opener = lines.at(-1);
|
|
476
|
+
if (opener === void 0) return [...lines];
|
|
477
|
+
return [...lines.slice(0, -1), { ...opener, body: `${opener.body}${line}${LINE_BREAK}` }];
|
|
478
|
+
}
|
|
479
|
+
function scan_line(scan, line) {
|
|
480
|
+
if (scan.delimiter === void 0) {
|
|
481
|
+
return { lines: [...scan.lines, { text: line, body: "" }], delimiter: HEREDOC.exec(line)?.[1] };
|
|
482
|
+
}
|
|
483
|
+
if (line.trim() === scan.delimiter) return { ...scan, delimiter: void 0 };
|
|
484
|
+
return { ...scan, lines: with_body_line(scan.lines, line) };
|
|
485
|
+
}
|
|
486
|
+
function command_lines(command) {
|
|
487
|
+
let scan = { lines: [], delimiter: void 0 };
|
|
488
|
+
for (const line of command.split(LINE_BREAK)) scan = scan_line(scan, line);
|
|
489
|
+
return scan.lines;
|
|
490
|
+
}
|
|
478
491
|
var FILE_REDIRECT = /(?:^|\s)>>?\s*(?!&)("[^"]+"|'[^']+'|\S+)/u;
|
|
479
492
|
var TEE_TARGET = /\btee\s+(?:-a\s+)?(?!-)("[^"]+"|'[^']+'|\S+)/u;
|
|
480
493
|
var QUOTES = /^['"]|['"]$/gu;
|
|
@@ -482,22 +495,32 @@ function redirect_target(line) {
|
|
|
482
495
|
const target = FILE_REDIRECT.exec(line)?.[1] ?? TEE_TARGET.exec(line)?.[1];
|
|
483
496
|
return target === void 0 ? void 0 : target.replaceAll(QUOTES, "");
|
|
484
497
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
498
|
+
var BODY_INTERPRETERS = /* @__PURE__ */ new Set([
|
|
499
|
+
"python",
|
|
500
|
+
"python3",
|
|
501
|
+
"ruby",
|
|
502
|
+
"perl",
|
|
503
|
+
"php",
|
|
504
|
+
"node"
|
|
505
|
+
]);
|
|
491
506
|
var NODE = "node";
|
|
492
507
|
var NODE_EVAL = /(?:^|\s)(?:-e|--eval)\b/u;
|
|
493
|
-
var WRITE_CALL = /writeFile|appendFile|createWriteStream|\.write(?:lines)?\s*\(/u;
|
|
508
|
+
var WRITE_CALL = /writeFile|appendFile|createWriteStream|\.write(?:lines|_text|_bytes)?\s*\(/u;
|
|
494
509
|
var WRITE_MODE = /open\s*\([^)]*['"][rbt+]*[wax]|os\.replace|shutil\.(?:copy|move)/u;
|
|
495
|
-
function body_writes(
|
|
496
|
-
return WRITE_CALL.test(
|
|
510
|
+
function body_writes(body) {
|
|
511
|
+
return WRITE_CALL.test(body) || WRITE_MODE.test(body);
|
|
512
|
+
}
|
|
513
|
+
var SCRIPT_FILE = /\.(?:py|rb|pl|php|js|mjs|cjs)$/u;
|
|
514
|
+
function is_heredoc_write(line, has_file) {
|
|
515
|
+
const target = has_heredoc(line.text) ? redirect_target(line.text) : void 0;
|
|
516
|
+
if (target === void 0) return false;
|
|
517
|
+
if (has_file(target)) return true;
|
|
518
|
+
return SCRIPT_FILE.test(target) && body_writes(line.body);
|
|
497
519
|
}
|
|
498
|
-
function is_interpreter_write(segment,
|
|
520
|
+
function is_interpreter_write(segment, body) {
|
|
499
521
|
const leading = time_shell.leading_word(segment);
|
|
500
|
-
if (BODY_INTERPRETERS.has(leading)) return
|
|
522
|
+
if (!BODY_INTERPRETERS.has(leading)) return false;
|
|
523
|
+
if (has_heredoc(segment)) return body_writes(body);
|
|
501
524
|
return leading === NODE && NODE_EVAL.test(segment) && body_writes(segment);
|
|
502
525
|
}
|
|
503
526
|
var PERL = "perl";
|
|
@@ -507,13 +530,15 @@ function is_in_place_perl(segment) {
|
|
|
507
530
|
if (time_shell.leading_word(segment) !== PERL) return false;
|
|
508
531
|
return segment.split(WHITESPACE).some((word) => PERL_IN_PLACE.test(word));
|
|
509
532
|
}
|
|
510
|
-
function has_body_interpreter(
|
|
511
|
-
return shell_segments.segments_of(
|
|
533
|
+
function has_body_interpreter(line) {
|
|
534
|
+
return shell_segments.segments_of(line.text).some((segment) => is_interpreter_write(segment, line.body) || is_in_place_perl(segment));
|
|
512
535
|
}
|
|
513
536
|
function carries_a_file_body(command, has_file = existsSync) {
|
|
514
|
-
return
|
|
537
|
+
return command_lines(command).some(
|
|
538
|
+
(line) => is_heredoc_write(line, has_file) || has_body_interpreter(line)
|
|
539
|
+
);
|
|
515
540
|
}
|
|
516
|
-
var FILE_BODY_REASON = "\u26D4 file body in a shell command: this carries a file's new text inline \u2014 a heredoc rewriting an existing file, an interpreter (`python3 - <<`, `node -e`) whose body writes, or an in-place `perl -0pi -e`. `CLAUDE.md` forbids it because the command body is re-read on every later request of the run, so an editing script written early is billed for the rest of it (`file-edits.md` measured one run at ~2m45s spent retyping existing lines). Edit a region with the Edit tool (old / new),
|
|
541
|
+
var FILE_BODY_REASON = "\u26D4 file body in a shell command: this carries a file's new text inline \u2014 a heredoc rewriting an existing file, an interpreter (`python3 - <<`, `node -e`) whose body writes, a script file (`cat > edit.py <<EOF`) whose body writes, or an in-place `perl -0pi -e`. `CLAUDE.md` forbids it because the command body is re-read on every later request of the run, so an editing script written early is billed for the rest of it (`file-edits.md` measured one run at ~2m45s spent retyping existing lines). Edit a region with the Edit tool (old / new); a change scattered so widely that the partial edits would carry more than the file is rewritten whole with the Write tool, never a heredoc. Pass a body by path (`--field body=@<path>`, `--body-file <path>`). A new-file creation (`cat > <new-file> <<EOF`), a read-only heredoc (`cat <<EOF`), and a short `sed -i` stay allowed. **This rule fires on every occurrence, not once per run.**";
|
|
517
542
|
var ROW2 = {
|
|
518
543
|
id: "file-body",
|
|
519
544
|
is_trigger: bash_triggers.on_bash_command((command) => carries_a_file_body(command)),
|
|
@@ -535,6 +560,7 @@ var READ_METHOD = "GET";
|
|
|
535
560
|
var REPO_PATH = /repos\/([^/\s'"?]+)\/([^/\s'"?]+)/u;
|
|
536
561
|
var OWNER_GROUP = 1;
|
|
537
562
|
var REPO_GROUP = 2;
|
|
563
|
+
var OWNER_PLACEHOLDERS = /* @__PURE__ */ new Set(["{owner}", ":owner"]);
|
|
538
564
|
function is_gh_api(segment) {
|
|
539
565
|
return GH_API_COMMAND.test(segment);
|
|
540
566
|
}
|
|
@@ -554,7 +580,18 @@ function repo_target(segment) {
|
|
|
554
580
|
if (match === null) return void 0;
|
|
555
581
|
return { owner: match[OWNER_GROUP] ?? "", repo: match[REPO_GROUP] ?? "" };
|
|
556
582
|
}
|
|
557
|
-
|
|
583
|
+
function is_owner_placeholder(owner) {
|
|
584
|
+
return OWNER_PLACEHOLDERS.has(owner);
|
|
585
|
+
}
|
|
586
|
+
var gh_api = {
|
|
587
|
+
GH_FLAGS,
|
|
588
|
+
is_gh_api,
|
|
589
|
+
is_owner_placeholder,
|
|
590
|
+
is_read,
|
|
591
|
+
is_write,
|
|
592
|
+
method_of,
|
|
593
|
+
repo_target
|
|
594
|
+
};
|
|
558
595
|
|
|
559
596
|
// scripts/rules/git-argv.ts
|
|
560
597
|
var ENV_ASSIGNMENT = /^[A-Za-z_]\w*=/u;
|
|
@@ -859,22 +896,15 @@ var cost_corpus = {
|
|
|
859
896
|
var FAILURE_EXIT_CODE = 1;
|
|
860
897
|
var OVER_VERDICT = "over";
|
|
861
898
|
var UNDER_VERDICT = "under";
|
|
862
|
-
function recent_requests(measurement2) {
|
|
863
|
-
return measurement2.billed_input_per_request.slice(-RECENT_REQUEST_WINDOW);
|
|
864
|
-
}
|
|
865
899
|
function per_request_cost(measurement2) {
|
|
866
|
-
|
|
867
|
-
if (window.length === 0) return 0;
|
|
868
|
-
const total = window.reduce((sum, billed) => sum + billed, 0);
|
|
869
|
-
return Math.round(total / window.length);
|
|
900
|
+
return measurement2.billed_input_per_request.at(-1) ?? 0;
|
|
870
901
|
}
|
|
871
902
|
function classify(measurement2, limit) {
|
|
872
903
|
return per_request_cost(measurement2) > limit ? OVER_VERDICT : UNDER_VERDICT;
|
|
873
904
|
}
|
|
874
905
|
function over_summary(measurement2, limit) {
|
|
875
906
|
const total = measurement2.billed_input_per_request.length;
|
|
876
|
-
|
|
877
|
-
return `${String(per_request_cost(measurement2))} billed input tokens per request over the last ${String(window)} of ${String(total)} request(s); limit ${String(limit)}`;
|
|
907
|
+
return `${String(per_request_cost(measurement2))} billed input tokens per request, on the newest of ${String(total)} request(s); limit ${String(limit)}`;
|
|
878
908
|
}
|
|
879
909
|
function report_over(measurement2, limit) {
|
|
880
910
|
if (measurement2 === void 0 || measurement2.billed_input_per_request.length === 0) {
|
|
@@ -1144,7 +1174,7 @@ function is_over_threshold_edit(call, state = current_state()) {
|
|
|
1144
1174
|
return warrants_the_cut(state);
|
|
1145
1175
|
}
|
|
1146
1176
|
var THRESHOLD_TEXT = `${cost_format.format_tokens(CONTEXT_CUT_THRESHOLD)}-token`;
|
|
1147
|
-
var IMPLEMENTATION_CUT_REASON = `\u26D4 implementation-phase cut: this checkout is a lane dispatched for this issue, or a run holds it for this issue (joshuafolkken/kit#2760), and its recent-context cost has crossed the shared ${THRESHOLD_TEXT} threshold mid-implementation, so the thinking accumulated so far is now re-read on every later request. Take the cut before this edit. First write a handoff file with the Write tool \u2014 the user\u2019s instruction verbatim, what you have completed, what remains, and what you deliberately did not touch \u2014 and pass it as \`--handoff <path>\`, so the fresh process resumes on the original instruction rather than the working tree alone (joshuafolkken/kit#2354); a resume that finds no instruction is refused \`incomplete\` rather than continuing blind. \`pnpm josh run:cut --impl <N> --handoff <path>\` ends this process and relaunches a fresh one that resumes back into implementation (\`resume-impl\`), dropping the accumulated context rather than carrying it \u2014 joshuafolkken/kit#1933 built the boundary and joshuafolkken/kit#2310 measured it firing 0 times because the verdict was only ever read at session entry, where the context has not yet grown. The verdict is \`pnpm josh cost --cut\`'s exactly \u2014 the same per-request billed-input statistic against the same threshold, never a second measurement. Issue \`pnpm josh run:cut --impl <N> --handoff <path>\` now and read the verdict: on \`cut\`, **end the turn immediately** \u2014 in a lane the fresh process owns the run and continues implementing, so it must not be waited for; outside a lane nothing is relaunched, so first send the \`confirmation\` Telegram naming the resume command \`fullrun #<N>\` and keep the hold; on \`not-a-lane\`, \`unready\`, \`busy\`, \`failed\` or \`unknown\`, this process carries the run on and the edit is simply the next call. Never relaunch a second process after \`busy\`. This fired because the dispatch mark names this lane or the run hold names this issue; a person working here carries no mark and holds no run, so sees no refusal, so there is no human-or-child judgement left to make. The procedure is \`.claude/skills/workflow-commands/pre-gate-cut.md\`. Reissue this edit once the cut has answered \u2014 an edit reissued right after this refusal passes, so \`busy\` / \`failed\` cannot wedge the run edit after edit; this fires again on the next threshold crossing rather than once per run.`;
|
|
1177
|
+
var IMPLEMENTATION_CUT_REASON = `\u26D4 implementation-phase cut: this checkout is a lane dispatched for this issue, or a run holds it for this issue (joshuafolkken/kit#2760), and its recent-context cost has crossed the shared ${THRESHOLD_TEXT} threshold mid-implementation, so the thinking accumulated so far is now re-read on every later request. Take the cut before this edit. First write a handoff file with the Write tool \u2014 the user\u2019s instruction verbatim, what you have completed, what remains, and what you deliberately did not touch, as ${run_cut_handoff.HANDOFF_FORMAT} (Markdown is refused) \u2014 and pass it as \`--handoff <path>\`, so the fresh process resumes on the original instruction rather than the working tree alone (joshuafolkken/kit#2354); a resume that finds no instruction is refused \`incomplete\` rather than continuing blind. \`pnpm josh run:cut --impl <N> --handoff <path>\` ends this process and relaunches a fresh one that resumes back into implementation (\`resume-impl\`), dropping the accumulated context rather than carrying it \u2014 joshuafolkken/kit#1933 built the boundary and joshuafolkken/kit#2310 measured it firing 0 times because the verdict was only ever read at session entry, where the context has not yet grown. The verdict is \`pnpm josh cost --cut\`'s exactly \u2014 the same per-request billed-input statistic against the same threshold, never a second measurement. Issue \`pnpm josh run:cut --impl <N> --handoff <path>\` now and read the verdict: on \`cut\`, **end the turn immediately** \u2014 in a lane the fresh process owns the run and continues implementing, so it must not be waited for; outside a lane nothing is relaunched, so first send the \`confirmation\` Telegram naming the resume command \`fullrun #<N>\` and keep the hold; on \`not-a-lane\`, \`unready\`, \`busy\`, \`failed\` or \`unknown\`, this process carries the run on and the edit is simply the next call. Never relaunch a second process after \`busy\`. This fired because the dispatch mark names this lane or the run hold names this issue; a person working here carries no mark and holds no run, so sees no refusal, so there is no human-or-child judgement left to make. The procedure is \`.claude/skills/workflow-commands/pre-gate-cut.md\`. Reissue this edit once the cut has answered \u2014 an edit reissued right after this refusal passes, so \`busy\` / \`failed\` cannot wedge the run edit after edit; this fires again on the next threshold crossing rather than once per run.`;
|
|
1148
1178
|
var REISSUE_WINDOW_MS = 9e4;
|
|
1149
1179
|
function is_reissued_refusal(now_ms, delivered_at_ms) {
|
|
1150
1180
|
return now_ms - delivered_at_ms < REISSUE_WINDOW_MS;
|
|
@@ -1436,13 +1466,13 @@ var RUN_ENTRY_ORACLE = {
|
|
|
1436
1466
|
decision: "Where a run on an issue starts, and whether the typed command has already been reached",
|
|
1437
1467
|
args: "<N> [--to kickoff|halfrun|prrun|fullrun]",
|
|
1438
1468
|
vocabulary: run_stage.START_TOKENS,
|
|
1439
|
-
single_source: "
|
|
1469
|
+
single_source: "docs/how-to/run-issues.md"
|
|
1440
1470
|
};
|
|
1441
1471
|
|
|
1442
1472
|
// scripts/rules/decision-oracle.ts
|
|
1443
1473
|
var CHAIN_RULE_MD = ".claude/skills/workflow-commands/chain-rule.md";
|
|
1444
1474
|
var BACKLOGRUN_PROGRESS_MD = ".claude/skills/workflow-commands/backlogrun-progress.md";
|
|
1445
|
-
var SKILL_2E = ".claude/skills/workflow-commands/
|
|
1475
|
+
var SKILL_2E = ".claude/skills/workflow-commands/issue-scout.md";
|
|
1446
1476
|
var SPLIT_ASSESSMENT_QUESTION = ".claude/skills/workflow-commands/split-assessment.md \u2192 The question";
|
|
1447
1477
|
var PRE_GATE_CUT_MD = ".claude/skills/workflow-commands/pre-gate-cut.md";
|
|
1448
1478
|
var BACKLOGRUN_MD = ".claude/skills/workflow-commands/backlogrun.md";
|
|
@@ -1475,7 +1505,7 @@ var DECISION_ORACLES = [
|
|
|
1475
1505
|
decision: "Whether a run step may be delegated to a cheaper execution tier",
|
|
1476
1506
|
args: "<step>",
|
|
1477
1507
|
vocabulary: ["delegate", "keep"],
|
|
1478
|
-
single_source: ".claude/skills/workflow-commands/
|
|
1508
|
+
single_source: ".claude/skills/workflow-commands/delegation.md"
|
|
1479
1509
|
},
|
|
1480
1510
|
{
|
|
1481
1511
|
name: "review:level",
|
|
@@ -1518,7 +1548,7 @@ var DECISION_ORACLES = [
|
|
|
1518
1548
|
decision: "Whether this working tree is free for a run to claim",
|
|
1519
1549
|
args: `[${ISSUE_N_ARG}]`,
|
|
1520
1550
|
vocabulary: ["hold", BUSY, UNKNOWN],
|
|
1521
|
-
single_source: ".claude/skills/workflow-commands/
|
|
1551
|
+
single_source: ".claude/skills/workflow-commands/working-tree-hold.md"
|
|
1522
1552
|
},
|
|
1523
1553
|
{
|
|
1524
1554
|
name: "cost:cut",
|
|
@@ -1533,7 +1563,7 @@ var DECISION_ORACLES = [
|
|
|
1533
1563
|
decision: "Whether a release is owed after this merge",
|
|
1534
1564
|
args: "",
|
|
1535
1565
|
vocabulary: [REQUIRED, SKIP, UNKNOWN],
|
|
1536
|
-
single_source: ".claude/skills/workflow-commands/followup
|
|
1566
|
+
single_source: ".claude/skills/workflow-commands/followup.md"
|
|
1537
1567
|
},
|
|
1538
1568
|
{
|
|
1539
1569
|
name: "epic:bundle",
|
|
@@ -1582,7 +1612,7 @@ var DECISION_ORACLES = [
|
|
|
1582
1612
|
decision: "An issue's state, labels, and human-review flag",
|
|
1583
1613
|
args: ISSUE_N_ARG,
|
|
1584
1614
|
vocabulary: ["human_review: yes", "human_review: no"],
|
|
1585
|
-
single_source: ".claude/skills/workflow-commands/
|
|
1615
|
+
single_source: ".claude/skills/workflow-commands/needs-human-review.md"
|
|
1586
1616
|
},
|
|
1587
1617
|
{
|
|
1588
1618
|
name: "run:cut:resume",
|
|
@@ -1619,7 +1649,7 @@ var DECISION_ORACLES = [
|
|
|
1619
1649
|
decision: "Whether a named stash entry exists and can be applied",
|
|
1620
1650
|
args: "<message>",
|
|
1621
1651
|
vocabulary: ["popped", "conflicted", "no-match", "ambiguous"],
|
|
1622
|
-
single_source: ".claude/skills/workflow-commands/
|
|
1652
|
+
single_source: ".claude/skills/workflow-commands/prerequisite.md"
|
|
1623
1653
|
},
|
|
1624
1654
|
{
|
|
1625
1655
|
name: "backlog:next",
|
|
@@ -1889,6 +1919,67 @@ var ROW10 = {
|
|
|
1889
1919
|
};
|
|
1890
1920
|
var destructive_command = { DESTRUCTIVE_COMMAND_REASON, ROW: ROW10, is_destructive_command };
|
|
1891
1921
|
|
|
1922
|
+
// scripts/rules/direct-pr-create.ts
|
|
1923
|
+
var GH_COMMAND2 = "gh";
|
|
1924
|
+
var PR_GROUP2 = "pr";
|
|
1925
|
+
var PR_CREATE_ACTIONS = /* @__PURE__ */ new Set(["create", "new"]);
|
|
1926
|
+
var FLAG_PREFIX3 = "-";
|
|
1927
|
+
var VALUE_TAKING_FLAGS = /* @__PURE__ */ new Set(["-R", "--repo"]);
|
|
1928
|
+
var API_VALUE_TAKING_FLAGS = /* @__PURE__ */ new Set([
|
|
1929
|
+
...VALUE_TAKING_FLAGS,
|
|
1930
|
+
"-X",
|
|
1931
|
+
"--method",
|
|
1932
|
+
"-f",
|
|
1933
|
+
"--raw-field",
|
|
1934
|
+
"-F",
|
|
1935
|
+
"--field",
|
|
1936
|
+
"-H",
|
|
1937
|
+
"--header",
|
|
1938
|
+
"--input",
|
|
1939
|
+
"-q",
|
|
1940
|
+
"--jq",
|
|
1941
|
+
"-t",
|
|
1942
|
+
"--template",
|
|
1943
|
+
"--hostname",
|
|
1944
|
+
"-p",
|
|
1945
|
+
"--preview",
|
|
1946
|
+
"--cache"
|
|
1947
|
+
]);
|
|
1948
|
+
var API_SUBCOMMAND = "api";
|
|
1949
|
+
var PULLS_PATH = /^['"]?(?:https:\/\/api\.github\.com)?\/?repos\/[^/\s'"]+\/[^/\s'"]+\/pulls\/?['"]?$/u;
|
|
1950
|
+
function positional_words(args, value_taking_flags) {
|
|
1951
|
+
return args.filter((argument, index) => {
|
|
1952
|
+
if (argument.startsWith(FLAG_PREFIX3)) return false;
|
|
1953
|
+
return !value_taking_flags.has(args[index - 1] ?? "");
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
function is_pr_create_api_call(args) {
|
|
1957
|
+
const call = [GH_COMMAND2, ...args].join(" ");
|
|
1958
|
+
if (!gh_api.is_gh_api(call) || !gh_api.is_write(call)) return false;
|
|
1959
|
+
const [subcommand, endpoint = ""] = positional_words(args, API_VALUE_TAKING_FLAGS);
|
|
1960
|
+
return subcommand === API_SUBCOMMAND && PULLS_PATH.test(endpoint);
|
|
1961
|
+
}
|
|
1962
|
+
function is_pr_create_cli_call(args) {
|
|
1963
|
+
const [group, action = ""] = positional_words(args, VALUE_TAKING_FLAGS);
|
|
1964
|
+
return group === PR_GROUP2 && PR_CREATE_ACTIONS.has(action);
|
|
1965
|
+
}
|
|
1966
|
+
function is_pr_create_segment(segment) {
|
|
1967
|
+
const args = git_argv.arguments_of(segment, GH_COMMAND2);
|
|
1968
|
+
if (args === void 0) return false;
|
|
1969
|
+
return is_pr_create_cli_call(args) || is_pr_create_api_call(args);
|
|
1970
|
+
}
|
|
1971
|
+
function is_direct_pr_create(command) {
|
|
1972
|
+
return shell_segments.segments_of(command).some((segment) => is_pr_create_segment(segment));
|
|
1973
|
+
}
|
|
1974
|
+
var DIRECT_PR_CREATE_REASON = "\u26D4 direct PR creation: `gh pr create` (or a `gh api` POST to `repos/<o>/<r>/pulls`) bypasses `build_body`, which writes the `closes #N` line \u2014 the Issue would stay open after the merge (`CLAUDE.md` \u2192 Git Rules). Open the PR with `pnpm josh pr` instead; after a failed push, fix, push, then run `pnpm josh pr`. **This rule fires on every occurrence, not once per run.**";
|
|
1975
|
+
var ROW11 = {
|
|
1976
|
+
id: "direct-pr-create",
|
|
1977
|
+
is_trigger: bash_triggers.on_bash_command(is_direct_pr_create),
|
|
1978
|
+
reason: DIRECT_PR_CREATE_REASON,
|
|
1979
|
+
decide: () => true
|
|
1980
|
+
};
|
|
1981
|
+
var direct_pr_create = { DIRECT_PR_CREATE_REASON, ROW: ROW11, is_direct_pr_create };
|
|
1982
|
+
|
|
1892
1983
|
// scripts/rules/worktree-guard.ts
|
|
1893
1984
|
var CHECKOUT_SUBCOMMAND = "checkout";
|
|
1894
1985
|
var RESTORE_SUBCOMMAND = "restore";
|
|
@@ -1949,14 +2040,14 @@ function is_unauthorized_worktree_change(command) {
|
|
|
1949
2040
|
return shell_segments.segments_of(command).some((segment) => is_unauthorized_segment(segment));
|
|
1950
2041
|
}
|
|
1951
2042
|
var WORKTREE_MUTATION_REASON = '\u26D4 unauthorized working-tree change: `git checkout -- <path>`, `git restore <path>`, a forced `git clean` and an unauthorized `git stash` discard work or mutate the repository-wide stash every work tree shares, and none is on the `.claude/settings.json` deny list (`operating-rules.md`). Do not run them on your own judgement. A commit goes through `pnpm josh git`; a stash pop goes through `pnpm josh stash:pop "<message>"`, never a positional `git stash pop` a shared stack lets another lane divert. A stash push is authorized only inside a documented flow and only with a findable message \u2014 `git stash push -u -m "<message>"` \u2014 which this row allows; a bare `git stash`, a message-less push, or `pop` / `apply` / `drop` is refused. **This rule fires on every occurrence, not once per run.**';
|
|
1952
|
-
var
|
|
2043
|
+
var ROW12 = {
|
|
1953
2044
|
id: "worktree-mutation",
|
|
1954
2045
|
is_trigger: bash_triggers.on_bash_command(is_unauthorized_worktree_change),
|
|
1955
2046
|
reason: WORKTREE_MUTATION_REASON,
|
|
1956
2047
|
decide: () => true
|
|
1957
2048
|
};
|
|
1958
2049
|
var worktree_guard = {
|
|
1959
|
-
ROW:
|
|
2050
|
+
ROW: ROW12,
|
|
1960
2051
|
WORKTREE_MUTATION_REASON,
|
|
1961
2052
|
is_unauthorized_worktree_change,
|
|
1962
2053
|
touches_worktree
|
|
@@ -1985,13 +2076,13 @@ function is_index_mutation(command) {
|
|
|
1985
2076
|
return shell_segments.segments_of(command).some((segment) => is_index_segment(segment));
|
|
1986
2077
|
}
|
|
1987
2078
|
var INDEX_MUTATION_REASON = '\u26D4 git index mutation: `git add` / `stage` / `commit` / `reset` / `rm` / `mv` and `git restore --staged` overwrite the user\'s staged snapshot, which `CLAUDE.md` \u2192 Git Rules forbids on your own judgement (`prompts/collaboration-workflow/operating-rules.md` \u2192 "git index \u3092\u52DD\u624B\u306B\u5909\u66F4\u3057\u306A\u3044"). The `.claude/settings.json` deny list matches prefix globs, so it misses `git -C . commit`, `git -c k=v commit` and `env git commit`; this row reads the argv instead, so the spelling does not matter. A commit goes through `pnpm josh git -y`; any other staging needs explicit current-turn user instruction, run by the user in their own terminal. **This rule fires on every occurrence, not once per run.**';
|
|
1988
|
-
var
|
|
2079
|
+
var ROW13 = {
|
|
1989
2080
|
id: "index-mutation",
|
|
1990
2081
|
is_trigger: bash_triggers.on_bash_command(is_index_mutation),
|
|
1991
2082
|
reason: INDEX_MUTATION_REASON,
|
|
1992
2083
|
decide: () => true
|
|
1993
2084
|
};
|
|
1994
|
-
var index_guard = { INDEX_MUTATION_REASON, ROW:
|
|
2085
|
+
var index_guard = { INDEX_MUTATION_REASON, ROW: ROW13, is_index_mutation };
|
|
1995
2086
|
|
|
1996
2087
|
// scripts/rules/protected-files.ts
|
|
1997
2088
|
import path5 from "node:path";
|
|
@@ -2140,16 +2231,21 @@ function is_protected_file_call(call, is_kit_consumer2 = doctor_consumer.is_kit_
|
|
|
2140
2231
|
return is_environment_read(call) || is_consumer_settings_edit(call, is_kit_consumer2);
|
|
2141
2232
|
}
|
|
2142
2233
|
var PROTECTED_FILE_REASON = '\u26D4 protected file: `.env` holds the Telegram bot token, so reading it puts a secret in the transcript \u2014 the scripts that need it load it in their own process. `.claude/settings.json` in a consumer repository is the deny list and the hooks every other rule rests on, so a run must not rewrite it; `josh sync` owns it, and a change belongs upstream in kit (`CLAUDE.md` \u2192 "Route distributed-doc / config changes upstream to kit"). Leave both files alone, or ask the user. **This rule fires on every occurrence, not once per run.**';
|
|
2143
|
-
var
|
|
2234
|
+
var ROW14 = {
|
|
2144
2235
|
id: "protected-file",
|
|
2145
2236
|
is_trigger: is_protected_file_call,
|
|
2146
2237
|
reason: PROTECTED_FILE_REASON,
|
|
2147
2238
|
decide: () => true
|
|
2148
2239
|
};
|
|
2149
|
-
var protected_files = { ROW:
|
|
2240
|
+
var protected_files = { ROW: ROW14, is_protected_file_call };
|
|
2150
2241
|
|
|
2151
2242
|
// scripts/rules/permission-guards.ts
|
|
2152
|
-
var ROWS2 = [
|
|
2243
|
+
var ROWS2 = [
|
|
2244
|
+
index_guard.ROW,
|
|
2245
|
+
destructive_command.ROW,
|
|
2246
|
+
protected_files.ROW,
|
|
2247
|
+
direct_pr_create.ROW
|
|
2248
|
+
];
|
|
2153
2249
|
var permission_guards = { ROWS: ROWS2 };
|
|
2154
2250
|
|
|
2155
2251
|
// scripts/rules/piped-verification.ts
|
|
@@ -2220,7 +2316,7 @@ function is_poll_loop(command) {
|
|
|
2220
2316
|
return LOOP_KEYWORD2.test(plain) && SLEEP_COMMAND.test(plain);
|
|
2221
2317
|
}
|
|
2222
2318
|
var POLL_LOOP_REASON = '\u26D4 output poll loop: this hand-writes a `while`/`until` wait loop over a command\'s output, a marker file or a process \u2014 with a `sleep` or, worse, without one \u2014 and the loop does not know when the command finished. A regex that never matches waits to the harness block limit; one that matches a mid-run line exits too early \u2014 either way the command exit is not what ends the wait, and each pass spends a full-context round trip (joshuafolkken/kit#2371 measured about 45 minutes, 13% of six lanes, lost to exactly this). Do not poll the output file. A command known to take minutes \u2014 `pnpm josh gate`, `pnpm josh followup`, `pnpm josh format` \u2014 is started detached from the first with `run_in_background` set, and the harness re-invokes you when it exits: its completion notification is what ends the wait, on the task exit rather than a regex or the block limit. So issue the long command in the background and end the turn \u2014 do not arm a loop; the wake-up brings you back. To glance at interim output, `Read` the output file once, never in a sleep loop. If you are waiting on CI, `pnpm josh followup` waits on it for you. The procedure is `.claude/skills/workflow-commands/background-commands.md`, "A command that can take minutes is issued in the background". **This rule fires on every occurrence, not once per run.**';
|
|
2223
|
-
var
|
|
2319
|
+
var ROW15 = {
|
|
2224
2320
|
id: "poll-loop",
|
|
2225
2321
|
is_trigger: bash_triggers.on_bash_command(is_poll_loop),
|
|
2226
2322
|
reason: POLL_LOOP_REASON,
|
|
@@ -2228,7 +2324,7 @@ var ROW14 = {
|
|
|
2228
2324
|
};
|
|
2229
2325
|
var poll_loop = {
|
|
2230
2326
|
POLL_LOOP_REASON,
|
|
2231
|
-
ROW:
|
|
2327
|
+
ROW: ROW15,
|
|
2232
2328
|
is_poll_loop
|
|
2233
2329
|
};
|
|
2234
2330
|
|
|
@@ -2348,13 +2444,13 @@ function posts_at_path_literally(command) {
|
|
|
2348
2444
|
return RAW_FIELD_BODY_AT.test(command);
|
|
2349
2445
|
}
|
|
2350
2446
|
var RAW_FIELD_BODY_REASON = "\u26D4 literal @path body: this passes `body=@<path>` to `gh api` with a raw field flag (`-f` / `--raw-field`), which sends the value verbatim \u2014 the string `@<path>` is posted as the comment, not the file it points at. `-F` / `--field` is the flag that reads the file, and the two spellings differ by one character while `gh` exits 0 and returns a comment URL either way, so the break is invisible until a person reads the issue (joshuafolkken/kit#2304 lost two park comments this way). Post an issue or PR comment with `pnpm josh issue:comment <N> --body-file <path>` \u2014 the one spelling, which cannot take the wrong flag. The rule and the safe forms are in `prompts/collaboration-workflow/shell-body.md`. This rule fires on every occurrence, not once per run.";
|
|
2351
|
-
var
|
|
2447
|
+
var ROW16 = {
|
|
2352
2448
|
id: "raw-field-body",
|
|
2353
2449
|
is_trigger: bash_triggers.on_bash_command(posts_at_path_literally),
|
|
2354
2450
|
reason: RAW_FIELD_BODY_REASON,
|
|
2355
2451
|
decide: () => true
|
|
2356
2452
|
};
|
|
2357
|
-
var raw_field_body = { RAW_FIELD_BODY_REASON, ROW:
|
|
2453
|
+
var raw_field_body = { RAW_FIELD_BODY_REASON, ROW: ROW16, posts_at_path_literally };
|
|
2358
2454
|
|
|
2359
2455
|
// scripts/rules/rule-body-guard.ts
|
|
2360
2456
|
var EDIT_TOOL = "Edit";
|
|
@@ -2425,7 +2521,7 @@ function runs_placement_oracle(command) {
|
|
|
2425
2521
|
(names) => shell_segments.segments_of(command).some((segment) => shell_segments.is_josh_command(segment, names))
|
|
2426
2522
|
);
|
|
2427
2523
|
}
|
|
2428
|
-
var
|
|
2524
|
+
var ROW17 = {
|
|
2429
2525
|
id: "rule-body",
|
|
2430
2526
|
is_trigger: writes_rule_prose,
|
|
2431
2527
|
reason: RULE_BODY_REASON,
|
|
@@ -2434,7 +2530,7 @@ var ROW16 = {
|
|
|
2434
2530
|
};
|
|
2435
2531
|
var rule_body_guard = {
|
|
2436
2532
|
RULE_BODY_REASON,
|
|
2437
|
-
ROW:
|
|
2533
|
+
ROW: ROW17,
|
|
2438
2534
|
answered_placement,
|
|
2439
2535
|
is_rule_document,
|
|
2440
2536
|
writes_rule_prose
|
|
@@ -2869,31 +2965,53 @@ function is_untested_commit(call) {
|
|
|
2869
2965
|
return test_declared_changed.current_verdict() === "required";
|
|
2870
2966
|
}
|
|
2871
2967
|
var REASON = '\u26D4 test declared: this commits a runtime code change with no test beside it \u2014 `pnpm josh test:declared` reads the working tree as `required` (a changed file that is neither a test \u2014 `*.test.ts` / `*.e2e.ts` \u2014 nor a mechanically-exempt non-runtime path). `CLAUDE.md` \u2192 Code Change Rules requires a test for ALL code changes: a bug fix gets a regression test, a refactor gets tests pinning behavior first, logic gets a unit test, an observable UI/timing change gets an E2E. Add the declared test and reissue this commit. **If the change genuinely touches no executable runtime path** it is the pre-approved non-runtime exception \u2014 declare it in your Step 0 work summary with the reason it is exempt (non-executable config, a cosmetic asset swap) and reissue; the exception is a presentation, not a stop. Run `pnpm josh test:declared` to see the files it names. The procedure is `prompts/collaboration-workflow/rule-delivery.md` \u2192 "\u914D\u9001\u3055\u308C\u3066\u3044\u308B\u898F\u5247". This fires once per run, so reissuing will not repeat on the call in hand.';
|
|
2872
|
-
var
|
|
2873
|
-
var test_declared_commit = { REASON, ROW:
|
|
2968
|
+
var ROW18 = { id: "test-declared", is_trigger: is_untested_commit, reason: REASON };
|
|
2969
|
+
var test_declared_commit = { REASON, ROW: ROW18 };
|
|
2874
2970
|
|
|
2875
2971
|
// scripts/rules/third-party-write.ts
|
|
2876
|
-
function is_third_party_write_segment(segment, session_owner) {
|
|
2972
|
+
function is_third_party_write_segment(segment, session_owner, resolve_placeholder_owners) {
|
|
2877
2973
|
if (!gh_api.is_gh_api(segment) || !gh_api.is_write(segment)) return false;
|
|
2878
2974
|
const target = gh_api.repo_target(segment);
|
|
2879
2975
|
if (target === void 0) return false;
|
|
2880
|
-
|
|
2976
|
+
if (!gh_api.is_owner_placeholder(target.owner)) {
|
|
2977
|
+
return repo_party.classify(session_owner, target.owner) === repo_party.THIRD_PARTY;
|
|
2978
|
+
}
|
|
2979
|
+
return resolve_placeholder_owners().some(
|
|
2980
|
+
(owner) => owner === void 0 || repo_party.classify(session_owner, owner) === repo_party.THIRD_PARTY
|
|
2981
|
+
);
|
|
2881
2982
|
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2983
|
+
var GH_CONTEXT_CHANGE = /(?:^|\s)(?:cd|pushd)(?:\s|$)|(?:^|\s)(?:export\s+)?GH_REPO=/u;
|
|
2984
|
+
function unreadable_candidates() {
|
|
2985
|
+
return [void 0];
|
|
2986
|
+
}
|
|
2987
|
+
function candidates_at(segments, index, resolve_placeholder_owners) {
|
|
2988
|
+
const has_moved = segments.slice(0, index).some((segment) => GH_CONTEXT_CHANGE.test(segment));
|
|
2989
|
+
return has_moved ? unreadable_candidates : resolve_placeholder_owners;
|
|
2990
|
+
}
|
|
2991
|
+
function writes_third_party(command, resolve_owner = repo_party.current_owner, resolve_placeholder_owners = repo_party.placeholder_owners) {
|
|
2992
|
+
const segments = shell_segments.segments_of(command);
|
|
2993
|
+
const has_write = segments.some(
|
|
2994
|
+
(segment) => gh_api.is_gh_api(segment) && gh_api.is_write(segment)
|
|
2995
|
+
);
|
|
2996
|
+
if (!has_write) return false;
|
|
2885
2997
|
const session_owner = resolve_owner();
|
|
2886
|
-
return
|
|
2998
|
+
return segments.some(
|
|
2999
|
+
(segment, index) => is_third_party_write_segment(
|
|
3000
|
+
segment,
|
|
3001
|
+
session_owner,
|
|
3002
|
+
candidates_at(segments, index, resolve_placeholder_owners)
|
|
3003
|
+
)
|
|
3004
|
+
);
|
|
2887
3005
|
}
|
|
2888
3006
|
var THIRD_PARTY_WRITE_REASON = '\u26D4 third-party write: this `gh api` call writes to a repository whose owner is not this session \u2014 a tracker we do not own is Tier C, and every write there (Issue, comment, PR, Discussion, review) needs explicit current-turn user instruction; typing the target, or holding a correct diagnosis, is not that instruction (`CLAUDE.md` \u2192 "Third-party repositories are Tier C", `prompts/collaboration-workflow/upstream-interrupt.md`). Confirm the party with `pnpm josh repo:party <owner/repo>` \u2014 owner equality, computed not judged. A read (`-X GET`, or no field flag) passes untouched; only a write (`-f`/`-F`/`--field`/`--raw-field`/`--input`, or `-X POST|PATCH|PUT|DELETE`) is refused. Record the finding on our own Issue and draft the artifact for a person to post \u2014 do not publish it yourself. **This rule fires on every occurrence, not once per run.**';
|
|
2889
|
-
var
|
|
3007
|
+
var ROW19 = {
|
|
2890
3008
|
id: "third-party-write",
|
|
2891
3009
|
is_trigger: bash_triggers.on_bash_command((command) => writes_third_party(command)),
|
|
2892
3010
|
reason: THIRD_PARTY_WRITE_REASON,
|
|
2893
3011
|
decide: () => true
|
|
2894
3012
|
};
|
|
2895
3013
|
var third_party_write = {
|
|
2896
|
-
ROW:
|
|
3014
|
+
ROW: ROW19,
|
|
2897
3015
|
THIRD_PARTY_WRITE_REASON,
|
|
2898
3016
|
writes_third_party
|
|
2899
3017
|
};
|
|
@@ -2903,7 +3021,7 @@ var SWITCH_ENV_KEY = "JOSH_RULE_GUARD";
|
|
|
2903
3021
|
var STAMP_PREFIX = "josh-rule-guard-";
|
|
2904
3022
|
var { is_issue_filing, on_bash_command } = bash_triggers;
|
|
2905
3023
|
var WIP_CAP = 30;
|
|
2906
|
-
var WIP_CAP_REASON = `\u26D4 backlog WIP cap:
|
|
3024
|
+
var WIP_CAP_REASON = `\u26D4 backlog WIP cap: \`pnpm josh issue:file\` counts the target repository's open Issues before filing. With more than ${String(WIP_CAP)} open, close one first; nothing honestly closable means do not file \u2014 the command holds such a filing. Two filings are exempt and proceed while stating the overage \u2014 one the run is blocked by (\`--over-cap\`, or the \`tier-a\` / \`split\` route), and an interrupt (\`--route interrupt\`), decided by three tests rather than judgement: a verification answers wrongly, a documented workflow cannot complete, or data is lost or written outside the repository. Meeting none of the three, the finding is discretionary and waits. Both procedures are in \`prompts/collaboration-workflow/wip-cap.md\`. Reissue this call and let the command count \u2014 it fires once per run and cannot repeat on the call in hand.`;
|
|
2907
3025
|
var ISSUE_VIEW_COMMAND = new RegExp(String.raw`^gh\s+${gh_api.GH_FLAGS}issue\s+view\s`, "u");
|
|
2908
3026
|
var ISSUE_BODY_PATH = /repos\/[^\s'"]*\/issues\/\d+(?=$|["'\s])/u;
|
|
2909
3027
|
var FETCHES_COMMENTS = /--comments\b|--json\s[\w,]*\bcomments\b|\/comments\b/u;
|
|
@@ -2928,7 +3046,7 @@ function is_body_only_issue_read(command) {
|
|
|
2928
3046
|
if (segments.some((segment) => fetches_issue_comments(segment))) return false;
|
|
2929
3047
|
return segments.some((segment) => is_body_read_segment(segment));
|
|
2930
3048
|
}
|
|
2931
|
-
var ISSUE_COMMENTS_REASON = "\u26D4 an Issue's comments are part of the Issue: read them before implementing, not only the body. A decision recorded after the body was written lives only in a comment \u2014 a corrected diagnosis (joshuafolkken/kit#1537), a changed default and an added acceptance criterion (joshuafolkken/kit#1520), a scope handed to another Issue (joshuafolkken/kit#1304) \u2014 and nothing in the body says it was superseded, so a body-only reader builds the wrong thing and sees no contradiction. Reissue this read with the comments included: `gh api repos/{owner}/{repo}/issues/<N>/comments --jq '.[] | {user: .user.login, created_at, body}'` beside the body read, or `gh issue view <N> --comments` where GraphQL is reachable. Then the later text is the agreement in force \u2014 a comment supersedes the body it contradicts \u2014 except for two answers that are not the run's to make: work a comment reassigns to another Issue is out of scope and is not implemented, and a comment saying the Issue no longer has a reason to exist stops the run with a `confirmation` Telegram. The procedure is `.claude/skills/workflow-commands/
|
|
3049
|
+
var ISSUE_COMMENTS_REASON = "\u26D4 an Issue's comments are part of the Issue: read them before implementing, not only the body. A decision recorded after the body was written lives only in a comment \u2014 a corrected diagnosis (joshuafolkken/kit#1537), a changed default and an added acceptance criterion (joshuafolkken/kit#1520), a scope handed to another Issue (joshuafolkken/kit#1304) \u2014 and nothing in the body says it was superseded, so a body-only reader builds the wrong thing and sees no contradiction. Reissue this read with the comments included: `gh api repos/{owner}/{repo}/issues/<N>/comments --jq '.[] | {user: .user.login, created_at, body}'` beside the body read, or `gh issue view <N> --comments` where GraphQL is reachable. Then the later text is the agreement in force \u2014 a comment supersedes the body it contradicts \u2014 except for two answers that are not the run's to make: work a comment reassigns to another Issue is out of scope and is not implemented, and a comment saying the Issue no longer has a reason to exist stops the run with a `confirmation` Telegram. The procedure is `.claude/skills/workflow-commands/issue-comments.md`. Every body-only read is refused until the comments are read.";
|
|
2932
3050
|
var { SHELL_BODY_REASON: SHELL_BODY_REASON2, carries_a_body: carries_a_body2, is_shell_evaluated_body: is_shell_evaluated_body2, keeps_body_safe: keeps_body_safe2 } = shell_body_trigger;
|
|
2933
3051
|
var ISSUE_LISTING = /^gh\s+(?:-{1,2}[\w-]+(?:[= ]\S+)?\s+)*issue\s+list\b/u;
|
|
2934
3052
|
var ISSUES_QUERY = /repos\/[^\s'"]*\/issues\?[^\s'"]*state=open/u;
|
|
@@ -4297,7 +4415,29 @@ async function pretool_outcome_async(raw_payload) {
|
|
|
4297
4415
|
if (reason !== void 0) return { reason, notice: void 0, fault: void 0 };
|
|
4298
4416
|
return with_step_zero_notice(base, raw_payload);
|
|
4299
4417
|
}
|
|
4300
|
-
|
|
4418
|
+
function guarded_call(raw_payload) {
|
|
4419
|
+
try {
|
|
4420
|
+
const payload = hook_decision.parse_hook_payload(raw_payload);
|
|
4421
|
+
return payload === void 0 ? void 0 : { name: payload.tool_name, input: payload.tool_input };
|
|
4422
|
+
} catch {
|
|
4423
|
+
return void 0;
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4426
|
+
function foreground_rewrite(outcome, raw_payload, is_lane_child) {
|
|
4427
|
+
if (outcome.reason !== void 0) return void 0;
|
|
4428
|
+
const call = guarded_call(raw_payload);
|
|
4429
|
+
const input = call === void 0 ? void 0 : lane_background.foreground_input(call, is_lane_child);
|
|
4430
|
+
if (input === void 0) return void 0;
|
|
4431
|
+
const context = [lane_background.FOREGROUND_NOTE, outcome.notice ?? outcome.fault];
|
|
4432
|
+
return hook_decision.rewrite_envelope(input, context.filter(Boolean).join("\n\n"));
|
|
4433
|
+
}
|
|
4434
|
+
function emit(raw_payload, outcome) {
|
|
4435
|
+
const rewrite = foreground_rewrite(outcome, raw_payload);
|
|
4436
|
+
if (rewrite === void 0) hook_decision.emit_outcome(outcome);
|
|
4437
|
+
else process.stdout.write(`${rewrite}
|
|
4438
|
+
`);
|
|
4439
|
+
}
|
|
4440
|
+
var pretool_guard = { combine_outcomes, emit, foreground_rewrite, pretool_outcome };
|
|
4301
4441
|
|
|
4302
4442
|
export {
|
|
4303
4443
|
pretool_outcome_async,
|