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,227 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.session-log.record-chat-commit.smoke-test
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: session-log
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Smoke test chat commit recording metrics and transcript discovery.
15
+ # portability:
16
+ # class: reusable
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.checklists.before-commit
21
+ # path: .agentic/00.chat/checklists/before-commit.md
22
+ # - id: chat.script.session-log.record-chat-commit.readme
23
+ # path: scripts/00.chat/session-log/record-chat-commit/README.md
24
+ # - id: chat.script.session-log.record-chat-commit
25
+ # path: scripts/00.chat/session-log/record-chat-commit/script.sh
26
+ # effects:
27
+ # - writes-files
28
+ # - branches
29
+ # - commits
30
+ fail() {
31
+ echo "FAIL: $*" >&2
32
+ exit 1
33
+ }
34
+
35
+ SOURCE_ROOT="$(git rev-parse --show-toplevel)"
36
+ TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/record-chat-commit-metrics-smoke.XXXXXX")"
37
+
38
+ cleanup() {
39
+ rm -rf "$TMP_ROOT"
40
+ }
41
+
42
+ trap cleanup EXIT
43
+
44
+ REPO="$TMP_ROOT/repo"
45
+ SESSION_ID="2026-06-18-00-00-token-metrics"
46
+ BRANCH="chat/${SESSION_ID}"
47
+ LOG_FILE="commitLogs/2026/jun/18/${SESSION_ID}/README.md"
48
+
49
+ mkdir -p "$REPO/scripts/00.chat/transcript/discover-codex-session-log" \
50
+ "$REPO/scripts/00.chat/metrics/estimate-chat-cost" \
51
+ "$REPO/scripts/00.chat/metrics/data" \
52
+ "$REPO/scripts/00.chat/session-log/record-chat-commit" \
53
+ "$REPO/scripts/00.chat/session-log/paths" \
54
+ "$REPO/${LOG_FILE%/README.md}"
55
+ cp "$SOURCE_ROOT/scripts/00.chat/session-log/record-chat-commit/script.sh" \
56
+ "$REPO/scripts/00.chat/session-log/record-chat-commit/script.sh"
57
+ cp "$SOURCE_ROOT/scripts/00.chat/session-log/paths/lib.sh" \
58
+ "$REPO/scripts/00.chat/session-log/paths/lib.sh"
59
+ cp "$SOURCE_ROOT/scripts/00.chat/transcript/discover-codex-session-log/script.sh" \
60
+ "$REPO/scripts/00.chat/transcript/discover-codex-session-log/script.sh"
61
+ cp "$SOURCE_ROOT/scripts/00.chat/metrics/estimate-chat-cost/script.js" \
62
+ "$REPO/scripts/00.chat/metrics/estimate-chat-cost/script.js"
63
+ cp "$SOURCE_ROOT/scripts/00.chat/metrics/data/chat-pricing.json" \
64
+ "$REPO/scripts/00.chat/metrics/data/chat-pricing.json"
65
+ chmod +x "$REPO/scripts/00.chat/session-log/record-chat-commit/script.sh" \
66
+ "$REPO/scripts/00.chat/transcript/discover-codex-session-log/script.sh"
67
+
68
+ cat > "$REPO/$LOG_FILE" <<EOF
69
+ # Chat Session: token metrics
70
+
71
+ <!-- agentic-session
72
+ id: ${SESSION_ID}
73
+ branch: ${BRANCH}
74
+ raised_at_utc: 2026-06-18T00:00:00Z
75
+ transcript_provider:
76
+ transcript_path:
77
+ transcript_bytes:
78
+ transcript_source:
79
+ latest_commit_at_utc:
80
+ latest_commit_sha:
81
+ chat_duration:
82
+ estimated_tokens:
83
+ estimated_chat_cost:
84
+ estimated_chat_cost_basis:
85
+ -->
86
+
87
+ ## Commits
88
+
89
+ - None recorded yet.
90
+
91
+ ## Activity Log
92
+
93
+ - None recorded yet.
94
+
95
+ ## Session Metrics
96
+
97
+ Raised at UTC: 2026-06-18T00:00:00Z
98
+ Latest commit at UTC:
99
+ Latest commit SHA:
100
+ Chat duration:
101
+ Estimated tokens:
102
+ Estimated chat cost:
103
+ Estimated chat cost basis:
104
+ EOF
105
+
106
+ (
107
+ cd "$REPO"
108
+ git init -q
109
+ git config user.name "Smoke Test"
110
+ git config user.email "smoke@example.invalid"
111
+ git add .
112
+ git commit -q -m "initial"
113
+ git checkout -q -b "$BRANCH"
114
+ )
115
+
116
+ set +e
117
+ (
118
+ cd "$REPO"
119
+ CODEX_HOME="$TMP_ROOT/empty-codex" \
120
+ CHAT_TRANSCRIPT_METRICS_MODE=strict \
121
+ bash scripts/00.chat/session-log/record-chat-commit/script.sh abc1234 "Test commit" "Missing token metric"
122
+ ) >/dev/null 2>"$TMP_ROOT/missing-metrics.err"
123
+ MISSING_STATUS="$?"
124
+ set -e
125
+
126
+ if [ "$MISSING_STATUS" -eq 0 ]; then
127
+ fail "recording succeeded without chat transcript metrics"
128
+ fi
129
+
130
+ if ! grep -q "missing chat transcript metrics" "$TMP_ROOT/missing-metrics.err"; then
131
+ fail "missing metrics failure was not explained"
132
+ fi
133
+
134
+ (
135
+ cd "$REPO"
136
+ CODEX_HOME="$TMP_ROOT/empty-codex" \
137
+ bash scripts/00.chat/session-log/record-chat-commit/script.sh abc1234 "Test commit" "Portable unavailable token metric" >/dev/null
138
+ )
139
+
140
+ if grep -q '^estimated_tokens:' "$REPO/$LOG_FILE"; then
141
+ fail "legacy estimated_tokens metadata remained after recording"
142
+ fi
143
+
144
+ if ! grep -q '^estimated_chat_tokens: unavailable; transcript source not supplied by chat$' "$REPO/$LOG_FILE"; then
145
+ fail "portable missing transcript metric was not marked unavailable"
146
+ fi
147
+
148
+ if ! grep -q '^Estimated chat tokens: unavailable; transcript source not supplied by chat$' "$REPO/$LOG_FILE"; then
149
+ fail "visible portable missing transcript metric was not marked unavailable"
150
+ fi
151
+
152
+ if ! grep -q '^estimated_chat_cost: unavailable; estimated chat tokens are unavailable$' "$REPO/$LOG_FILE"; then
153
+ fail "missing-token escape did not mark estimated chat cost unavailable"
154
+ fi
155
+
156
+ CODEX_HOME_FIXTURE="$TMP_ROOT/codex-home"
157
+ CODEX_SESSION_LOG="$CODEX_HOME_FIXTURE/sessions/2026/06/18/rollout-test.jsonl"
158
+ mkdir -p "${CODEX_SESSION_LOG%/*}"
159
+ cat > "$CODEX_SESSION_LOG" <<EOF
160
+ {"type":"message","payload":"${SESSION_ID}"}
161
+ {"type":"message","payload":"${BRANCH}"}
162
+ {"type":"message","payload":"${LOG_FILE}"}
163
+ EOF
164
+ CODEX_SESSION_BYTES="$(wc -c < "$CODEX_SESSION_LOG" | tr -d ' ')"
165
+ CODEX_SESSION_TOKENS="$(( (CODEX_SESSION_BYTES + 3) / 4 ))"
166
+
167
+ (
168
+ cd "$REPO"
169
+ CODEX_HOME="$CODEX_HOME_FIXTURE" \
170
+ CHAT_TRANSCRIPT_PROVIDER=codex \
171
+ bash scripts/00.chat/session-log/record-chat-commit/script.sh cde4567 "Test commit 2" "Discovered Codex session metric" >/dev/null
172
+ )
173
+
174
+ if ! grep -q '^transcript_provider: codex$' "$REPO/$LOG_FILE"; then
175
+ fail "discovered Codex provider was not recorded"
176
+ fi
177
+
178
+ if ! grep -q "^transcript_path: ${CODEX_SESSION_LOG}$" "$REPO/$LOG_FILE"; then
179
+ fail "discovered Codex transcript path was not recorded"
180
+ fi
181
+
182
+ if ! grep -q "^estimated_chat_tokens: ${CODEX_SESSION_TOKENS} estimated from chat transcript bytes (${CODEX_SESSION_BYTES} bytes; source: codex path: ${CODEX_SESSION_LOG})$" "$REPO/$LOG_FILE"; then
183
+ fail "discovered Codex session byte metric was not recorded"
184
+ fi
185
+
186
+ if ! grep -q '^estimated_chat_cost: unavailable; no pricing profile selected$' "$REPO/$LOG_FILE"; then
187
+ fail "Codex transcript without explicit pricing profile did not leave cost unavailable"
188
+ fi
189
+
190
+ if ! grep -q '^estimated_chat_cost_basis: unavailable; set CHAT_COST_PROFILE or CHAT_COST_PRICING_FILE$' "$REPO/$LOG_FILE"; then
191
+ fail "Codex transcript without explicit pricing profile did not explain unavailable cost basis"
192
+ fi
193
+
194
+ if grep -q '^estimated_chat_cost_basis: profile=.*openai' "$REPO/$LOG_FILE"; then
195
+ fail "default Codex transcript cost used an OpenAI pricing profile"
196
+ fi
197
+
198
+ (
199
+ cd "$REPO"
200
+ CHAT_TRANSCRIPT_PROVIDER=manual \
201
+ CHAT_TRANSCRIPT_BYTES=4096 \
202
+ CHAT_TRANSCRIPT_SOURCE="smoke transcript fixture" \
203
+ CHAT_COST_PROFILE=openai-chat-latest-standard-conservative-output \
204
+ bash scripts/00.chat/session-log/record-chat-commit/script.sh def5678 "Test commit 3" "Transcript byte token metric" >/dev/null
205
+ )
206
+
207
+ if ! grep -q '^estimated_chat_tokens: 1024 estimated from chat transcript bytes (4096 bytes; source: smoke transcript fixture)$' "$REPO/$LOG_FILE"; then
208
+ fail "transcript-byte chat token metric was not recorded"
209
+ fi
210
+
211
+ if ! grep -q '^transcript_provider: manual$' "$REPO/$LOG_FILE"; then
212
+ fail "manual transcript provider was not recorded"
213
+ fi
214
+
215
+ if ! grep -q '^estimated_chat_cost: USD 0.0307 estimated from estimated_chat_tokens$' "$REPO/$LOG_FILE"; then
216
+ fail "explicit OpenAI chat cost profile did not record transcript-byte cost"
217
+ fi
218
+
219
+ if ! grep -q '^estimated_chat_cost_basis: profile=openai-chat-latest-standard-conservative-output; model=chat-latest;' "$REPO/$LOG_FILE"; then
220
+ fail "explicit OpenAI chat cost profile was not recorded in the cost basis"
221
+ fi
222
+
223
+ if grep -q 'estimated from session log' "$REPO/$LOG_FILE"; then
224
+ fail "session log size was used as a token source"
225
+ fi
226
+
227
+ echo "record chat commit metrics smoke test passed."
@@ -0,0 +1,34 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.session-log.record-main-refresh-conflict.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: session-log
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain recording governed main-refresh conflict resolutions.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.workflows.chat-refresh-from-main
18
+ path: .agentic/00.chat/workflows/chat-refresh-from-main.md
19
+ - id: chat.script.session-log.record-main-refresh-conflict
20
+ path: scripts/00.chat/session-log/record-main-refresh-conflict/script.sh
21
+ -->
22
+ # Record Main Refresh Conflict
23
+
24
+ `script.sh` appends a main-refresh conflict audit entry to the current chat
25
+ session log.
26
+
27
+ Use it after a refresh from `main` encounters a conflict and the conflict has
28
+ been classified, resolved, stopped, or handed to a manual path. The entry names
29
+ the conflicted path, conflict type, reason, resolution action, mode, preflight
30
+ branch, preflight worktree, changed files, and checks.
31
+
32
+ The script records evidence. It does not resolve conflicts, apply refreshes,
33
+ merge branches, or push.
34
+
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.session-log.record-main-refresh-conflict
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: refresh
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Record main-refresh conflict classification and resolution in the current
15
+ # chat log.
16
+ # portability:
17
+ # class: required
18
+ # targets:
19
+ # - llm-workbench
20
+ # used_by:
21
+ # - id: chat.workflows.chat-refresh-from-main
22
+ # path: .agentic/00.chat/workflows/chat-refresh-from-main.md
23
+ # - id: chat.standards.main-refresh-conflict-types
24
+ # path: .agentic/00.chat/standards/main-refresh-conflict-types.md
25
+ # effects:
26
+ # - writes-files
27
+
28
+ # shellcheck source=../paths/lib.sh
29
+ source "scripts/00.chat/session-log/paths/lib.sh"
30
+
31
+ usage() {
32
+ cat <<'EOF'
33
+ Usage:
34
+ record-main-refresh-conflict.sh \
35
+ --path <conflicted-path> \
36
+ --type <conflict-type> \
37
+ --reason <classification-reason> \
38
+ --action <resolution-action> \
39
+ --mode <deterministic|skill-assisted|manual|stopped> \
40
+ --preflight-branch <branch> \
41
+ --preflight-worktree <path> \
42
+ [--files <changed-files-summary>] \
43
+ [--checks <checks-summary>]
44
+
45
+ Records a main-refresh conflict classification and resolution audit entry in
46
+ the current chat session log.
47
+ EOF
48
+ }
49
+
50
+ CONFLICT_PATH=""
51
+ CONFLICT_TYPE=""
52
+ REASON=""
53
+ ACTION=""
54
+ MODE=""
55
+ PREFLIGHT_BRANCH=""
56
+ PREFLIGHT_WORKTREE=""
57
+ FILES="pending"
58
+ CHECKS="pending"
59
+
60
+ while [ $# -gt 0 ]; do
61
+ case "$1" in
62
+ --path)
63
+ CONFLICT_PATH="${2:-}"
64
+ shift 2
65
+ ;;
66
+ --type)
67
+ CONFLICT_TYPE="${2:-}"
68
+ shift 2
69
+ ;;
70
+ --reason)
71
+ REASON="${2:-}"
72
+ shift 2
73
+ ;;
74
+ --action)
75
+ ACTION="${2:-}"
76
+ shift 2
77
+ ;;
78
+ --mode)
79
+ MODE="${2:-}"
80
+ shift 2
81
+ ;;
82
+ --preflight-branch)
83
+ PREFLIGHT_BRANCH="${2:-}"
84
+ shift 2
85
+ ;;
86
+ --preflight-worktree)
87
+ PREFLIGHT_WORKTREE="${2:-}"
88
+ shift 2
89
+ ;;
90
+ --files)
91
+ FILES="${2:-}"
92
+ shift 2
93
+ ;;
94
+ --checks)
95
+ CHECKS="${2:-}"
96
+ shift 2
97
+ ;;
98
+ --help|-h)
99
+ usage
100
+ exit 0
101
+ ;;
102
+ *)
103
+ echo "ERROR: unknown argument: $1" >&2
104
+ usage >&2
105
+ exit 2
106
+ ;;
107
+ esac
108
+ done
109
+
110
+ for required in CONFLICT_PATH CONFLICT_TYPE REASON ACTION MODE PREFLIGHT_BRANCH PREFLIGHT_WORKTREE; do
111
+ if [ -z "${!required// }" ]; then
112
+ echo "ERROR: missing required value: ${required}" >&2
113
+ usage >&2
114
+ exit 2
115
+ fi
116
+ done
117
+
118
+ case "$MODE" in
119
+ deterministic|skill-assisted|manual|stopped)
120
+ ;;
121
+ *)
122
+ echo "ERROR: invalid mode: $MODE" >&2
123
+ echo "Expected deterministic, skill-assisted, manual, or stopped." >&2
124
+ exit 2
125
+ ;;
126
+ esac
127
+
128
+ BRANCH="$(git branch --show-current)"
129
+
130
+ case "$BRANCH" in
131
+ chat/*|agentic/preflight/*)
132
+ ;;
133
+ *)
134
+ echo "ERROR: current branch is not a chat or preflight branch: $BRANCH" >&2
135
+ exit 1
136
+ ;;
137
+ esac
138
+
139
+ if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH" 2>/dev/null)"; then
140
+ if [ -z "${AGENTIC_SESSION_LOG:-}" ]; then
141
+ echo "ERROR: could not infer chat session from branch. Set AGENTIC_SESSION_LOG." >&2
142
+ exit 1
143
+ fi
144
+ LOG_FILE="$AGENTIC_SESSION_LOG"
145
+ else
146
+ LOG_FILE="$(chat_log_file_for_session "$SESSION_ID")"
147
+ fi
148
+
149
+ if [ ! -f "$LOG_FILE" ]; then
150
+ echo "ERROR: missing chat log: $LOG_FILE" >&2
151
+ exit 1
152
+ fi
153
+
154
+ TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
155
+
156
+ insert_section_entry() {
157
+ local section="$1"
158
+ local entry="$2"
159
+ local tmp
160
+ local entry_tmp
161
+
162
+ tmp="$(mktemp)"
163
+ entry_tmp="$(mktemp)"
164
+ printf '%s\n' "$entry" > "$entry_tmp"
165
+
166
+ if awk -v section="$section" -v entry_path="$entry_tmp" '
167
+ BEGIN {
168
+ in_section = 0
169
+ inserted = 0
170
+ found = 0
171
+ entry = ""
172
+ while ((getline line < entry_path) > 0) {
173
+ entry = entry (entry == "" ? "" : "\n") line
174
+ }
175
+ close(entry_path)
176
+ }
177
+ $0 == section {
178
+ found = 1
179
+ in_section = 1
180
+ print
181
+ next
182
+ }
183
+ in_section && /^## / && inserted == 0 {
184
+ print ""
185
+ print entry
186
+ print ""
187
+ inserted = 1
188
+ in_section = 0
189
+ }
190
+ in_section && $0 == "- None recorded yet." {
191
+ next
192
+ }
193
+ {
194
+ print
195
+ }
196
+ END {
197
+ if (found == 0) {
198
+ print ""
199
+ print section
200
+ print ""
201
+ print entry
202
+ } else if (in_section == 1 && inserted == 0) {
203
+ print ""
204
+ print entry
205
+ }
206
+ }
207
+ ' "$LOG_FILE" > "$tmp"; then
208
+ mv "$tmp" "$LOG_FILE"
209
+ else
210
+ rm -f "$tmp"
211
+ rm -f "$entry_tmp"
212
+ return 1
213
+ fi
214
+
215
+ rm -f "$entry_tmp"
216
+ }
217
+
218
+ ENTRY="- Path: \`${CONFLICT_PATH}\`
219
+ Type: \`${CONFLICT_TYPE}\`
220
+ Mode: ${MODE}
221
+ Reason: ${REASON}
222
+ Action: ${ACTION}
223
+ Preflight branch: \`${PREFLIGHT_BRANCH}\`
224
+ Preflight worktree: \`${PREFLIGHT_WORKTREE}\`
225
+ Files changed by resolution: ${FILES}
226
+ Checks: ${CHECKS}"
227
+
228
+ insert_section_entry "## Main Refresh Conflicts" "$ENTRY"
229
+ insert_section_entry "## Activity Log" "### ${TIMESTAMP} - Main refresh conflict recorded
230
+
231
+ Path: \`${CONFLICT_PATH}\`
232
+
233
+ Type: \`${CONFLICT_TYPE}\`
234
+
235
+ Mode: ${MODE}
236
+
237
+ Action: ${ACTION}"
238
+
239
+ echo "Recorded main refresh conflict: ${CONFLICT_PATH}"
@@ -0,0 +1,32 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.session-log.rename-current-chat-log-folder.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: session-log
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain renaming the current chat session log folder.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.workflows.chat-start
18
+ path: .agentic/00.chat/workflows/chat-start.md
19
+ - id: chat.script.session-log.rename-current-chat-log-folder
20
+ path: scripts/00.chat/session-log/rename-current-chat-log-folder/script.sh
21
+ -->
22
+ # Rename Current Chat Log Folder
23
+
24
+ `script.sh` renames the current chat session log folder to a shorter human
25
+ summary while preserving the existing branch name and session metadata.
26
+
27
+ This is useful when an auto-generated session slug is too long or unclear. The
28
+ session remains the same chat; only the log folder path changes.
29
+
30
+ Because this writes files, it is approval-sensitive through the governed runner.
31
+ It does not rename branches, rewrite commits, or change task ownership.
32
+
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.session-log.rename-current-chat-log-folder
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: session-log
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Rename the current chat session log folder while preserving metadata.
15
+ # portability:
16
+ # class: required
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.workflows.chat-start
21
+ # path: .agentic/00.chat/workflows/chat-start.md
22
+ # - id: harness.standards.governed-script-permissions
23
+ # - id: harness.script.run-governed-script
24
+ # path: scripts/01.harness/run-governed-script.sh
25
+ # effects:
26
+ # - writes-files
27
+
28
+ # shellcheck source=../paths/lib.sh
29
+ source "scripts/00.chat/session-log/paths/lib.sh"
30
+
31
+ usage() {
32
+ cat <<'EOF'
33
+ Usage: rename-current-chat-log-folder.sh <short-summary>
34
+
35
+ Renames the current chat session log folder to a shorter summary while keeping
36
+ the branch name and session metadata stable.
37
+ EOF
38
+ }
39
+
40
+ if [ $# -lt 1 ]; then
41
+ usage >&2
42
+ exit 2
43
+ fi
44
+
45
+ SUMMARY="$*"
46
+
47
+ if [ -z "${SUMMARY// }" ]; then
48
+ echo "ERROR: provide a non-empty summary." >&2
49
+ exit 2
50
+ fi
51
+
52
+ BRANCH="$(git branch --show-current)"
53
+
54
+ if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH")"; then
55
+ echo "ERROR: current branch is not a chat branch: $BRANCH" >&2
56
+ exit 1
57
+ fi
58
+
59
+ LOG_FILE="$(chat_log_file_for_session "$SESSION_ID")"
60
+
61
+ if [ ! -f "$LOG_FILE" ]; then
62
+ echo "ERROR: missing chat log: $LOG_FILE" >&2
63
+ exit 1
64
+ fi
65
+
66
+ STAMP="${SESSION_ID:0:16}"
67
+ SLUG="$(printf '%s' "$SUMMARY" \
68
+ | tr '[:upper:]' '[:lower:]' \
69
+ | sed -E 's/[^a-z0-9]+/-/g' \
70
+ | sed -E 's/^-+|-+$//g' \
71
+ | cut -c1-40)"
72
+
73
+ if [ -z "$SLUG" ]; then
74
+ echo "ERROR: summary must contain at least one ASCII letter or number." >&2
75
+ exit 2
76
+ fi
77
+
78
+ CURRENT_DIR="${LOG_FILE%/README.md}"
79
+ PARENT_DIR="${CURRENT_DIR%/*}"
80
+ TARGET_DIR="${PARENT_DIR}/${STAMP}-${SLUG}"
81
+ TARGET_FILE="${TARGET_DIR}/README.md"
82
+
83
+ if [ "$CURRENT_DIR" = "$TARGET_DIR" ]; then
84
+ echo "Chat log folder already matches: $CURRENT_DIR"
85
+ exit 0
86
+ fi
87
+
88
+ if [ -e "$TARGET_DIR" ]; then
89
+ echo "ERROR: target commit log folder already exists: $TARGET_DIR" >&2
90
+ exit 1
91
+ fi
92
+
93
+ if git rev-parse --is-inside-work-tree >/dev/null 2>&1 \
94
+ && git ls-files --error-unmatch "$LOG_FILE" >/dev/null 2>&1; then
95
+ git mv "$CURRENT_DIR" "$TARGET_DIR"
96
+ else
97
+ mv "$CURRENT_DIR" "$TARGET_DIR"
98
+ fi
99
+
100
+ tmp="$(mktemp)"
101
+ awk -v stamp="$STAMP" -v slug="$SLUG" '
102
+ NR == 1 && /^# Chat Session:/ {
103
+ print "# Chat Session: " stamp " " slug
104
+ next
105
+ }
106
+ { print }
107
+ ' "$TARGET_FILE" > "$tmp"
108
+ mv "$tmp" "$TARGET_FILE"
109
+
110
+ echo "Renamed chat log folder:"
111
+ echo " from: $CURRENT_DIR"
112
+ echo " to: $TARGET_DIR"
@@ -0,0 +1,32 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.session-log.update-chat-log.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: session-log
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain the internal structured chat log update helper.
12
+ portability:
13
+ class: internal
14
+ targets: []
15
+ used_by:
16
+ - id: chat.checklists.before-commit
17
+ path: .agentic/00.chat/checklists/before-commit.md
18
+ - id: chat.script.session-log.update-chat-log
19
+ path: scripts/00.chat/session-log/update-chat-log/script.sh
20
+ -->
21
+ # Update Chat Log
22
+
23
+ `script.sh` is an internal helper for appending structured entries to the
24
+ current chat session log.
25
+
26
+ It supports entries for questions, issues, decisions, commit summaries, and ADR
27
+ disposition. The helper keeps common log updates consistent so humans and
28
+ future agents can scan session history without guessing which section to read.
29
+
30
+ This script writes the current chat log only. It does not create commits,
31
+ record transcript metrics, or decide whether an ADR is needed.
32
+