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,154 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.main-refresh.verify-conflict-audit
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: main-refresh
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Verify main-refresh conflict paths are recorded in the chat session log.
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.standards.main-refresh-conflict-types
23
+ # path: .agentic/00.chat/standards/main-refresh-conflict-types.md
24
+ # effects:
25
+ # - read-only
26
+
27
+ # shellcheck source=../../session-log/paths/lib.sh
28
+ source "scripts/00.chat/session-log/paths/lib.sh"
29
+
30
+ usage() {
31
+ cat <<'EOF'
32
+ Usage:
33
+ script.sh [--session-log <path>] [--path <conflict-path>]... [--paths-file <file>]
34
+
35
+ Verifies that each conflict path has a matching `- Path: `<path>`` entry under
36
+ the chat session log's `## Main Refresh Conflicts` section.
37
+
38
+ If no paths are supplied, unresolved conflict paths are read from the Git index.
39
+ For resolved preflight conflicts, pass the captured paths explicitly.
40
+ EOF
41
+ }
42
+
43
+ SESSION_LOG=""
44
+ PATHS_FILE=""
45
+ PATHS=()
46
+
47
+ while [ $# -gt 0 ]; do
48
+ case "$1" in
49
+ --session-log)
50
+ SESSION_LOG="${2:-}"
51
+ shift 2
52
+ ;;
53
+ --path)
54
+ PATHS+=("${2:-}")
55
+ shift 2
56
+ ;;
57
+ --paths-file)
58
+ PATHS_FILE="${2:-}"
59
+ shift 2
60
+ ;;
61
+ --help|-h)
62
+ usage
63
+ exit 0
64
+ ;;
65
+ *)
66
+ echo "ERROR: unknown argument: $1" >&2
67
+ usage >&2
68
+ exit 2
69
+ ;;
70
+ esac
71
+ done
72
+
73
+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
74
+ echo "ERROR: not inside a Git worktree." >&2
75
+ exit 1
76
+ fi
77
+
78
+ if [ -n "$PATHS_FILE" ]; then
79
+ if [ ! -f "$PATHS_FILE" ]; then
80
+ echo "ERROR: missing paths file: $PATHS_FILE" >&2
81
+ exit 1
82
+ fi
83
+
84
+ while IFS= read -r path; do
85
+ [ -z "$path" ] && continue
86
+ PATHS+=("$path")
87
+ done < "$PATHS_FILE"
88
+ fi
89
+
90
+ if [ "${#PATHS[@]}" -eq 0 ]; then
91
+ while IFS= read -r path; do
92
+ [ -z "$path" ] && continue
93
+ PATHS+=("$path")
94
+ done < <(git diff --name-only --diff-filter=U)
95
+ fi
96
+
97
+ if [ -z "$SESSION_LOG" ]; then
98
+ BRANCH="$(git branch --show-current)"
99
+ if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH" 2>/dev/null)"; then
100
+ if [ -n "${AGENTIC_SESSION_LOG:-}" ]; then
101
+ SESSION_LOG="$AGENTIC_SESSION_LOG"
102
+ else
103
+ echo "ERROR: could not infer chat session from branch. Use --session-log." >&2
104
+ exit 1
105
+ fi
106
+ else
107
+ SESSION_LOG="$(chat_log_file_for_session "$SESSION_ID")"
108
+ fi
109
+ fi
110
+
111
+ if [ ! -f "$SESSION_LOG" ]; then
112
+ echo "ERROR: missing session log: $SESSION_LOG" >&2
113
+ exit 1
114
+ fi
115
+
116
+ if [ "${#PATHS[@]}" -eq 0 ]; then
117
+ echo "No conflict paths supplied or unresolved in the Git index."
118
+ echo "For resolved preflight conflicts, rerun with --path or --paths-file."
119
+ exit 0
120
+ fi
121
+
122
+ AUDIT_PATHS="$(
123
+ awk '
124
+ $0 == "## Main Refresh Conflicts" { in_section = 1; next }
125
+ in_section && /^## / { in_section = 0 }
126
+ in_section && /^- Path: `/ {
127
+ line = $0
128
+ sub(/^- Path: `/, "", line)
129
+ sub(/`$/, "", line)
130
+ print line
131
+ }
132
+ ' "$SESSION_LOG"
133
+ )"
134
+
135
+ FAILED=0
136
+
137
+ for path in "${PATHS[@]}"; do
138
+ if [ -z "$path" ]; then
139
+ continue
140
+ fi
141
+
142
+ if printf '%s\n' "$AUDIT_PATHS" | grep -Fxq "$path"; then
143
+ echo "OK: conflict path recorded: $path"
144
+ else
145
+ echo "ERROR: conflict path missing from session audit: $path" >&2
146
+ FAILED=1
147
+ fi
148
+ done
149
+
150
+ if [ "$FAILED" -ne 0 ]; then
151
+ exit 1
152
+ fi
153
+
154
+ echo "Main refresh conflict audit verified."
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.main-refresh.verify-conflict-audit.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 main-refresh conflict audit verification.
15
+ # portability:
16
+ # class: required
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.script.main-refresh.verify-conflict-audit
21
+ # path: scripts/00.chat/main-refresh/verify-conflict-audit/script.sh
22
+ # effects:
23
+ # - writes-files
24
+
25
+ fail() {
26
+ echo "FAIL: $*" >&2
27
+ exit 1
28
+ }
29
+
30
+ SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd -P)"
31
+ TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/verify-main-refresh-conflict-audit-smoke.XXXXXX")"
32
+
33
+ cleanup() {
34
+ rm -rf "$TMP_ROOT"
35
+ }
36
+
37
+ trap cleanup EXIT
38
+
39
+ REPO="$TMP_ROOT/repo"
40
+ mkdir -p "$REPO"
41
+ git -C "$REPO" init -q
42
+ git -C "$REPO" config user.email test@example.com
43
+ git -C "$REPO" config user.name "Test User"
44
+
45
+ mkdir -p \
46
+ "$REPO/scripts/00.chat/main-refresh/verify-conflict-audit" \
47
+ "$REPO/scripts/00.chat/session-log/paths" \
48
+ "$REPO/commitLogs/2026/jun/20/test-session"
49
+
50
+ cp "$SOURCE_ROOT/scripts/00.chat/main-refresh/verify-conflict-audit/script.sh" "$REPO/scripts/00.chat/main-refresh/verify-conflict-audit/script.sh"
51
+ cp "$SOURCE_ROOT/scripts/00.chat/session-log/paths/lib.sh" "$REPO/scripts/00.chat/session-log/paths/lib.sh"
52
+
53
+ SESSION_LOG="$REPO/commitLogs/2026/jun/20/test-session/README.md"
54
+ CONFLICT_PATH="docs/example-conflict.md"
55
+ cat > "$SESSION_LOG" <<'EOF'
56
+ # Chat Session: test
57
+
58
+ ## Main Refresh Conflicts
59
+
60
+ - Path: `docs/example-conflict.md`
61
+ Type: `ownership-migration-conflict`
62
+ Mode: deterministic
63
+ Reason: test
64
+ Action: test
65
+ Preflight branch: `agentic/preflight/chat-test/20000101000000`
66
+ Preflight worktree: `/tmp/preflight`
67
+ Files changed by resolution: docs/example-conflict.md
68
+ Checks: test
69
+ EOF
70
+
71
+ git -C "$REPO" add scripts commitLogs
72
+ git -C "$REPO" commit -q -m base
73
+
74
+ (
75
+ cd "$REPO"
76
+ bash scripts/00.chat/main-refresh/verify-conflict-audit/script.sh \
77
+ --session-log commitLogs/2026/jun/20/test-session/README.md \
78
+ --path "$CONFLICT_PATH"
79
+ ) >/dev/null
80
+
81
+ set +e
82
+ (
83
+ cd "$REPO"
84
+ bash scripts/00.chat/main-refresh/verify-conflict-audit/script.sh \
85
+ --session-log commitLogs/2026/jun/20/test-session/README.md \
86
+ --path missing/path.md
87
+ ) > "$TMP_ROOT/missing.out" 2> "$TMP_ROOT/missing.err"
88
+ MISSING_STATUS="$?"
89
+ set -e
90
+
91
+ if [ "$MISSING_STATUS" -eq 0 ]; then
92
+ fail "missing conflict audit path passed"
93
+ fi
94
+
95
+ if ! grep -q "conflict path missing from session audit" "$TMP_ROOT/missing.err"; then
96
+ fail "missing path failure was not explained"
97
+ fi
98
+
99
+ echo "main refresh conflict audit verifier smoke test passed."
@@ -0,0 +1,35 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.metrics.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: metrics
8
+ disciplines:
9
+ - agentic
10
+ kind: script-domain-readme
11
+ purpose: Explain chat metric helper scripts.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.script.metrics.estimate-chat-cost.readme
18
+ path: scripts/00.chat/metrics/estimate-chat-cost/README.md
19
+ - id: chat.script.session-log.record-chat-commit.readme
20
+ path: scripts/00.chat/session-log/record-chat-commit/README.md
21
+ -->
22
+ # Metrics Scripts
23
+
24
+ Metrics scripts provide derived chat metadata such as estimated token cost.
25
+ They support session logs and reports; they are not billing systems.
26
+
27
+ Estimates should be transparent about their assumptions. When exact model
28
+ pricing or token splits are unavailable, scripts should record the basis and
29
+ avoid pretending to be precise.
30
+
31
+ Default chat pricing data lives with the chat metrics scripts at
32
+ `scripts/00.chat/metrics/data/chat-pricing.json`. Treat it as a bundled
33
+ best-effort profile store, not live provider pricing. The bundled default is
34
+ provider-neutral and records cost as unavailable until `CHAT_COST_PROFILE` or
35
+ `CHAT_COST_PRICING_FILE` selects a concrete pricing profile.
@@ -0,0 +1,107 @@
1
+ {
2
+ "schema_version": 1,
3
+ "default_profile": "portable-unpriced",
4
+ "currency": "USD",
5
+ "unit": "1M tokens",
6
+ "source": {
7
+ "name": "Bundled chat pricing profile store",
8
+ "url": "local chat pricing snapshot",
9
+ "retrieved_at_utc": "2026-06-19T00:00:00Z",
10
+ "note": "Best-effort local profiles for chat session cost estimates. Override with CHAT_COST_PRICING_FILE for organization-specific or current provider pricing."
11
+ },
12
+ "profiles": {
13
+ "portable-unpriced": {
14
+ "provider": "unknown",
15
+ "model": "unknown",
16
+ "category": "chat",
17
+ "tier": "unknown",
18
+ "context": "unknown",
19
+ "estimate_rate_usd_per_1m_tokens": null,
20
+ "assumption": "No provider pricing profile selected. Set CHAT_COST_PROFILE or CHAT_COST_PRICING_FILE for cost estimates."
21
+ },
22
+ "openai-chat-latest-standard-conservative-output": {
23
+ "provider": "openai",
24
+ "model": "chat-latest",
25
+ "category": "chat",
26
+ "tier": "standard",
27
+ "context": "standard",
28
+ "input_usd_per_1m_tokens": 5,
29
+ "cached_input_usd_per_1m_tokens": 0.5,
30
+ "output_usd_per_1m_tokens": 30,
31
+ "estimate_rate_usd_per_1m_tokens": 30,
32
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
33
+ },
34
+ "gpt-5.5-standard-short-conservative-output": {
35
+ "provider": "openai",
36
+ "model": "gpt-5.5",
37
+ "category": "flagship",
38
+ "tier": "standard",
39
+ "context": "short",
40
+ "input_usd_per_1m_tokens": 5,
41
+ "cached_input_usd_per_1m_tokens": 0.5,
42
+ "output_usd_per_1m_tokens": 30,
43
+ "estimate_rate_usd_per_1m_tokens": 30,
44
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
45
+ },
46
+ "gpt-5.5-standard-long-conservative-output": {
47
+ "provider": "openai",
48
+ "model": "gpt-5.5",
49
+ "category": "flagship",
50
+ "tier": "standard",
51
+ "context": "long",
52
+ "input_usd_per_1m_tokens": 10,
53
+ "cached_input_usd_per_1m_tokens": 1,
54
+ "output_usd_per_1m_tokens": 45,
55
+ "estimate_rate_usd_per_1m_tokens": 45,
56
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
57
+ },
58
+ "gpt-5.4-standard-short-conservative-output": {
59
+ "provider": "openai",
60
+ "model": "gpt-5.4",
61
+ "category": "flagship",
62
+ "tier": "standard",
63
+ "context": "short",
64
+ "input_usd_per_1m_tokens": 2.5,
65
+ "cached_input_usd_per_1m_tokens": 0.25,
66
+ "output_usd_per_1m_tokens": 15,
67
+ "estimate_rate_usd_per_1m_tokens": 15,
68
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
69
+ },
70
+ "gpt-5.4-standard-long-conservative-output": {
71
+ "provider": "openai",
72
+ "model": "gpt-5.4",
73
+ "category": "flagship",
74
+ "tier": "standard",
75
+ "context": "long",
76
+ "input_usd_per_1m_tokens": 5,
77
+ "cached_input_usd_per_1m_tokens": 0.5,
78
+ "output_usd_per_1m_tokens": 22.5,
79
+ "estimate_rate_usd_per_1m_tokens": 22.5,
80
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
81
+ },
82
+ "gpt-5.4-mini-standard-conservative-output": {
83
+ "provider": "openai",
84
+ "model": "gpt-5.4-mini",
85
+ "category": "flagship",
86
+ "tier": "standard",
87
+ "context": "standard",
88
+ "input_usd_per_1m_tokens": 0.75,
89
+ "cached_input_usd_per_1m_tokens": 0.075,
90
+ "output_usd_per_1m_tokens": 4.5,
91
+ "estimate_rate_usd_per_1m_tokens": 4.5,
92
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
93
+ },
94
+ "gpt-5.4-nano-standard-conservative-output": {
95
+ "provider": "openai",
96
+ "model": "gpt-5.4-nano",
97
+ "category": "flagship",
98
+ "tier": "standard",
99
+ "context": "standard",
100
+ "input_usd_per_1m_tokens": 0.2,
101
+ "cached_input_usd_per_1m_tokens": 0.02,
102
+ "output_usd_per_1m_tokens": 1.25,
103
+ "estimate_rate_usd_per_1m_tokens": 1.25,
104
+ "assumption": "all estimated chat tokens are costed at the output-token rate because the transcript-byte metric does not split input, cached input, and output tokens"
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Chat pricing profile store",
4
+ "type": "object",
5
+ "required": ["schema_version", "default_profile", "currency", "unit", "profiles"],
6
+ "properties": {
7
+ "schema_version": {
8
+ "type": "integer",
9
+ "minimum": 1
10
+ },
11
+ "default_profile": {
12
+ "type": "string",
13
+ "minLength": 1
14
+ },
15
+ "currency": {
16
+ "type": "string",
17
+ "minLength": 1
18
+ },
19
+ "unit": {
20
+ "type": "string",
21
+ "minLength": 1
22
+ },
23
+ "source": {
24
+ "type": "object",
25
+ "additionalProperties": true
26
+ },
27
+ "profiles": {
28
+ "type": "object",
29
+ "minProperties": 1,
30
+ "additionalProperties": {
31
+ "type": "object",
32
+ "required": ["model", "tier", "context", "estimate_rate_usd_per_1m_tokens", "assumption"],
33
+ "properties": {
34
+ "provider": {
35
+ "type": "string"
36
+ },
37
+ "model": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "tier": {
42
+ "type": "string",
43
+ "minLength": 1
44
+ },
45
+ "context": {
46
+ "type": "string",
47
+ "minLength": 1
48
+ },
49
+ "estimate_rate_usd_per_1m_tokens": {
50
+ "type": ["number", "null"],
51
+ "minimum": 0
52
+ },
53
+ "assumption": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ }
57
+ },
58
+ "additionalProperties": true
59
+ }
60
+ }
61
+ },
62
+ "additionalProperties": true
63
+ }
@@ -0,0 +1,40 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.metrics.estimate-chat-cost.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: metrics
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain chat cost estimate metadata generation.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.script.metrics.estimate-chat-cost.script-js
18
+ path: scripts/00.chat/metrics/estimate-chat-cost/script.js
19
+ - id: chat.script.session-log.record-chat-commit
20
+ path: scripts/00.chat/session-log/record-chat-commit/script.sh
21
+ -->
22
+ # Estimate Chat Cost
23
+
24
+ `script.js` converts an estimated token count into session-log cost metadata.
25
+
26
+ The estimate is intentionally conservative and records its basis. Transcript
27
+ byte-derived token estimates do not split input, cached input, and output
28
+ tokens, so the output tells readers what assumption was used rather than
29
+ presenting the number as exact billing.
30
+
31
+ This capability does not call external pricing APIs. It reads local pricing
32
+ profile data when available and otherwise emits unavailable metadata with a
33
+ reason.
34
+
35
+ By default it reads `scripts/00.chat/metrics/data/chat-pricing.json`, a
36
+ chat-owned local profile store bundled for standalone installs. Set
37
+ `CHAT_COST_PRICING_FILE` to point at an organization-maintained pricing file and
38
+ `CHAT_COST_PROFILE` to select a profile when local pricing needs to differ from
39
+ the bundled snapshot. The bundled default profile is provider-neutral and marks
40
+ cost unavailable until a concrete pricing profile is selected.
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env node
2
+ // agentic-artifact:
3
+ // schema: agentic-artifact/v2
4
+ // id: chat.script.metrics.estimate-chat-cost
5
+ // version: 1
6
+ // status: active
7
+ // layer: 00.chat
8
+ // domain: metrics
9
+ // disciplines:
10
+ // - agentic
11
+ // kind: script
12
+ // purpose: Estimate chat cost metadata from an estimated token count.
13
+ // portability:
14
+ // class: required
15
+ // targets:
16
+ // - llm-workbench
17
+ // effects:
18
+ // - read-only
19
+ // used_by:
20
+ // - id: chat.script.session-log.record-chat-commit
21
+ // path: scripts/00.chat/session-log/record-chat-commit/script.sh
22
+ // - id: chat.script.session-log.record-chat-commit.smoke-test
23
+ // path: scripts/00.chat/session-log/record-chat-commit/smoke-test.sh
24
+
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+
28
+ function usage() {
29
+ console.error(`Usage:
30
+ estimate-chat-cost.js <estimated-token-count> [pricing-profile]
31
+
32
+ Prints estimated_chat_cost and estimated_chat_cost_basis metadata lines.
33
+ `);
34
+ }
35
+
36
+ function unavailable(costReason, basisReason = costReason) {
37
+ console.log(`estimated_chat_cost: unavailable; ${costReason}`);
38
+ console.log(`estimated_chat_cost_basis: unavailable; ${basisReason}`);
39
+ }
40
+
41
+ function formatUsd(value) {
42
+ if (value > 0 && value < 1) {
43
+ return value.toFixed(4);
44
+ }
45
+ return value.toFixed(2);
46
+ }
47
+
48
+ function findRepoRoot(start) {
49
+ let current = start;
50
+ while (current !== path.dirname(current)) {
51
+ if (fs.existsSync(path.join(current, '.git'))) {
52
+ return current;
53
+ }
54
+ current = path.dirname(current);
55
+ }
56
+ return start;
57
+ }
58
+
59
+ const tokenValue = process.argv[2];
60
+ const requestedProfile = process.argv[3] || process.env.CHAT_COST_PROFILE || '';
61
+
62
+ if (!tokenValue || tokenValue === '-h' || tokenValue === '--help') {
63
+ usage();
64
+ process.exit(tokenValue ? 0 : 2);
65
+ }
66
+
67
+ if (!/^\d+$/.test(tokenValue)) {
68
+ console.error('ERROR: estimated-token-count must be a non-negative integer.');
69
+ process.exit(1);
70
+ }
71
+
72
+ const tokenCount = Number(tokenValue);
73
+ const repoRoot = findRepoRoot(process.cwd());
74
+ const pricingPath = process.env.CHAT_COST_PRICING_FILE ||
75
+ path.join(repoRoot, 'scripts/00.chat/metrics/data/chat-pricing.json');
76
+
77
+ if (!fs.existsSync(pricingPath)) {
78
+ unavailable('pricing snapshot not found');
79
+ process.exit(0);
80
+ }
81
+
82
+ let pricing;
83
+ try {
84
+ pricing = JSON.parse(fs.readFileSync(pricingPath, 'utf8'));
85
+ } catch (error) {
86
+ console.error(`ERROR: failed to parse pricing snapshot: ${pricingPath}`);
87
+ console.error(error.message);
88
+ process.exit(1);
89
+ }
90
+
91
+ const profileName = requestedProfile || pricing.default_profile;
92
+ const profile = pricing.profiles && pricing.profiles[profileName];
93
+
94
+ if (!profile) {
95
+ unavailable(`pricing profile not found: ${profileName || 'none'}`);
96
+ process.exit(0);
97
+ }
98
+
99
+ if (profile.estimate_rate_usd_per_1m_tokens === null ||
100
+ profile.estimate_rate_usd_per_1m_tokens === undefined) {
101
+ unavailable('no pricing profile selected', 'set CHAT_COST_PROFILE or CHAT_COST_PRICING_FILE');
102
+ process.exit(0);
103
+ }
104
+
105
+ const rate = Number(profile.estimate_rate_usd_per_1m_tokens);
106
+ if (!Number.isFinite(rate) || rate < 0) {
107
+ console.error(`ERROR: invalid estimate_rate_usd_per_1m_tokens for profile: ${profileName}`);
108
+ process.exit(1);
109
+ }
110
+
111
+ const currency = pricing.currency || 'USD';
112
+ const cost = (tokenCount / 1000000) * rate;
113
+ const source = pricing.source && pricing.source.url ? pricing.source.url : 'unknown';
114
+ const retrieved = pricing.source && pricing.source.retrieved_at_utc
115
+ ? pricing.source.retrieved_at_utc
116
+ : 'unknown';
117
+
118
+ const basis = [
119
+ `profile=${profileName}`,
120
+ `model=${profile.model}`,
121
+ `tier=${profile.tier}`,
122
+ `context=${profile.context}`,
123
+ `rate=${currency} ${rate}/1M tokens`,
124
+ `assumption=${profile.assumption}`,
125
+ `pricing_snapshot=${retrieved}`,
126
+ `source=${source}`,
127
+ ].join('; ');
128
+
129
+ console.log(`estimated_chat_cost: ${currency} ${formatUsd(cost)} estimated from estimated_chat_tokens`);
130
+ console.log(`estimated_chat_cost_basis: ${basis}`);
@@ -0,0 +1,30 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.migration.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: migration
8
+ disciplines:
9
+ - agentic
10
+ kind: script-domain-readme
11
+ purpose: Explain migration audit scripts for the chat layer.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.migration-plan
18
+ path: .agentic/00.chat/migration-plan.md
19
+ - id: chat.script.migration.audit-chat-layer-migration.readme
20
+ path: scripts/00.chat/migration/audit-chat-layer-migration/README.md
21
+ -->
22
+ # Migration Scripts
23
+
24
+ Migration scripts check whether the chat lifecycle layer still depends on old
25
+ locations. They are guardrails for moving behavior into canonical
26
+ `.agentic/00.chat` and `scripts/00.chat` surfaces.
27
+
28
+ Use this domain when changing ownership, moving compatibility paths, or
29
+ preparing the harness for a standalone workbench repo.
30
+
@@ -0,0 +1,33 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.migration.audit-chat-layer-migration.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: migration
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain the chat layer migration audit.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.migration-plan
18
+ path: .agentic/00.chat/migration-plan.md
19
+ - id: chat.script.migration.audit-chat-layer-migration
20
+ path: scripts/00.chat/migration/audit-chat-layer-migration/script.sh
21
+ -->
22
+ # Audit Chat Layer Migration
23
+
24
+ `script.sh` checks that the canonical chat-layer files exist, retired
25
+ compatibility paths stay absent, and retired compatibility references do not
26
+ return to active process files.
27
+
28
+ The audit distinguishes current canonical requirements from historical or
29
+ policy references. It does not treat old session logs as migration blockers.
30
+
31
+ Use this after moving workflows, checklists, standards, or scripts so the next
32
+ agent can see whether the chat layer still relies on retired compatibility
33
+ paths.