create-egregore 0.19.33 → 0.20.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/assets/egregore-launcher.js +118 -13
- package/bin/cli.js +19 -3
- package/lib/connect-runtime.js +4 -2
- package/lib/local.js +15 -1
- package/lib/prime-runtime.js +208 -0
- package/lib/setup.js +45 -3
- package/package.json +4 -3
- package/runtime/codex/.codex/skills/ingest-notion/SKILL.md +29 -0
- package/runtime/codex/.codex/skills/notion-connect/SKILL.md +29 -0
- package/runtime/codex/.codex/skills/teams-connect/SKILL.md +29 -0
- package/runtime/codex/.codex/spec-manifest.json +3 -3
- package/runtime/codex/AGENTS.md +11 -4
- package/runtime/codex/bin/activity-data.sh +4 -8
- package/runtime/codex/bin/attendant.sh +13 -0
- package/runtime/codex/bin/autosave.sh +27 -1
- package/runtime/codex/bin/codex-render-spec.mjs +6 -0
- package/runtime/codex/bin/codex-session-start.sh +3 -1
- package/runtime/codex/bin/graph-batch.sh +25 -6
- package/runtime/codex/bin/graph-op.sh +5 -4
- package/runtime/codex/bin/graph.sh +31 -5
- package/runtime/codex/bin/ingest.py +81 -5
- package/runtime/codex/bin/lib/context.sh +26 -1
- package/runtime/codex/bin/lib/greeting.sh +4 -1
- package/runtime/codex/bin/lib/worktree-links.sh +25 -0
- package/runtime/codex/manifest.json +7 -1
- package/runtime/pi/.codex/skills/ingest-notion/SKILL.md +29 -0
- package/runtime/pi/.codex/skills/notion-connect/SKILL.md +29 -0
- package/runtime/pi/.codex/skills/teams-connect/SKILL.md +29 -0
- package/runtime/pi/.codex/spec-manifest.json +3 -3
- package/runtime/pi/.pi/APPEND_SYSTEM.md +3 -2
- package/runtime/pi/.pi/extensions/egregore.ts +17 -6
- package/runtime/pi/.pi/spec-manifest.json +2 -2
- package/runtime/pi/AGENTS.md +11 -4
- package/runtime/pi/bin/activity-data.sh +4 -8
- package/runtime/pi/bin/attendant.sh +13 -0
- package/runtime/pi/bin/autosave.sh +27 -1
- package/runtime/pi/bin/codex-render-spec.mjs +6 -0
- package/runtime/pi/bin/codex-session-start.sh +3 -1
- package/runtime/pi/bin/graph-batch.sh +25 -6
- package/runtime/pi/bin/graph-op.sh +5 -4
- package/runtime/pi/bin/graph.sh +31 -5
- package/runtime/pi/bin/ingest.py +81 -5
- package/runtime/pi/bin/lib/context.sh +26 -1
- package/runtime/pi/bin/lib/greeting.sh +4 -1
- package/runtime/pi/bin/lib/worktree-links.sh +25 -0
- package/runtime/pi/bin/pi-branch-policy.mjs +138 -1
- package/runtime/pi/bin/pi-product-workflows.mjs +35 -7
- package/runtime/pi/manifest.json +7 -1
- package/runtime/prime/.claude/context/notification-consent.md +66 -0
- package/runtime/prime/.codex/config.toml +17 -0
- package/runtime/prime/.codex/hooks/branch-guard.js +461 -0
- package/runtime/prime/.codex/hooks/search-hint.js +67 -0
- package/runtime/prime/.codex/hooks.json +30 -0
- package/runtime/prime/.codex/skills/activity/SKILL.md +82 -0
- package/runtime/prime/.codex/skills/announce/SKILL.md +67 -0
- package/runtime/prime/.codex/skills/archive/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/branch/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/checkup/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/commit/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/contribute/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/create-skill/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/dark-mode/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/dashboard/SKILL.md +59 -0
- package/runtime/prime/.codex/skills/deep-reflect/SKILL.md +109 -0
- package/runtime/prime/.codex/skills/delete-user/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/emissary/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/handoff/SKILL.md +166 -0
- package/runtime/prime/.codex/skills/harvest/QUESTION_PALETTE.md +76 -0
- package/runtime/prime/.codex/skills/harvest/SKILL.md +131 -0
- package/runtime/prime/.codex/skills/ingest/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/ingest-notion/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/ingest-user-interview/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/invite/SKILL.md +44 -0
- package/runtime/prime/.codex/skills/issue/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/me/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/meeting/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/note/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/notion-connect/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/onboarding/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/pr/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/pull/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/push/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/quest/SKILL.md +80 -0
- package/runtime/prime/.codex/skills/reflect/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/review-pr/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/save/SKILL.md +125 -0
- package/runtime/prime/.codex/skills/slack-connect/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/summon/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/sync-repos/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/teams-connect/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/telegram-connect/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/telemetry/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/test/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/the-spiral/SKILL.md +84 -0
- package/runtime/prime/.codex/skills/tui-design/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/tutorial/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/update/SKILL.md +29 -0
- package/runtime/prime/.codex/skills/view/SKILL.md +156 -0
- package/runtime/prime/.codex/skills/view/agents/openai.yaml +4 -0
- package/runtime/prime/.codex/skills/view/assets/compose-scaffold.html +221 -0
- package/runtime/prime/.codex/skills/visual-explain/SKILL.md +45 -0
- package/runtime/prime/.codex/skills/wrap/SKILL.md +58 -0
- package/runtime/prime/.codex/spec-manifest.json +132 -0
- package/runtime/prime/.prime/agent/APPEND_SYSTEM.md +393 -0
- package/runtime/prime/.prime/agent/extensions/egregore.ts +460 -0
- package/runtime/prime/.prime/agent/settings.json +4 -0
- package/runtime/prime/.prime/agent/skills/egregore/SKILL.md +34 -0
- package/runtime/prime/.prime/agent/skills/egregore/pyproject.toml +13 -0
- package/runtime/prime/.prime/agent/skills/egregore/src/egregore/__init__.py +156 -0
- package/runtime/prime/.prime/agent/spec-manifest.json +12 -0
- package/runtime/prime/AGENTS.md +489 -0
- package/runtime/prime/bin/activity-data.sh +238 -0
- package/runtime/prime/bin/agent.sh +775 -0
- package/runtime/prime/bin/attendant.sh +707 -0
- package/runtime/prime/bin/autosave.sh +112 -0
- package/runtime/prime/bin/capture-reconcile.sh +69 -0
- package/runtime/prime/bin/capture-run.sh +341 -0
- package/runtime/prime/bin/codex-install-skills.sh +78 -0
- package/runtime/prime/bin/codex-render-spec.mjs +440 -0
- package/runtime/prime/bin/codex-session-start.sh +265 -0
- package/runtime/prime/bin/codex-skill-render.mjs +347 -0
- package/runtime/prime/bin/codex-sync-skills.sh +232 -0
- package/runtime/prime/bin/connect-refresh.sh +33 -0
- package/runtime/prime/bin/dashboard-data.sh +178 -0
- package/runtime/prime/bin/graph-batch.sh +79 -0
- package/runtime/prime/bin/graph-op.sh +1102 -0
- package/runtime/prime/bin/graph-wal.sh +229 -0
- package/runtime/prime/bin/graph.sh +223 -0
- package/runtime/prime/bin/handoff-pr-backfill.sh +86 -0
- package/runtime/prime/bin/handoff-run.sh +671 -0
- package/runtime/prime/bin/handoff-save-egregore.sh +212 -0
- package/runtime/prime/bin/index-handoff.sh +322 -0
- package/runtime/prime/bin/ingest-graph.sh +80 -0
- package/runtime/prime/bin/ingest-surface.html +495 -0
- package/runtime/prime/bin/ingest.py +756 -0
- package/runtime/prime/bin/ingest.sh +279 -0
- package/runtime/prime/bin/ingest_graph.py +856 -0
- package/runtime/prime/bin/ingest_surface.py +544 -0
- package/runtime/prime/bin/lib/artifact-id.sh +46 -0
- package/runtime/prime/bin/lib/config.sh +116 -0
- package/runtime/prime/bin/lib/context.sh +621 -0
- package/runtime/prime/bin/lib/dashboard-artifact.sh +242 -0
- package/runtime/prime/bin/lib/ensure-develop.sh +183 -0
- package/runtime/prime/bin/lib/git-sync.sh +406 -0
- package/runtime/prime/bin/lib/greeting.sh +519 -0
- package/runtime/prime/bin/lib/hash.sh +13 -0
- package/runtime/prime/bin/lib/identity.sh +213 -0
- package/runtime/prime/bin/lib/metrics.sh +374 -0
- package/runtime/prime/bin/lib/noncode.sh +31 -0
- package/runtime/prime/bin/lib/permissions.sh +106 -0
- package/runtime/prime/bin/lib/time.sh +56 -0
- package/runtime/prime/bin/lib/worktree-links.sh +79 -0
- package/runtime/prime/bin/notify.sh +636 -0
- package/runtime/prime/bin/person.py +630 -0
- package/runtime/prime/bin/person.sh +448 -0
- package/runtime/prime/bin/pi-branch-policy.mjs +312 -0
- package/runtime/prime/bin/pi-product-workflows.mjs +394 -0
- package/runtime/prime/bin/prime-render-spec.mjs +123 -0
- package/runtime/prime/bin/prime-session-start.sh +24 -0
- package/runtime/prime/bin/publish-artifact.sh +271 -0
- package/runtime/prime/bin/publish-references.sh +144 -0
- package/runtime/prime/bin/repo-state.sh +96 -0
- package/runtime/prime/bin/search.sh +240 -0
- package/runtime/prime/bin/session-autosave.sh +209 -0
- package/runtime/prime/bin/session-log.sh +199 -0
- package/runtime/prime/bin/settings.sh +304 -0
- package/runtime/prime/bin/telemetry.sh +391 -0
- package/runtime/prime/bin/worktree-create.sh +128 -0
- package/runtime/prime/bin/worktree-remove.sh +50 -0
- package/runtime/prime/bin/worktree.sh +198 -0
- package/runtime/prime/manifest.json +178 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# WorktreeCreate hook — replaces EnterWorktree's default behavior.
|
|
3
|
+
# Receives {"name": "<slug>"} on stdin. Must print absolute worktree path to stdout.
|
|
4
|
+
# All diagnostic output goes to stderr or /dev/null — stdout is ONLY for the path.
|
|
5
|
+
# Must complete in under 2 seconds.
|
|
6
|
+
|
|
7
|
+
# No set -e — a jq failure must not crash the hook
|
|
8
|
+
set -o pipefail
|
|
9
|
+
|
|
10
|
+
# --- Read input ---
|
|
11
|
+
INPUT=$(cat /dev/stdin 2>/dev/null || echo '{}')
|
|
12
|
+
SLUG=$(echo "$INPUT" | jq -r '.name // empty' 2>/dev/null)
|
|
13
|
+
|
|
14
|
+
if [ -z "$SLUG" ]; then
|
|
15
|
+
echo "Error: no name provided" >&2
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# --- Resolve main repo root ---
|
|
20
|
+
# CLAUDE_PROJECT_DIR may point to main repo or a worktree
|
|
21
|
+
REPO_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
22
|
+
if [ -f "$REPO_ROOT/.git" ]; then
|
|
23
|
+
# In a worktree — trace back to main repo
|
|
24
|
+
WT_GITDIR=$(sed 's/^gitdir: //' "$REPO_ROOT/.git" 2>/dev/null)
|
|
25
|
+
REPO_ROOT=$(cd "$WT_GITDIR/../../.." 2>/dev/null && pwd)
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# --- Read author ---
|
|
29
|
+
STATE_FILE="$REPO_ROOT/.egregore-state.json"
|
|
30
|
+
AUTHOR=$(jq -r '.github_username // .display_name // "unknown"' "$STATE_FILE" 2>/dev/null) || AUTHOR="unknown"
|
|
31
|
+
|
|
32
|
+
# --- Branch and worktree names ---
|
|
33
|
+
BRANCH="dev/${AUTHOR}/${SLUG}"
|
|
34
|
+
WT_PATH="$REPO_ROOT/.claude/worktrees/${SLUG}"
|
|
35
|
+
|
|
36
|
+
# --- Resolve and fetch the configured base branch ---
|
|
37
|
+
SCRIPT_DIR="$REPO_ROOT"
|
|
38
|
+
CONFIG="$REPO_ROOT/egregore.json"
|
|
39
|
+
if [ -f "$REPO_ROOT/bin/lib/config.sh" ]; then
|
|
40
|
+
# shellcheck source=bin/lib/config.sh
|
|
41
|
+
source "$REPO_ROOT/bin/lib/config.sh"
|
|
42
|
+
fi
|
|
43
|
+
if ! BASE_BRANCH=$(_get_base_branch); then
|
|
44
|
+
echo "Error: could not resolve the configured base branch" >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
git -C "$REPO_ROOT" fetch origin "$BASE_BRANCH" --quiet 2>/dev/null || true
|
|
48
|
+
|
|
49
|
+
# --- Create branch (idempotent — skip if exists) ---
|
|
50
|
+
if ! git -C "$REPO_ROOT" show-ref --verify --quiet "refs/heads/$BRANCH" 2>/dev/null; then
|
|
51
|
+
git -C "$REPO_ROOT" branch "$BRANCH" "origin/$BASE_BRANCH" >/dev/null 2>&1 || {
|
|
52
|
+
echo "Error: failed to create branch $BRANCH" >&2
|
|
53
|
+
exit 1
|
|
54
|
+
}
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# --- Handle stale worktree at same path ---
|
|
58
|
+
if [ -d "$WT_PATH" ]; then
|
|
59
|
+
git -C "$REPO_ROOT" worktree remove "$WT_PATH" --force 2>/dev/null || rm -rf "$WT_PATH" 2>/dev/null
|
|
60
|
+
git -C "$REPO_ROOT" worktree prune 2>/dev/null || true
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# --- Create worktree on our branch ---
|
|
64
|
+
mkdir -p "$REPO_ROOT/.claude/worktrees" 2>/dev/null
|
|
65
|
+
git -C "$REPO_ROOT" worktree add "$WT_PATH" "$BRANCH" --quiet 2>/dev/null || {
|
|
66
|
+
echo "Error: failed to create worktree at $WT_PATH" >&2
|
|
67
|
+
exit 1
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# --- Symlinks (same as worktree.sh setup) ---
|
|
71
|
+
# Memory — may be a symlink (follow to its target) or a real directory.
|
|
72
|
+
MEMORY_TARGET=""
|
|
73
|
+
if [ -L "$REPO_ROOT/memory" ]; then
|
|
74
|
+
MEMORY_TARGET=$(realpath "$REPO_ROOT/memory" 2>/dev/null)
|
|
75
|
+
elif [ -d "$REPO_ROOT/memory" ]; then
|
|
76
|
+
MEMORY_TARGET="$REPO_ROOT/memory"
|
|
77
|
+
fi
|
|
78
|
+
if [ -n "$MEMORY_TARGET" ] && [ -d "$MEMORY_TARGET" ]; then
|
|
79
|
+
ln -sfn "$MEMORY_TARGET" "$WT_PATH/memory"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# .env
|
|
83
|
+
[ -f "$REPO_ROOT/.env" ] && ln -sfn "$REPO_ROOT/.env" "$WT_PATH/.env"
|
|
84
|
+
|
|
85
|
+
# .egregore-state.json
|
|
86
|
+
[ -f "$REPO_ROOT/.egregore-state.json" ] && ln -sfn "$REPO_ROOT/.egregore-state.json" "$WT_PATH/.egregore-state.json"
|
|
87
|
+
|
|
88
|
+
# .egregore-session-id
|
|
89
|
+
[ -f "$REPO_ROOT/.egregore-session-id" ] && ln -sfn "$REPO_ROOT/.egregore-session-id" "$WT_PATH/.egregore-session-id"
|
|
90
|
+
|
|
91
|
+
# egregore.json
|
|
92
|
+
[ -f "$REPO_ROOT/egregore.json" ] && [ ! -f "$WT_PATH/egregore.json" ] && ln -sfn "$REPO_ROOT/egregore.json" "$WT_PATH/egregore.json"
|
|
93
|
+
|
|
94
|
+
# --- Compute boundary for worktree (so isolation hook works) ---
|
|
95
|
+
# session-start.sh doesn't re-run for worktrees, so we compute it here.
|
|
96
|
+
HASH=$(echo -n "$WT_PATH" | md5 2>/dev/null || echo -n "$WT_PATH" | md5sum 2>/dev/null | cut -d' ' -f1)
|
|
97
|
+
BOUNDARY_FILE="/tmp/egregore-boundary-${HASH}.json"
|
|
98
|
+
MEMORY_DIR=""
|
|
99
|
+
[ -L "$WT_PATH/memory" ] && MEMORY_DIR=$(realpath "$WT_PATH/memory" 2>/dev/null || true)
|
|
100
|
+
# Managed repos: include main repo (worktree symlinks resolve there) + sibling repos
|
|
101
|
+
MANAGED_REPOS_JSON="[\"$REPO_ROOT\""
|
|
102
|
+
PARENT_DIR="$(dirname "$REPO_ROOT")"
|
|
103
|
+
_repos=$(jq -r '(.repos[]? // empty) | if type == "object" then .name else . end' "$WT_PATH/egregore.json" 2>/dev/null || true)
|
|
104
|
+
for _r in $_repos; do
|
|
105
|
+
[[ "$_r" == *".."* ]] && continue
|
|
106
|
+
_resolved=$(realpath "$PARENT_DIR/$_r" 2>/dev/null || true)
|
|
107
|
+
[ -z "$_resolved" ] && continue
|
|
108
|
+
MANAGED_REPOS_JSON="$MANAGED_REPOS_JSON,\"$_resolved\""
|
|
109
|
+
done
|
|
110
|
+
MANAGED_REPOS_JSON="$MANAGED_REPOS_JSON]"
|
|
111
|
+
# Denied paths: other instances, but NOT the main repo (worktree is its child)
|
|
112
|
+
DENIED_JSON="[]"
|
|
113
|
+
REGISTRY="$HOME/.egregore/instances.json"
|
|
114
|
+
if [ -f "$REGISTRY" ]; then
|
|
115
|
+
DENIED_JSON=$(jq --arg self "$REPO_ROOT" --arg wt "$WT_PATH" \
|
|
116
|
+
'[.[] | select(.path != $self and .path != $wt) | .path]' \
|
|
117
|
+
"$REGISTRY" 2>/dev/null || echo "[]")
|
|
118
|
+
fi
|
|
119
|
+
jq -n \
|
|
120
|
+
--arg project_dir "$WT_PATH" \
|
|
121
|
+
--arg memory_dir "$MEMORY_DIR" \
|
|
122
|
+
--argjson managed_repos "$MANAGED_REPOS_JSON" \
|
|
123
|
+
--argjson denied_paths "$DENIED_JSON" \
|
|
124
|
+
'{project_dir: $project_dir, memory_dir: $memory_dir, managed_repos: $managed_repos, denied_paths: $denied_paths}' \
|
|
125
|
+
> "$BOUNDARY_FILE.tmp" 2>/dev/null && mv "$BOUNDARY_FILE.tmp" "$BOUNDARY_FILE" 2>/dev/null || true
|
|
126
|
+
|
|
127
|
+
# --- Output the worktree path (ONLY stdout line) ---
|
|
128
|
+
echo "$WT_PATH"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# WorktreeRemove hook — handles cleanup when a worktree is removed.
|
|
3
|
+
# Receives {"worktree_path": "<path>"} on stdin. Best-effort, always exit 0.
|
|
4
|
+
|
|
5
|
+
INPUT=$(cat /dev/stdin 2>/dev/null || echo '{}')
|
|
6
|
+
WT_PATH=$(echo "$INPUT" | jq -r '.worktree_path // empty' 2>/dev/null)
|
|
7
|
+
|
|
8
|
+
if [ -z "$WT_PATH" ] || [ ! -d "$WT_PATH" ]; then
|
|
9
|
+
exit 0
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
# --- Resolve main repo for git operations ---
|
|
13
|
+
REPO_ROOT="${CLAUDE_PROJECT_DIR:-}"
|
|
14
|
+
if [ -z "$REPO_ROOT" ] || [ -f "$REPO_ROOT/.git" ]; then
|
|
15
|
+
# In a worktree or no CLAUDE_PROJECT_DIR — trace from the worktree path
|
|
16
|
+
if [ -f "$WT_PATH/.git" ]; then
|
|
17
|
+
WT_GITDIR=$(sed 's/^gitdir: //' "$WT_PATH/.git" 2>/dev/null)
|
|
18
|
+
REPO_ROOT=$(cd "$WT_GITDIR/../../.." 2>/dev/null && pwd) || REPO_ROOT=""
|
|
19
|
+
fi
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# --- Remove from instance registry ---
|
|
23
|
+
REGISTRY="$HOME/.egregore/instances.json"
|
|
24
|
+
if [ -f "$REGISTRY" ]; then
|
|
25
|
+
RESOLVED_WT=$(realpath "$WT_PATH" 2>/dev/null || echo "$WT_PATH")
|
|
26
|
+
UPDATED=$(jq --arg p "$RESOLVED_WT" '[.[] | select(.path != $p)]' "$REGISTRY" 2>/dev/null)
|
|
27
|
+
if [ -n "$UPDATED" ]; then
|
|
28
|
+
echo "$UPDATED" > "$REGISTRY.tmp" && mv "$REGISTRY.tmp" "$REGISTRY"
|
|
29
|
+
fi
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# --- Remove worktree ---
|
|
33
|
+
if [ -n "$REPO_ROOT" ] && [ -d "$REPO_ROOT/.git" ]; then
|
|
34
|
+
git -C "$REPO_ROOT" worktree remove "$WT_PATH" --force 2>/dev/null || true
|
|
35
|
+
git -C "$REPO_ROOT" worktree prune 2>/dev/null || true
|
|
36
|
+
else
|
|
37
|
+
# Fallback: just remove the directory
|
|
38
|
+
rm -rf "$WT_PATH" 2>/dev/null || true
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# --- Clean up stale marker files ---
|
|
42
|
+
for MARKER_FILE in "$HOME/.egregore"/worktree-cleanup-*.marker; do
|
|
43
|
+
[ -f "$MARKER_FILE" ] || continue
|
|
44
|
+
MARKER_PATH=$(cat "$MARKER_FILE" 2>/dev/null)
|
|
45
|
+
if [ "$MARKER_PATH" = "$WT_PATH" ] || [ ! -d "$MARKER_PATH" ]; then
|
|
46
|
+
rm -f "$MARKER_FILE" 2>/dev/null || true
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
|
|
50
|
+
exit 0
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Worktree lifecycle management for Egregore sessions.
|
|
3
|
+
# Each session gets an isolated worktree so parallel sessions don't conflict.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# bash bin/worktree.sh setup <worktree-path> <main-project-dir>
|
|
7
|
+
# bash bin/worktree.sh cleanup <worktree-path>
|
|
8
|
+
# bash bin/worktree.sh cleanup-stale <main-project-dir>
|
|
9
|
+
# bash bin/worktree.sh health [path]
|
|
10
|
+
# bash bin/worktree.sh list
|
|
11
|
+
|
|
12
|
+
set -o pipefail
|
|
13
|
+
|
|
14
|
+
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
|
15
|
+
echo "Usage: worktree.sh <command> [args...]"
|
|
16
|
+
echo ""
|
|
17
|
+
echo "Worktree lifecycle management for Egregore sessions."
|
|
18
|
+
echo ""
|
|
19
|
+
echo "Commands:"
|
|
20
|
+
echo " setup <path> <main-dir> Set up symlinks for a new worktree"
|
|
21
|
+
echo " cleanup <path> Remove a worktree"
|
|
22
|
+
echo " cleanup-stale <main-dir> List stale worktrees (manual review)"
|
|
23
|
+
echo " health [path] Check worktree + branch health"
|
|
24
|
+
echo " list List all git worktrees"
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
CMD="${1:-}"
|
|
29
|
+
shift 2>/dev/null || true
|
|
30
|
+
|
|
31
|
+
case "$CMD" in
|
|
32
|
+
|
|
33
|
+
setup)
|
|
34
|
+
# Setup symlinks so worktree shares state with main project.
|
|
35
|
+
# Args: <worktree-path> <main-project-dir>
|
|
36
|
+
WT_PATH="${1:?Usage: worktree.sh setup <worktree-path> <main-project-dir>}"
|
|
37
|
+
MAIN_DIR="${2:?Usage: worktree.sh setup <worktree-path> <main-project-dir>}"
|
|
38
|
+
|
|
39
|
+
# Symlink shared files from main project
|
|
40
|
+
for FILE in memory .env .egregore-state.json .egregore-session-id; do
|
|
41
|
+
SRC="$MAIN_DIR/$FILE"
|
|
42
|
+
DST="$WT_PATH/$FILE"
|
|
43
|
+
if [ "$FILE" = "memory" ]; then
|
|
44
|
+
# memory may be a symlink (follow to its target) or a real directory.
|
|
45
|
+
if [ -L "$SRC" ]; then
|
|
46
|
+
SRC=$(realpath "$SRC" 2>/dev/null) || continue
|
|
47
|
+
fi
|
|
48
|
+
[ -d "$SRC" ] || continue
|
|
49
|
+
else
|
|
50
|
+
[ -f "$SRC" ] || continue
|
|
51
|
+
fi
|
|
52
|
+
ln -sfn "$SRC" "$DST"
|
|
53
|
+
done
|
|
54
|
+
|
|
55
|
+
# Symlink egregore.json if not already present (committed file)
|
|
56
|
+
if [ -f "$MAIN_DIR/egregore.json" ] && [ ! -f "$WT_PATH/egregore.json" ]; then
|
|
57
|
+
ln -sfn "$MAIN_DIR/egregore.json" "$WT_PATH/egregore.json"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# Find terminal TTY for statusline matching
|
|
61
|
+
_pid=$$
|
|
62
|
+
_tty=""
|
|
63
|
+
while [ "$_pid" -gt 1 ] 2>/dev/null; do
|
|
64
|
+
_ptty=$(ps -o tty= -p "$_pid" 2>/dev/null | tr -d ' ')
|
|
65
|
+
if [ -n "$_ptty" ] && [ "$_ptty" != "??" ]; then
|
|
66
|
+
_tty="$_ptty"
|
|
67
|
+
break
|
|
68
|
+
fi
|
|
69
|
+
_pid=$(ps -o ppid= -p "$_pid" 2>/dev/null | tr -d ' ')
|
|
70
|
+
done
|
|
71
|
+
[ -n "$_tty" ] && echo "$_tty" > "$WT_PATH/.egregore-worktree-tty"
|
|
72
|
+
|
|
73
|
+
echo "Worktree setup complete: $WT_PATH"
|
|
74
|
+
;;
|
|
75
|
+
|
|
76
|
+
cleanup)
|
|
77
|
+
# Remove a worktree. Only called explicitly (ExitWorktree or manual).
|
|
78
|
+
# Args: <worktree-path>
|
|
79
|
+
WT_PATH="${1:?Usage: worktree.sh cleanup <worktree-path>}"
|
|
80
|
+
|
|
81
|
+
# Remove from instance registry if accidentally registered
|
|
82
|
+
REGISTRY="$HOME/.egregore/instances.json"
|
|
83
|
+
if [ -f "$REGISTRY" ]; then
|
|
84
|
+
RESOLVED_WT=$(realpath "$WT_PATH" 2>/dev/null || echo "$WT_PATH")
|
|
85
|
+
UPDATED=$(jq --arg p "$RESOLVED_WT" '[.[] | select(.path != $p)]' "$REGISTRY" 2>/dev/null)
|
|
86
|
+
if [ -n "$UPDATED" ]; then
|
|
87
|
+
echo "$UPDATED" > "$REGISTRY.tmp" && mv "$REGISTRY.tmp" "$REGISTRY"
|
|
88
|
+
fi
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
git worktree remove "$WT_PATH" --force 2>/dev/null || true
|
|
92
|
+
git worktree prune 2>/dev/null || true
|
|
93
|
+
|
|
94
|
+
echo "Worktree cleaned up: $WT_PATH"
|
|
95
|
+
;;
|
|
96
|
+
|
|
97
|
+
cleanup-stale)
|
|
98
|
+
# List stale worktrees for manual review. Does NOT auto-delete.
|
|
99
|
+
# Run interactively or from a cleanup command — never from session-start.
|
|
100
|
+
# Args: <main-project-dir>
|
|
101
|
+
MAIN_DIR="${1:?Usage: worktree.sh cleanup-stale <main-project-dir>}"
|
|
102
|
+
WT_BASE="$MAIN_DIR/.claude/worktrees"
|
|
103
|
+
|
|
104
|
+
if [ ! -d "$WT_BASE" ]; then
|
|
105
|
+
echo "No worktrees directory."
|
|
106
|
+
exit 0
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
NOW_TS=$(date +%s)
|
|
110
|
+
FOUND=0
|
|
111
|
+
|
|
112
|
+
for WT_DIR in "$WT_BASE"/*/; do
|
|
113
|
+
[ -d "$WT_DIR" ] || continue
|
|
114
|
+
|
|
115
|
+
WT_NAME=$(basename "$WT_DIR")
|
|
116
|
+
WT_BRANCH=""
|
|
117
|
+
STATUS="unknown"
|
|
118
|
+
|
|
119
|
+
if [ -f "$WT_DIR/.git" ]; then
|
|
120
|
+
WT_BRANCH=$(git -C "$WT_DIR" branch --show-current 2>/dev/null || echo "?")
|
|
121
|
+
|
|
122
|
+
# Check if merged
|
|
123
|
+
if [ "$WT_BRANCH" != "?" ] && [ "$WT_BRANCH" != "develop" ] && [ "$WT_BRANCH" != "main" ]; then
|
|
124
|
+
if git merge-base --is-ancestor "$(git -C "$WT_DIR" rev-parse HEAD 2>/dev/null)" \
|
|
125
|
+
"$(git -C "$MAIN_DIR" rev-parse origin/develop 2>/dev/null)" 2>/dev/null; then
|
|
126
|
+
STATUS="merged"
|
|
127
|
+
else
|
|
128
|
+
STATUS="active"
|
|
129
|
+
fi
|
|
130
|
+
fi
|
|
131
|
+
else
|
|
132
|
+
STATUS="broken"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Age
|
|
136
|
+
WT_MTIME=$(stat -f %m "$WT_DIR" 2>/dev/null || stat -c %Y "$WT_DIR" 2>/dev/null || echo "$NOW_TS")
|
|
137
|
+
WT_AGE_H=$(( (NOW_TS - WT_MTIME) / 3600 ))
|
|
138
|
+
|
|
139
|
+
if [ "$STATUS" = "merged" ] || [ "$STATUS" = "broken" ] || [ "$WT_AGE_H" -gt 24 ]; then
|
|
140
|
+
echo " $WT_NAME [$STATUS] ${WT_AGE_H}h old branch: ${WT_BRANCH:-none}"
|
|
141
|
+
FOUND=$((FOUND + 1))
|
|
142
|
+
fi
|
|
143
|
+
done
|
|
144
|
+
|
|
145
|
+
if [ "$FOUND" -eq 0 ]; then
|
|
146
|
+
echo "No stale worktrees found."
|
|
147
|
+
else
|
|
148
|
+
echo ""
|
|
149
|
+
echo "To remove: bash bin/worktree.sh cleanup <path>"
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
# Prune git's internal worktree list
|
|
153
|
+
git -C "$MAIN_DIR" worktree prune 2>/dev/null || true
|
|
154
|
+
;;
|
|
155
|
+
|
|
156
|
+
health)
|
|
157
|
+
# Check worktree + branch health
|
|
158
|
+
# Exit codes: 0=healthy, 1=not_worktree, 2=branch_gone, 3=protected_branch
|
|
159
|
+
WT_PATH="${1:-$(pwd)}"
|
|
160
|
+
|
|
161
|
+
if [ ! -f "$WT_PATH/.git" ]; then
|
|
162
|
+
echo '{"status":"not_worktree"}'
|
|
163
|
+
exit 1
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
BRANCH=$(git -C "$WT_PATH" branch --show-current 2>/dev/null || echo "")
|
|
167
|
+
|
|
168
|
+
case "$BRANCH" in
|
|
169
|
+
develop|main|master)
|
|
170
|
+
jq -n --arg branch "$BRANCH" '{status: "protected_branch", branch: $branch}'
|
|
171
|
+
exit 3
|
|
172
|
+
;;
|
|
173
|
+
esac
|
|
174
|
+
|
|
175
|
+
# Check if remote branch still exists
|
|
176
|
+
git -C "$WT_PATH" fetch origin --prune --quiet 2>/dev/null || true
|
|
177
|
+
if ! git -C "$WT_PATH" ls-remote --heads origin "$BRANCH" 2>/dev/null | grep -q "$BRANCH"; then
|
|
178
|
+
if git -C "$WT_PATH" branch -r --merged origin/develop 2>/dev/null | grep -q "origin/$BRANCH" 2>/dev/null; then
|
|
179
|
+
jq -n --arg branch "$BRANCH" '{status: "merged", branch: $branch}'
|
|
180
|
+
else
|
|
181
|
+
jq -n --arg branch "$BRANCH" '{status: "remote_deleted", branch: $branch}'
|
|
182
|
+
fi
|
|
183
|
+
exit 2
|
|
184
|
+
fi
|
|
185
|
+
|
|
186
|
+
jq -n --arg branch "$BRANCH" '{status: "healthy", branch: $branch}'
|
|
187
|
+
exit 0
|
|
188
|
+
;;
|
|
189
|
+
|
|
190
|
+
list)
|
|
191
|
+
git worktree list
|
|
192
|
+
;;
|
|
193
|
+
|
|
194
|
+
*)
|
|
195
|
+
echo "Usage: worktree.sh {setup|cleanup|cleanup-stale|health|list}" >&2
|
|
196
|
+
exit 1
|
|
197
|
+
;;
|
|
198
|
+
esac
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "egregore-prime-meta-harness",
|
|
3
|
+
"policy": "Prime Agent-native lifecycle layer over the available OSS Codex skill corpus",
|
|
4
|
+
"skillCount": 46,
|
|
5
|
+
"skills": [
|
|
6
|
+
"activity",
|
|
7
|
+
"announce",
|
|
8
|
+
"archive",
|
|
9
|
+
"branch",
|
|
10
|
+
"checkup",
|
|
11
|
+
"commit",
|
|
12
|
+
"contribute",
|
|
13
|
+
"create-skill",
|
|
14
|
+
"dark-mode",
|
|
15
|
+
"dashboard",
|
|
16
|
+
"deep-reflect",
|
|
17
|
+
"delete-user",
|
|
18
|
+
"emissary",
|
|
19
|
+
"handoff",
|
|
20
|
+
"harvest",
|
|
21
|
+
"ingest",
|
|
22
|
+
"ingest-notion",
|
|
23
|
+
"ingest-user-interview",
|
|
24
|
+
"invite",
|
|
25
|
+
"issue",
|
|
26
|
+
"me",
|
|
27
|
+
"meeting",
|
|
28
|
+
"note",
|
|
29
|
+
"notion-connect",
|
|
30
|
+
"onboarding",
|
|
31
|
+
"pr",
|
|
32
|
+
"pull",
|
|
33
|
+
"push",
|
|
34
|
+
"quest",
|
|
35
|
+
"reflect",
|
|
36
|
+
"review-pr",
|
|
37
|
+
"save",
|
|
38
|
+
"slack-connect",
|
|
39
|
+
"summon",
|
|
40
|
+
"sync-repos",
|
|
41
|
+
"teams-connect",
|
|
42
|
+
"telegram-connect",
|
|
43
|
+
"telemetry",
|
|
44
|
+
"test",
|
|
45
|
+
"the-spiral",
|
|
46
|
+
"tui-design",
|
|
47
|
+
"tutorial",
|
|
48
|
+
"update",
|
|
49
|
+
"view",
|
|
50
|
+
"visual-explain",
|
|
51
|
+
"wrap"
|
|
52
|
+
],
|
|
53
|
+
"availability": "oss",
|
|
54
|
+
"files": [
|
|
55
|
+
".claude/context/notification-consent.md",
|
|
56
|
+
".codex/config.toml",
|
|
57
|
+
".codex/hooks.json",
|
|
58
|
+
".codex/hooks/branch-guard.js",
|
|
59
|
+
".codex/hooks/search-hint.js",
|
|
60
|
+
".codex/skills/activity/SKILL.md",
|
|
61
|
+
".codex/skills/announce/SKILL.md",
|
|
62
|
+
".codex/skills/archive/SKILL.md",
|
|
63
|
+
".codex/skills/branch/SKILL.md",
|
|
64
|
+
".codex/skills/checkup/SKILL.md",
|
|
65
|
+
".codex/skills/commit/SKILL.md",
|
|
66
|
+
".codex/skills/contribute/SKILL.md",
|
|
67
|
+
".codex/skills/create-skill/SKILL.md",
|
|
68
|
+
".codex/skills/dark-mode/SKILL.md",
|
|
69
|
+
".codex/skills/dashboard/SKILL.md",
|
|
70
|
+
".codex/skills/deep-reflect/SKILL.md",
|
|
71
|
+
".codex/skills/delete-user/SKILL.md",
|
|
72
|
+
".codex/skills/emissary/SKILL.md",
|
|
73
|
+
".codex/skills/handoff/SKILL.md",
|
|
74
|
+
".codex/skills/harvest/QUESTION_PALETTE.md",
|
|
75
|
+
".codex/skills/harvest/SKILL.md",
|
|
76
|
+
".codex/skills/ingest-notion/SKILL.md",
|
|
77
|
+
".codex/skills/ingest-user-interview/SKILL.md",
|
|
78
|
+
".codex/skills/ingest/SKILL.md",
|
|
79
|
+
".codex/skills/invite/SKILL.md",
|
|
80
|
+
".codex/skills/issue/SKILL.md",
|
|
81
|
+
".codex/skills/me/SKILL.md",
|
|
82
|
+
".codex/skills/meeting/SKILL.md",
|
|
83
|
+
".codex/skills/note/SKILL.md",
|
|
84
|
+
".codex/skills/notion-connect/SKILL.md",
|
|
85
|
+
".codex/skills/onboarding/SKILL.md",
|
|
86
|
+
".codex/skills/pr/SKILL.md",
|
|
87
|
+
".codex/skills/pull/SKILL.md",
|
|
88
|
+
".codex/skills/push/SKILL.md",
|
|
89
|
+
".codex/skills/quest/SKILL.md",
|
|
90
|
+
".codex/skills/reflect/SKILL.md",
|
|
91
|
+
".codex/skills/review-pr/SKILL.md",
|
|
92
|
+
".codex/skills/save/SKILL.md",
|
|
93
|
+
".codex/skills/slack-connect/SKILL.md",
|
|
94
|
+
".codex/skills/summon/SKILL.md",
|
|
95
|
+
".codex/skills/sync-repos/SKILL.md",
|
|
96
|
+
".codex/skills/teams-connect/SKILL.md",
|
|
97
|
+
".codex/skills/telegram-connect/SKILL.md",
|
|
98
|
+
".codex/skills/telemetry/SKILL.md",
|
|
99
|
+
".codex/skills/test/SKILL.md",
|
|
100
|
+
".codex/skills/the-spiral/SKILL.md",
|
|
101
|
+
".codex/skills/tui-design/SKILL.md",
|
|
102
|
+
".codex/skills/tutorial/SKILL.md",
|
|
103
|
+
".codex/skills/update/SKILL.md",
|
|
104
|
+
".codex/skills/view/SKILL.md",
|
|
105
|
+
".codex/skills/view/agents/openai.yaml",
|
|
106
|
+
".codex/skills/view/assets/compose-scaffold.html",
|
|
107
|
+
".codex/skills/visual-explain/SKILL.md",
|
|
108
|
+
".codex/skills/wrap/SKILL.md",
|
|
109
|
+
".codex/spec-manifest.json",
|
|
110
|
+
".prime/agent/APPEND_SYSTEM.md",
|
|
111
|
+
".prime/agent/extensions/egregore.ts",
|
|
112
|
+
".prime/agent/settings.json",
|
|
113
|
+
".prime/agent/skills/egregore/SKILL.md",
|
|
114
|
+
".prime/agent/skills/egregore/pyproject.toml",
|
|
115
|
+
".prime/agent/skills/egregore/src/egregore/__init__.py",
|
|
116
|
+
".prime/agent/spec-manifest.json",
|
|
117
|
+
"AGENTS.md",
|
|
118
|
+
"bin/activity-data.sh",
|
|
119
|
+
"bin/agent.sh",
|
|
120
|
+
"bin/attendant.sh",
|
|
121
|
+
"bin/autosave.sh",
|
|
122
|
+
"bin/capture-reconcile.sh",
|
|
123
|
+
"bin/capture-run.sh",
|
|
124
|
+
"bin/codex-install-skills.sh",
|
|
125
|
+
"bin/codex-render-spec.mjs",
|
|
126
|
+
"bin/codex-session-start.sh",
|
|
127
|
+
"bin/codex-skill-render.mjs",
|
|
128
|
+
"bin/codex-sync-skills.sh",
|
|
129
|
+
"bin/connect-refresh.sh",
|
|
130
|
+
"bin/dashboard-data.sh",
|
|
131
|
+
"bin/graph-batch.sh",
|
|
132
|
+
"bin/graph-op.sh",
|
|
133
|
+
"bin/graph-wal.sh",
|
|
134
|
+
"bin/graph.sh",
|
|
135
|
+
"bin/handoff-pr-backfill.sh",
|
|
136
|
+
"bin/handoff-run.sh",
|
|
137
|
+
"bin/handoff-save-egregore.sh",
|
|
138
|
+
"bin/index-handoff.sh",
|
|
139
|
+
"bin/ingest-graph.sh",
|
|
140
|
+
"bin/ingest-surface.html",
|
|
141
|
+
"bin/ingest.py",
|
|
142
|
+
"bin/ingest.sh",
|
|
143
|
+
"bin/ingest_graph.py",
|
|
144
|
+
"bin/ingest_surface.py",
|
|
145
|
+
"bin/lib/artifact-id.sh",
|
|
146
|
+
"bin/lib/config.sh",
|
|
147
|
+
"bin/lib/context.sh",
|
|
148
|
+
"bin/lib/dashboard-artifact.sh",
|
|
149
|
+
"bin/lib/ensure-develop.sh",
|
|
150
|
+
"bin/lib/git-sync.sh",
|
|
151
|
+
"bin/lib/greeting.sh",
|
|
152
|
+
"bin/lib/hash.sh",
|
|
153
|
+
"bin/lib/identity.sh",
|
|
154
|
+
"bin/lib/metrics.sh",
|
|
155
|
+
"bin/lib/noncode.sh",
|
|
156
|
+
"bin/lib/permissions.sh",
|
|
157
|
+
"bin/lib/time.sh",
|
|
158
|
+
"bin/lib/worktree-links.sh",
|
|
159
|
+
"bin/notify.sh",
|
|
160
|
+
"bin/person.py",
|
|
161
|
+
"bin/person.sh",
|
|
162
|
+
"bin/pi-branch-policy.mjs",
|
|
163
|
+
"bin/pi-product-workflows.mjs",
|
|
164
|
+
"bin/prime-render-spec.mjs",
|
|
165
|
+
"bin/prime-session-start.sh",
|
|
166
|
+
"bin/publish-artifact.sh",
|
|
167
|
+
"bin/publish-references.sh",
|
|
168
|
+
"bin/repo-state.sh",
|
|
169
|
+
"bin/search.sh",
|
|
170
|
+
"bin/session-autosave.sh",
|
|
171
|
+
"bin/session-log.sh",
|
|
172
|
+
"bin/settings.sh",
|
|
173
|
+
"bin/telemetry.sh",
|
|
174
|
+
"bin/worktree-create.sh",
|
|
175
|
+
"bin/worktree-remove.sh",
|
|
176
|
+
"bin/worktree.sh"
|
|
177
|
+
]
|
|
178
|
+
}
|