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,127 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.migration.audit-chat-layer-migration
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: migration
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Verify canonical chat-layer files and retired compatibility paths.
15
+ # portability:
16
+ # class: required
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.migration-plan
21
+ # path: .agentic/00.chat/migration-plan.md
22
+ # effects:
23
+ # - read-only
24
+
25
+ required_paths=(
26
+ "package.json"
27
+ ".agentic/00.chat/README.md"
28
+ ".agentic/00.chat/migration-plan.md"
29
+ ".agentic/00.chat/workflows/README.md"
30
+ ".agentic/00.chat/workflows/chat-start.md"
31
+ ".agentic/00.chat/workflows/chat-commit.md"
32
+ ".agentic/00.chat/workflows/chat-refresh-from-main.md"
33
+ ".agentic/00.chat/workflows/chat-promote-to-main.md"
34
+ ".agentic/00.chat/workflows/chat-cleanup.md"
35
+ ".agentic/00.chat/workflows/chat-reporting.md"
36
+ ".agentic/00.chat/workflows/chat-upstream-reusable-lesson.md"
37
+ ".agentic/00.chat/workflows/bootstrap-chat-workbench-repo.md"
38
+ ".agentic/00.chat/checklists/before-commit.md"
39
+ ".agentic/00.chat/skills/session-summary.md"
40
+ )
41
+
42
+ retired_paths=(
43
+ ".agentic/shared/workflows/chat-start-interview.md"
44
+ ".agentic/shared/workflows/main-updated.md"
45
+ ".agentic/shared/workflows/local-convergence.md"
46
+ ".agentic/shared/checklists/before-commit.md"
47
+ ".agentic/shared/workflows/default.md"
48
+ ".agentic/01.harness/workflows/default.md"
49
+ )
50
+
51
+ failures=0
52
+
53
+ check_file() {
54
+ local path="$1"
55
+ local label="$2"
56
+
57
+ if [ -f "$path" ]; then
58
+ echo "OK: ${label}: ${path}"
59
+ else
60
+ echo "ERROR: missing ${label}: ${path}" >&2
61
+ failures=$((failures + 1))
62
+ fi
63
+ }
64
+
65
+ check_absent() {
66
+ local path="$1"
67
+ local label="$2"
68
+
69
+ if [ -e "$path" ]; then
70
+ echo "ERROR: retired ${label} still exists: ${path}" >&2
71
+ failures=$((failures + 1))
72
+ else
73
+ echo "OK: retired ${label} absent: ${path}"
74
+ fi
75
+ }
76
+
77
+ echo "Canonical chat layer files"
78
+ for path in "${required_paths[@]}"; do
79
+ check_file "$path" "canonical file"
80
+ done
81
+
82
+ echo
83
+ echo "Retired compatibility paths"
84
+ for path in "${retired_paths[@]}"; do
85
+ check_absent "$path" "path"
86
+ done
87
+
88
+ echo
89
+ echo "Retired compatibility references"
90
+ retired_matches="$(
91
+ grep -RIlE \
92
+ '\.agentic/shared/workflows/(chat-start-interview|main-updated|local-convergence|default)\.md|\.agentic/shared/checklists/before-commit\.md|\.agentic/01.harness/workflows/default\.md' \
93
+ .agentic scripts docs 2>/dev/null \
94
+ | grep -v -E '^\.agentic/00\.chat/migration-plan\.md$|^scripts/00\.chat/migration/audit-chat-layer-migration/script\.sh$' \
95
+ || true
96
+ )"
97
+
98
+ if [ -z "$retired_matches" ]; then
99
+ echo "OK: no retired compatibility references found."
100
+ else
101
+ echo "Retired compatibility reference files:"
102
+ printf '%s\n' "$retired_matches"
103
+ failures=$((failures + 1))
104
+ fi
105
+
106
+ echo
107
+ echo "Retired aggregate summary policy references"
108
+ summary_matches="$(
109
+ grep -RIl 'commitLogs/README.md' .agentic scripts docs 2>/dev/null \
110
+ | grep -v -E '^\.agentic/00\.chat/migration-plan\.md$|^scripts/00\.chat/migration/audit-chat-layer-migration/script\.sh$' \
111
+ || true
112
+ )"
113
+
114
+ if [ -z "$summary_matches" ]; then
115
+ echo "OK: no commitLogs/README.md policy references found."
116
+ else
117
+ echo "Policy reference files:"
118
+ printf '%s\n' "$summary_matches"
119
+ fi
120
+
121
+ if [ "$failures" -gt 0 ]; then
122
+ echo "Chat layer migration audit failed." >&2
123
+ exit 1
124
+ fi
125
+
126
+ echo
127
+ echo "Chat layer migration audit completed."
@@ -0,0 +1,30 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.recovery.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: recovery
8
+ disciplines:
9
+ - agentic
10
+ kind: script-domain-readme
11
+ purpose: Explain recovery scripts for wrong-worktree chat edits.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.workflows.chat-commit
18
+ path: .agentic/00.chat/workflows/chat-commit.md
19
+ - id: chat.script.recovery.import-active-paths-to-chat-worktree.readme
20
+ path: scripts/00.chat/recovery/import-active-paths-to-chat-worktree/README.md
21
+ -->
22
+ # Recovery Scripts
23
+
24
+ Recovery scripts handle exceptional chat lifecycle situations, especially work
25
+ that was edited in the wrong checkout.
26
+
27
+ Normal task work should happen directly in the chat-owned worktree. Recovery
28
+ scripts exist so explicit paths can be moved back into the right worktree
29
+ without normalizing broad or ambiguous repair actions.
30
+
@@ -0,0 +1,76 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.recovery.import-active-paths-to-chat-worktree.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: recovery
8
+ disciplines:
9
+ - agentic
10
+ kind: guide
11
+ purpose: Explain governed recovery import from an active worktree into a chat-owned
12
+ worktree.
13
+ portability:
14
+ class: required
15
+ targets:
16
+ - llm-workbench
17
+ used_by:
18
+ - id: chat.script.recovery.import-active-paths-to-chat-worktree
19
+ path: scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh
20
+ -->
21
+ # Import Active Paths To Chat Worktree
22
+
23
+ This capability is for recovery, not normal chat work.
24
+
25
+ Normal chat task work should happen directly in the chat-owned worktree recorded
26
+ in the session log. That worktree has its own files, index, and branch, so task
27
+ commits can be prepared without touching the root integration worktree.
28
+
29
+ Sometimes edits happen in the wrong place anyway: an IDE opens the root checkout,
30
+ a human changes files before noticing the active path, or an older workflow
31
+ leaves useful changes outside the chat-owned worktree. In that case the harness
32
+ needs a governed way to bring only the approved files back into the session's
33
+ chat worktree.
34
+
35
+ `script.sh` does that import.
36
+
37
+ It reads the session log, finds the chat branch and chat-owned worktree, then
38
+ copies only the explicit repository-relative paths passed on the command line
39
+ from the source worktree into the chat-owned worktree. Existing source paths are
40
+ copied. Missing source paths are treated as deletions. The same paths are staged
41
+ in the chat-owned worktree.
42
+
43
+ The script refuses broad or ambiguous recovery:
44
+
45
+ - no paths means no import
46
+ - absolute paths and `..` paths are rejected
47
+ - the source and target worktrees cannot be the same path
48
+ - the target must be the session's chat branch
49
+ - the target chat-owned worktree must be clean before import
50
+
51
+ That last rule matters. Recovery should not hide existing target work. If the
52
+ chat-owned worktree is already dirty, inspect, commit, checkpoint, or otherwise
53
+ resolve that state first.
54
+
55
+ Example:
56
+
57
+ ```bash
58
+ bash scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh \
59
+ --session-log commitLogs/2026/jun/19/example-session/README.md \
60
+ --source-worktree /home/owner/projects/entity-builder-harness-001 \
61
+ -- docs/example.md scripts/example.sh
62
+ ```
63
+
64
+ After the import, continue from the chat-owned worktree and run the normal
65
+ before-commit gates.
66
+
67
+ ## Relationship To Older Helpers
68
+
69
+ The older `with-chat-branch.sh` and `stage-active-worktree-paths.sh` helpers
70
+ came from the commit-boundary-only model, where commands could be run in a
71
+ temporary isolated session worktree while normal edits happened elsewhere.
72
+
73
+ The current harness model is stricter: each chat owns its worktree. This
74
+ capability keeps the useful recovery behavior, but names it as recovery import
75
+ instead of normal commit flow. The old shared helpers have been retired so new
76
+ instructions and scripts do not accidentally revive the earlier model.
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.recovery.import-active-paths-to-chat-worktree
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: recovery
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Import explicit paths from an active worktree into a session's chat-owned
15
+ # worktree.
16
+ # portability:
17
+ # class: required
18
+ # targets:
19
+ # - llm-workbench
20
+ # used_by:
21
+ # - id: chat.script.recovery.import-active-paths-to-chat-worktree.readme
22
+ # path: scripts/00.chat/recovery/import-active-paths-to-chat-worktree/README.md
23
+ # effects:
24
+ # - stages-files
25
+ # - writes-files
26
+
27
+ usage() {
28
+ cat <<'EOF'
29
+ Usage:
30
+ script.sh --session-log <path> [--source-worktree <path>] -- <path>...
31
+
32
+ Imports explicit repository-relative paths from the source worktree into the
33
+ chat-owned worktree recorded in a session log, then stages those paths in the
34
+ chat-owned worktree.
35
+
36
+ This is recovery tooling for edits made in the wrong worktree. Normal chat task
37
+ work should happen directly in the chat-owned worktree.
38
+ EOF
39
+ }
40
+
41
+ SESSION_LOG="${AGENTIC_SESSION_LOG:-}"
42
+ SOURCE_WORKTREE="${AGENTIC_ACTIVE_WORKTREE:-}"
43
+
44
+ while [ $# -gt 0 ]; do
45
+ case "$1" in
46
+ --session-log)
47
+ if [ $# -lt 2 ]; then
48
+ usage >&2
49
+ exit 2
50
+ fi
51
+ SESSION_LOG="$2"
52
+ shift 2
53
+ ;;
54
+ --source-worktree)
55
+ if [ $# -lt 2 ]; then
56
+ usage >&2
57
+ exit 2
58
+ fi
59
+ SOURCE_WORKTREE="$2"
60
+ shift 2
61
+ ;;
62
+ --)
63
+ shift
64
+ break
65
+ ;;
66
+ -h|--help)
67
+ usage
68
+ exit 0
69
+ ;;
70
+ *)
71
+ break
72
+ ;;
73
+ esac
74
+ done
75
+
76
+ if [ $# -eq 0 ]; then
77
+ usage >&2
78
+ exit 2
79
+ fi
80
+
81
+ validate_path() {
82
+ local path="$1"
83
+
84
+ if [ -z "${path// }" ]; then
85
+ echo "ERROR: empty path is not allowed." >&2
86
+ exit 1
87
+ fi
88
+
89
+ case "$path" in
90
+ /*|../*|*/../*|*/..|.)
91
+ echo "ERROR: path must be a repository-relative path without '..': $path" >&2
92
+ exit 1
93
+ ;;
94
+ esac
95
+ }
96
+
97
+ for path in "$@"; do
98
+ validate_path "$path"
99
+ done
100
+
101
+ REPO_ROOT="$(git rev-parse --show-toplevel)"
102
+ REPO_ROOT="$(cd "$REPO_ROOT" && pwd -P)"
103
+
104
+ # shellcheck source=../../worktree/paths/lib.sh
105
+ source "$REPO_ROOT/scripts/00.chat/worktree/paths/lib.sh"
106
+ # shellcheck source=../../session-log/paths/lib.sh
107
+ source "$REPO_ROOT/scripts/00.chat/session-log/paths/lib.sh"
108
+
109
+ if [ -z "${SOURCE_WORKTREE// }" ]; then
110
+ SOURCE_WORKTREE="$REPO_ROOT"
111
+ fi
112
+
113
+ SOURCE_WORKTREE="$(cd "$SOURCE_WORKTREE" && pwd -P)"
114
+
115
+ if [ -z "${SESSION_LOG// }" ]; then
116
+ CURRENT_BRANCH="$(git -C "$SOURCE_WORKTREE" branch --show-current)"
117
+ if ! SESSION_ID="$(chat_session_id_from_branch "$CURRENT_BRANCH")"; then
118
+ echo "ERROR: --session-log is required when the source worktree is not on a chat branch." >&2
119
+ exit 1
120
+ fi
121
+ SESSION_LOG="$(chat_log_file_for_session "$SESSION_ID")"
122
+ fi
123
+
124
+ case "$SESSION_LOG" in
125
+ /*) ;;
126
+ *) SESSION_LOG="$REPO_ROOT/$SESSION_LOG" ;;
127
+ esac
128
+
129
+ if [ ! -f "$SESSION_LOG" ]; then
130
+ echo "ERROR: missing chat session log: $SESSION_LOG" >&2
131
+ exit 1
132
+ fi
133
+
134
+ TARGET_BRANCH="$(chat_worktree_metadata_value "$SESSION_LOG" "branch")"
135
+ if [ -z "${TARGET_BRANCH// }" ]; then
136
+ echo "ERROR: session log is missing branch metadata: $SESSION_LOG" >&2
137
+ exit 1
138
+ fi
139
+
140
+ case "$TARGET_BRANCH" in
141
+ chat/*) ;;
142
+ *)
143
+ echo "ERROR: session branch is not a chat branch: $TARGET_BRANCH" >&2
144
+ exit 1
145
+ ;;
146
+ esac
147
+
148
+ TARGET_WORKTREE="$(chat_worktree_metadata_value "$SESSION_LOG" "worktree")"
149
+ if [ -z "${TARGET_WORKTREE// }" ]; then
150
+ TARGET_WORKTREE="$(chat_worktree_path_for_branch "$REPO_ROOT" "$TARGET_BRANCH")"
151
+ fi
152
+
153
+ case "$TARGET_WORKTREE" in
154
+ /*) ;;
155
+ *) TARGET_WORKTREE="$REPO_ROOT/$TARGET_WORKTREE" ;;
156
+ esac
157
+
158
+ if [ ! -d "$TARGET_WORKTREE" ]; then
159
+ echo "ERROR: chat-owned worktree is missing: $TARGET_WORKTREE" >&2
160
+ echo "Run scripts/00.chat/worktree/ensure-chat-worktree/script.sh first." >&2
161
+ exit 1
162
+ fi
163
+
164
+ TARGET_WORKTREE="$(cd "$TARGET_WORKTREE" && pwd -P)"
165
+
166
+ if [ "$SOURCE_WORKTREE" = "$TARGET_WORKTREE" ]; then
167
+ echo "ERROR: source worktree and chat-owned worktree are the same path." >&2
168
+ echo "Normal task work should be staged directly in the chat-owned worktree." >&2
169
+ exit 1
170
+ fi
171
+
172
+ if ! git -C "$TARGET_WORKTREE" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
173
+ echo "ERROR: chat-owned worktree path is not a git worktree: $TARGET_WORKTREE" >&2
174
+ exit 1
175
+ fi
176
+
177
+ TARGET_CURRENT_BRANCH="$(git -C "$TARGET_WORKTREE" branch --show-current)"
178
+ if [ "$TARGET_CURRENT_BRANCH" != "$TARGET_BRANCH" ]; then
179
+ echo "ERROR: chat-owned worktree is on '$TARGET_CURRENT_BRANCH', expected '$TARGET_BRANCH': $TARGET_WORKTREE" >&2
180
+ exit 1
181
+ fi
182
+
183
+ if [ -n "$(git -C "$TARGET_WORKTREE" status --porcelain)" ]; then
184
+ echo "ERROR: chat-owned worktree is dirty; refusing to import over existing work." >&2
185
+ echo "Commit, checkpoint, or inspect the target worktree before recovery import." >&2
186
+ exit 1
187
+ fi
188
+
189
+ import_path() {
190
+ local path="$1"
191
+ local source_path="$SOURCE_WORKTREE/$path"
192
+ local target_path="$TARGET_WORKTREE/$path"
193
+ local target_parent
194
+
195
+ if [ -e "$source_path" ] || [ -L "$source_path" ]; then
196
+ target_parent="$(dirname "$target_path")"
197
+ mkdir -p "$target_parent"
198
+ rm -rf "$target_path"
199
+ cp -a "$source_path" "$target_path"
200
+ git -C "$TARGET_WORKTREE" add -A -- "$path"
201
+ else
202
+ git -C "$TARGET_WORKTREE" rm -r --ignore-unmatch -- "$path" >/dev/null 2>&1 || true
203
+ fi
204
+ }
205
+
206
+ for path in "$@"; do
207
+ import_path "$path"
208
+ done
209
+
210
+ echo "Imported active worktree paths into chat-owned worktree:"
211
+ printf '%s\n' "$@"
212
+ echo "Target worktree: $TARGET_WORKTREE"
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # agentic-artifact:
5
+ # schema: agentic-artifact/v2
6
+ # id: chat.script.recovery.import-active-paths-to-chat-worktree.smoke-test
7
+ # version: 1
8
+ # status: active
9
+ # layer: 00.chat
10
+ # domain: recovery
11
+ # disciplines:
12
+ # - agentic
13
+ # kind: script
14
+ # purpose: Smoke test recovery import from an active worktree into a chat-owned worktree.
15
+ # portability:
16
+ # class: reusable
17
+ # targets:
18
+ # - llm-workbench
19
+ # used_by:
20
+ # - id: chat.script.recovery.import-active-paths-to-chat-worktree
21
+ # path: scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh
22
+ # effects:
23
+ # - branches
24
+ # - commits
25
+ # - worktrees
26
+ # - writes-files
27
+
28
+ SOURCE_ROOT="$(git rev-parse --show-toplevel)"
29
+ TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/import-active-paths-smoke.XXXXXX")"
30
+
31
+ cleanup() {
32
+ rm -rf "$TMP_ROOT"
33
+ }
34
+
35
+ trap cleanup EXIT
36
+
37
+ fail() {
38
+ echo "ERROR: $*" >&2
39
+ exit 1
40
+ }
41
+
42
+ assert_file_equals() {
43
+ local file="$1"
44
+ local expected="$2"
45
+ local actual
46
+
47
+ actual="$(cat "$file")"
48
+ if [ "$actual" != "$expected" ]; then
49
+ fail "expected $file to contain '$expected', got '$actual'"
50
+ fi
51
+ }
52
+
53
+ REPO="$TMP_ROOT/repo"
54
+ mkdir -p \
55
+ "$REPO/scripts/00.chat/recovery/import-active-paths-to-chat-worktree" \
56
+ "$REPO/scripts/00.chat/session-log/paths" \
57
+ "$REPO/scripts/00.chat/worktree/paths"
58
+
59
+ cp "$SOURCE_ROOT/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh" \
60
+ "$REPO/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh"
61
+ cp "$SOURCE_ROOT/scripts/00.chat/session-log/paths/lib.sh" \
62
+ "$REPO/scripts/00.chat/session-log/paths/lib.sh"
63
+ cp "$SOURCE_ROOT/scripts/00.chat/worktree/paths/lib.sh" \
64
+ "$REPO/scripts/00.chat/worktree/paths/lib.sh"
65
+
66
+ git -C "$REPO" init -q -b main
67
+ git -C "$REPO" config user.name "Smoke Test"
68
+ git -C "$REPO" config user.email "smoke@example.invalid"
69
+
70
+ mkdir -p "$REPO/docs"
71
+ printf 'base\n' > "$REPO/docs/kept.txt"
72
+ printf 'delete me\n' > "$REPO/docs/remove-me.txt"
73
+ git -C "$REPO" add \
74
+ docs/kept.txt \
75
+ docs/remove-me.txt \
76
+ scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh \
77
+ scripts/00.chat/session-log/paths/lib.sh \
78
+ scripts/00.chat/worktree/paths/lib.sh
79
+ git -C "$REPO" commit -q -m "initial"
80
+
81
+ SESSION_ID="2026-06-19-21-00-import-smoke"
82
+ SESSION_BRANCH="chat/$SESSION_ID"
83
+ SESSION_DIR="$REPO/commitLogs/2026/jun/19/$SESSION_ID"
84
+ SESSION_LOG="$SESSION_DIR/README.md"
85
+ WORKTREE_ROOT="$TMP_ROOT/worktrees"
86
+ WORKTREE_PATH="$WORKTREE_ROOT/chat_${SESSION_ID}-$(printf '%s' "$SESSION_BRANCH" | cksum | awk '{print $1}')"
87
+
88
+ mkdir -p "$SESSION_DIR"
89
+ cat > "$SESSION_LOG" <<EOF
90
+ # Chat Session: import smoke
91
+
92
+ <!-- agentic-session
93
+ id: $SESSION_ID
94
+ task: import smoke
95
+ branch: $SESSION_BRANCH
96
+ worktree: $WORKTREE_PATH
97
+ layer: 00.chat
98
+ mode: implementation
99
+ workflow: .agentic/00.chat/workflows/chat-start.md
100
+ status: ready
101
+ raised_at_utc: 2026-06-19T20:00:00Z
102
+ -->
103
+ EOF
104
+
105
+ git -C "$REPO" add "$SESSION_LOG"
106
+ git -C "$REPO" commit -q -m "add session log"
107
+ git -C "$REPO" branch "$SESSION_BRANCH"
108
+ git -C "$REPO" worktree add --quiet "$WORKTREE_PATH" "$SESSION_BRANCH"
109
+
110
+ printf 'changed in active\n' > "$REPO/docs/kept.txt"
111
+ rm "$REPO/docs/remove-me.txt"
112
+ mkdir -p "$REPO/docs/new-dir"
113
+ printf 'new file\n' > "$REPO/docs/new-dir/new.txt"
114
+
115
+ (
116
+ cd "$REPO"
117
+ AGENTIC_CHAT_WORKTREE_ROOT="$WORKTREE_ROOT" \
118
+ bash scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh \
119
+ --session-log "$SESSION_LOG" \
120
+ --source-worktree "$REPO" \
121
+ -- docs/kept.txt docs/remove-me.txt docs/new-dir
122
+ )
123
+
124
+ assert_file_equals "$WORKTREE_PATH/docs/kept.txt" "changed in active"
125
+ assert_file_equals "$WORKTREE_PATH/docs/new-dir/new.txt" "new file"
126
+
127
+ if [ -e "$WORKTREE_PATH/docs/remove-me.txt" ]; then
128
+ fail "deleted active path still exists in chat-owned worktree"
129
+ fi
130
+
131
+ if ! git -C "$WORKTREE_PATH" diff --cached --name-only | grep -qx 'docs/kept.txt'; then
132
+ fail "changed file was not staged"
133
+ fi
134
+
135
+ if ! git -C "$WORKTREE_PATH" diff --cached --name-only | grep -qx 'docs/remove-me.txt'; then
136
+ fail "deleted file was not staged"
137
+ fi
138
+
139
+ if ! git -C "$WORKTREE_PATH" diff --cached --name-only | grep -qx 'docs/new-dir/new.txt'; then
140
+ fail "new file was not staged"
141
+ fi
142
+
143
+ set +e
144
+ (
145
+ cd "$REPO"
146
+ bash scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh \
147
+ --session-log "$SESSION_LOG" \
148
+ --source-worktree "$REPO" \
149
+ -- /absolute/path
150
+ ) > "$TMP_ROOT/unsafe.out" 2> "$TMP_ROOT/unsafe.err"
151
+ UNSAFE_STATUS="$?"
152
+ set -e
153
+
154
+ if [ "$UNSAFE_STATUS" -eq 0 ]; then
155
+ fail "unsafe absolute path was not rejected"
156
+ fi
157
+
158
+ if ! grep -q "path must be a repository-relative path" "$TMP_ROOT/unsafe.err"; then
159
+ fail "unsafe path rejection message was not emitted"
160
+ fi
161
+
162
+ echo "import active paths recovery smoke test passed."
@@ -0,0 +1,30 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.reporting.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: reporting
8
+ disciplines:
9
+ - agentic
10
+ kind: script-domain-readme
11
+ purpose: Explain on-demand chat reporting scripts.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.workflows.chat-reporting
18
+ path: .agentic/00.chat/workflows/chat-reporting.md
19
+ - id: chat.script.reporting.generate-commit-log-summary.readme
20
+ path: scripts/00.chat/reporting/generate-commit-log-summary/README.md
21
+ -->
22
+ # Reporting Scripts
23
+
24
+ Reporting scripts summarize chat branches, worktrees, and session logs on
25
+ demand. They do not create always-generated aggregate artifacts.
26
+
27
+ The durable source evidence is each individual session log under `commitLogs/`.
28
+ Reports should be reproducible from those logs and should avoid reviving the
29
+ retired tracked `commitLogs/README.md` summary.
30
+
@@ -0,0 +1,35 @@
1
+ <!-- agentic-artifact:
2
+ schema: agentic-artifact/v2
3
+ id: chat.script.reporting.generate-commit-log-summary.readme
4
+ version: 1
5
+ status: active
6
+ layer: 00.chat
7
+ domain: reporting
8
+ disciplines:
9
+ - agentic
10
+ kind: capability-readme
11
+ purpose: Explain on-demand aggregate summaries from chat session logs.
12
+ portability:
13
+ class: required
14
+ targets:
15
+ - llm-workbench
16
+ used_by:
17
+ - id: chat.skills.session-summary
18
+ path: .agentic/00.chat/skills/session-summary.md
19
+ - id: chat.script.reporting.generate-commit-log-summary
20
+ path: scripts/00.chat/reporting/generate-commit-log-summary/script.sh
21
+ -->
22
+ # Generate Commit Log Summary
23
+
24
+ `script.sh` builds an aggregate summary from individual chat session logs.
25
+
26
+ By default it prints the summary. With `--output <path>`, it writes to an
27
+ explicit on-demand artifact path. It must not recreate the retired tracked
28
+ `commitLogs/README.md` file.
29
+
30
+ Use this capability when a human asks for a session overview, metrics summary,
31
+ or chat history report. The individual session logs remain the durable source.
32
+
33
+ `smoke-test.sh` verifies that summary generation works and that the retired
34
+ aggregate artifact is not written by default.
35
+