sessionlog 0.0.3 → 0.0.5

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 (55) hide show
  1. package/README.md +65 -0
  2. package/dist/agent/agents/claude-code.d.ts.map +1 -1
  3. package/dist/agent/agents/claude-code.js +91 -0
  4. package/dist/agent/agents/claude-code.js.map +1 -1
  5. package/dist/cli.js +124 -10
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/enable.d.ts.map +1 -1
  8. package/dist/commands/enable.js +6 -5
  9. package/dist/commands/enable.js.map +1 -1
  10. package/dist/commands/setup-ccweb.d.ts +37 -0
  11. package/dist/commands/setup-ccweb.d.ts.map +1 -0
  12. package/dist/commands/setup-ccweb.js +192 -0
  13. package/dist/commands/setup-ccweb.js.map +1 -0
  14. package/dist/config.d.ts +7 -2
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +24 -9
  17. package/dist/config.js.map +1 -1
  18. package/dist/events/event-log.d.ts +43 -0
  19. package/dist/events/event-log.d.ts.map +1 -0
  20. package/dist/events/event-log.js +91 -0
  21. package/dist/events/event-log.js.map +1 -0
  22. package/dist/hooks/lifecycle.d.ts.map +1 -1
  23. package/dist/hooks/lifecycle.js +163 -1
  24. package/dist/hooks/lifecycle.js.map +1 -1
  25. package/dist/index.d.ts +6 -3
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +7 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/store/checkpoint-store.d.ts.map +1 -1
  30. package/dist/store/checkpoint-store.js +5 -0
  31. package/dist/store/checkpoint-store.js.map +1 -1
  32. package/dist/store/session-store.d.ts.map +1 -1
  33. package/dist/store/session-store.js +26 -0
  34. package/dist/store/session-store.js.map +1 -1
  35. package/dist/strategy/content-overlap.d.ts.map +1 -1
  36. package/dist/strategy/content-overlap.js +6 -2
  37. package/dist/strategy/content-overlap.js.map +1 -1
  38. package/dist/strategy/manual-commit.d.ts +7 -0
  39. package/dist/strategy/manual-commit.d.ts.map +1 -1
  40. package/dist/strategy/manual-commit.js +73 -0
  41. package/dist/strategy/manual-commit.js.map +1 -1
  42. package/dist/types.d.ts +96 -1
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js +6 -0
  45. package/dist/types.js.map +1 -1
  46. package/dist/utils/paths.d.ts +11 -1
  47. package/dist/utils/paths.d.ts.map +1 -1
  48. package/dist/utils/paths.js +21 -3
  49. package/dist/utils/paths.js.map +1 -1
  50. package/dist/wire-types.d.ts +56 -0
  51. package/dist/wire-types.d.ts.map +1 -0
  52. package/dist/wire-types.js +11 -0
  53. package/dist/wire-types.js.map +1 -0
  54. package/package.json +3 -2
  55. package/templates/setup-env.sh +153 -0
@@ -0,0 +1,153 @@
1
+ #!/bin/sh
2
+ # Sessionlog setup script for Claude Code Web (ccweb)
3
+ #
4
+ # This script is executed as a SessionStart hook in Claude Code Web sessions.
5
+ # It installs the sessionlog CLI, enables it for the current repo, and
6
+ # configures GitHub direct-push access for session/checkpoint branches.
7
+ #
8
+ # Generated by: sessionlog setup-ccweb
9
+ set -e
10
+
11
+ # Only run in remote Claude Code environments
12
+ if [ "$CLAUDE_CODE_REMOTE" != "true" ]; then
13
+ exit 0
14
+ fi
15
+
16
+ # ============================================================================
17
+ # Configuration
18
+ # ============================================================================
19
+
20
+ # Branch prefixes allowed for direct push (space-separated).
21
+ # Edit this to allow additional prefixes beyond sessionlog's defaults.
22
+ ALLOWED_PUSH_PREFIXES="sessionlog/ claude/"
23
+
24
+ # ============================================================================
25
+ # Install sessionlog CLI
26
+ # ============================================================================
27
+
28
+ if ! command -v sessionlog >/dev/null 2>&1; then
29
+ echo "[sessionlog-ccweb] Installing sessionlog CLI..."
30
+ npm install -g sessionlog 2>/dev/null || {
31
+ echo "[sessionlog-ccweb] Warning: Failed to install sessionlog globally, trying npx..."
32
+ }
33
+ fi
34
+
35
+ # ============================================================================
36
+ # Enable sessionlog for this repository
37
+ # ============================================================================
38
+
39
+ if command -v sessionlog >/dev/null 2>&1; then
40
+ # Enable with Claude Code agent (idempotent)
41
+ sessionlog enable --agent claude-code --local 2>/dev/null || true
42
+ echo "[sessionlog-ccweb] Sessionlog enabled."
43
+ else
44
+ echo "[sessionlog-ccweb] Warning: sessionlog not found. Skipping enable."
45
+ fi
46
+
47
+ # ============================================================================
48
+ # Configure GitHub direct-push access
49
+ # ============================================================================
50
+
51
+ # The ccweb proxy only allows pushing to the current working branch.
52
+ # We need direct GitHub access to push sessionlog shadow branches.
53
+
54
+ if [ -n "$GITHUB_TOKEN" ]; then
55
+ # Get the remote URL and extract owner/repo
56
+ REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")
57
+
58
+ if [ -n "$REMOTE_URL" ]; then
59
+ # Extract owner/repo from various URL formats
60
+ OWNER_REPO=$(echo "$REMOTE_URL" | sed -E 's#.*github\.com[:/]([^/]+/[^/.]+)(\.git)?$#\1#')
61
+
62
+ if [ -n "$OWNER_REPO" ]; then
63
+ # Configure git to push directly to GitHub (bypassing ccweb proxy)
64
+ DIRECT_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER_REPO}.git"
65
+ git remote set-url --push origin "$DIRECT_URL" 2>/dev/null || true
66
+ echo "[sessionlog-ccweb] Configured direct GitHub push access."
67
+ fi
68
+ fi
69
+ else
70
+ echo "[sessionlog-ccweb] Warning: GITHUB_TOKEN not set. Session push will be limited."
71
+ fi
72
+
73
+ # ============================================================================
74
+ # Install pre-push branch filter
75
+ # ============================================================================
76
+
77
+ # Restrict direct pushes to only allowed prefixes and the current working branch.
78
+ # This prevents accidental pushes to other branches via the direct GitHub URL.
79
+
80
+ HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
81
+ PRE_PUSH_HOOK="$HOOKS_DIR/pre-push"
82
+
83
+ install_push_filter() {
84
+ mkdir -p "$HOOKS_DIR"
85
+
86
+ # Check if pre-push hook already exists
87
+ if [ -f "$PRE_PUSH_HOOK" ]; then
88
+ # Check if our filter is already installed
89
+ if grep -q "sessionlog-ccweb-push-filter" "$PRE_PUSH_HOOK" 2>/dev/null; then
90
+ return
91
+ fi
92
+
93
+ # Append to existing hook
94
+ cat >> "$PRE_PUSH_HOOK" << 'HOOKEOF'
95
+
96
+ # sessionlog-ccweb-push-filter
97
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
98
+ while read local_ref local_sha remote_ref remote_sha; do
99
+ BRANCH_NAME=$(echo "$remote_ref" | sed 's#refs/heads/##')
100
+ # Allow current working branch
101
+ if [ "$BRANCH_NAME" = "$CURRENT_BRANCH" ]; then
102
+ continue
103
+ fi
104
+ # Check allowed prefixes
105
+ ALLOWED=false
106
+ for prefix in ALLOWED_PUSH_PREFIXES_PLACEHOLDER; do
107
+ case "$BRANCH_NAME" in
108
+ "$prefix"*) ALLOWED=true; break ;;
109
+ esac
110
+ done
111
+ if [ "$ALLOWED" = "false" ]; then
112
+ echo "[sessionlog-ccweb] Blocked push to '$BRANCH_NAME' (not in allowed prefixes)"
113
+ exit 1
114
+ fi
115
+ done
116
+ HOOKEOF
117
+ else
118
+ # Create new hook
119
+ cat > "$PRE_PUSH_HOOK" << 'HOOKEOF'
120
+ #!/bin/sh
121
+ # sessionlog-ccweb-push-filter
122
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
123
+ while read local_ref local_sha remote_ref remote_sha; do
124
+ BRANCH_NAME=$(echo "$remote_ref" | sed 's#refs/heads/##')
125
+ # Allow current working branch
126
+ if [ "$BRANCH_NAME" = "$CURRENT_BRANCH" ]; then
127
+ continue
128
+ fi
129
+ # Check allowed prefixes
130
+ ALLOWED=false
131
+ for prefix in ALLOWED_PUSH_PREFIXES_PLACEHOLDER; do
132
+ case "$BRANCH_NAME" in
133
+ "$prefix"*) ALLOWED=true; break ;;
134
+ esac
135
+ done
136
+ if [ "$ALLOWED" = "false" ]; then
137
+ echo "[sessionlog-ccweb] Blocked push to '$BRANCH_NAME' (not in allowed prefixes)"
138
+ exit 1
139
+ fi
140
+ done
141
+ HOOKEOF
142
+ fi
143
+
144
+ chmod +x "$PRE_PUSH_HOOK"
145
+ }
146
+
147
+ # Replace placeholder with actual prefixes and install
148
+ install_push_filter
149
+ if [ -f "$PRE_PUSH_HOOK" ]; then
150
+ sed -i "s/ALLOWED_PUSH_PREFIXES_PLACEHOLDER/$ALLOWED_PUSH_PREFIXES/g" "$PRE_PUSH_HOOK"
151
+ fi
152
+
153
+ echo "[sessionlog-ccweb] Setup complete."