llm-wb 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/.agentic/00.chat/README.md +78 -0
  2. package/.agentic/00.chat/checklists/before-commit.md +195 -0
  3. package/.agentic/00.chat/checklists/llm-workbench-public-beta.md +94 -0
  4. package/.agentic/00.chat/commands/README.md +108 -0
  5. package/.agentic/00.chat/migration-plan.md +132 -0
  6. package/.agentic/00.chat/skills/session-summary.md +48 -0
  7. package/.agentic/00.chat/standards/llm-workbench-public-beta-contract.md +216 -0
  8. package/.agentic/00.chat/standards/main-refresh-conflict-types.md +358 -0
  9. package/.agentic/00.chat/workflows/README.md +40 -0
  10. package/.agentic/00.chat/workflows/bootstrap-chat-workbench-repo.md +212 -0
  11. package/.agentic/00.chat/workflows/chat-cleanup.md +102 -0
  12. package/.agentic/00.chat/workflows/chat-commit.md +56 -0
  13. package/.agentic/00.chat/workflows/chat-promote-to-main.md +169 -0
  14. package/.agentic/00.chat/workflows/chat-refresh-from-main.md +242 -0
  15. package/.agentic/00.chat/workflows/chat-reporting.md +69 -0
  16. package/.agentic/00.chat/workflows/chat-start.md +173 -0
  17. package/.agentic/00.chat/workflows/chat-upstream-reusable-lesson.md +123 -0
  18. package/.agentic/shared/standards/README.md +32 -0
  19. package/.agentic/shared/standards/upstream-repo-bootstrap.md +131 -0
  20. package/.agentic/shared/workflows/README.md +35 -0
  21. package/.agentic/shared/workflows/capability-resolution-workflow.md +189 -0
  22. package/.agentic/shared/workflows/change-shared-process.md +92 -0
  23. package/.cursor/rules/llm-workbench.mdc +17 -0
  24. package/.github/copilot-instructions.md +16 -0
  25. package/AGENTS.md +63 -0
  26. package/CLAUDE.md +16 -0
  27. package/CONTRIBUTING.md +57 -0
  28. package/LICENSE +21 -0
  29. package/LLM_WORKBENCH.md +17 -0
  30. package/README.md +98 -0
  31. package/SECURITY.md +44 -0
  32. package/bin/llm-workbench.js +672 -0
  33. package/docs/00.chat/README.md +47 -0
  34. package/docs/00.chat/llm-workbench-acceptance-matrix.md +55 -0
  35. package/docs/00.chat/script-layout.md +107 -0
  36. package/docs/adapting-to-your-repo.md +29 -0
  37. package/docs/concepts.md +38 -0
  38. package/docs/install.md +114 -0
  39. package/docs/public-beta-contract.md +45 -0
  40. package/docs/workflows.md +103 -0
  41. package/examples/minimal-repo/README.md +13 -0
  42. package/package.json +93 -0
  43. package/scripts/00.chat/README.md +46 -0
  44. package/scripts/00.chat/bootstrap/README.md +35 -0
  45. package/scripts/00.chat/bootstrap/audit-chat-bootstrap-file-set/README.md +39 -0
  46. package/scripts/00.chat/bootstrap/audit-chat-bootstrap-file-set/script.sh +213 -0
  47. package/scripts/00.chat/closeout/README.md +30 -0
  48. package/scripts/00.chat/closeout/build-closeout-prompt/README.md +35 -0
  49. package/scripts/00.chat/closeout/build-closeout-prompt/script.sh +124 -0
  50. package/scripts/00.chat/command/README.md +31 -0
  51. package/scripts/00.chat/command/close/README.md +30 -0
  52. package/scripts/00.chat/command/close/script.sh +25 -0
  53. package/scripts/00.chat/command/dispatcher/README.md +46 -0
  54. package/scripts/00.chat/command/dispatcher/script.sh +91 -0
  55. package/scripts/00.chat/command/dispatcher/smoke-test.sh +168 -0
  56. package/scripts/00.chat/command/new/README.md +32 -0
  57. package/scripts/00.chat/command/new/script.sh +28 -0
  58. package/scripts/00.chat/command/open-window/README.md +38 -0
  59. package/scripts/00.chat/command/open-window/script.sh +25 -0
  60. package/scripts/00.chat/command/package-scripts/README.md +34 -0
  61. package/scripts/00.chat/command/package-scripts/smoke-test.sh +113 -0
  62. package/scripts/00.chat/git/README.md +30 -0
  63. package/scripts/00.chat/git/cleanup-empty-chat-branches/README.md +36 -0
  64. package/scripts/00.chat/git/cleanup-empty-chat-branches/script.sh +243 -0
  65. package/scripts/00.chat/git/cleanup-empty-chat-branches/smoke-test.sh +136 -0
  66. package/scripts/00.chat/local-merge/README.md +30 -0
  67. package/scripts/00.chat/local-merge/list-active-chat-branches/README.md +29 -0
  68. package/scripts/00.chat/local-merge/list-active-chat-branches/script.sh +109 -0
  69. package/scripts/00.chat/local-merge/report-chat-branch-overlaps/README.md +29 -0
  70. package/scripts/00.chat/local-merge/report-chat-branch-overlaps/script.sh +142 -0
  71. package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/README.md +33 -0
  72. package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/script.sh +345 -0
  73. package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/smoke-test.sh +244 -0
  74. package/scripts/00.chat/main-refresh/README.md +39 -0
  75. package/scripts/00.chat/main-refresh/apply-rehearsed-refresh/README.md +32 -0
  76. package/scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh +198 -0
  77. package/scripts/00.chat/main-refresh/check-chat-is-current-with-main/README.md +30 -0
  78. package/scripts/00.chat/main-refresh/check-chat-is-current-with-main/script.sh +121 -0
  79. package/scripts/00.chat/main-refresh/classify-conflict/README.md +39 -0
  80. package/scripts/00.chat/main-refresh/classify-conflict/script.sh +169 -0
  81. package/scripts/00.chat/main-refresh/classify-conflict/smoke-test.sh +137 -0
  82. package/scripts/00.chat/main-refresh/classify-refresh-readiness/README.md +35 -0
  83. package/scripts/00.chat/main-refresh/classify-refresh-readiness/script.sh +171 -0
  84. package/scripts/00.chat/main-refresh/classify-refresh-readiness/smoke-test.sh +132 -0
  85. package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/README.md +34 -0
  86. package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh +124 -0
  87. package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/smoke-test.sh +257 -0
  88. package/scripts/00.chat/main-refresh/show-main-update-status/README.md +31 -0
  89. package/scripts/00.chat/main-refresh/show-main-update-status/script.sh +73 -0
  90. package/scripts/00.chat/main-refresh/verify-conflict-audit/README.md +37 -0
  91. package/scripts/00.chat/main-refresh/verify-conflict-audit/script.sh +154 -0
  92. package/scripts/00.chat/main-refresh/verify-conflict-audit/smoke-test.sh +99 -0
  93. package/scripts/00.chat/metrics/README.md +35 -0
  94. package/scripts/00.chat/metrics/data/chat-pricing.json +107 -0
  95. package/scripts/00.chat/metrics/data/chat-pricing.schema.json +63 -0
  96. package/scripts/00.chat/metrics/estimate-chat-cost/README.md +40 -0
  97. package/scripts/00.chat/metrics/estimate-chat-cost/script.js +130 -0
  98. package/scripts/00.chat/migration/README.md +30 -0
  99. package/scripts/00.chat/migration/audit-chat-layer-migration/README.md +33 -0
  100. package/scripts/00.chat/migration/audit-chat-layer-migration/script.sh +127 -0
  101. package/scripts/00.chat/recovery/README.md +30 -0
  102. package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/README.md +76 -0
  103. package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh +212 -0
  104. package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/smoke-test.sh +162 -0
  105. package/scripts/00.chat/reporting/README.md +30 -0
  106. package/scripts/00.chat/reporting/generate-commit-log-summary/README.md +35 -0
  107. package/scripts/00.chat/reporting/generate-commit-log-summary/script.sh +299 -0
  108. package/scripts/00.chat/reporting/generate-commit-log-summary/smoke-test.sh +93 -0
  109. package/scripts/00.chat/reporting/report-chat-workspaces/README.md +32 -0
  110. package/scripts/00.chat/reporting/report-chat-workspaces/script.sh +82 -0
  111. package/scripts/00.chat/session-log/README.md +33 -0
  112. package/scripts/00.chat/session-log/check-commit-prerequisites/README.md +89 -0
  113. package/scripts/00.chat/session-log/check-commit-prerequisites/script.sh +121 -0
  114. package/scripts/00.chat/session-log/check-commit-prerequisites/smoke-test.sh +119 -0
  115. package/scripts/00.chat/session-log/check-commitlog-deletions/README.md +90 -0
  116. package/scripts/00.chat/session-log/check-commitlog-deletions/script.sh +131 -0
  117. package/scripts/00.chat/session-log/check-commitlog-deletions/smoke-test.sh +123 -0
  118. package/scripts/00.chat/session-log/checkpoint-chat-session-log/README.md +98 -0
  119. package/scripts/00.chat/session-log/checkpoint-chat-session-log/script.sh +126 -0
  120. package/scripts/00.chat/session-log/paths/README.md +38 -0
  121. package/scripts/00.chat/session-log/paths/lib.sh +133 -0
  122. package/scripts/00.chat/session-log/prepare-chat-session-before-commit/README.md +90 -0
  123. package/scripts/00.chat/session-log/prepare-chat-session-before-commit/script.sh +145 -0
  124. package/scripts/00.chat/session-log/read-current-chat-log/README.md +44 -0
  125. package/scripts/00.chat/session-log/read-current-chat-log/script.sh +92 -0
  126. package/scripts/00.chat/session-log/read-current-chat-log/smoke-test.sh +127 -0
  127. package/scripts/00.chat/session-log/record-chat-commit/README.md +133 -0
  128. package/scripts/00.chat/session-log/record-chat-commit/script.sh +394 -0
  129. package/scripts/00.chat/session-log/record-chat-commit/smoke-test.sh +227 -0
  130. package/scripts/00.chat/session-log/record-main-refresh-conflict/README.md +34 -0
  131. package/scripts/00.chat/session-log/record-main-refresh-conflict/script.sh +239 -0
  132. package/scripts/00.chat/session-log/rename-current-chat-log-folder/README.md +32 -0
  133. package/scripts/00.chat/session-log/rename-current-chat-log-folder/script.sh +112 -0
  134. package/scripts/00.chat/session-log/update-chat-log/README.md +32 -0
  135. package/scripts/00.chat/session-log/update-chat-log/script.sh +294 -0
  136. package/scripts/00.chat/startup/README.md +37 -0
  137. package/scripts/00.chat/startup/auto-start-missing-session/README.md +113 -0
  138. package/scripts/00.chat/startup/auto-start-missing-session/script.sh +54 -0
  139. package/scripts/00.chat/startup/resolve-current-chat-session/README.md +57 -0
  140. package/scripts/00.chat/startup/resolve-current-chat-session/script.sh +47 -0
  141. package/scripts/00.chat/startup/resolve-current-chat-session/smoke-test.sh +130 -0
  142. package/scripts/00.chat/startup/start-chat-session/README.md +197 -0
  143. package/scripts/00.chat/startup/start-chat-session/script.sh +330 -0
  144. package/scripts/00.chat/startup/start-chat-session/smoke-test.sh +182 -0
  145. package/scripts/00.chat/startup/start-new-chat/README.md +31 -0
  146. package/scripts/00.chat/startup/start-new-chat/script.sh +29 -0
  147. package/scripts/00.chat/transcript/README.md +36 -0
  148. package/scripts/00.chat/transcript/discover-codex-session-log/README.md +32 -0
  149. package/scripts/00.chat/transcript/discover-codex-session-log/script.sh +106 -0
  150. package/scripts/00.chat/transcript/register-codex-session-log/README.md +32 -0
  151. package/scripts/00.chat/transcript/register-codex-session-log/script.sh +115 -0
  152. package/scripts/00.chat/worktree/README.md +32 -0
  153. package/scripts/00.chat/worktree/check-write-location/README.md +87 -0
  154. package/scripts/00.chat/worktree/check-write-location/script.sh +95 -0
  155. package/scripts/00.chat/worktree/dirty-worktree-check/README.md +77 -0
  156. package/scripts/00.chat/worktree/dirty-worktree-check/script.sh +93 -0
  157. package/scripts/00.chat/worktree/ensure-chat-worktree/README.md +33 -0
  158. package/scripts/00.chat/worktree/ensure-chat-worktree/script.sh +132 -0
  159. package/scripts/00.chat/worktree/open-window/README.md +34 -0
  160. package/scripts/00.chat/worktree/open-window/script.sh +131 -0
  161. package/scripts/00.chat/worktree/paths/README.md +32 -0
  162. package/scripts/00.chat/worktree/paths/lib.sh +71 -0
  163. package/scripts/01.harness/artifact-metadata/check-headers/script.sh +522 -0
  164. package/scripts/01.harness/artifact-metadata/check-headers/smoke-test.sh +48 -0
  165. package/scripts/01.harness/check-deterministic-process-drift.sh +416 -0
  166. package/scripts/01.harness/check-governed-script-command-drift.sh +184 -0
  167. package/scripts/01.harness/run-governed-script.sh +178 -0
  168. package/scripts/install.sh +503 -0
  169. package/scripts/uninstall.sh +199 -0
  170. package/tests/smoke-test-install.sh +70 -0
@@ -0,0 +1,34 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.main-refresh.rehearse-refresh-from-main.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: main-refresh
8
+ disciplines:
9
+ - agentic
10
+ kind: guide
11
+ purpose: Explain how the harness rehearses refreshing a chat branch from main before
12
+ applying it.
13
+ portability:
14
+ class: required
15
+ targets:
16
+ - llm-workbench
17
+ used_by:
18
+ - id: chat.script.main-refresh.rehearse-refresh-from-main
19
+ path: scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh
20
+ - id: chat.script.main-refresh.rehearse-refresh-from-main.smoke-test
21
+ path: scripts/00.chat/main-refresh/rehearse-refresh-from-main/smoke-test.sh
22
+ -->
23
+ # Rehearse Refresh From Main
24
+
25
+ This capability answers: would refreshing this chat branch from `main` work
26
+ safely?
27
+
28
+ It creates a temporary preflight branch and worktree from the current chat
29
+ branch, then merges the base branch there. The active chat worktree is left
30
+ untouched. If the merge succeeds, the temporary branch contains the tested merge
31
+ result and can be applied with `apply-rehearsed-refresh`.
32
+
33
+ Use this when a chat branch has real work and a direct refresh would be too
34
+ risky to perform without rehearsal.
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.main-refresh.rehearse-refresh-from-main
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: main-refresh
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Rehearse refreshing a chat branch from main in a temporary worktree.
15
+ # portability:
16
+ # class: required
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.workflows.chat-refresh-from-main
21
+ # path: .agentic/00.chat/workflows/chat-refresh-from-main.md
22
+ # - id: chat.script.main-refresh.rehearse-refresh-from-main.smoke-test
23
+ # path: scripts/00.chat/main-refresh/rehearse-refresh-from-main/smoke-test.sh
24
+ # effects:
25
+ # - branches
26
+ # - commits
27
+ # - worktrees
28
+
29
+ usage() {
30
+ cat <<'EOF'
31
+ Usage:
32
+ script.sh [base-branch]
33
+
34
+ Creates a temporary worktree and branch from the current chat branch, then
35
+ attempts to merge the base branch there. The active chat worktree is left
36
+ untouched. If the merge succeeds, the preflight branch contains the merge
37
+ commit and can be applied with apply-rehearsed-refresh.
38
+ EOF
39
+ }
40
+
41
+ BASE_BRANCH="${1:-main}"
42
+
43
+ if [ $# -gt 1 ]; then
44
+ usage >&2
45
+ exit 2
46
+ fi
47
+
48
+ case "$BASE_BRANCH" in
49
+ -h|--help)
50
+ usage
51
+ exit 0
52
+ ;;
53
+ esac
54
+
55
+ if ! git show-ref --verify --quiet "refs/heads/${BASE_BRANCH}"; then
56
+ echo "ERROR: base branch does not exist: ${BASE_BRANCH}" >&2
57
+ exit 1
58
+ fi
59
+
60
+ CLASSIFICATION="$(bash scripts/00.chat/main-refresh/classify-refresh-readiness/script.sh "$BASE_BRANCH" | sed -n 's/^classification=//p' | head -n 1)"
61
+
62
+ if [ "$CLASSIFICATION" != "clean" ]; then
63
+ echo "ERROR: preflight requires a clean chat worktree." >&2
64
+ echo "Classifier reported: ${CLASSIFICATION}" >&2
65
+ echo "Checkpoint or recover dirty state before preflighting main refresh." >&2
66
+ exit 1
67
+ fi
68
+
69
+ CURRENT_BRANCH="$(git branch --show-current)"
70
+
71
+ case "$CURRENT_BRANCH" in
72
+ chat/*)
73
+ ;;
74
+ *)
75
+ echo "ERROR: current branch is not a chat branch: ${CURRENT_BRANCH}" >&2
76
+ exit 1
77
+ ;;
78
+ esac
79
+
80
+ CURRENT_HEAD="$(git rev-parse HEAD)"
81
+ RAW_SAFE_BRANCH="$(printf '%s' "$CURRENT_BRANCH" | tr -c 'A-Za-z0-9._-' '-')"
82
+ SAFE_BRANCH_PREFIX="$(printf '%s' "$RAW_SAFE_BRANCH" | cut -c1-48 | sed -E 's/[-.]+$//')"
83
+ if [ -z "${SAFE_BRANCH_PREFIX// }" ]; then
84
+ SAFE_BRANCH_PREFIX="chat"
85
+ fi
86
+ SAFE_BRANCH="${SAFE_BRANCH_PREFIX}-$(git rev-parse --short=12 HEAD)"
87
+ STAMP="$(date -u +%Y%m%d%H%M%S)"
88
+ PREFLIGHT_BRANCH="agentic/preflight/${SAFE_BRANCH}/${STAMP}"
89
+ PREFLIGHT_ROOT="${TMPDIR:-/tmp}/agentic-main-refresh-preflight"
90
+ PREFLIGHT_WORKTREE="${PREFLIGHT_ROOT}/${SAFE_BRANCH}-${STAMP}"
91
+ MERGE_OUT="${PREFLIGHT_ROOT}/${SAFE_BRANCH}-${STAMP}.merge.out"
92
+ MERGE_ERR="${PREFLIGHT_ROOT}/${SAFE_BRANCH}-${STAMP}.merge.err"
93
+
94
+ mkdir -p "$PREFLIGHT_ROOT"
95
+
96
+ git branch "$PREFLIGHT_BRANCH" "$CURRENT_HEAD"
97
+ git worktree add -q "$PREFLIGHT_WORKTREE" "$PREFLIGHT_BRANCH"
98
+
99
+ set +e
100
+ git -C "$PREFLIGHT_WORKTREE" merge --no-ff --no-edit "$BASE_BRANCH" \
101
+ > "$MERGE_OUT" 2> "$MERGE_ERR"
102
+ MERGE_STATUS="$?"
103
+ set -e
104
+
105
+ echo "preflight_branch=${PREFLIGHT_BRANCH}"
106
+ echo "preflight_worktree=${PREFLIGHT_WORKTREE}"
107
+ echo "source_branch=${CURRENT_BRANCH}"
108
+ echo "source_head=${CURRENT_HEAD}"
109
+ echo "base_branch=${BASE_BRANCH}"
110
+
111
+ if [ "$MERGE_STATUS" -ne 0 ]; then
112
+ echo "result=conflict-or-failed"
113
+ echo "conflict_paths<<EOF"
114
+ git -C "$PREFLIGHT_WORKTREE" diff --name-only --diff-filter=U | sort -u
115
+ echo "EOF"
116
+ echo "Merge output:"
117
+ sed 's/^/ /' "$MERGE_ERR"
118
+ exit 1
119
+ fi
120
+
121
+ echo "result=clean-merge"
122
+ echo "preflight_head=$(git -C "$PREFLIGHT_WORKTREE" rev-parse HEAD)"
123
+ echo "Apply with:"
124
+ echo " bash scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh ${PREFLIGHT_BRANCH}"
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.main-refresh.rehearse-refresh-from-main.smoke-test
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: main-refresh
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Smoke test rehearsed main refresh and apply behavior.
15
+ # portability:
16
+ # class: reusable
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.workflows.chat-refresh-from-main
21
+ # path: .agentic/00.chat/workflows/chat-refresh-from-main.md
22
+ # - id: chat.script.main-refresh.rehearse-refresh-from-main
23
+ # path: scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh
24
+ # effects:
25
+ # - branches
26
+ # - commits
27
+ # - destructive
28
+ # - worktrees
29
+ # - writes-files
30
+
31
+ fail() {
32
+ echo "FAIL: $*" >&2
33
+ exit 1
34
+ }
35
+
36
+ SOURCE_ROOT="$(git rev-parse --show-toplevel)"
37
+ TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/main-refresh-preflight-smoke.XXXXXX")"
38
+
39
+ cleanup() {
40
+ if [ -n "${PREFLIGHT_WORKTREE:-}" ] && [ -d "$PREFLIGHT_WORKTREE" ]; then
41
+ git -C "$REPO" worktree remove -f "$PREFLIGHT_WORKTREE" >/dev/null 2>&1 || true
42
+ fi
43
+ if [ -n "${DIRTY_PREFLIGHT_WORKTREE:-}" ] && [ -d "$DIRTY_PREFLIGHT_WORKTREE" ]; then
44
+ git -C "$REPO" worktree remove -f "$DIRTY_PREFLIGHT_WORKTREE" >/dev/null 2>&1 || true
45
+ fi
46
+ if [ -n "${PREFLIGHT_BRANCH:-}" ]; then
47
+ git -C "$REPO" branch -D "$PREFLIGHT_BRANCH" >/dev/null 2>&1 || true
48
+ fi
49
+ if [ -n "${DIRTY_PREFLIGHT_BRANCH:-}" ]; then
50
+ git -C "$REPO" branch -D "$DIRTY_PREFLIGHT_BRANCH" >/dev/null 2>&1 || true
51
+ fi
52
+ if [ -n "${STALE_PREFLIGHT_WORKTREE:-}" ] && [ -d "$STALE_PREFLIGHT_WORKTREE" ]; then
53
+ git -C "$REPO" worktree remove -f "$STALE_PREFLIGHT_WORKTREE" >/dev/null 2>&1 || true
54
+ fi
55
+ if [ -n "${UNIQUE_PREFLIGHT_WORKTREE:-}" ] && [ -d "$UNIQUE_PREFLIGHT_WORKTREE" ]; then
56
+ git -C "$REPO" worktree remove -f "$UNIQUE_PREFLIGHT_WORKTREE" >/dev/null 2>&1 || true
57
+ fi
58
+ if [ -n "${STALE_PREFLIGHT_BRANCH:-}" ]; then
59
+ git -C "$REPO" branch -D "$STALE_PREFLIGHT_BRANCH" >/dev/null 2>&1 || true
60
+ fi
61
+ if [ -n "${UNIQUE_PREFLIGHT_BRANCH:-}" ]; then
62
+ git -C "$REPO" branch -D "$UNIQUE_PREFLIGHT_BRANCH" >/dev/null 2>&1 || true
63
+ fi
64
+ rm -rf "$TMP_ROOT"
65
+ }
66
+
67
+ trap cleanup EXIT
68
+
69
+ REPO="$TMP_ROOT/repo"
70
+ SESSION_ID="2026-06-17-00-01-preflight-chat-with-a-long-trailing-hyphen-name-that-needs-safe-preflight-shortening-"
71
+ SESSION_LOG="commitLogs/2026/jun/17/${SESSION_ID}/README.md"
72
+
73
+ mkdir -p \
74
+ "$REPO/scripts/00.chat/main-refresh/classify-refresh-readiness" \
75
+ "$REPO/scripts/00.chat/main-refresh/rehearse-refresh-from-main" \
76
+ "$REPO/scripts/00.chat/main-refresh/apply-rehearsed-refresh" \
77
+ "$REPO/scripts/00.chat/reporting/generate-commit-log-summary" \
78
+ "$REPO/scripts/00.chat/session-log/paths" \
79
+ "$REPO/$(dirname "$SESSION_LOG")"
80
+
81
+ cp "$SOURCE_ROOT/scripts/00.chat/session-log/paths/lib.sh" \
82
+ "$REPO/scripts/00.chat/session-log/paths/lib.sh"
83
+ cp "$SOURCE_ROOT/scripts/00.chat/reporting/generate-commit-log-summary/script.sh" \
84
+ "$REPO/scripts/00.chat/reporting/generate-commit-log-summary/script.sh"
85
+ cp "$SOURCE_ROOT/scripts/00.chat/main-refresh/classify-refresh-readiness/script.sh" \
86
+ "$REPO/scripts/00.chat/main-refresh/classify-refresh-readiness/script.sh"
87
+ cp "$SOURCE_ROOT/scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh" \
88
+ "$REPO/scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh"
89
+ cp "$SOURCE_ROOT/scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh" \
90
+ "$REPO/scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh"
91
+
92
+ git -C "$REPO" init -q -b main
93
+ git -C "$REPO" config user.name "Smoke Test"
94
+ git -C "$REPO" config user.email "smoke@example.invalid"
95
+
96
+ cat > "$REPO/README.md" <<'EOF'
97
+ base
98
+ EOF
99
+
100
+ cat > "$REPO/$SESSION_LOG" <<EOF
101
+ # Chat Session: ${SESSION_ID}
102
+
103
+ <!-- agentic-session
104
+ id: ${SESSION_ID}
105
+ chat_duration: 10s
106
+ estimated_chat_tokens: 50 tokens
107
+ -->
108
+ EOF
109
+
110
+ (
111
+ cd "$REPO"
112
+ bash scripts/00.chat/reporting/generate-commit-log-summary/script.sh >/dev/null
113
+ )
114
+
115
+ git -C "$REPO" add .
116
+ git -C "$REPO" commit -q -m "base"
117
+ git -C "$REPO" switch -q -c "chat/${SESSION_ID}"
118
+
119
+ git -C "$REPO" switch -q main
120
+ printf 'main update\n' >> "$REPO/README.md"
121
+ git -C "$REPO" add README.md
122
+ git -C "$REPO" commit -q -m "update main"
123
+ git -C "$REPO" switch -q "chat/${SESSION_ID}"
124
+
125
+ PREFLIGHT_OUTPUT="$(
126
+ cd "$REPO"
127
+ TMPDIR="$TMP_ROOT" bash scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh
128
+ )"
129
+
130
+ PREFLIGHT_BRANCH="$(printf '%s\n' "$PREFLIGHT_OUTPUT" | sed -n 's/^preflight_branch=//p')"
131
+ PREFLIGHT_WORKTREE="$(printf '%s\n' "$PREFLIGHT_OUTPUT" | sed -n 's/^preflight_worktree=//p')"
132
+ PREFLIGHT_HEAD="$(printf '%s\n' "$PREFLIGHT_OUTPUT" | sed -n 's/^preflight_head=//p')"
133
+
134
+ if [ -z "$PREFLIGHT_BRANCH" ] || [ -z "$PREFLIGHT_WORKTREE" ] || [ -z "$PREFLIGHT_HEAD" ]; then
135
+ fail "preflight did not report branch, worktree, and head"
136
+ fi
137
+
138
+ PREFLIGHT_NAMESPACE="${PREFLIGHT_BRANCH%/*}"
139
+ PREFLIGHT_NAMESPACE="${PREFLIGHT_NAMESPACE##*/}"
140
+ if [ "${#PREFLIGHT_NAMESPACE}" -gt 64 ]; then
141
+ fail "preflight namespace was not shortened: $PREFLIGHT_NAMESPACE"
142
+ fi
143
+
144
+ if ! printf '%s\n' "$PREFLIGHT_OUTPUT" | grep -q '^result=clean-merge$'; then
145
+ fail "preflight did not report a clean merge"
146
+ fi
147
+
148
+ printf 'dirty preflight residue\n' >> "$PREFLIGHT_WORKTREE/preflight-note.txt"
149
+
150
+ set +e
151
+ DIRTY_PROMOTE_OUTPUT="$({
152
+ cd "$REPO"
153
+ bash scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh "$PREFLIGHT_BRANCH"
154
+ } 2> "$TMP_ROOT/dirty-promote.err")"
155
+ DIRTY_PROMOTE_STATUS="$?"
156
+ set -e
157
+
158
+ if [ "$DIRTY_PROMOTE_STATUS" -eq 0 ]; then
159
+ fail "apply succeeded with dirty preflight worktree"
160
+ fi
161
+
162
+ if ! grep -q "refusing to clean dirty preflight worktree" "$TMP_ROOT/dirty-promote.err"; then
163
+ fail "dirty preflight worktree failure was not explained"
164
+ fi
165
+
166
+ if [ "$(git -C "$REPO" rev-parse HEAD)" = "$PREFLIGHT_HEAD" ]; then
167
+ fail "dirty cleanup failure still applied to chat branch"
168
+ fi
169
+
170
+ rm -f "$PREFLIGHT_WORKTREE/preflight-note.txt"
171
+
172
+ PREFLIGHT_PREFIX="${PREFLIGHT_BRANCH%/*}"
173
+ STALE_PREFLIGHT_BRANCH="${PREFLIGHT_PREFIX}/20000101000000"
174
+ STALE_PREFLIGHT_WORKTREE="$TMP_ROOT/stale-preflight-worktree"
175
+ git -C "$REPO" branch "$STALE_PREFLIGHT_BRANCH" HEAD
176
+ git -C "$REPO" worktree add --quiet "$STALE_PREFLIGHT_WORKTREE" "$STALE_PREFLIGHT_BRANCH"
177
+
178
+ UNIQUE_PREFLIGHT_BRANCH="${PREFLIGHT_PREFIX}/20000101000001"
179
+ UNIQUE_PREFLIGHT_WORKTREE="$TMP_ROOT/unique-preflight-worktree"
180
+ git -C "$REPO" branch "$UNIQUE_PREFLIGHT_BRANCH" HEAD
181
+ git -C "$REPO" worktree add --quiet "$UNIQUE_PREFLIGHT_WORKTREE" "$UNIQUE_PREFLIGHT_BRANCH"
182
+ printf 'unique stale preflight\n' >> "$UNIQUE_PREFLIGHT_WORKTREE/unique.txt"
183
+ git -C "$UNIQUE_PREFLIGHT_WORKTREE" add unique.txt
184
+ git -C "$UNIQUE_PREFLIGHT_WORKTREE" commit -q -m "unique stale preflight work"
185
+
186
+ PROMOTE_OUTPUT="$(
187
+ cd "$REPO"
188
+ bash scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh "$PREFLIGHT_BRANCH"
189
+ )"
190
+
191
+ if ! grep -q "main update" "$REPO/README.md"; then
192
+ fail "promoted chat branch does not include main update"
193
+ fi
194
+
195
+ if [ "$(git -C "$REPO" rev-parse HEAD)" != "$PREFLIGHT_HEAD" ]; then
196
+ fail "applied chat branch does not point at preflight head"
197
+ fi
198
+
199
+ if git -C "$REPO" show-ref --verify --quiet "refs/heads/${PREFLIGHT_BRANCH}"; then
200
+ fail "preflight branch still exists after successful promotion"
201
+ fi
202
+
203
+ if git -C "$REPO" worktree list --porcelain | grep -Fqx "worktree ${PREFLIGHT_WORKTREE}"; then
204
+ fail "preflight worktree still exists after successful promotion"
205
+ fi
206
+
207
+ if ! printf '%s\n' "$PROMOTE_OUTPUT" | grep -q '^cleanup_result=removed-worktree-and-deleted-branch$'; then
208
+ fail "apply did not report cleanup result"
209
+ fi
210
+
211
+ if git -C "$REPO" show-ref --verify --quiet "refs/heads/${STALE_PREFLIGHT_BRANCH}"; then
212
+ fail "ancestor stale preflight branch still exists after promotion"
213
+ fi
214
+
215
+ if git -C "$REPO" worktree list --porcelain | grep -Fqx "worktree ${STALE_PREFLIGHT_WORKTREE}"; then
216
+ fail "ancestor stale preflight worktree still exists after promotion"
217
+ fi
218
+
219
+ if ! printf '%s\n' "$PROMOTE_OUTPUT" | grep -q "^stale_preflight_removed=${STALE_PREFLIGHT_BRANCH} "; then
220
+ fail "apply did not report stale preflight removal"
221
+ fi
222
+
223
+ if ! git -C "$REPO" show-ref --verify --quiet "refs/heads/${UNIQUE_PREFLIGHT_BRANCH}"; then
224
+ fail "unique stale preflight branch was deleted"
225
+ fi
226
+
227
+ if ! git -C "$REPO" worktree list --porcelain | grep -Fqx "worktree ${UNIQUE_PREFLIGHT_WORKTREE}"; then
228
+ fail "unique stale preflight worktree was removed"
229
+ fi
230
+
231
+ if ! printf '%s\n' "$PROMOTE_OUTPUT" | grep -q "^stale_preflight_skipped=${UNIQUE_PREFLIGHT_BRANCH} reason=unique-commits-not-in-promoted-head$"; then
232
+ fail "apply did not report unique stale preflight skip"
233
+ fi
234
+
235
+ DIRTY_PREFLIGHT_BRANCH="topic/not-preflight"
236
+ git -C "$REPO" branch "$DIRTY_PREFLIGHT_BRANCH" HEAD
237
+ set +e
238
+ (
239
+ cd "$REPO"
240
+ bash scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh "$DIRTY_PREFLIGHT_BRANCH"
241
+ ) > "$TMP_ROOT/non-preflight.out" 2> "$TMP_ROOT/non-preflight.err"
242
+ NON_PREFLIGHT_STATUS="$?"
243
+ set -e
244
+
245
+ if [ "$NON_PREFLIGHT_STATUS" -eq 0 ]; then
246
+ fail "apply accepted a non-preflight branch"
247
+ fi
248
+
249
+ if ! grep -q "refusing non-preflight branch" "$TMP_ROOT/non-preflight.err"; then
250
+ fail "non-preflight branch failure was not explained"
251
+ fi
252
+
253
+ if [ -n "$(git -C "$REPO" status --porcelain)" ]; then
254
+ fail "repo is dirty after preflight promotion"
255
+ fi
256
+
257
+ echo "main refresh rehearsal smoke test passed."
@@ -0,0 +1,31 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.main-refresh.show-main-update-status.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: main-refresh
8
+ disciplines:
9
+ - agentic
10
+ kind: guide
11
+ purpose: Explain the local main update status report for chat branches.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.script.main-refresh.show-main-update-status
18
+ path: scripts/00.chat/main-refresh/show-main-update-status/script.sh
19
+ -->
20
+ # Show Main Update Status
21
+
22
+ This read-only capability answers: has local `main` moved relative to the chat
23
+ branches?
24
+
25
+ It prints each local branch's ahead/behind count relative to the selected base
26
+ branch, defaulting to `main`. It does not fetch, merge, rebase, stage, or write
27
+ files. If remotes exist, it reminds the operator to fetch before treating the
28
+ comparison as current.
29
+
30
+ Use this near the start of a main-refresh conversation so the human and agent
31
+ share the same branch map before choosing a refresh path.
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.main-refresh.show-main-update-status
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: main-refresh
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Show whether local chat branches are ahead of or behind the base branch.
15
+ # portability:
16
+ # class: required
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.workflows.chat-refresh-from-main
21
+ # path: .agentic/00.chat/workflows/chat-refresh-from-main.md
22
+ # - id: harness.script.run-governed-script
23
+ # path: scripts/01.harness/run-governed-script.sh
24
+ # effects:
25
+ # - read-only
26
+
27
+ BASE_BRANCH="${1:-main}"
28
+
29
+ if ! git show-ref --verify --quiet "refs/heads/${BASE_BRANCH}"; then
30
+ echo "ERROR: base branch does not exist: ${BASE_BRANCH}" >&2
31
+ exit 1
32
+ fi
33
+
34
+ current_branch="$(git branch --show-current)"
35
+
36
+ if [ -z "$current_branch" ]; then
37
+ echo "ERROR: current HEAD is detached." >&2
38
+ exit 1
39
+ fi
40
+
41
+ echo "Base branch: ${BASE_BRANCH}"
42
+ echo "Current branch: ${current_branch}"
43
+
44
+ if git remote | grep -q .; then
45
+ echo "Remote freshness: remotes configured; run git fetch --prune before relying on remote comparisons."
46
+ else
47
+ echo "Remote freshness: no remotes configured; comparisons are local only."
48
+ fi
49
+
50
+ echo
51
+ printf '%-72s %8s %8s %s\n' "branch" "behind" "ahead" "state"
52
+
53
+ git branch --format='%(refname:short)' | while IFS= read -r branch; do
54
+ if [ "$branch" = "$BASE_BRANCH" ]; then
55
+ continue
56
+ fi
57
+
58
+ counts="$(git rev-list --left-right --count "${BASE_BRANCH}...${branch}")"
59
+ behind="${counts%% *}"
60
+ ahead="${counts##* }"
61
+
62
+ if [ "$behind" = "0" ] && [ "$ahead" = "0" ]; then
63
+ state="even"
64
+ elif [ "$behind" = "0" ]; then
65
+ state="ahead"
66
+ elif [ "$ahead" = "0" ]; then
67
+ state="behind"
68
+ else
69
+ state="diverged"
70
+ fi
71
+
72
+ printf '%-72s %8s %8s %s\n' "$branch" "$behind" "$ahead" "$state"
73
+ done
@@ -0,0 +1,37 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.main-refresh.verify-conflict-audit.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: main-refresh
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain verification of main-refresh conflict audit entries.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.script.main-refresh.verify-conflict-audit
18
+ path: scripts/00.chat/main-refresh/verify-conflict-audit/script.sh
19
+ - id: chat.workflows.chat-refresh-from-main
20
+ path: .agentic/00.chat/workflows/chat-refresh-from-main.md
21
+ -->
22
+ # Verify Main Refresh Conflict Audit
23
+
24
+ `script.sh` verifies that known main-refresh conflict paths have matching
25
+ entries in a chat session log's `## Main Refresh Conflicts` section.
26
+
27
+ Use it before applying or promoting a rehearsed refresh that encountered
28
+ conflicts. If conflicts are still unresolved, the script can discover them from
29
+ the Git index. If conflicts have already been resolved in the preflight
30
+ worktree, pass the captured path list explicitly with `--path` or
31
+ `--paths-file`.
32
+
33
+ ```bash
34
+ bash scripts/00.chat/main-refresh/verify-conflict-audit/script.sh \
35
+ --session-log commitLogs/.../README.md \
36
+ --path docs/example-conflict.md
37
+ ```