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.
- package/.agentic/00.chat/README.md +78 -0
- package/.agentic/00.chat/checklists/before-commit.md +195 -0
- package/.agentic/00.chat/checklists/llm-workbench-public-beta.md +94 -0
- package/.agentic/00.chat/commands/README.md +108 -0
- package/.agentic/00.chat/migration-plan.md +132 -0
- package/.agentic/00.chat/skills/session-summary.md +48 -0
- package/.agentic/00.chat/standards/llm-workbench-public-beta-contract.md +216 -0
- package/.agentic/00.chat/standards/main-refresh-conflict-types.md +358 -0
- package/.agentic/00.chat/workflows/README.md +40 -0
- package/.agentic/00.chat/workflows/bootstrap-chat-workbench-repo.md +212 -0
- package/.agentic/00.chat/workflows/chat-cleanup.md +102 -0
- package/.agentic/00.chat/workflows/chat-commit.md +56 -0
- package/.agentic/00.chat/workflows/chat-promote-to-main.md +169 -0
- package/.agentic/00.chat/workflows/chat-refresh-from-main.md +242 -0
- package/.agentic/00.chat/workflows/chat-reporting.md +69 -0
- package/.agentic/00.chat/workflows/chat-start.md +173 -0
- package/.agentic/00.chat/workflows/chat-upstream-reusable-lesson.md +123 -0
- package/.agentic/shared/standards/README.md +32 -0
- package/.agentic/shared/standards/upstream-repo-bootstrap.md +131 -0
- package/.agentic/shared/workflows/README.md +35 -0
- package/.agentic/shared/workflows/capability-resolution-workflow.md +189 -0
- package/.agentic/shared/workflows/change-shared-process.md +92 -0
- package/.cursor/rules/llm-workbench.mdc +17 -0
- package/.github/copilot-instructions.md +16 -0
- package/AGENTS.md +63 -0
- package/CLAUDE.md +16 -0
- package/CONTRIBUTING.md +57 -0
- package/LICENSE +21 -0
- package/LLM_WORKBENCH.md +17 -0
- package/README.md +98 -0
- package/SECURITY.md +44 -0
- package/bin/llm-workbench.js +672 -0
- package/docs/00.chat/README.md +47 -0
- package/docs/00.chat/llm-workbench-acceptance-matrix.md +55 -0
- package/docs/00.chat/script-layout.md +107 -0
- package/docs/adapting-to-your-repo.md +29 -0
- package/docs/concepts.md +38 -0
- package/docs/install.md +114 -0
- package/docs/public-beta-contract.md +45 -0
- package/docs/workflows.md +103 -0
- package/examples/minimal-repo/README.md +13 -0
- package/package.json +93 -0
- package/scripts/00.chat/README.md +46 -0
- package/scripts/00.chat/bootstrap/README.md +35 -0
- package/scripts/00.chat/bootstrap/audit-chat-bootstrap-file-set/README.md +39 -0
- package/scripts/00.chat/bootstrap/audit-chat-bootstrap-file-set/script.sh +213 -0
- package/scripts/00.chat/closeout/README.md +30 -0
- package/scripts/00.chat/closeout/build-closeout-prompt/README.md +35 -0
- package/scripts/00.chat/closeout/build-closeout-prompt/script.sh +124 -0
- package/scripts/00.chat/command/README.md +31 -0
- package/scripts/00.chat/command/close/README.md +30 -0
- package/scripts/00.chat/command/close/script.sh +25 -0
- package/scripts/00.chat/command/dispatcher/README.md +46 -0
- package/scripts/00.chat/command/dispatcher/script.sh +91 -0
- package/scripts/00.chat/command/dispatcher/smoke-test.sh +168 -0
- package/scripts/00.chat/command/new/README.md +32 -0
- package/scripts/00.chat/command/new/script.sh +28 -0
- package/scripts/00.chat/command/open-window/README.md +38 -0
- package/scripts/00.chat/command/open-window/script.sh +25 -0
- package/scripts/00.chat/command/package-scripts/README.md +34 -0
- package/scripts/00.chat/command/package-scripts/smoke-test.sh +113 -0
- package/scripts/00.chat/git/README.md +30 -0
- package/scripts/00.chat/git/cleanup-empty-chat-branches/README.md +36 -0
- package/scripts/00.chat/git/cleanup-empty-chat-branches/script.sh +243 -0
- package/scripts/00.chat/git/cleanup-empty-chat-branches/smoke-test.sh +136 -0
- package/scripts/00.chat/local-merge/README.md +30 -0
- package/scripts/00.chat/local-merge/list-active-chat-branches/README.md +29 -0
- package/scripts/00.chat/local-merge/list-active-chat-branches/script.sh +109 -0
- package/scripts/00.chat/local-merge/report-chat-branch-overlaps/README.md +29 -0
- package/scripts/00.chat/local-merge/report-chat-branch-overlaps/script.sh +142 -0
- package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/README.md +33 -0
- package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/script.sh +345 -0
- package/scripts/00.chat/local-merge/verify-chat-ready-to-merge-local-main/smoke-test.sh +244 -0
- package/scripts/00.chat/main-refresh/README.md +39 -0
- package/scripts/00.chat/main-refresh/apply-rehearsed-refresh/README.md +32 -0
- package/scripts/00.chat/main-refresh/apply-rehearsed-refresh/script.sh +198 -0
- package/scripts/00.chat/main-refresh/check-chat-is-current-with-main/README.md +30 -0
- package/scripts/00.chat/main-refresh/check-chat-is-current-with-main/script.sh +121 -0
- package/scripts/00.chat/main-refresh/classify-conflict/README.md +39 -0
- package/scripts/00.chat/main-refresh/classify-conflict/script.sh +169 -0
- package/scripts/00.chat/main-refresh/classify-conflict/smoke-test.sh +137 -0
- package/scripts/00.chat/main-refresh/classify-refresh-readiness/README.md +35 -0
- package/scripts/00.chat/main-refresh/classify-refresh-readiness/script.sh +171 -0
- package/scripts/00.chat/main-refresh/classify-refresh-readiness/smoke-test.sh +132 -0
- package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/README.md +34 -0
- package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/script.sh +124 -0
- package/scripts/00.chat/main-refresh/rehearse-refresh-from-main/smoke-test.sh +257 -0
- package/scripts/00.chat/main-refresh/show-main-update-status/README.md +31 -0
- package/scripts/00.chat/main-refresh/show-main-update-status/script.sh +73 -0
- package/scripts/00.chat/main-refresh/verify-conflict-audit/README.md +37 -0
- package/scripts/00.chat/main-refresh/verify-conflict-audit/script.sh +154 -0
- package/scripts/00.chat/main-refresh/verify-conflict-audit/smoke-test.sh +99 -0
- package/scripts/00.chat/metrics/README.md +35 -0
- package/scripts/00.chat/metrics/data/chat-pricing.json +107 -0
- package/scripts/00.chat/metrics/data/chat-pricing.schema.json +63 -0
- package/scripts/00.chat/metrics/estimate-chat-cost/README.md +40 -0
- package/scripts/00.chat/metrics/estimate-chat-cost/script.js +130 -0
- package/scripts/00.chat/migration/README.md +30 -0
- package/scripts/00.chat/migration/audit-chat-layer-migration/README.md +33 -0
- package/scripts/00.chat/migration/audit-chat-layer-migration/script.sh +127 -0
- package/scripts/00.chat/recovery/README.md +30 -0
- package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/README.md +76 -0
- package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/script.sh +212 -0
- package/scripts/00.chat/recovery/import-active-paths-to-chat-worktree/smoke-test.sh +162 -0
- package/scripts/00.chat/reporting/README.md +30 -0
- package/scripts/00.chat/reporting/generate-commit-log-summary/README.md +35 -0
- package/scripts/00.chat/reporting/generate-commit-log-summary/script.sh +299 -0
- package/scripts/00.chat/reporting/generate-commit-log-summary/smoke-test.sh +93 -0
- package/scripts/00.chat/reporting/report-chat-workspaces/README.md +32 -0
- package/scripts/00.chat/reporting/report-chat-workspaces/script.sh +82 -0
- package/scripts/00.chat/session-log/README.md +33 -0
- package/scripts/00.chat/session-log/check-commit-prerequisites/README.md +89 -0
- package/scripts/00.chat/session-log/check-commit-prerequisites/script.sh +121 -0
- package/scripts/00.chat/session-log/check-commit-prerequisites/smoke-test.sh +119 -0
- package/scripts/00.chat/session-log/check-commitlog-deletions/README.md +90 -0
- package/scripts/00.chat/session-log/check-commitlog-deletions/script.sh +131 -0
- package/scripts/00.chat/session-log/check-commitlog-deletions/smoke-test.sh +123 -0
- package/scripts/00.chat/session-log/checkpoint-chat-session-log/README.md +98 -0
- package/scripts/00.chat/session-log/checkpoint-chat-session-log/script.sh +126 -0
- package/scripts/00.chat/session-log/paths/README.md +38 -0
- package/scripts/00.chat/session-log/paths/lib.sh +133 -0
- package/scripts/00.chat/session-log/prepare-chat-session-before-commit/README.md +90 -0
- package/scripts/00.chat/session-log/prepare-chat-session-before-commit/script.sh +145 -0
- package/scripts/00.chat/session-log/read-current-chat-log/README.md +44 -0
- package/scripts/00.chat/session-log/read-current-chat-log/script.sh +92 -0
- package/scripts/00.chat/session-log/read-current-chat-log/smoke-test.sh +127 -0
- package/scripts/00.chat/session-log/record-chat-commit/README.md +133 -0
- package/scripts/00.chat/session-log/record-chat-commit/script.sh +394 -0
- package/scripts/00.chat/session-log/record-chat-commit/smoke-test.sh +227 -0
- package/scripts/00.chat/session-log/record-main-refresh-conflict/README.md +34 -0
- package/scripts/00.chat/session-log/record-main-refresh-conflict/script.sh +239 -0
- package/scripts/00.chat/session-log/rename-current-chat-log-folder/README.md +32 -0
- package/scripts/00.chat/session-log/rename-current-chat-log-folder/script.sh +112 -0
- package/scripts/00.chat/session-log/update-chat-log/README.md +32 -0
- package/scripts/00.chat/session-log/update-chat-log/script.sh +294 -0
- package/scripts/00.chat/startup/README.md +37 -0
- package/scripts/00.chat/startup/auto-start-missing-session/README.md +113 -0
- package/scripts/00.chat/startup/auto-start-missing-session/script.sh +54 -0
- package/scripts/00.chat/startup/resolve-current-chat-session/README.md +57 -0
- package/scripts/00.chat/startup/resolve-current-chat-session/script.sh +47 -0
- package/scripts/00.chat/startup/resolve-current-chat-session/smoke-test.sh +130 -0
- package/scripts/00.chat/startup/start-chat-session/README.md +197 -0
- package/scripts/00.chat/startup/start-chat-session/script.sh +330 -0
- package/scripts/00.chat/startup/start-chat-session/smoke-test.sh +182 -0
- package/scripts/00.chat/startup/start-new-chat/README.md +31 -0
- package/scripts/00.chat/startup/start-new-chat/script.sh +29 -0
- package/scripts/00.chat/transcript/README.md +36 -0
- package/scripts/00.chat/transcript/discover-codex-session-log/README.md +32 -0
- package/scripts/00.chat/transcript/discover-codex-session-log/script.sh +106 -0
- package/scripts/00.chat/transcript/register-codex-session-log/README.md +32 -0
- package/scripts/00.chat/transcript/register-codex-session-log/script.sh +115 -0
- package/scripts/00.chat/worktree/README.md +32 -0
- package/scripts/00.chat/worktree/check-write-location/README.md +87 -0
- package/scripts/00.chat/worktree/check-write-location/script.sh +95 -0
- package/scripts/00.chat/worktree/dirty-worktree-check/README.md +77 -0
- package/scripts/00.chat/worktree/dirty-worktree-check/script.sh +93 -0
- package/scripts/00.chat/worktree/ensure-chat-worktree/README.md +33 -0
- package/scripts/00.chat/worktree/ensure-chat-worktree/script.sh +132 -0
- package/scripts/00.chat/worktree/open-window/README.md +34 -0
- package/scripts/00.chat/worktree/open-window/script.sh +131 -0
- package/scripts/00.chat/worktree/paths/README.md +32 -0
- package/scripts/00.chat/worktree/paths/lib.sh +71 -0
- package/scripts/01.harness/artifact-metadata/check-headers/script.sh +522 -0
- package/scripts/01.harness/artifact-metadata/check-headers/smoke-test.sh +48 -0
- package/scripts/01.harness/check-deterministic-process-drift.sh +416 -0
- package/scripts/01.harness/check-governed-script-command-drift.sh +184 -0
- package/scripts/01.harness/run-governed-script.sh +178 -0
- package/scripts/install.sh +503 -0
- package/scripts/uninstall.sh +199 -0
- package/tests/smoke-test-install.sh +70 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# agentic-artifact:
|
|
5
|
+
# schema: agentic-artifact/v2
|
|
6
|
+
# id: chat.script.session-log.checkpoint-chat-session-log
|
|
7
|
+
# version: 1
|
|
8
|
+
# status: active
|
|
9
|
+
# layer: 00.chat
|
|
10
|
+
# domain: session-log
|
|
11
|
+
# disciplines:
|
|
12
|
+
# - agentic
|
|
13
|
+
# kind: script
|
|
14
|
+
# purpose: Commit only the current chat session log as bookkeeping.
|
|
15
|
+
# portability:
|
|
16
|
+
# class: required
|
|
17
|
+
# targets:
|
|
18
|
+
# - llm-workbench
|
|
19
|
+
# used_by:
|
|
20
|
+
# - id: chat.script.session-log.checkpoint-chat-session-log.readme
|
|
21
|
+
# path: scripts/00.chat/session-log/checkpoint-chat-session-log/README.md
|
|
22
|
+
# effects:
|
|
23
|
+
# - stages-files
|
|
24
|
+
# - commits
|
|
25
|
+
|
|
26
|
+
# shellcheck source=../paths/lib.sh
|
|
27
|
+
source "scripts/00.chat/session-log/paths/lib.sh"
|
|
28
|
+
|
|
29
|
+
usage() {
|
|
30
|
+
cat <<'EOF'
|
|
31
|
+
Usage:
|
|
32
|
+
checkpoint-chat-session-log.sh [--dry-run] [message]
|
|
33
|
+
|
|
34
|
+
Commits only the current chat session log as a narrow bookkeeping checkpoint.
|
|
35
|
+
Use after record-chat-commit.sh leaves the session log dirty.
|
|
36
|
+
EOF
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
DRY_RUN="no"
|
|
40
|
+
|
|
41
|
+
if [ $# -gt 2 ]; then
|
|
42
|
+
usage >&2
|
|
43
|
+
exit 2
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
if [ "${1:-}" = "--dry-run" ]; then
|
|
47
|
+
DRY_RUN="yes"
|
|
48
|
+
shift
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [ $# -gt 1 ]; then
|
|
52
|
+
usage >&2
|
|
53
|
+
exit 2
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
COMMIT_MESSAGE="${1:-chore(session): checkpoint chat log}"
|
|
57
|
+
|
|
58
|
+
BRANCH="$(git branch --show-current)"
|
|
59
|
+
|
|
60
|
+
if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH")"; then
|
|
61
|
+
echo "ERROR: current branch is not a chat branch: $BRANCH" >&2
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
LOG_FILE="$(chat_log_file_for_session "$SESSION_ID")"
|
|
66
|
+
|
|
67
|
+
if [ ! -f "$LOG_FILE" ]; then
|
|
68
|
+
echo "ERROR: missing chat log: $LOG_FILE" >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
STAGED_FILES="$(git diff --cached --name-only)"
|
|
73
|
+
|
|
74
|
+
if [ -n "${STAGED_FILES// }" ]; then
|
|
75
|
+
MIXED_STAGED="$(printf '%s\n' "$STAGED_FILES" | awk \
|
|
76
|
+
-v log_file="$LOG_FILE" \
|
|
77
|
+
'$0 != log_file')"
|
|
78
|
+
if [ -n "${MIXED_STAGED// }" ]; then
|
|
79
|
+
echo "ERROR: cannot checkpoint session bookkeeping with other staged files:" >&2
|
|
80
|
+
printf '%s\n' "$MIXED_STAGED" >&2
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
MIXED_DIRTY="$(
|
|
86
|
+
{
|
|
87
|
+
git diff --name-only
|
|
88
|
+
git diff --cached --name-only
|
|
89
|
+
git ls-files --others --exclude-standard
|
|
90
|
+
} | awk \
|
|
91
|
+
-v log_file="$LOG_FILE" \
|
|
92
|
+
'$0 != "" && $0 != log_file' \
|
|
93
|
+
| sort -u
|
|
94
|
+
)"
|
|
95
|
+
|
|
96
|
+
if [ -n "${MIXED_DIRTY// }" ]; then
|
|
97
|
+
echo "ERROR: cannot checkpoint session bookkeeping with other dirty files:" >&2
|
|
98
|
+
printf '%s\n' "$MIXED_DIRTY" >&2
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
LOG_HAS_CHANGES="no"
|
|
103
|
+
|
|
104
|
+
if ! git ls-files --error-unmatch "$LOG_FILE" >/dev/null 2>&1 ||
|
|
105
|
+
! git diff --quiet -- "$LOG_FILE" ||
|
|
106
|
+
! git diff --cached --quiet -- "$LOG_FILE"; then
|
|
107
|
+
LOG_HAS_CHANGES="yes"
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
if [ "$LOG_HAS_CHANGES" = "no" ]; then
|
|
111
|
+
echo "No session bookkeeping changes to checkpoint."
|
|
112
|
+
exit 0
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
if [ "$DRY_RUN" = "yes" ]; then
|
|
116
|
+
echo "Would checkpoint chat session bookkeeping:"
|
|
117
|
+
echo "Message: $COMMIT_MESSAGE"
|
|
118
|
+
echo "Log: $LOG_FILE"
|
|
119
|
+
exit 0
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
git add -- "$LOG_FILE"
|
|
123
|
+
git commit -m "$COMMIT_MESSAGE" -- "$LOG_FILE"
|
|
124
|
+
|
|
125
|
+
echo "Checkpointed chat session bookkeeping:"
|
|
126
|
+
echo "Log: $LOG_FILE"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!-- agentic-artifact:
|
|
2
|
+
schema: agentic-artifact/v2
|
|
3
|
+
id: chat.script.session-log.paths.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 helper functions for chat session log paths and metadata.
|
|
12
|
+
portability:
|
|
13
|
+
class: required
|
|
14
|
+
targets:
|
|
15
|
+
- llm-workbench
|
|
16
|
+
used_by:
|
|
17
|
+
- id: chat.script.session-log.paths.lib
|
|
18
|
+
path: scripts/00.chat/session-log/paths/lib.sh
|
|
19
|
+
- id: chat.script.session-log.read-current-chat-log
|
|
20
|
+
path: scripts/00.chat/session-log/read-current-chat-log/script.sh
|
|
21
|
+
-->
|
|
22
|
+
# Session Log Paths
|
|
23
|
+
|
|
24
|
+
`lib.sh` provides shell helper functions for converting chat branch names and
|
|
25
|
+
session ids into session-log paths.
|
|
26
|
+
|
|
27
|
+
The library understands the grouped log layout:
|
|
28
|
+
|
|
29
|
+
```txt
|
|
30
|
+
commitLogs/<year>/<month>/<day>/<session>/README.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
It also reads metadata values from the `agentic-session` comment block. Scripts
|
|
34
|
+
use these helpers so branch-to-log lookup stays consistent across startup,
|
|
35
|
+
commit gates, reporting, recovery, and cleanup.
|
|
36
|
+
|
|
37
|
+
This library is read-only. It does not create, modify, stage, or commit logs.
|
|
38
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# agentic-artifact:
|
|
4
|
+
# schema: agentic-artifact/v2
|
|
5
|
+
# id: chat.script.session-log.paths.lib
|
|
6
|
+
# version: 1
|
|
7
|
+
# status: active
|
|
8
|
+
# layer: 00.chat
|
|
9
|
+
# domain: session-log
|
|
10
|
+
# disciplines:
|
|
11
|
+
# - agentic
|
|
12
|
+
# kind: script
|
|
13
|
+
# purpose: Provide canonical chat session id and commit log path helper functions.
|
|
14
|
+
# portability:
|
|
15
|
+
# class: required
|
|
16
|
+
# targets:
|
|
17
|
+
# - llm-workbench
|
|
18
|
+
# used_by:
|
|
19
|
+
# - id: chat.script.session-log.read-current-chat-log
|
|
20
|
+
# path: scripts/00.chat/session-log/read-current-chat-log/script.sh
|
|
21
|
+
# - id: chat.script.session-log.update-chat-log
|
|
22
|
+
# path: scripts/00.chat/session-log/update-chat-log/script.sh
|
|
23
|
+
# effects:
|
|
24
|
+
# - read-only
|
|
25
|
+
chat_session_id_from_branch() {
|
|
26
|
+
local branch="$1"
|
|
27
|
+
|
|
28
|
+
case "$branch" in
|
|
29
|
+
chat/*)
|
|
30
|
+
printf '%s\n' "${branch#chat/}"
|
|
31
|
+
;;
|
|
32
|
+
*)
|
|
33
|
+
return 1
|
|
34
|
+
;;
|
|
35
|
+
esac
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
chat_log_month_name() {
|
|
39
|
+
case "$1" in
|
|
40
|
+
01) printf 'jan\n' ;;
|
|
41
|
+
02) printf 'feb\n' ;;
|
|
42
|
+
03) printf 'mar\n' ;;
|
|
43
|
+
04) printf 'apr\n' ;;
|
|
44
|
+
05) printf 'may\n' ;;
|
|
45
|
+
06) printf 'jun\n' ;;
|
|
46
|
+
07) printf 'jul\n' ;;
|
|
47
|
+
08) printf 'aug\n' ;;
|
|
48
|
+
09) printf 'sep\n' ;;
|
|
49
|
+
10) printf 'oct\n' ;;
|
|
50
|
+
11) printf 'nov\n' ;;
|
|
51
|
+
12) printf 'dec\n' ;;
|
|
52
|
+
*) return 1 ;;
|
|
53
|
+
esac
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
chat_log_grouped_dir_for_session() {
|
|
57
|
+
local session_id="$1"
|
|
58
|
+
local year month day month_name
|
|
59
|
+
|
|
60
|
+
year="${session_id:0:4}"
|
|
61
|
+
month="${session_id:5:2}"
|
|
62
|
+
day="${session_id:8:2}"
|
|
63
|
+
|
|
64
|
+
if ! month_name="$(chat_log_month_name "$month")"; then
|
|
65
|
+
return 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
printf 'commitLogs/%s/%s/%s/%s\n' "$year" "$month_name" "$day" "$session_id"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
chat_log_metadata_value() {
|
|
72
|
+
local log_file="$1"
|
|
73
|
+
local key="$2"
|
|
74
|
+
|
|
75
|
+
sed -n '/<!-- agentic-session/,/-->/p' "$log_file" \
|
|
76
|
+
| sed '/<!-- agentic-session/d;/-->/d' \
|
|
77
|
+
| sed -n "s/^${key}: //p" \
|
|
78
|
+
| head -n 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
chat_log_file_for_session_by_metadata() {
|
|
82
|
+
local session_id="$1"
|
|
83
|
+
local branch="chat/${session_id}"
|
|
84
|
+
local grouped_parent found_file found_count file
|
|
85
|
+
|
|
86
|
+
grouped_parent="$(chat_log_grouped_dir_for_session "$session_id")"
|
|
87
|
+
grouped_parent="${grouped_parent%/*}"
|
|
88
|
+
found_file=""
|
|
89
|
+
found_count=0
|
|
90
|
+
|
|
91
|
+
if [ -d "$grouped_parent" ]; then
|
|
92
|
+
while IFS= read -r file; do
|
|
93
|
+
if [ "$(chat_log_metadata_value "$file" "id")" = "$session_id" ] \
|
|
94
|
+
|| [ "$(chat_log_metadata_value "$file" "branch")" = "$branch" ]; then
|
|
95
|
+
found_file="$file"
|
|
96
|
+
found_count=$((found_count + 1))
|
|
97
|
+
fi
|
|
98
|
+
done < <(find "$grouped_parent" -mindepth 2 -maxdepth 2 -type f -name README.md | sort)
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
if [ "$found_count" -eq 1 ]; then
|
|
102
|
+
printf '%s\n' "$found_file"
|
|
103
|
+
return 0
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
return 1
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
chat_log_file_for_session() {
|
|
110
|
+
local session_id="$1"
|
|
111
|
+
local grouped_dir flat_file metadata_file
|
|
112
|
+
|
|
113
|
+
grouped_dir="$(chat_log_grouped_dir_for_session "$session_id")"
|
|
114
|
+
flat_file="commitLogs/${session_id}/README.md"
|
|
115
|
+
|
|
116
|
+
if [ -f "${grouped_dir}/README.md" ]; then
|
|
117
|
+
printf '%s\n' "${grouped_dir}/README.md"
|
|
118
|
+
elif [ -f "$flat_file" ]; then
|
|
119
|
+
printf '%s\n' "$flat_file"
|
|
120
|
+
elif metadata_file="$(chat_log_file_for_session_by_metadata "$session_id")"; then
|
|
121
|
+
printf '%s\n' "$metadata_file"
|
|
122
|
+
else
|
|
123
|
+
printf '%s\n' "${grouped_dir}/README.md"
|
|
124
|
+
fi
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
chat_log_dir_for_session() {
|
|
128
|
+
local session_id="$1"
|
|
129
|
+
local log_file
|
|
130
|
+
|
|
131
|
+
log_file="$(chat_log_file_for_session "$session_id")"
|
|
132
|
+
printf '%s\n' "${log_file%/README.md}"
|
|
133
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!-- agentic-artifact:
|
|
2
|
+
schema: agentic-artifact/v2
|
|
3
|
+
id: chat.script.session-log.prepare-chat-session-before-commit.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 chat commit-boundary readiness check before task commits.
|
|
12
|
+
portability:
|
|
13
|
+
class: required
|
|
14
|
+
targets:
|
|
15
|
+
- llm-workbench
|
|
16
|
+
used_by:
|
|
17
|
+
- id: chat.script.session-log.prepare-chat-session-before-commit
|
|
18
|
+
path: scripts/00.chat/session-log/prepare-chat-session-before-commit/script.sh
|
|
19
|
+
- id: harness.architecture.adr.0017-organize-scripts-by-owner-domain-and-capability
|
|
20
|
+
-->
|
|
21
|
+
# Prepare Chat Session Before Commit
|
|
22
|
+
|
|
23
|
+
`script.sh` is the readiness gate for task commits in a governed chat.
|
|
24
|
+
|
|
25
|
+
It does not create a commit. It checks whether the current chat session has
|
|
26
|
+
enough process context, clean enough staged state, and complete enough session
|
|
27
|
+
metadata for a task commit to proceed.
|
|
28
|
+
|
|
29
|
+
## Mental Model
|
|
30
|
+
|
|
31
|
+
Before a task commit, the harness needs two kinds of confidence:
|
|
32
|
+
|
|
33
|
+
- the Git state is appropriate for committing from this chat worktree
|
|
34
|
+
- the session log has enough context to explain the work after the commit lands
|
|
35
|
+
|
|
36
|
+
This helper coordinates those checks. It is deliberately read-only. If anything
|
|
37
|
+
is missing, it stops before the commit boundary so the human and agent can fix
|
|
38
|
+
the session state rather than writing an incomplete audit trail.
|
|
39
|
+
|
|
40
|
+
## Checks
|
|
41
|
+
|
|
42
|
+
The script runs shared gates first:
|
|
43
|
+
|
|
44
|
+
- write-location check
|
|
45
|
+
- commit prerequisite check
|
|
46
|
+
- commit-log deletion check
|
|
47
|
+
- deterministic process drift check for staged files
|
|
48
|
+
- metadata header check for newly staged artifacts
|
|
49
|
+
- governed script command drift check
|
|
50
|
+
- optional repo-provided commit gate when
|
|
51
|
+
`LLM_WORKBENCH_OPTIONAL_COMMIT_GATE` is set to a repository-relative script
|
|
52
|
+
|
|
53
|
+
Then it validates the current chat session:
|
|
54
|
+
|
|
55
|
+
- current branch must be a `chat/*` branch
|
|
56
|
+
- matching session log must exist
|
|
57
|
+
- `## Initial Intent` must be recorded
|
|
58
|
+
- `## Decisions Made` must have a real entry
|
|
59
|
+
- `## ADR Disposition` must have a real entry
|
|
60
|
+
- `ADR needed` must be `yes` or `no`
|
|
61
|
+
- when `ADR needed: yes`, the ADR path must point to an existing file under
|
|
62
|
+
`docs/harness/architecture/adrs/`
|
|
63
|
+
- when `ADR needed` is `yes` or `no`, the reason must be present
|
|
64
|
+
|
|
65
|
+
## What This Does Not Do
|
|
66
|
+
|
|
67
|
+
- It does not stage files.
|
|
68
|
+
- It does not create the task commit.
|
|
69
|
+
- It does not record the task commit in the session log.
|
|
70
|
+
- It does not checkpoint session-log bookkeeping.
|
|
71
|
+
- It does not decide whether an ADR is needed.
|
|
72
|
+
|
|
73
|
+
## Typical Sequence
|
|
74
|
+
|
|
75
|
+
1. Run this readiness check.
|
|
76
|
+
2. Commit the task changes.
|
|
77
|
+
3. Run `record-chat-commit` with the task commit SHA and summary.
|
|
78
|
+
4. If only the session log is dirty, run `checkpoint-chat-session-log`.
|
|
79
|
+
|
|
80
|
+
## Compatibility
|
|
81
|
+
|
|
82
|
+
The governed runner still approves the old path:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
scripts/00.chat/session-log/prepare-chat-session-before-commit/script.sh
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
That file is now a compatibility wrapper around the canonical implementation.
|
|
89
|
+
Checklists should keep using the approved shared path until the governed runner
|
|
90
|
+
allowlist policy is migrated.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# agentic-artifact:
|
|
5
|
+
# schema: agentic-artifact/v2
|
|
6
|
+
# id: chat.script.session-log.prepare-chat-session-before-commit
|
|
7
|
+
# version: 1
|
|
8
|
+
# status: active
|
|
9
|
+
# layer: 00.chat
|
|
10
|
+
# domain: session-log
|
|
11
|
+
# disciplines:
|
|
12
|
+
# - agentic
|
|
13
|
+
# kind: script
|
|
14
|
+
# purpose: Run commit-boundary gates and session-log readiness checks before task commits.
|
|
15
|
+
# portability:
|
|
16
|
+
# class: required
|
|
17
|
+
# targets:
|
|
18
|
+
# - llm-workbench
|
|
19
|
+
# used_by:
|
|
20
|
+
# - id: chat.script.session-log.prepare-chat-session-before-commit.readme
|
|
21
|
+
# path: scripts/00.chat/session-log/prepare-chat-session-before-commit/README.md
|
|
22
|
+
# effects:
|
|
23
|
+
# - read-only
|
|
24
|
+
|
|
25
|
+
# shellcheck source=../paths/lib.sh
|
|
26
|
+
source "scripts/00.chat/session-log/paths/lib.sh"
|
|
27
|
+
|
|
28
|
+
bash scripts/00.chat/worktree/check-write-location/script.sh
|
|
29
|
+
bash scripts/00.chat/session-log/check-commit-prerequisites/script.sh
|
|
30
|
+
bash scripts/00.chat/session-log/check-commitlog-deletions/script.sh
|
|
31
|
+
bash scripts/01.harness/check-deterministic-process-drift.sh --staged
|
|
32
|
+
bash scripts/01.harness/artifact-metadata/check-headers/script.sh --staged-added
|
|
33
|
+
bash scripts/01.harness/check-governed-script-command-drift.sh
|
|
34
|
+
|
|
35
|
+
OPTIONAL_COMMIT_GATE="${LLM_WORKBENCH_OPTIONAL_COMMIT_GATE:-}"
|
|
36
|
+
|
|
37
|
+
if [ -n "${OPTIONAL_COMMIT_GATE//[[:space:]]/}" ]; then
|
|
38
|
+
case "$OPTIONAL_COMMIT_GATE" in
|
|
39
|
+
/*|../*|*/../*|*/..|..|-*|*$'\n'*|*$'\r'*)
|
|
40
|
+
echo "ERROR: refused non-repository optional commit gate: $OPTIONAL_COMMIT_GATE" >&2
|
|
41
|
+
exit 1
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
|
|
45
|
+
if [ ! -f "$OPTIONAL_COMMIT_GATE" ]; then
|
|
46
|
+
echo "ERROR: optional commit gate does not exist: $OPTIONAL_COMMIT_GATE" >&2
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
bash "$OPTIONAL_COMMIT_GATE"
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
BRANCH="$(git branch --show-current)"
|
|
54
|
+
|
|
55
|
+
if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH")"; then
|
|
56
|
+
echo "ERROR: current branch is not a chat branch: $BRANCH" >&2
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
LOG_FILE="$(chat_log_file_for_session "$SESSION_ID")"
|
|
61
|
+
|
|
62
|
+
if [ ! -f "$LOG_FILE" ]; then
|
|
63
|
+
echo "ERROR: missing chat log: $LOG_FILE" >&2
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
FAILURES=0
|
|
68
|
+
|
|
69
|
+
fail() {
|
|
70
|
+
echo "ERROR: $*" >&2
|
|
71
|
+
FAILURES=$((FAILURES + 1))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
section_has_recorded_entry() {
|
|
75
|
+
local section="$1"
|
|
76
|
+
|
|
77
|
+
awk -v section="$section" '
|
|
78
|
+
$0 == section {
|
|
79
|
+
in_section = 1
|
|
80
|
+
next
|
|
81
|
+
}
|
|
82
|
+
in_section && /^## / {
|
|
83
|
+
exit
|
|
84
|
+
}
|
|
85
|
+
in_section && $0 != "" && $0 != "- None recorded yet." {
|
|
86
|
+
found = 1
|
|
87
|
+
}
|
|
88
|
+
END {
|
|
89
|
+
exit found ? 0 : 1
|
|
90
|
+
}
|
|
91
|
+
' "$LOG_FILE"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
field_value() {
|
|
95
|
+
local label="$1"
|
|
96
|
+
sed -n "s/^${label}: //p" "$LOG_FILE" | tail -n 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
require_section_entry() {
|
|
100
|
+
local section="$1"
|
|
101
|
+
local description="$2"
|
|
102
|
+
|
|
103
|
+
if ! section_has_recorded_entry "$section"; then
|
|
104
|
+
fail "$description is still missing in $LOG_FILE"
|
|
105
|
+
fi
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
require_section_entry "## Initial Intent" "Initial intent"
|
|
109
|
+
require_section_entry "## Decisions Made" "Decisions made summary"
|
|
110
|
+
require_section_entry "## ADR Disposition" "ADR disposition"
|
|
111
|
+
|
|
112
|
+
ADR_NEEDED="$(field_value "ADR needed")"
|
|
113
|
+
ADR_PATH="$(field_value "ADR path")"
|
|
114
|
+
ADR_REASON="$(field_value "Reason")"
|
|
115
|
+
|
|
116
|
+
case "$ADR_NEEDED" in
|
|
117
|
+
yes)
|
|
118
|
+
if [ -z "${ADR_PATH// }" ]; then
|
|
119
|
+
fail "ADR needed is yes, but ADR path is empty"
|
|
120
|
+
elif [[ "$ADR_PATH" != docs/harness/architecture/adrs/*.md ]]; then
|
|
121
|
+
fail "ADR path must be under docs/harness/architecture/adrs/: $ADR_PATH"
|
|
122
|
+
elif [ ! -f "$ADR_PATH" ]; then
|
|
123
|
+
fail "ADR path does not exist: $ADR_PATH"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
if [ -z "${ADR_REASON// }" ]; then
|
|
127
|
+
fail "ADR needed is yes, but reason is empty"
|
|
128
|
+
fi
|
|
129
|
+
;;
|
|
130
|
+
no)
|
|
131
|
+
if [ -z "${ADR_REASON// }" ]; then
|
|
132
|
+
fail "ADR needed is no, but reason is empty"
|
|
133
|
+
fi
|
|
134
|
+
;;
|
|
135
|
+
*)
|
|
136
|
+
fail "ADR needed must be yes or no, got: ${ADR_NEEDED:-missing}"
|
|
137
|
+
;;
|
|
138
|
+
esac
|
|
139
|
+
|
|
140
|
+
if [ "$FAILURES" -gt 0 ]; then
|
|
141
|
+
echo "Chat session is not ready for commit." >&2
|
|
142
|
+
exit 1
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
echo "Chat session is ready for commit: $LOG_FILE"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- agentic-artifact:
|
|
2
|
+
schema: agentic-artifact/v2
|
|
3
|
+
id: chat.script.session-log.read-current-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 reading current chat session metadata.
|
|
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.read-current-chat-log
|
|
20
|
+
path: scripts/00.chat/session-log/read-current-chat-log/script.sh
|
|
21
|
+
-->
|
|
22
|
+
# Read Current Chat Log
|
|
23
|
+
|
|
24
|
+
`script.sh` prints the metadata block from the current chat branch's session
|
|
25
|
+
log.
|
|
26
|
+
|
|
27
|
+
It is useful when a workflow or human needs to inspect the current session id,
|
|
28
|
+
branch, worktree, layer, mode, or workflow without opening the full log.
|
|
29
|
+
|
|
30
|
+
The script requires the current branch to be a `chat/*` branch and the matching
|
|
31
|
+
session log to exist. It is read-only.
|
|
32
|
+
|
|
33
|
+
By default, it refuses to print metadata for a session that already has a
|
|
34
|
+
`latest_commit_sha`. That protects new user conversations from accidentally
|
|
35
|
+
continuing an old chat worktree simply because the process started there.
|
|
36
|
+
|
|
37
|
+
Use:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bash scripts/00.chat/session-log/read-current-chat-log/script.sh --allow-recorded-session
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
only after the user explicitly approves continuing the existing chat session and
|
|
44
|
+
worktree.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# agentic-artifact:
|
|
5
|
+
# schema: agentic-artifact/v2
|
|
6
|
+
# id: chat.script.session-log.read-current-chat-log
|
|
7
|
+
# version: 1
|
|
8
|
+
# status: active
|
|
9
|
+
# layer: 00.chat
|
|
10
|
+
# domain: session-log
|
|
11
|
+
# disciplines:
|
|
12
|
+
# - agentic
|
|
13
|
+
# kind: script
|
|
14
|
+
# purpose: Print current chat session metadata from the active chat branch log.
|
|
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: chat.script.session-log.check-commit-prerequisites.smoke-test
|
|
23
|
+
# path: scripts/00.chat/session-log/check-commit-prerequisites/smoke-test.sh
|
|
24
|
+
# effects:
|
|
25
|
+
# - read-only
|
|
26
|
+
|
|
27
|
+
# shellcheck source=../paths/lib.sh
|
|
28
|
+
source "scripts/00.chat/session-log/paths/lib.sh"
|
|
29
|
+
|
|
30
|
+
ALLOW_RECORDED_SESSION="no"
|
|
31
|
+
|
|
32
|
+
usage() {
|
|
33
|
+
cat <<'EOF'
|
|
34
|
+
Usage:
|
|
35
|
+
read-current-chat-log/script.sh [--allow-recorded-session]
|
|
36
|
+
|
|
37
|
+
Prints current chat session metadata.
|
|
38
|
+
|
|
39
|
+
By default, refuses to reuse a chat session that already has recorded commits.
|
|
40
|
+
Use --allow-recorded-session only after the user explicitly approves continuing
|
|
41
|
+
the existing chat session and worktree.
|
|
42
|
+
EOF
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
while [ $# -gt 0 ]; do
|
|
46
|
+
case "$1" in
|
|
47
|
+
--allow-recorded-session)
|
|
48
|
+
ALLOW_RECORDED_SESSION="yes"
|
|
49
|
+
shift
|
|
50
|
+
;;
|
|
51
|
+
-h|--help)
|
|
52
|
+
usage
|
|
53
|
+
exit 0
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo "ERROR: unknown argument: $1" >&2
|
|
57
|
+
usage >&2
|
|
58
|
+
exit 2
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
BRANCH="$(git branch --show-current)"
|
|
64
|
+
|
|
65
|
+
if ! SESSION_ID="$(chat_session_id_from_branch "$BRANCH")"; then
|
|
66
|
+
echo "ERROR: current branch is not a chat branch: $BRANCH"
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
LOG_FILE="$(chat_log_file_for_session "$SESSION_ID")"
|
|
71
|
+
|
|
72
|
+
if [ ! -f "$LOG_FILE" ]; then
|
|
73
|
+
echo "ERROR: missing chat log: $LOG_FILE"
|
|
74
|
+
exit 1
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
METADATA="$(sed -n '/<!-- agentic-session/,/-->/p' "$LOG_FILE" \
|
|
78
|
+
| sed '/<!-- agentic-session/d;/-->/d')"
|
|
79
|
+
|
|
80
|
+
LATEST_COMMIT_SHA="$(printf '%s\n' "$METADATA" | sed -n 's/^latest_commit_sha: //p' | head -n 1)"
|
|
81
|
+
|
|
82
|
+
if [ -n "${LATEST_COMMIT_SHA// }" ] && [ "$ALLOW_RECORDED_SESSION" != "yes" ]; then
|
|
83
|
+
echo "ERROR: recorded-session-approval-required"
|
|
84
|
+
echo "Session: $SESSION_ID"
|
|
85
|
+
echo "Branch: $BRANCH"
|
|
86
|
+
echo "Log: $LOG_FILE"
|
|
87
|
+
echo "Latest commit: $LATEST_COMMIT_SHA"
|
|
88
|
+
echo "Required action: Ask the user to approve continuing this existing chat/worktree, or start a new chat."
|
|
89
|
+
exit 3
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
printf '%s\n' "$METADATA"
|