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,130 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# agentic-artifact:
|
|
5
|
+
# schema: agentic-artifact/v2
|
|
6
|
+
# id: chat.script.startup.resolve-current-chat-session.smoke-test
|
|
7
|
+
# version: 1
|
|
8
|
+
# status: active
|
|
9
|
+
# layer: 00.chat
|
|
10
|
+
# domain: startup
|
|
11
|
+
# disciplines:
|
|
12
|
+
# - agentic
|
|
13
|
+
# kind: script
|
|
14
|
+
# purpose: Smoke test startup resolution for missing and existing chat sessions.
|
|
15
|
+
# portability:
|
|
16
|
+
# class: reusable
|
|
17
|
+
# targets:
|
|
18
|
+
# - llm-workbench
|
|
19
|
+
# used_by:
|
|
20
|
+
# - id: chat.script.startup.resolve-current-chat-session.readme
|
|
21
|
+
# path: scripts/00.chat/startup/resolve-current-chat-session/README.md
|
|
22
|
+
# effects:
|
|
23
|
+
# - writes-files
|
|
24
|
+
# - branches
|
|
25
|
+
# - worktrees
|
|
26
|
+
# - commits
|
|
27
|
+
|
|
28
|
+
fail() {
|
|
29
|
+
echo "FAIL: $*" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
SOURCE_ROOT="$(git rev-parse --show-toplevel)"
|
|
34
|
+
TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/resolve-current-chat-session-smoke.XXXXXX")"
|
|
35
|
+
|
|
36
|
+
cleanup() {
|
|
37
|
+
rm -rf "$TMP_ROOT"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
trap cleanup EXIT
|
|
41
|
+
|
|
42
|
+
REPO="$TMP_ROOT/repo"
|
|
43
|
+
mkdir -p "$REPO"
|
|
44
|
+
git -C "$REPO" init --quiet --initial-branch=main
|
|
45
|
+
|
|
46
|
+
mkdir -p \
|
|
47
|
+
"$REPO/scripts/00.chat/command/dispatcher" \
|
|
48
|
+
"$REPO/scripts/00.chat/command/new" \
|
|
49
|
+
"$REPO/scripts/00.chat/git/cleanup-empty-chat-branches" \
|
|
50
|
+
"$REPO/scripts/00.chat/session-log/paths" \
|
|
51
|
+
"$REPO/scripts/00.chat/session-log/read-current-chat-log" \
|
|
52
|
+
"$REPO/scripts/00.chat/startup/auto-start-missing-session" \
|
|
53
|
+
"$REPO/scripts/00.chat/startup/resolve-current-chat-session" \
|
|
54
|
+
"$REPO/scripts/00.chat/startup/start-chat-session" \
|
|
55
|
+
"$REPO/scripts/00.chat/startup/start-new-chat" \
|
|
56
|
+
"$REPO/scripts/00.chat/worktree/ensure-chat-worktree" \
|
|
57
|
+
"$REPO/scripts/00.chat/worktree/open-window" \
|
|
58
|
+
"$REPO/scripts/00.chat/worktree/paths"
|
|
59
|
+
|
|
60
|
+
cp "$SOURCE_ROOT/scripts/00.chat/session-log/paths/lib.sh" "$REPO/scripts/00.chat/session-log/paths/lib.sh"
|
|
61
|
+
cp "$SOURCE_ROOT/scripts/00.chat/worktree/paths/lib.sh" "$REPO/scripts/00.chat/worktree/paths/lib.sh"
|
|
62
|
+
cp "$SOURCE_ROOT/scripts/00.chat/session-log/read-current-chat-log/script.sh" "$REPO/scripts/00.chat/session-log/read-current-chat-log/script.sh"
|
|
63
|
+
cp "$SOURCE_ROOT/scripts/00.chat/startup/resolve-current-chat-session/script.sh" "$REPO/scripts/00.chat/startup/resolve-current-chat-session/script.sh"
|
|
64
|
+
cp "$SOURCE_ROOT/scripts/00.chat/startup/auto-start-missing-session/script.sh" "$REPO/scripts/00.chat/startup/auto-start-missing-session/script.sh"
|
|
65
|
+
cp "$SOURCE_ROOT/scripts/00.chat/command/dispatcher/script.sh" "$REPO/scripts/00.chat/command/dispatcher/script.sh"
|
|
66
|
+
cp "$SOURCE_ROOT/scripts/00.chat/command/new/script.sh" "$REPO/scripts/00.chat/command/new/script.sh"
|
|
67
|
+
cp "$SOURCE_ROOT/scripts/00.chat/startup/start-new-chat/script.sh" "$REPO/scripts/00.chat/startup/start-new-chat/script.sh"
|
|
68
|
+
cp "$SOURCE_ROOT/scripts/00.chat/startup/start-chat-session/script.sh" "$REPO/scripts/00.chat/startup/start-chat-session/script.sh"
|
|
69
|
+
cp "$SOURCE_ROOT/scripts/00.chat/worktree/ensure-chat-worktree/script.sh" "$REPO/scripts/00.chat/worktree/ensure-chat-worktree/script.sh"
|
|
70
|
+
cp "$SOURCE_ROOT/scripts/00.chat/worktree/open-window/script.sh" "$REPO/scripts/00.chat/worktree/open-window/script.sh"
|
|
71
|
+
cp "$SOURCE_ROOT/scripts/00.chat/git/cleanup-empty-chat-branches/script.sh" "$REPO/scripts/00.chat/git/cleanup-empty-chat-branches/script.sh"
|
|
72
|
+
chmod +x \
|
|
73
|
+
"$REPO/scripts/00.chat/session-log/read-current-chat-log/script.sh" \
|
|
74
|
+
"$REPO/scripts/00.chat/startup/resolve-current-chat-session/script.sh" \
|
|
75
|
+
"$REPO/scripts/00.chat/startup/auto-start-missing-session/script.sh" \
|
|
76
|
+
"$REPO/scripts/00.chat/command/dispatcher/script.sh" \
|
|
77
|
+
"$REPO/scripts/00.chat/command/new/script.sh" \
|
|
78
|
+
"$REPO/scripts/00.chat/startup/start-new-chat/script.sh" \
|
|
79
|
+
"$REPO/scripts/00.chat/startup/start-chat-session/script.sh" \
|
|
80
|
+
"$REPO/scripts/00.chat/worktree/ensure-chat-worktree/script.sh" \
|
|
81
|
+
"$REPO/scripts/00.chat/worktree/open-window/script.sh" \
|
|
82
|
+
"$REPO/scripts/00.chat/git/cleanup-empty-chat-branches/script.sh"
|
|
83
|
+
|
|
84
|
+
printf 'base\n' > "$REPO/README.md"
|
|
85
|
+
git -C "$REPO" add README.md scripts
|
|
86
|
+
git -C "$REPO" -c user.name='Smoke Test' -c user.email='smoke@example.invalid' commit --quiet -m 'base'
|
|
87
|
+
|
|
88
|
+
AGENTIC_CHAT_WORKTREE_ROOT="$TMP_ROOT/worktrees" \
|
|
89
|
+
CHAT_CLEANUP_EMPTY_BRANCHES=skip \
|
|
90
|
+
CHAT_COPY_PROMPT=skip \
|
|
91
|
+
CHAT_OPEN_WORKTREE_WINDOW=skip \
|
|
92
|
+
bash -c 'cd "$1" && shift && "$@"' sh "$REPO" \
|
|
93
|
+
bash scripts/00.chat/startup/resolve-current-chat-session/script.sh "use the existing chat start process" \
|
|
94
|
+
>"$TMP_ROOT/resolve-missing.out"
|
|
95
|
+
|
|
96
|
+
grep -q 'Created branch: chat/' "$TMP_ROOT/resolve-missing.out" \
|
|
97
|
+
|| fail "resolver did not auto-start a missing root-main session"
|
|
98
|
+
grep -q 'Task: use the existing chat start process' "$TMP_ROOT/resolve-missing.out" \
|
|
99
|
+
|| fail "resolver did not pass the opening prompt to auto-start"
|
|
100
|
+
|
|
101
|
+
chat_branch="$(git -C "$REPO" branch --format='%(refname:short)' | grep '^chat/' | head -n 1)"
|
|
102
|
+
worktree_path="$(
|
|
103
|
+
git -C "$REPO" worktree list --porcelain \
|
|
104
|
+
| awk -v branch="refs/heads/${chat_branch}" '
|
|
105
|
+
/^worktree / { path = substr($0, 10) }
|
|
106
|
+
/^branch / && substr($0, 8) == branch { print path }
|
|
107
|
+
'
|
|
108
|
+
)"
|
|
109
|
+
|
|
110
|
+
if [ -z "$worktree_path" ]; then
|
|
111
|
+
fail "resolver-created chat branch did not have a worktree"
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
branch_count_before="$(git -C "$REPO" branch --format='%(refname:short)' | grep -c '^chat/')"
|
|
115
|
+
|
|
116
|
+
bash -c 'cd "$1" && shift && "$@"' sh "$worktree_path" \
|
|
117
|
+
bash scripts/00.chat/startup/resolve-current-chat-session/script.sh "ignored because metadata exists" \
|
|
118
|
+
>"$TMP_ROOT/resolve-existing.out"
|
|
119
|
+
|
|
120
|
+
grep -q '^task: use the existing chat start process$' "$TMP_ROOT/resolve-existing.out" \
|
|
121
|
+
|| fail "resolver did not return existing session metadata"
|
|
122
|
+
grep -q '^chat_lifecycle_workflow: .agentic/00.chat/workflows/chat-start.md$' "$TMP_ROOT/resolve-existing.out" \
|
|
123
|
+
|| fail "resolver existing-session metadata did not include chat lifecycle workflow"
|
|
124
|
+
|
|
125
|
+
branch_count_after="$(git -C "$REPO" branch --format='%(refname:short)' | grep -c '^chat/')"
|
|
126
|
+
if [ "$branch_count_after" != "$branch_count_before" ]; then
|
|
127
|
+
fail "resolver created another chat branch despite existing metadata"
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
echo "resolve current chat session smoke test passed."
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<!-- agentic-artifact:
|
|
2
|
+
schema: agentic-artifact/v2
|
|
3
|
+
id: chat.script.startup.start-chat-session.readme
|
|
4
|
+
version: 1
|
|
5
|
+
status: active
|
|
6
|
+
layer: 00.chat
|
|
7
|
+
domain: startup
|
|
8
|
+
disciplines:
|
|
9
|
+
- agentic
|
|
10
|
+
kind: capability-readme
|
|
11
|
+
purpose: Explain how the chat session startup engine creates branches, logs, prompts,
|
|
12
|
+
and worktrees.
|
|
13
|
+
portability:
|
|
14
|
+
class: required
|
|
15
|
+
targets:
|
|
16
|
+
- llm-workbench
|
|
17
|
+
used_by:
|
|
18
|
+
- id: chat.script.startup.start-chat-session
|
|
19
|
+
path: scripts/00.chat/startup/start-chat-session/script.sh
|
|
20
|
+
- id: harness.architecture.adr.0017-organize-scripts-by-owner-domain-and-capability
|
|
21
|
+
-->
|
|
22
|
+
# Start Chat Session
|
|
23
|
+
|
|
24
|
+
`script.sh` is the chat startup engine. It turns a short task summary into the
|
|
25
|
+
working environment for one governed agent conversation: a `chat/*` branch, a
|
|
26
|
+
chat-owned worktree, a session log, and a first prompt for the next agent.
|
|
27
|
+
|
|
28
|
+
The important idea is that a chat is treated as a small, auditable unit of work.
|
|
29
|
+
Startup does the bookkeeping before the agent begins editing so the work has a
|
|
30
|
+
known branch, location, lifecycle workflow, and history from the first turn.
|
|
31
|
+
|
|
32
|
+
## Mental Model
|
|
33
|
+
|
|
34
|
+
The root worktree is the integration console. It is where finished chat work can
|
|
35
|
+
be reviewed, merged, and coordinated.
|
|
36
|
+
|
|
37
|
+
Each chat gets its own branch and sibling worktree. That keeps task edits away
|
|
38
|
+
from the integration console and away from other active chats. If several chats
|
|
39
|
+
are open at once, each one has a physical directory and branch that belong to
|
|
40
|
+
that conversation.
|
|
41
|
+
|
|
42
|
+
The session log is the chat's durable memory. It records the task, branch,
|
|
43
|
+
worktree, lifecycle workflow, latest context-packet references, commits,
|
|
44
|
+
unresolved questions, decisions, conflicts, and metrics. The harness uses that
|
|
45
|
+
file as the first source of truth when a chat resumes.
|
|
46
|
+
|
|
47
|
+
The first prompt is the handoff packet. It tells the next agent the exact branch,
|
|
48
|
+
worktree, chat lifecycle workflow, context-packet continuity fields, and
|
|
49
|
+
dirty-state handling rule. It also makes
|
|
50
|
+
the startup boundary explicit: branch, worktree, and session-log bootstrap has
|
|
51
|
+
already happened, while task edits remain read-only until the user grants write
|
|
52
|
+
permission. That prevents a new agent from guessing where it should work or
|
|
53
|
+
which chat lifecycle workflow governs the conversation. Prompt-level layer,
|
|
54
|
+
mode, workflow, and corpus routing uses the current request, repo assistant
|
|
55
|
+
instructions, and any repo-provided context router if one exists, not durable
|
|
56
|
+
chat startup metadata.
|
|
57
|
+
|
|
58
|
+
## Inputs
|
|
59
|
+
|
|
60
|
+
- Task summary: the human description of the work. It can be passed as command
|
|
61
|
+
arguments, or entered interactively when the script prompts for it.
|
|
62
|
+
- `.agentic/env.local`: optional local environment values for this checkout.
|
|
63
|
+
- `CHAT_COPY_PROMPT`: controls terminal first-prompt handoff. The default is
|
|
64
|
+
`copy`, which tries the clipboard first and prints the prompt as a fallback.
|
|
65
|
+
Use `skip` to print only.
|
|
66
|
+
- `CHAT_CLEANUP_EMPTY_BRANCHES`: controls startup cleanup. The default is
|
|
67
|
+
`apply`, which removes empty abandoned chat branches through the governed
|
|
68
|
+
cleanup script. Use `dry-run` to inspect only, or `skip` when startup should
|
|
69
|
+
not clean empty chat branches.
|
|
70
|
+
|
|
71
|
+
## Terminal Handoff And IDE Integrations
|
|
72
|
+
|
|
73
|
+
The startup script always builds a first prompt. That prompt is a portable
|
|
74
|
+
session packet for terminal-based startup: it contains the task, session log,
|
|
75
|
+
chat worktree, chat lifecycle workflow, latest context-packet continuity fields,
|
|
76
|
+
and dirty-worktree stop response.
|
|
77
|
+
|
|
78
|
+
`CHAT_COPY_PROMPT` only controls how that terminal packet is handed to a human:
|
|
79
|
+
copy it to the clipboard, or print it in the terminal. It is a terminal
|
|
80
|
+
convenience, not the startup contract.
|
|
81
|
+
|
|
82
|
+
IDE extensions and app integrations should not depend on clipboard behavior.
|
|
83
|
+
They should use the startup data directly:
|
|
84
|
+
|
|
85
|
+
- task summary
|
|
86
|
+
- session log path
|
|
87
|
+
- chat worktree path
|
|
88
|
+
- chat lifecycle workflow
|
|
89
|
+
- latest context packet id
|
|
90
|
+
- latest context packet routing summary
|
|
91
|
+
- starting worktree status
|
|
92
|
+
|
|
93
|
+
That keeps the durable startup model the same while allowing different surfaces
|
|
94
|
+
to present or pass the session packet in their own way.
|
|
95
|
+
|
|
96
|
+
## Flow
|
|
97
|
+
|
|
98
|
+
1. Validate the task summary.
|
|
99
|
+
|
|
100
|
+
Startup rejects an empty task or the placeholder `new chat` because the
|
|
101
|
+
summary becomes the session identity. A useful summary makes the branch,
|
|
102
|
+
folder, and log readable later.
|
|
103
|
+
|
|
104
|
+
2. Create the session id and branch name.
|
|
105
|
+
|
|
106
|
+
The script combines a timestamp with a slug from the task summary. That gives
|
|
107
|
+
each chat a stable id and creates a branch name like
|
|
108
|
+
`chat/2026-06-19-20-27-move-chat-session-startup-engine`.
|
|
109
|
+
|
|
110
|
+
3. Record chat lifecycle metadata.
|
|
111
|
+
|
|
112
|
+
Startup records the chat lifecycle workflow and initializes latest
|
|
113
|
+
context-packet fields. It does not classify the whole chat into a task layer,
|
|
114
|
+
mode, or workflow. The consuming agent should use the current request, repo
|
|
115
|
+
assistant instructions, and any repo-provided context router for prompt-level
|
|
116
|
+
routing context.
|
|
117
|
+
|
|
118
|
+
4. Capture the starting worktree state.
|
|
119
|
+
|
|
120
|
+
Startup records whether the current worktree was clean or dirty. If it was
|
|
121
|
+
dirty, the first prompt tells the next agent to stop and ask for confirmation
|
|
122
|
+
before doing more discovery. That protects existing uncommitted work.
|
|
123
|
+
|
|
124
|
+
5. Create the branch and chat-owned worktree.
|
|
125
|
+
|
|
126
|
+
The branch starts from `main` when available. If `main` does not exist, the
|
|
127
|
+
script falls back to the current branch so the harness can still bootstrap in
|
|
128
|
+
a new or unusual repo. The sibling worktree is where the chat should edit
|
|
129
|
+
files.
|
|
130
|
+
|
|
131
|
+
6. Write the session log.
|
|
132
|
+
|
|
133
|
+
The log is created at
|
|
134
|
+
`commitLogs/<year>/<month>/<day>/<session>/README.md` inside the new
|
|
135
|
+
worktree. It starts with machine-readable session metadata and human-readable
|
|
136
|
+
sections for activity, decisions, issues, commits, conflicts, and metrics.
|
|
137
|
+
|
|
138
|
+
7. Offer a chat worktree window.
|
|
139
|
+
|
|
140
|
+
Startup does not open a VS Code window by default. Set
|
|
141
|
+
`CHAT_OPEN_WORKTREE_WINDOW=open` to opt into opening the new chat worktree.
|
|
142
|
+
The explicit `chat:open-window` command remains available after startup.
|
|
143
|
+
|
|
144
|
+
8. Print or copy the first prompt for terminal use.
|
|
145
|
+
|
|
146
|
+
The prompt is the bridge from startup automation into the next agent turn. It
|
|
147
|
+
names the task, session log, worktree, chat lifecycle workflow, context-packet
|
|
148
|
+
continuity fields, startup bootstrap boundary, and the dirty-worktree stop
|
|
149
|
+
response. Terminal startup can copy or print it. IDE and app integrations
|
|
150
|
+
should treat those fields as structured startup data rather than depending on
|
|
151
|
+
clipboard behavior.
|
|
152
|
+
|
|
153
|
+
9. Clean empty chat branches.
|
|
154
|
+
|
|
155
|
+
Startup can run the empty-chat-branch cleanup script after creating the new
|
|
156
|
+
session. This keeps abandoned zero-commit chat branches from accumulating
|
|
157
|
+
while still routing cleanup through a governed script.
|
|
158
|
+
|
|
159
|
+
10. Stage the session log in the chat worktree.
|
|
160
|
+
|
|
161
|
+
The log is staged so the first real task commit can include the session
|
|
162
|
+
record if appropriate. The root worktree is left alone.
|
|
163
|
+
|
|
164
|
+
## What This Does Not Do
|
|
165
|
+
|
|
166
|
+
- It does not push anything.
|
|
167
|
+
- It does not merge the chat branch.
|
|
168
|
+
- It does not grant task write permission to the agent.
|
|
169
|
+
- It does not decide that dirty root work is safe to ignore.
|
|
170
|
+
- It does not classify the whole chat into one task layer, mode, or workflow.
|
|
171
|
+
- It does not replace prompt-level routing from assistant instructions or a
|
|
172
|
+
repo-provided context router.
|
|
173
|
+
|
|
174
|
+
## Typical Result
|
|
175
|
+
|
|
176
|
+
After a successful run, expect:
|
|
177
|
+
|
|
178
|
+
- a new `chat/*` branch
|
|
179
|
+
- a sibling chat worktree
|
|
180
|
+
- a staged session log inside that worktree
|
|
181
|
+
- a first prompt printed or copied for the next agent
|
|
182
|
+
- no VS Code window unless `CHAT_OPEN_WORKTREE_WINDOW=open` is set
|
|
183
|
+
- the original root worktree still on its original branch
|
|
184
|
+
|
|
185
|
+
## Smoke Test
|
|
186
|
+
|
|
187
|
+
`smoke-test.sh` creates a throwaway Git repo and runs startup there. It verifies
|
|
188
|
+
that startup leaves the root repo on `main`, creates a separate chat worktree,
|
|
189
|
+
stages the session log in that chat worktree, records chat lifecycle metadata,
|
|
190
|
+
skips opening a VS Code window by default, and falls back to printed terminal
|
|
191
|
+
handoff when clipboard copy fails.
|
|
192
|
+
|
|
193
|
+
## Compatibility
|
|
194
|
+
|
|
195
|
+
The old request-initialization entrypoint
|
|
196
|
+
`scripts/shared/chat/request-initialization/start-chat-session.sh` was retired
|
|
197
|
+
after smoke fixtures and downstream references moved to this canonical script.
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# agentic-artifact:
|
|
5
|
+
# schema: agentic-artifact/v2
|
|
6
|
+
# id: chat.script.startup.start-chat-session
|
|
7
|
+
# version: 1
|
|
8
|
+
# status: active
|
|
9
|
+
# layer: 00.chat
|
|
10
|
+
# domain: startup
|
|
11
|
+
# disciplines:
|
|
12
|
+
# - agentic
|
|
13
|
+
# kind: script
|
|
14
|
+
# purpose: Create chat branch, session log, prompt, and chat-owned worktree.
|
|
15
|
+
# portability:
|
|
16
|
+
# class: required
|
|
17
|
+
# targets:
|
|
18
|
+
# - llm-workbench
|
|
19
|
+
# used_by:
|
|
20
|
+
# - id: chat.script.startup.start-new-chat
|
|
21
|
+
# path: scripts/00.chat/startup/start-new-chat/script.sh
|
|
22
|
+
# - id: chat.workflows.chat-start
|
|
23
|
+
# path: .agentic/00.chat/workflows/chat-start.md
|
|
24
|
+
# effects:
|
|
25
|
+
# - branches
|
|
26
|
+
# - worktrees
|
|
27
|
+
# - writes-files
|
|
28
|
+
# - stages-files
|
|
29
|
+
AGENTIC_ENV_FILE=".agentic/env.local"
|
|
30
|
+
|
|
31
|
+
# shellcheck source=../../session-log/paths/lib.sh
|
|
32
|
+
source "scripts/00.chat/session-log/paths/lib.sh"
|
|
33
|
+
# shellcheck source=../../worktree/paths/lib.sh
|
|
34
|
+
source "scripts/00.chat/worktree/paths/lib.sh"
|
|
35
|
+
|
|
36
|
+
CHAT_CLEANUP_EMPTY_BRANCHES_WAS_SET="no"
|
|
37
|
+
CHAT_CLEANUP_EMPTY_BRANCHES_SHELL_VALUE="${CHAT_CLEANUP_EMPTY_BRANCHES:-}"
|
|
38
|
+
|
|
39
|
+
if [ "${CHAT_CLEANUP_EMPTY_BRANCHES+x}" = "x" ]; then
|
|
40
|
+
CHAT_CLEANUP_EMPTY_BRANCHES_WAS_SET="yes"
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
if [ -f "$AGENTIC_ENV_FILE" ]; then
|
|
44
|
+
set -a
|
|
45
|
+
# shellcheck disable=SC1090
|
|
46
|
+
source "$AGENTIC_ENV_FILE"
|
|
47
|
+
set +a
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if [ "$CHAT_CLEANUP_EMPTY_BRANCHES_WAS_SET" = "yes" ]; then
|
|
51
|
+
CHAT_CLEANUP_EMPTY_BRANCHES="$CHAT_CLEANUP_EMPTY_BRANCHES_SHELL_VALUE"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
OUTPUT_FORMAT="text"
|
|
55
|
+
|
|
56
|
+
case "${1:-}" in
|
|
57
|
+
--json)
|
|
58
|
+
OUTPUT_FORMAT="json"
|
|
59
|
+
shift
|
|
60
|
+
;;
|
|
61
|
+
esac
|
|
62
|
+
|
|
63
|
+
if [ $# -gt 0 ]; then
|
|
64
|
+
QUESTION="$*"
|
|
65
|
+
else
|
|
66
|
+
read -r -p "Short task summary: " QUESTION
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
if [ -z "${QUESTION// }" ] || [ "$QUESTION" = "new chat" ]; then
|
|
70
|
+
echo "ERROR: Provide a meaningful task summary."
|
|
71
|
+
echo "Example: add tenant auth guard"
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
STAMP="$(date +"%Y-%m-%d-%H-%M")"
|
|
76
|
+
RAISED_AT_UTC="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
77
|
+
|
|
78
|
+
SLUG="$(echo "$QUESTION" \
|
|
79
|
+
| tr '[:upper:]' '[:lower:]' \
|
|
80
|
+
| sed -E 's/[^a-z0-9]+/-/g' \
|
|
81
|
+
| sed -E 's/^-+|-+$//g' \
|
|
82
|
+
| cut -c1-60)"
|
|
83
|
+
|
|
84
|
+
BRANCH="chat/${STAMP}-${SLUG}"
|
|
85
|
+
LOG_DIR="$(chat_log_grouped_dir_for_session "${STAMP}-${SLUG}")"
|
|
86
|
+
LOG_FILE="${LOG_DIR}/README.md"
|
|
87
|
+
REPO_ROOT="$(chat_worktree_repo_root)"
|
|
88
|
+
WORKTREE_PATH="$(chat_worktree_path_for_branch "$REPO_ROOT" "$BRANCH")"
|
|
89
|
+
BASE_BRANCH="main"
|
|
90
|
+
CHAT_LIFECYCLE_WORKFLOW=".agentic/00.chat/workflows/chat-start.md"
|
|
91
|
+
|
|
92
|
+
if ! git show-ref --verify --quiet "refs/heads/${BASE_BRANCH}"; then
|
|
93
|
+
BASE_BRANCH="$(git branch --show-current)"
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
if [ -z "${BASE_BRANCH// }" ]; then
|
|
97
|
+
echo "ERROR: could not determine a base branch for the chat branch." >&2
|
|
98
|
+
exit 1
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
if [ -n "$(git status --porcelain)" ]; then
|
|
102
|
+
WORKTREE_STATUS="dirty"
|
|
103
|
+
else
|
|
104
|
+
WORKTREE_STATUS="clean"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
if [ "$OUTPUT_FORMAT" = "text" ]; then
|
|
108
|
+
git status --short
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
git branch "$BRANCH" "$BASE_BRANCH"
|
|
112
|
+
mkdir -p "${WORKTREE_PATH%/*}"
|
|
113
|
+
git worktree add --quiet "$WORKTREE_PATH" "$BRANCH"
|
|
114
|
+
|
|
115
|
+
mkdir -p "$WORKTREE_PATH/$LOG_DIR"
|
|
116
|
+
|
|
117
|
+
cat > "$WORKTREE_PATH/$LOG_FILE" <<EOF
|
|
118
|
+
# Chat Session: ${STAMP} ${SLUG}
|
|
119
|
+
|
|
120
|
+
<!-- agentic-session
|
|
121
|
+
id: ${STAMP}-${SLUG}
|
|
122
|
+
task: ${QUESTION}
|
|
123
|
+
branch: ${BRANCH}
|
|
124
|
+
worktree: ${WORKTREE_PATH}
|
|
125
|
+
chat_lifecycle_workflow: ${CHAT_LIFECYCLE_WORKFLOW}
|
|
126
|
+
status: ready
|
|
127
|
+
raised_at_utc: ${RAISED_AT_UTC}
|
|
128
|
+
transcript_provider:
|
|
129
|
+
transcript_path:
|
|
130
|
+
transcript_bytes:
|
|
131
|
+
transcript_source:
|
|
132
|
+
latest_context_packet_id:
|
|
133
|
+
latest_context_packet_routing_summary:
|
|
134
|
+
latest_context_packet_at_utc:
|
|
135
|
+
latest_commit_at_utc:
|
|
136
|
+
latest_commit_sha:
|
|
137
|
+
chat_duration:
|
|
138
|
+
estimated_chat_tokens:
|
|
139
|
+
estimated_chat_cost:
|
|
140
|
+
estimated_chat_cost_basis:
|
|
141
|
+
-->
|
|
142
|
+
|
|
143
|
+
## Initial Intent
|
|
144
|
+
|
|
145
|
+
${QUESTION}
|
|
146
|
+
|
|
147
|
+
## Session Log
|
|
148
|
+
|
|
149
|
+
- Session started.
|
|
150
|
+
- Branch created.
|
|
151
|
+
- Chat-owned worktree created.
|
|
152
|
+
- Commit log initialized.
|
|
153
|
+
|
|
154
|
+
## Questions Asked
|
|
155
|
+
|
|
156
|
+
- None recorded yet.
|
|
157
|
+
|
|
158
|
+
## Issues Raised
|
|
159
|
+
|
|
160
|
+
- None recorded yet.
|
|
161
|
+
|
|
162
|
+
## Decisions Made
|
|
163
|
+
|
|
164
|
+
- None recorded yet.
|
|
165
|
+
|
|
166
|
+
## Activity Log
|
|
167
|
+
|
|
168
|
+
### ${RAISED_AT_UTC} - Session started
|
|
169
|
+
|
|
170
|
+
Initial intent: ${QUESTION}
|
|
171
|
+
|
|
172
|
+
## Commits
|
|
173
|
+
|
|
174
|
+
- None recorded yet.
|
|
175
|
+
|
|
176
|
+
## Main Refresh Conflicts
|
|
177
|
+
|
|
178
|
+
- None recorded yet.
|
|
179
|
+
|
|
180
|
+
## ADR Disposition
|
|
181
|
+
|
|
182
|
+
ADR needed: unknown
|
|
183
|
+
ADR path:
|
|
184
|
+
Reason:
|
|
185
|
+
|
|
186
|
+
## Session Metrics
|
|
187
|
+
|
|
188
|
+
Raised at UTC: ${RAISED_AT_UTC}
|
|
189
|
+
Latest commit at UTC:
|
|
190
|
+
Latest commit SHA:
|
|
191
|
+
Chat duration:
|
|
192
|
+
Estimated chat tokens:
|
|
193
|
+
Estimated chat cost:
|
|
194
|
+
Estimated chat cost basis:
|
|
195
|
+
|
|
196
|
+
## Notes
|
|
197
|
+
|
|
198
|
+
- None recorded yet.
|
|
199
|
+
EOF
|
|
200
|
+
|
|
201
|
+
if [ "$OUTPUT_FORMAT" = "text" ]; then
|
|
202
|
+
echo "Created branch: $BRANCH"
|
|
203
|
+
echo "Created log: $LOG_FILE"
|
|
204
|
+
echo "Created worktree: $WORKTREE_PATH"
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
if [ "$OUTPUT_FORMAT" = "text" ]; then
|
|
208
|
+
CHAT_OPEN_WORKTREE_WINDOW="${CHAT_OPEN_WORKTREE_WINDOW:-skip}" \
|
|
209
|
+
bash scripts/00.chat/worktree/open-window/script.sh "$WORKTREE_PATH"
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
FIRST_PROMPT="Task: ${QUESTION}
|
|
213
|
+
Session log: ${LOG_FILE}
|
|
214
|
+
Chat worktree: ${WORKTREE_PATH}
|
|
215
|
+
Chat lifecycle workflow: ${CHAT_LIFECYCLE_WORKFLOW}
|
|
216
|
+
Latest context packet id:
|
|
217
|
+
Latest context packet routing summary:
|
|
218
|
+
Bootstrap worktree status: ${WORKTREE_STATUS}
|
|
219
|
+
|
|
220
|
+
If Bootstrap worktree status is dirty, reply exactly:
|
|
221
|
+
Blocked: dirty worktree. Confirm proceed?
|
|
222
|
+
|
|
223
|
+
Before that response, do not read workflows or run git status/dirty checks.
|
|
224
|
+
|
|
225
|
+
Governed startup bootstrap has already created this chat branch, worktree, and session log.
|
|
226
|
+
Default mode after startup bootstrap: read-only until I grant write permission in this chat.
|
|
227
|
+
For task writes or commit-boundary work, use the chat worktree above and follow the current workflow gates.
|
|
228
|
+
For prompt-level routing, use the current user request, this repo's assistant instructions, and any repo-provided context router if one exists. Do not assign the whole chat a durable layer, mode, or workflow.
|
|
229
|
+
Do not commit without my explicit approval."
|
|
230
|
+
|
|
231
|
+
emit_json_packet() {
|
|
232
|
+
node - \
|
|
233
|
+
"$QUESTION" \
|
|
234
|
+
"$LOG_FILE" \
|
|
235
|
+
"$WORKTREE_PATH" \
|
|
236
|
+
"$CHAT_LIFECYCLE_WORKFLOW" \
|
|
237
|
+
"$WORKTREE_STATUS" \
|
|
238
|
+
"$FIRST_PROMPT" <<'NODE'
|
|
239
|
+
const [
|
|
240
|
+
task,
|
|
241
|
+
sessionLog,
|
|
242
|
+
chatWorktree,
|
|
243
|
+
chatLifecycleWorkflow,
|
|
244
|
+
bootstrapWorktreeStatus,
|
|
245
|
+
firstPrompt
|
|
246
|
+
] = process.argv.slice(2);
|
|
247
|
+
|
|
248
|
+
const packet = {
|
|
249
|
+
schema: 'llm-workbench/startup-packet/v1',
|
|
250
|
+
task,
|
|
251
|
+
session_log: sessionLog,
|
|
252
|
+
chat_worktree: chatWorktree,
|
|
253
|
+
chat_lifecycle_workflow: chatLifecycleWorkflow,
|
|
254
|
+
latest_context_packet_id: '',
|
|
255
|
+
latest_context_packet_routing_summary: '',
|
|
256
|
+
bootstrap_worktree_status: bootstrapWorktreeStatus,
|
|
257
|
+
first_prompt: firstPrompt
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
process.stdout.write(`${JSON.stringify(packet, null, 2)}\n`);
|
|
261
|
+
NODE
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
print_first_prompt() {
|
|
265
|
+
echo
|
|
266
|
+
echo "Paste this into Codex / Claude / Mistral:"
|
|
267
|
+
echo "$FIRST_PROMPT"
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
copy_first_prompt_with_retry() {
|
|
271
|
+
local label="$1"
|
|
272
|
+
shift
|
|
273
|
+
|
|
274
|
+
local attempt=1
|
|
275
|
+
while [ "$attempt" -le 2 ]; do
|
|
276
|
+
if printf '%s' "$FIRST_PROMPT" | "$@"; then
|
|
277
|
+
echo "Copied first agent prompt to clipboard."
|
|
278
|
+
return 0
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
if [ "$attempt" -lt 2 ]; then
|
|
282
|
+
echo "Clipboard copy via ${label} failed; retrying..." >&2
|
|
283
|
+
sleep 1
|
|
284
|
+
fi
|
|
285
|
+
|
|
286
|
+
attempt=$((attempt + 1))
|
|
287
|
+
done
|
|
288
|
+
|
|
289
|
+
echo "WARNING: Clipboard copy via ${label} failed; printing prompt instead." >&2
|
|
290
|
+
return 1
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if [ "$OUTPUT_FORMAT" = "json" ]; then
|
|
294
|
+
git -C "$WORKTREE_PATH" add "$LOG_FILE"
|
|
295
|
+
emit_json_packet
|
|
296
|
+
exit 0
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
if [ "${CHAT_COPY_PROMPT:-copy}" = "skip" ]; then
|
|
300
|
+
print_first_prompt
|
|
301
|
+
elif command -v clip.exe >/dev/null 2>&1; then
|
|
302
|
+
copy_first_prompt_with_retry "clip.exe" clip.exe || print_first_prompt
|
|
303
|
+
elif command -v pbcopy >/dev/null 2>&1; then
|
|
304
|
+
copy_first_prompt_with_retry "pbcopy" pbcopy || print_first_prompt
|
|
305
|
+
elif command -v xclip >/dev/null 2>&1; then
|
|
306
|
+
copy_first_prompt_with_retry "xclip" xclip -selection clipboard || print_first_prompt
|
|
307
|
+
else
|
|
308
|
+
print_first_prompt
|
|
309
|
+
fi
|
|
310
|
+
|
|
311
|
+
case "${CHAT_CLEANUP_EMPTY_BRANCHES:-apply}" in
|
|
312
|
+
apply)
|
|
313
|
+
echo "Cleaning up empty chat branches..."
|
|
314
|
+
bash scripts/00.chat/git/cleanup-empty-chat-branches/script.sh --apply
|
|
315
|
+
;;
|
|
316
|
+
dry-run)
|
|
317
|
+
echo "Previewing empty chat branch cleanup..."
|
|
318
|
+
bash scripts/00.chat/git/cleanup-empty-chat-branches/script.sh --dry-run
|
|
319
|
+
;;
|
|
320
|
+
0|false|no|skip)
|
|
321
|
+
echo "Skipping empty chat branch cleanup."
|
|
322
|
+
;;
|
|
323
|
+
*)
|
|
324
|
+
echo "ERROR: invalid CHAT_CLEANUP_EMPTY_BRANCHES value: ${CHAT_CLEANUP_EMPTY_BRANCHES}" >&2
|
|
325
|
+
echo "Use apply, dry-run, skip, 0, false, or no." >&2
|
|
326
|
+
exit 2
|
|
327
|
+
;;
|
|
328
|
+
esac
|
|
329
|
+
|
|
330
|
+
git -C "$WORKTREE_PATH" add "$LOG_FILE"
|